mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-20 13:24:40 -04:00
Add restart to prelaunch button to settings, remove gamemodeStub functions
This commit is contained in:
@@ -189,7 +189,7 @@ void dBrightCheck_c::modeMove() {
|
||||
if (!dusk::getSettings().game.hideTvSettingsScreen) {
|
||||
const dusk::gamemode::Gamemode* gamemode = dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnSaveLoadedFunction();
|
||||
gamemode->invokeOnSaveLoadedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -425,7 +425,7 @@ void dScnName_c::changeGameScene() {
|
||||
if (dusk::getSettings().game.hideTvSettingsScreen) {
|
||||
const dusk::gamemode::Gamemode* gamemode = dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnSaveLoadedFunction();
|
||||
gamemode->invokeOnSaveLoadedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1541,7 +1541,7 @@ void dSv_save_c::init() {
|
||||
#ifdef TARGET_PC
|
||||
const dusk::gamemode::Gamemode* gamemode = dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnNewSaveFunction();
|
||||
gamemode->invokeOnNewSaveFunction();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void GamemodeManager::setCurrentGamemode(const GamemodeId& id) {
|
||||
}
|
||||
const Gamemode* currentGamemode = getCurrentGamemode();
|
||||
if (currentGamemode) {
|
||||
currentGamemode->mOnDeactivatedFunction();
|
||||
currentGamemode->invokeOnDeactivatedFunction();
|
||||
}
|
||||
if (mRegisteredGamemodes.find(id) == mRegisteredGamemodes.end()) {
|
||||
DuskGamemodeLog.warn("Attempting to set current game mode to {} when it hasn't been registered!", id);
|
||||
@@ -86,7 +86,7 @@ void GamemodeManager::setCurrentGamemode(const GamemodeId& id) {
|
||||
if (currentGamemode) {
|
||||
// Set the loaded save file to our gamemode's save name
|
||||
mDoMemCd_SetFileName(currentGamemode->mSaveName);
|
||||
currentGamemode->mOnActivatedFunction();
|
||||
currentGamemode->invokeOnActivatedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+48
-9
@@ -21,16 +21,55 @@ public:
|
||||
std::string mFullName;
|
||||
std::string mSaveName;
|
||||
|
||||
std::function<void()> mOnActivatedFunction = gamemodeStub;
|
||||
std::function<void()> mOnDeactivatedFunction = gamemodeStub;
|
||||
std::function<void()> mOnPlayFunction = gamemodeStub;
|
||||
std::function<void()> mOnSaveLoadedFunction = gamemodeStub;
|
||||
std::function<void()> mOnNewSaveFunction = gamemodeStub;
|
||||
std::function<void()> mOnGameResetFunction = gamemodeStub;
|
||||
std::function<void()> mOnTickFunction = gamemodeStub;
|
||||
void invokeOnActivatedFunction() const {
|
||||
if (mOnActivatedFunction) {
|
||||
mOnActivatedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void gamemodeStub() {}
|
||||
void invokeOnDeactivatedFunction() const {
|
||||
if (mOnDeactivatedFunction) {
|
||||
mOnDeactivatedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
void invokeOnPlayFunction() const {
|
||||
if (mOnPlayFunction) {
|
||||
mOnPlayFunction();
|
||||
}
|
||||
}
|
||||
|
||||
void invokeOnSaveLoadedFunction() const {
|
||||
if (mOnSaveLoadedFunction) {
|
||||
mOnSaveLoadedFunction();
|
||||
}
|
||||
}
|
||||
|
||||
void invokeOnNewSaveFunction() const {
|
||||
if (mOnNewSaveFunction) {
|
||||
mOnNewSaveFunction();
|
||||
}
|
||||
}
|
||||
|
||||
void invokeOnGameResetFunction() const {
|
||||
if (mOnGameResetFunction) {
|
||||
mOnGameResetFunction();
|
||||
}
|
||||
}
|
||||
|
||||
void invokeOnTickFunction() const {
|
||||
if (mOnTickFunction) {
|
||||
mOnTickFunction();
|
||||
}
|
||||
}
|
||||
|
||||
std::function<void()> mOnActivatedFunction;
|
||||
std::function<void()> mOnDeactivatedFunction;
|
||||
std::function<void()> mOnPlayFunction;
|
||||
std::function<void()> mOnSaveLoadedFunction;
|
||||
std::function<void()> mOnNewSaveFunction;
|
||||
std::function<void()> mOnGameResetFunction;
|
||||
std::function<void()> mOnTickFunction;
|
||||
};
|
||||
|
||||
class GamemodeManager {
|
||||
|
||||
@@ -95,7 +95,10 @@ MenuBar::MenuBar()
|
||||
dismiss(modal);
|
||||
return;
|
||||
}
|
||||
prelaunch_state().showPrelaunchOnReset = true;
|
||||
if (gamemode::getGamemodeManager().getRegisteredGamemodes().size() > 1) {
|
||||
// If we have gamemodes registered, show pre-launch on a menubar reset
|
||||
prelaunch_state().showPrelaunchOnReset = true;
|
||||
}
|
||||
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
|
||||
dismiss(modal);
|
||||
Document::hide(true);
|
||||
|
||||
@@ -27,7 +27,6 @@ Modal::Modal(Props props) : WindowSmall("modal", "modal-dialog"), mProps(std::mo
|
||||
actions->SetClass("modal-actions", true);
|
||||
if (props.isVertical) {
|
||||
actions->SetClass("modal-actions-vertical", true);
|
||||
}else{
|
||||
}
|
||||
|
||||
for (auto& action : mProps.actions) {
|
||||
|
||||
@@ -701,7 +701,7 @@ void Prelaunch::rebuild_menu_buttons() {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string getPlayButtonText() {
|
||||
static std::string get_playbutton_text() {
|
||||
auto& state = prelaunch_state();
|
||||
const bool activeDiscLoaded = !state.activeDiscPath.empty();
|
||||
if (activeDiscLoaded == false) {
|
||||
@@ -765,7 +765,7 @@ void Prelaunch::build_menu_buttons() {
|
||||
// Set the gamemode to the last used before showing the play button
|
||||
dusk::gamemode::getGamemodeManager().setGamemodeToPrevious();
|
||||
|
||||
mMenuButtons.push_back(std::make_unique<Button>(menuList, getPlayButtonText()));
|
||||
mMenuButtons.push_back(std::make_unique<Button>(menuList, get_playbutton_text()));
|
||||
mMenuButtons.back()->on_pressed([this] {
|
||||
if (prelaunch_state().activeDiscPath.empty()) {
|
||||
open_iso_picker();
|
||||
@@ -791,7 +791,7 @@ void Prelaunch::build_menu_buttons() {
|
||||
const dusk::gamemode::Gamemode* gamemode =
|
||||
dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnPlayFunction();
|
||||
gamemode->invokeOnPlayFunction();
|
||||
}
|
||||
|
||||
IsGameLaunched = true;
|
||||
@@ -958,7 +958,7 @@ void Prelaunch::update() {
|
||||
}
|
||||
|
||||
if (!mMenuButtons.empty()) {
|
||||
mMenuButtons[0]->set_text(getPlayButtonText());
|
||||
mMenuButtons[0]->set_text(get_playbutton_text());
|
||||
}
|
||||
|
||||
const auto discStatusLabel = mDiscStatus->GetElementById("disc-status-label");
|
||||
|
||||
@@ -1351,6 +1351,17 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
|
||||
"replacements, and other app data.");
|
||||
});
|
||||
#endif
|
||||
leftPane.register_control(
|
||||
leftPane.add_button("Restart To Main Menu").on_pressed([this] {
|
||||
mDoAud_seStartMenu(kSoundClick);
|
||||
pop();
|
||||
ui::prelaunch_state().showPrelaunchOnReset = true;
|
||||
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
|
||||
}),
|
||||
rightPane, [](Pane& pane) {
|
||||
pane.add_text(
|
||||
"Restart Dusklight to the pre-launch menu to change settings, gamemodes, or mods.");
|
||||
});
|
||||
leftPane.register_control(
|
||||
leftPane.add_select_button({
|
||||
.key = "Notifications",
|
||||
@@ -1439,7 +1450,8 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
|
||||
{
|
||||
.key = "Skip Dusklight Main Menu",
|
||||
.helpText = "When starting Dusklight, skip the main menu and boot straight into the "
|
||||
"game if a disc image is available.",
|
||||
"game if a disc image is available.<br/><br/>Note: If any mods register gamemodes, "
|
||||
"then this option will be ignored.",
|
||||
});
|
||||
config_bool_select(leftPane, rightPane, getSettings().backend.checkForUpdates,
|
||||
{
|
||||
|
||||
@@ -848,7 +848,7 @@ void fapGm_Execute() {
|
||||
#ifdef TARGET_PC
|
||||
const dusk::gamemode::Gamemode* gamemode = dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnTickFunction();
|
||||
gamemode->invokeOnTickFunction();
|
||||
}
|
||||
dusk::AchievementSystem::get().tick();
|
||||
dusk::menu_pointer::end_game_frame();
|
||||
|
||||
@@ -114,7 +114,7 @@ void mDoRst_resetCallBack(int port, void*) {
|
||||
#ifdef TARGET_PC
|
||||
const dusk::gamemode::Gamemode* gamemode = dusk::gamemode::getGamemodeManager().getCurrentGamemode();
|
||||
if (gamemode) {
|
||||
gamemode->mOnGameResetFunction();
|
||||
gamemode->invokeOnGameResetFunction();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -158,7 +158,7 @@ void mDoRst_resetCallBack(int port, void*) {
|
||||
mDoRst::onReset();
|
||||
#ifdef TARGET_PC
|
||||
// Show pre-launch only if we have a registered gamemode and are resetting from the menubar
|
||||
if (dusk::ui::prelaunch_state().showPrelaunchOnReset == false || dusk::gamemode::getGamemodeManager().getRegisteredGamemodes().size() == 1) {
|
||||
if (dusk::ui::prelaunch_state().showPrelaunchOnReset == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user