1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-21 09:52:09 +00:00

Add arguments support to Daybreak (#1616)

* Add arguments support to Daybreak

* Check if Daybreak is run as NRO
This commit is contained in:
HamletDuFromage 2021-09-11 19:55:25 +02:00 committed by GitHub
parent bfeba7c1e8
commit a1fb8a91c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 5 deletions

View file

@ -261,7 +261,10 @@ class Daybreak : public CApplication {
int main(int argc, char **argv) {
/* Initialize the menu. */
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight);
if (argc > 1)
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight, argv[1]);
else
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight);
Daybreak daybreak;
daybreak.run();

View file

@ -1216,7 +1216,7 @@ namespace dbk {
}
}
void InitializeMenu(u32 screen_width, u32 screen_height) {
bool InitializeMenu(u32 screen_width, u32 screen_height) {
Result rc = 0;
/* Configure and initialize the gamepad. */
@ -1237,7 +1237,7 @@ namespace dbk {
u64 version;
if (R_FAILED(rc = splGetConfig(static_cast<SplConfigItem>(ExosphereApiVersionConfigItem), &version))) {
ChangeMenu(std::make_shared<ErrorMenu>("Atmosphere not found", "Daybreak requires Atmosphere to be installed.", rc));
return;
return false;
}
const u32 version_micro = (version >> 40) & 0xff;
@ -1248,7 +1248,13 @@ namespace dbk {
const bool ams_supports_sysupdate_api = EncodeVersion(version_major, version_minor, version_micro) >= EncodeVersion(0, 14, 0);
if (!ams_supports_sysupdate_api) {
ChangeMenu(std::make_shared<ErrorMenu>("Outdated Atmosphere version", "Daybreak requires Atmosphere 0.14.0 or later.", rc));
return;
return false;
}
/* Ensure DayBreak is ran as a NRO. */
if (envIsNso()) {
ChangeMenu(std::make_shared<ErrorMenu>("Unsupported Environment", "Please launch Daybreak via the Homebrew menu.", rc));
return false;
}
/* Attempt to get the supported version. */
@ -1263,6 +1269,23 @@ namespace dbk {
/* Change the current menu to the main menu. */
g_current_menu = std::make_shared<MainMenu>();
return true;
}
bool InitializeMenu(u32 screen_width, u32 screen_height, const char *update_path) {
if (InitializeMenu(screen_width, screen_height)) {
/* Set the update path. */
strncpy(g_update_path, update_path, sizeof(g_update_path));
/* Change the menu. */
ChangeMenu(std::make_shared<ValidateUpdateMenu>(g_current_menu));
return true;
}
return false;
}
void UpdateMenu(u64 ns) {

View file

@ -263,7 +263,8 @@ namespace dbk {
virtual void Draw(NVGcontext *vg, u64 ns) override;
};
void InitializeMenu(u32 screen_width, u32 screen_height);
bool InitializeMenu(u32 screen_width, u32 screen_height);
bool InitializeMenu(u32 screen_width, u32 screen_height, const char *update_path);
void UpdateMenu(u64 ns);
void RenderMenu(NVGcontext *vg, u64 ns);
bool IsExitRequested();