1
+ #define NOMINMAX
2
+
1
3
#include " Application.h"
2
4
#include " ../GUI/MainComponent/MainComponent.h"
3
5
#include " ../GUI/Windows/PresetManagerWindow.h"
4
6
#include " ../GUI/Windows/PluginManagerWindow.h"
5
7
#include " ../GUI/Windows/SplashScreenComponent.h"
6
8
#include " ../Data/AppState.h"
7
9
#include " ../Data/LanguageManager/LanguageManager.h"
8
- // Dòng #include "CrashHandler.h" đã được xóa
9
-
10
+ #include " ../Data/SoundboardManager.h"
11
+ #include " ../AudioEngine/SoundPlayer.h"
12
+ #include < algorithm> // This is still required for std::max
10
13
14
+ // ==============================================================================
11
15
PluginManager& getSharedPluginManager ()
12
16
{
13
17
auto * app = dynamic_cast <idolLiveAudioApplication*>(juce::JUCEApplication::getInstance ());
@@ -26,22 +30,20 @@ PresetManager& getSharedPresetManager()
26
30
}
27
31
28
32
// ==============================================================================
29
-
30
33
idolLiveAudioApplication::idolLiveAudioApplication () {}
31
34
32
35
idolLiveAudioApplication::MainWindow::MainWindow (juce::String name)
33
36
: DocumentWindow(name,
34
37
juce::Desktop::getInstance ().getDefaultLookAndFeel()
35
38
.findColour(juce::ResizableWindow::backgroundColourId),
36
- DocumentWindow::allButtons )
39
+ DocumentWindow::minimiseButton | DocumentWindow::closeButton )
37
40
{
38
41
setUsingNativeTitleBar (true );
39
42
setContentOwned (new MainComponent (), true );
40
43
#if JUCE_IOS || JUCE_ANDROID
41
44
setFullScreen (true );
42
45
#else
43
- setResizable (true , true );
44
- setResizeLimits (1640 , 1010 , 10000 , 10000 );
46
+ setResizable (false , false );
45
47
centreWithSize (1640 , 1010 );
46
48
#endif
47
49
setVisible (false );
@@ -62,7 +64,7 @@ void idolLiveAudioApplication::MainWindow::closeButtonPressed()
62
64
}
63
65
}
64
66
65
- // ... (Class SplashWindow không thay đổi) ...
67
+
66
68
class SplashWindow final : public juce::DocumentWindow
67
69
{
68
70
public:
@@ -76,23 +78,15 @@ class SplashWindow final : public juce::DocumentWindow
76
78
const int desiredHeight = static_cast <int >(desiredWidth * aspectRatio);
77
79
78
80
setContentOwned (new SplashScreenComponent (), true );
79
-
80
81
setUsingNativeTitleBar (false );
81
82
setResizable (false , false );
82
-
83
83
centreWithSize (static_cast <int >(desiredWidth), desiredHeight);
84
-
85
84
setVisible (true );
86
85
}
87
86
88
- SplashScreenComponent* getSplashContent ()
89
- {
90
- return dynamic_cast <SplashScreenComponent*>(getContentComponent ());
91
- }
92
-
93
87
void setStatusMessage (const juce::String& msg)
94
88
{
95
- if (auto * content = getSplashContent ( ))
89
+ if (auto * content = dynamic_cast <SplashScreenComponent*>( getContentComponent () ))
96
90
content->setStatusMessage (msg);
97
91
}
98
92
@@ -101,11 +95,8 @@ class SplashWindow final : public juce::DocumentWindow
101
95
102
96
103
97
// ==============================================================================
104
-
105
98
void idolLiveAudioApplication::initialise (const juce::String& commandLine)
106
99
{
107
- // Lời gọi CrashHandler::install(); đã được xóa
108
-
109
100
juce::ignoreUnused (commandLine);
110
101
111
102
splashWindow = std::make_unique<SplashWindow>();
@@ -115,6 +106,9 @@ void idolLiveAudioApplication::initialise(const juce::String& commandLine)
115
106
splashWindow->setStatusMessage (lang.get (" splash.initManagers" ));
116
107
pluginManager = std::make_unique<PluginManager>();
117
108
presetManager = std::make_unique<PresetManager>();
109
+ #if JUCE_WINDOWS
110
+ globalHotkeyManager = std::make_unique<GlobalHotkeyManager>();
111
+ #endif
118
112
119
113
splashWindow->setStatusMessage (lang.get (" splash.createWindow" ));
120
114
mainWindow.reset (new MainWindow (getApplicationName ()));
@@ -140,6 +134,25 @@ void idolLiveAudioApplication::initialise(const juce::String& commandLine)
140
134
}
141
135
}
142
136
137
+ #if JUCE_WINDOWS
138
+ if (globalHotkeyManager != nullptr )
139
+ {
140
+ globalHotkeyManager->onHotkeyTriggered = [mainComp](int slotIndex)
141
+ {
142
+ if (mainComp)
143
+ {
144
+ auto & soundPlayer = mainComp->getAudioEngine ().getSoundPlayer ();
145
+ const auto & slot = getSharedSoundboardProfileManager ().getCurrentSlots ().getReference (slotIndex);
146
+ if (!slot.isEmpty ())
147
+ {
148
+ soundPlayer.play (slot.audioFile , slotIndex);
149
+ }
150
+ }
151
+ };
152
+ globalHotkeyManager->start ();
153
+ }
154
+ #endif
155
+
143
156
auto error = deviceManager.initialise (32 , 32 , deviceSettingsXml.get (), true );
144
157
if (error.isNotEmpty ()) { DBG (" Audio device initialisation failed: " + error); }
145
158
}
@@ -148,6 +161,7 @@ void idolLiveAudioApplication::initialise(const juce::String& commandLine)
148
161
const auto elapsedTime = juce::Time::getMillisecondCounter () - startTime;
149
162
const int minDisplayTime = 4000 ;
150
163
164
+ // Now this line will compile correctly without conflicts.
151
165
int timeToWait = std::max (0 , minDisplayTime - (int )elapsedTime);
152
166
153
167
auto * mainWin = mainWindow.get ();
@@ -160,11 +174,23 @@ void idolLiveAudioApplication::initialise(const juce::String& commandLine)
160
174
161
175
void idolLiveAudioApplication::shutdown ()
162
176
{
177
+ #if JUCE_WINDOWS
178
+ if (globalHotkeyManager != nullptr )
179
+ {
180
+ globalHotkeyManager->stop ();
181
+ globalHotkeyManager.reset ();
182
+ }
183
+ #endif
184
+
185
+ /*
186
+ // <<< VÔ HIỆU HÓA KHỐI LỆNH NÀY >>>
187
+ // Ngăn không cho lưu trạng thái của MainComponent khi tắt ứng dụng.
163
188
if (mainWindow != nullptr)
164
189
{
165
190
if (auto* mainComp = dynamic_cast<MainComponent*>(mainWindow->getContentComponent()))
166
191
AppState::getInstance().saveState(*mainComp);
167
192
}
193
+ */
168
194
169
195
if (auto * mainComp = dynamic_cast <MainComponent*>(mainWindow->getContentComponent ()))
170
196
{
@@ -197,5 +223,5 @@ void idolLiveAudioApplication::showPluginManagerWindow()
197
223
pluginManagerWindow->toFront (true );
198
224
}
199
225
200
-
226
+ // ==============================================================================
201
227
START_JUCE_APPLICATION (idolLiveAudioApplication)
0 commit comments