diff --git a/common/lang.h b/common/lang.h index 29994b2..692f9ec 100644 --- a/common/lang.h +++ b/common/lang.h @@ -26,6 +26,7 @@ struct config_strings { const char *plugin_name; std::string_view network_category; std::string_view connect_to_network_setting; + std::string_view show_startup_toast_setting; std::string_view other_category; std::string_view reset_wwp_setting; std::string_view press_a_action; diff --git a/plugin/src/config.cpp b/plugin/src/config.cpp index 9533b1c..5e68c15 100644 --- a/plugin/src/config.cpp +++ b/plugin/src/config.cpp @@ -40,6 +40,7 @@ static config_strings strings; bool Config::connect_to_network = true; +bool Config::show_startup_toast = true; bool Config::need_relaunch = false; bool Config::unregister_task_item_pressed = false; bool Config::is_wiiu_menu = false; @@ -82,6 +83,15 @@ static void language_changed(ConfigItemMultipleValues* item, uint32_t new_value) if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); } +static void show_startup_toast_changed(ConfigItemBoolean* item, bool new_value) { + DEBUG_FUNCTION_LINE_VERBOSE("show_startup_toast changed to: %d", new_value); + Config::show_startup_toast = new_value; + + WUPSStorageError res; + res = WUPSStorageAPI::Store("show_startup_toast", Config::show_startup_toast); + if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); +} + static void unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadData input) { if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && ((input.buttons_d & WUPS_CONFIG_BUTTON_A) == WUPS_CONFIG_BUTTON_A)) { @@ -174,6 +184,9 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa auto other_cat = WUPSConfigCategory::Create(strings.other_category, err); if (!other_cat) return report_error(err); + auto startup_toast_item = WUPSConfigItemBoolean::Create("show_startup_toast", strings.show_startup_toast_setting, true, Config::show_startup_toast, &show_startup_toast_changed, err); + if (!startup_toast_item) return report_error(err); + WUPSConfigAPIItemCallbacksV2 unregisterTasksItemCallbacks = { .getCurrentValueDisplay = unregister_task_item_get_display_value, .getCurrentValueSelectedDisplay = unregister_task_item_get_display_value, @@ -220,7 +233,11 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa if (!language_item) return report_error(err); res = other_cat->add(std::move(*language_item), err); - if (!res) report_error(err); + if (!res) return report_error(err); + + res = other_cat->add(std::move(*startup_toast_item), err); + if (!res) return report_error(err); + res = root.add(std::move(*other_cat), err); if (!res) return report_error(err); @@ -251,7 +268,7 @@ void Config::Init() { if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void)report_error(cres); WUPSStorageError res; - // Try to get value from storage + // Try to get values from storage res = WUPSStorageAPI::Get("connect_to_network", Config::connect_to_network); if (res == WUPS_STORAGE_ERROR_NOT_FOUND) { DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create"); @@ -278,6 +295,16 @@ void Config::Init() { if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); } else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); + + res = WUPSStorageAPI::Get("show_startup_toast", Config::show_startup_toast); + if (res == WUPS_STORAGE_ERROR_NOT_FOUND) { + DEBUG_FUNCTION_LINE("Show startup toast value not found, attempting to create"); + + // Add the value to the storage if it's missing. + res = WUPSStorageAPI::Store("show_startup_toast", show_startup_toast); + if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); + } + else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); // Set the language that's currently used if (Config::language == inkay_language::System) diff --git a/plugin/src/config.h b/plugin/src/config.h index fc84610..a2c97d5 100644 --- a/plugin/src/config.h +++ b/plugin/src/config.h @@ -16,6 +16,8 @@ public: static bool connect_to_network; static uint32_t language; + static bool show_startup_toast; + // private stuff static bool need_relaunch; diff --git a/plugin/src/main.cpp b/plugin/src/main.cpp index e95eaac..535c266 100644 --- a/plugin/src/main.cpp +++ b/plugin/src/main.cpp @@ -50,7 +50,7 @@ INITIALIZE_PLUGIN() { } // if using pretendo then (try to) apply the ssl patches - Inkay_Initialize(Config::connect_to_network); + Inkay_Initialize(Config::connect_to_network, Config::show_startup_toast); } DEINITIALIZE_PLUGIN() { diff --git a/plugin/src/module.cpp b/plugin/src/module.cpp index 586a4c7..94325cd 100644 --- a/plugin/src/module.cpp +++ b/plugin/src/module.cpp @@ -24,7 +24,7 @@ #include static OSDynLoad_Module module; -static void (*moduleInitialize)(bool, inkay_language) = nullptr; +static void (*moduleInitialize)(bool, bool, inkay_language) = nullptr; static InkayStatus (*moduleGetStatus)() = nullptr; static void (*moduleSetPluginRunning)() = nullptr; @@ -36,7 +36,7 @@ static const char *get_module_init_not_found_message() { return get_config_strings(Config::current_language).module_init_not_found.data(); } -void Inkay_Initialize(bool apply_patches) { +void Inkay_Initialize(bool apply_patches, bool show_startup_toast) { if (module) { return; } @@ -53,8 +53,8 @@ void Inkay_Initialize(bool apply_patches) { OSDynLoad_Release(module); return; } - - moduleInitialize(apply_patches, Config::current_language); + + moduleInitialize(apply_patches, show_startup_toast, Config::current_language); } void Inkay_Finalize() { diff --git a/plugin/src/module.h b/plugin/src/module.h index ab7836d..22e2356 100644 --- a/plugin/src/module.h +++ b/plugin/src/module.h @@ -24,7 +24,7 @@ enum class InkayStatus { Error = -1 ///< Failed to retrieve the module status }; -void Inkay_Initialize(bool apply_patches); +void Inkay_Initialize(bool apply_patches, bool show_startup_toast); void Inkay_Finalize(); InkayStatus Inkay_GetStatus(); void Inkay_SetPluginRunning(); diff --git a/src/config.cpp b/src/config.cpp index 66a78c4..8400d21 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -18,6 +18,7 @@ #include "config.h" bool Config::connect_to_network = false; +bool Config::show_startup_toast = false; bool Config::initialized = false; bool Config::shown_warning = false; bool Config::plugin_is_loaded = false; diff --git a/src/config.h b/src/config.h index 8455bb0..faecea9 100644 --- a/src/config.h +++ b/src/config.h @@ -10,6 +10,8 @@ public: static bool connect_to_network; + static bool show_startup_toast; + static bool initialized; static bool shown_warning; diff --git a/src/lang/en_US.lang b/src/lang/en_US.lang index 09ebe6a..1fb1fd0 100644 --- a/src/lang/en_US.lang +++ b/src/lang/en_US.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Network selection" ,.connect_to_network_setting="Connect to Pretendo Network" +,.show_startup_toast_setting="Show startup toast" ,.other_category="Other settings" ,.reset_wwp_setting="Reset Wara Wara Plaza" ,.press_a_action="Press A" diff --git a/src/lang/nl_NL.lang b/src/lang/nl_NL.lang index 9e67847..f96206f 100644 --- a/src/lang/nl_NL.lang +++ b/src/lang/nl_NL.lang @@ -1,6 +1,6 @@ .plugin_name="Inkay" ,.network_category="Netwerkselectie" -,.connect_to_network_setting="Verbind met het Pretendo-netwerk" +,.connect_to_network_setting="Verbind met het Pretendo-Netwerk" ,.other_category="Overige instellingen" ,.reset_wwp_setting="Reset het Wara Wara Plaza" ,.press_a_action="Druk A" @@ -10,4 +10,4 @@ ,.using_pretendo_network="Pretendo Network wordt gebruikt" ,.multiplayer_port_display="Gebruikt UDP port %hu voor multiplayer" ,.module_not_found="Pretendo patch mislukt - gebruik Aroma Updater om het te herstellen (686-1001 Module ontbreekt)" -,.module_init_not_found="Pretendo patch mislukt - gebruik Aroma Updater om het te herstellen (686-1002 Module init)" +,.module_init_not_found="Pretendo-Netwerk patch mislukt - gebruik Aroma Updater om het te herstellen (686-1002 Module init)" diff --git a/src/main.cpp b/src/main.cpp index 008c976..b91d271 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,10 +122,12 @@ static InkayStatus Inkay_GetStatus() { } } -static void Inkay_Initialize(bool apply_patches, inkay_language language) { +static void Inkay_Initialize(bool apply_patches, bool show_startup_toast, inkay_language language) { if (Config::initialized) return; + Config::show_startup_toast = show_startup_toast; + if (Config::block_initialize) { ShowNotification("Cannot load Inkay while the system is running. Please restart the console"); return; @@ -150,12 +152,16 @@ static void Inkay_Initialize(bool apply_patches, inkay_language language) { DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully."); - ShowNotification(get_pretendo_message(language)); + if (Config::show_startup_toast) { + ShowNotification(get_pretendo_message(language)); + } Config::initialized = true; } else { DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped."); - ShowNotification(get_nintendo_network_message(language)); + if(Config::show_startup_toast) { + ShowNotification(get_nintendo_network_message(language)); + } Config::initialized = true; return; }