Added function to reload the UI

This commit is contained in:
Maschell 2017-05-07 14:52:18 +02:00
parent b7d5e68026
commit f749160fd4
2 changed files with 61 additions and 52 deletions

View File

@ -90,6 +90,9 @@ s32 Application::exec(){
return exitCode; return exitCode;
} }
void Application::reloadUI(){
reloadUIflag = true;
}
void Application::fadeOut(){ void Application::fadeOut(){
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 }); GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 });
@ -149,26 +152,29 @@ void Application::executeThread(void){
GuiText::setPresetFont(fontSystem); GuiText::setPresetFont(fontSystem);
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__); log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
reloadUIflag = true;
bgMusic->SetLoop(true);
bgMusic->SetVolume(50);
while(reloadUIflag){
reloadUIflag = false;
exitCode = EXIT_RELAUNCH_ON_LOAD;
loadLanguageFromConfig();
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight()); mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
bgMusic->SetLoop(true);
bgMusic->Play();
bgMusic->SetVolume(50);
log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__); log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__);
exitApplication = false;
//! main GX2 loop (60 Hz cycle with max priority on core 1) //! main GX2 loop (60 Hz cycle with max priority on core 1)
while(!exitApplication) while(!exitApplication && !reloadUIflag){
{
if(!bgMusic->IsPlaying() && CSettings::getValueAsBool(CSettings::MusicActivated)) bgMusic->Play();
if(bgMusic->IsPlaying() && !CSettings::getValueAsBool(CSettings::MusicActivated)) bgMusic->Pause();
//! Read out inputs //! Read out inputs
for(s32 i = 0; i < 5; i++) for(s32 i = 0; i < 5; i++)
{ {
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false) if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
continue; continue;
if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS){ if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS){
exitCode = APPLICATION_CLOSE_APPLY; exitCode = APPLICATION_CLOSE_APPLY;
exitApplication = true; exitApplication = true;
@ -179,7 +185,6 @@ void Application::executeThread(void){
exitApplication = true; exitApplication = true;
} }
//! update controller states //! update controller states
mainWindow->update(controller[i]); mainWindow->update(controller[i]);
} }
@ -211,10 +216,10 @@ void Application::executeThread(void){
//! and avoid blocking the GUI thread //! and avoid blocking the GUI thread
AsyncDeleter::triggerDeleteProcess(); AsyncDeleter::triggerDeleteProcess();
} }
fadeOut(); fadeOut();
MainWindow::destroyInstance(); MainWindow::destroyInstance();
}
delete fontSystem; delete fontSystem;
delete video; delete video;
} }

View File

@ -54,6 +54,8 @@ public:
s32 exec(void); s32 exec(void);
void fadeOut(void); void fadeOut(void);
void reloadUI(void);
void quit(s32 code) { void quit(s32 code) {
exitCode = code; exitCode = code;
exitApplication = true; exitApplication = true;
@ -70,6 +72,8 @@ private:
void loadLanguageFromConfig(); void loadLanguageFromConfig();
bool reloadUIflag = false;
GuiSound *bgMusic; GuiSound *bgMusic;
CVideo *video; CVideo *video;
MainWindow *mainWindow; MainWindow *mainWindow;