Skip to content

Commit

Permalink
add message broadcast for significant game (re)loading events
Browse files Browse the repository at this point in the history
ReloadedScripts, GameChanged, ReloadedMetrics, ReloadedOverlayScreens, ReloadedTextures
NOTE: the primary uses of these right now are just for my convenience at fixing the very specific scripting issues that come up when you press F2, ctrl F2, shift F2, or shift ctrl F2. THIS IS NOT COMPREHENSIVE (because I figured it wouldn't be necessary)
  • Loading branch information
poco0317 committed Feb 28, 2023
1 parent b0be391 commit c7b68fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Etterna/Globals/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ namespace {
THEME->ReloadMetrics();
g_NewGame = std::string();
g_NewTheme = std::string();
MESSAGEMAN->Broadcast("ReloadedScripts");
MESSAGEMAN->Broadcast("GameChanged");
}
} // namespace

Expand Down
6 changes: 6 additions & 0 deletions src/Etterna/Globals/StepMania.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,16 +1278,20 @@ HandleGlobalInputs(const InputEventPlus& input)
NOTESKIN->RefreshNoteSkinData(GAMESTATE->m_pCurGame);
CodeDetector::RefreshCacheItems();
SCREENMAN->SystemMessage(RELOADED_METRICS);
MESSAGEMAN->Broadcast("ReloadedMetrics");
} else if (bIsCtrlHeld && !bIsShiftHeld) {
// Ctrl+F2: reload scripts only
THEME->UpdateLuaGlobals();
SCREENMAN->SystemMessage(RELOADED_SCRIPTS);
MESSAGEMAN->Broadcast("ReloadedScripts");
} else if (bIsCtrlHeld && bIsShiftHeld) {
// Shift+Ctrl+F2: reload overlay screens (and metrics, since themers
// are likely going to do this after changing metrics.)
THEME->ReloadMetrics();
SCREENMAN->ReloadOverlayScreens();
SCREENMAN->SystemMessage(RELOADED_OVERLAY_SCREENS);
MESSAGEMAN->Broadcast("ReloadedMetrics");
MESSAGEMAN->Broadcast("ReloadedOverlayScreens");
} else {
// F2 alone: refresh metrics, textures, noteskins, codedetector
// cache
Expand All @@ -1296,6 +1300,8 @@ HandleGlobalInputs(const InputEventPlus& input)
NOTESKIN->RefreshNoteSkinData(GAMESTATE->m_pCurGame);
CodeDetector::RefreshCacheItems();
SCREENMAN->SystemMessage(RELOADED_METRICS_AND_TEXTURES);
MESSAGEMAN->Broadcast("ReloadedMetrics");
MESSAGEMAN->Broadcast("ReloadedTextures");
}

return true;
Expand Down
15 changes: 9 additions & 6 deletions src/Etterna/Screen/Options/ScreenOptionsMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ ScreenOptionsMaster::HandleScreenMessage(const ScreenMessage& SM)
ExportOptions(r, PLAYER_1);

if ((m_iChangeMask & OPT_APPLY_ASPECT_RATIO) != 0) {
THEME->UpdateLuaGlobals(); // This needs to be done before resetting
// the projection matrix below
THEME->ReloadSubscribers(); // SCREEN_* has changed, so re-read all
// subscribing ThemeMetrics
SCREENMAN
->ThemeChanged(); // recreate ScreenSystemLayer and SharedBGA
// This needs to be done before resetting
// the projection matrix below
THEME->UpdateLuaGlobals();
// SCREEN_* has changed, so re-read all
// subscribing ThemeMetrics
THEME->ReloadSubscribers();
// recreate ScreenSystemLayer and SharedBGA
SCREENMAN->ThemeChanged();
MESSAGEMAN->Broadcast("ReloadedScripts");
}

/* If the theme changes, we need to reset RageDisplay to apply the new
Expand Down

0 comments on commit c7b68fa

Please sign in to comment.