Skip to content

Commit

Permalink
Add Shutdown option
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew1Hawes committed May 21, 2024
1 parent 8c0e12b commit 46b3624
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sysapp/launch.h>
#include <nn/act/client_cpp.h>
#include <coreinit/title.h>
#include <coreinit/launch.h>
#include <string_view>

WUPS_USE_STORAGE("CloseRestartGamePlugin");
Expand Down Expand Up @@ -43,6 +44,7 @@ static bool sCloseNow = false;
static bool sRestartNow = false;
static bool sSwitchUsers = false;
static bool sManageData = false;
static bool sShutdownNow = false;

void checkboxItemChanged(ConfigItemCheckbox *item, bool newValue)
{
Expand All @@ -55,6 +57,8 @@ void checkboxItemChanged(ConfigItemCheckbox *item, bool newValue)
sSwitchUsers = newValue;
} else if (std::string_view("sManageData") == item->identifier) {
sManageData = newValue;
} else if (std::string_view("sShutdownNow") == item->identifier) {
sShutdownNow = newValue;
}
}
}
Expand Down Expand Up @@ -122,6 +126,12 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle ro
root.add(WUPSConfigItemStub::Create("\uE06B Game options will appear here when in-game"));
}

root.add(WUPSConfigItemCheckbox::Create("sShutdownNow",
"Shutdown \uE040",
false,
sShutdownNow,
&checkboxItemChanged));

// Category: HOME Menu settings
auto homeMenuSettings = WUPSConfigCategory::Create("\ue073 Menu settings");

Expand Down Expand Up @@ -195,11 +205,14 @@ void ConfigMenuClosedCallback()
} else {
_SYSLaunchSettings(&settingsArgs);
}
} else if (sShutdownNow) {
OSShutdown();
}
sCloseNow = false;
sRestartNow = false;
sSwitchUsers = false;
sManageData = false;
sShutdownNow = false;
}

void initConfig()
Expand Down

0 comments on commit 46b3624

Please sign in to comment.