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,72 +152,74 @@ 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;
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
bgMusic->SetLoop(true); bgMusic->SetLoop(true);
bgMusic->Play();
bgMusic->SetVolume(50); bgMusic->SetVolume(50);
while(reloadUIflag){
reloadUIflag = false;
exitCode = EXIT_RELAUNCH_ON_LOAD;
loadLanguageFromConfig();
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
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)
while(!exitApplication && !reloadUIflag){
//! main GX2 loop (60 Hz cycle with max priority on core 1) if(!bgMusic->IsPlaying() && CSettings::getValueAsBool(CSettings::MusicActivated)) bgMusic->Play();
while(!exitApplication) if(bgMusic->IsPlaying() && !CSettings::getValueAsBool(CSettings::MusicActivated)) bgMusic->Pause();
{
//! Read out inputs
for(s32 i = 0; i < 5; i++)
{
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
continue;
//! Read out inputs
for(s32 i = 0; i < 5; i++)
{
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
continue;
if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS){
exitCode = APPLICATION_CLOSE_APPLY;
exitApplication = true;
}
if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS){ if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME){
exitCode = APPLICATION_CLOSE_APPLY; exitCode = APPLICATION_CLOSE_MIIMAKER;
exitApplication = true; exitApplication = true;
}
//! update controller states
mainWindow->update(controller[i]);
}
mainWindow->process();
//! start rendering DRC
video->prepareDrcRendering();
mainWindow->drawDrc(video);
video->drcDrawDone();
//! start rendering TV
video->prepareTvRendering();
mainWindow->drawTv(video);
video->tvDrawDone();
//! enable screen after first frame render
if(video->getFrameCount() == 0) {
video->tvEnable(true);
video->drcEnable(true);
} }
if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME){ //! as last point update the effects as it can drop elements
exitCode = APPLICATION_CLOSE_MIIMAKER; mainWindow->updateEffects();
exitApplication = true;
}
video->waitForVSync();
//! update controller states //! transfer elements to real delete list here after all processes are finished
mainWindow->update(controller[i]); //! the elements are transfered to another list to delete the elements in a separate thread
//! and avoid blocking the GUI thread
AsyncDeleter::triggerDeleteProcess();
} }
mainWindow->process(); fadeOut();
MainWindow::destroyInstance();
//! start rendering DRC
video->prepareDrcRendering();
mainWindow->drawDrc(video);
video->drcDrawDone();
//! start rendering TV
video->prepareTvRendering();
mainWindow->drawTv(video);
video->tvDrawDone();
//! enable screen after first frame render
if(video->getFrameCount() == 0) {
video->tvEnable(true);
video->drcEnable(true);
}
//! as last point update the effects as it can drop elements
mainWindow->updateEffects();
video->waitForVSync();
//! transfer elements to real delete list here after all processes are finished
//! the elements are transfered to another list to delete the elements in a separate thread
//! and avoid blocking the GUI thread
AsyncDeleter::triggerDeleteProcess();
} }
fadeOut();
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;