1313#include " views/ViewController.h"
1414#include " CollectionSystemManager.h"
1515#include " EmulationStation.h"
16+ #include " Scripting.h"
1617#include " SystemData.h"
1718#include " VolumeControl.h"
1819#include < SDL_events.h>
@@ -296,13 +297,15 @@ void GuiMenu::openUISettings()
296297 s->addSaveFunc ([window, theme_set]
297298 {
298299 bool needReload = false ;
299- if (Settings::getInstance ()->getString (" ThemeSet" ) != theme_set->getSelected ())
300+ std::string oldTheme = Settings::getInstance ()->getString (" ThemeSet" );
301+ if (oldTheme != theme_set->getSelected ())
300302 needReload = true ;
301303
302304 Settings::getInstance ()->setString (" ThemeSet" , theme_set->getSelected ());
303305
304306 if (needReload)
305307 {
308+ Scripting::fireEvent (" theme-changed" , theme_set->getSelected (), oldTheme);
306309 CollectionSystemManager::get ()->updateSystemsList ();
307310 ViewController::get ()->goToStart ();
308311 ViewController::get ()->reloadAll (); // TODO - replace this with some sort of signal-based implementation
@@ -472,6 +475,7 @@ void GuiMenu::openQuitMenu()
472475 row.makeAcceptInputHandler ([window] {
473476 window->pushGui (new GuiMsgBox (window, " REALLY RESTART?" , " YES" ,
474477 [] {
478+ Scripting::fireEvent (" quit" );
475479 if (quitES (" /tmp/es-restart" ) != 0 )
476480 LOG (LogWarning) << " Restart terminated with non-zero result!" ;
477481 }, " NO" , nullptr ));
@@ -487,9 +491,8 @@ void GuiMenu::openQuitMenu()
487491 row.makeAcceptInputHandler ([window] {
488492 window->pushGui (new GuiMsgBox (window, " REALLY QUIT?" , " YES" ,
489493 [] {
490- SDL_Event ev;
491- ev.type = SDL_QUIT ;
492- SDL_PushEvent (&ev);
494+ Scripting::fireEvent (" quit" );
495+ quitES (" " );
493496 }, " NO" , nullptr ));
494497 });
495498 row.addElement (std::make_shared<TextComponent>(window, " QUIT EMULATIONSTATION" , Font::get (FONT_SIZE_MEDIUM ), 0x777777FF ), true );
@@ -500,6 +503,8 @@ void GuiMenu::openQuitMenu()
500503 row.makeAcceptInputHandler ([window] {
501504 window->pushGui (new GuiMsgBox (window, " REALLY RESTART?" , " YES" ,
502505 [] {
506+ Scripting::fireEvent (" quit" , " reboot" );
507+ Scripting::fireEvent (" reboot" );
503508 if (quitES (" /tmp/es-sysrestart" ) != 0 )
504509 LOG (LogWarning) << " Restart terminated with non-zero result!" ;
505510 }, " NO" , nullptr ));
@@ -511,6 +516,8 @@ void GuiMenu::openQuitMenu()
511516 row.makeAcceptInputHandler ([window] {
512517 window->pushGui (new GuiMsgBox (window, " REALLY SHUTDOWN?" , " YES" ,
513518 [] {
519+ Scripting::fireEvent (" quit" , " shutdown" );
520+ Scripting::fireEvent (" shutdown" );
514521 if (quitES (" /tmp/es-shutdown" ) != 0 )
515522 LOG (LogWarning) << " Shutdown terminated with non-zero result!" ;
516523 }, " NO" , nullptr ));
0 commit comments