mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-22 02:12:06 +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:
parent
bfeba7c1e8
commit
a1fb8a91c8
3 changed files with 32 additions and 5 deletions
|
@ -261,6 +261,9 @@ class Daybreak : public CApplication {
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
/* Initialize the menu. */
|
/* Initialize the menu. */
|
||||||
|
if (argc > 1)
|
||||||
|
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight, argv[1]);
|
||||||
|
else
|
||||||
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight);
|
dbk::InitializeMenu(FramebufferWidth, FramebufferHeight);
|
||||||
|
|
||||||
Daybreak daybreak;
|
Daybreak daybreak;
|
||||||
|
|
|
@ -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;
|
Result rc = 0;
|
||||||
|
|
||||||
/* Configure and initialize the gamepad. */
|
/* Configure and initialize the gamepad. */
|
||||||
|
@ -1237,7 +1237,7 @@ namespace dbk {
|
||||||
u64 version;
|
u64 version;
|
||||||
if (R_FAILED(rc = splGetConfig(static_cast<SplConfigItem>(ExosphereApiVersionConfigItem), &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));
|
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;
|
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);
|
const bool ams_supports_sysupdate_api = EncodeVersion(version_major, version_minor, version_micro) >= EncodeVersion(0, 14, 0);
|
||||||
if (!ams_supports_sysupdate_api) {
|
if (!ams_supports_sysupdate_api) {
|
||||||
ChangeMenu(std::make_shared<ErrorMenu>("Outdated Atmosphere version", "Daybreak requires Atmosphere 0.14.0 or later.", rc));
|
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. */
|
/* Attempt to get the supported version. */
|
||||||
|
@ -1263,6 +1269,23 @@ namespace dbk {
|
||||||
|
|
||||||
/* Change the current menu to the main menu. */
|
/* Change the current menu to the main menu. */
|
||||||
g_current_menu = std::make_shared<MainMenu>();
|
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) {
|
void UpdateMenu(u64 ns) {
|
||||||
|
|
|
@ -263,7 +263,8 @@ namespace dbk {
|
||||||
virtual void Draw(NVGcontext *vg, u64 ns) override;
|
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 UpdateMenu(u64 ns);
|
||||||
void RenderMenu(NVGcontext *vg, u64 ns);
|
void RenderMenu(NVGcontext *vg, u64 ns);
|
||||||
bool IsExitRequested();
|
bool IsExitRequested();
|
||||||
|
|
Loading…
Reference in a new issue