forked from PretendoNetwork/Inkay
Merge pull request #85 from jazamb/show-startup-toast-patch
feat: make startup toast optional
This commit is contained in:
commit
b4407310e5
10 changed files with 48 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ struct config_strings {
|
||||||
const char *plugin_name;
|
const char *plugin_name;
|
||||||
std::string_view network_category;
|
std::string_view network_category;
|
||||||
std::string_view connect_to_network_setting;
|
std::string_view connect_to_network_setting;
|
||||||
|
std::string_view show_startup_toast_setting;
|
||||||
std::string_view other_category;
|
std::string_view other_category;
|
||||||
std::string_view reset_wwp_setting;
|
std::string_view reset_wwp_setting;
|
||||||
std::string_view press_a_action;
|
std::string_view press_a_action;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
static config_strings strings;
|
static config_strings strings;
|
||||||
|
|
||||||
bool Config::connect_to_network = true;
|
bool Config::connect_to_network = true;
|
||||||
|
bool Config::show_startup_toast = true;
|
||||||
bool Config::need_relaunch = false;
|
bool Config::need_relaunch = false;
|
||||||
bool Config::unregister_task_item_pressed = false;
|
bool Config::unregister_task_item_pressed = false;
|
||||||
bool Config::is_wiiu_menu = false;
|
bool Config::is_wiiu_menu = false;
|
||||||
|
|
@ -64,6 +65,15 @@ static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value)
|
||||||
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
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<bool>("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) {
|
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)) {
|
if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && ((input.buttons_d & WUPS_CONFIG_BUTTON_A) == WUPS_CONFIG_BUTTON_A)) {
|
||||||
|
|
||||||
|
|
@ -156,6 +166,9 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
|
||||||
auto other_cat = WUPSConfigCategory::Create(strings.other_category, err);
|
auto other_cat = WUPSConfigCategory::Create(strings.other_category, err);
|
||||||
if (!other_cat) return report_error(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 = {
|
WUPSConfigAPIItemCallbacksV2 unregisterTasksItemCallbacks = {
|
||||||
.getCurrentValueDisplay = unregister_task_item_get_display_value,
|
.getCurrentValueDisplay = unregister_task_item_get_display_value,
|
||||||
.getCurrentValueSelectedDisplay = unregister_task_item_get_display_value,
|
.getCurrentValueSelectedDisplay = unregister_task_item_get_display_value,
|
||||||
|
|
@ -181,6 +194,9 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
|
||||||
err = WUPSConfigAPI_Category_AddItem(other_cat->getHandle(), unregisterTasksItem);
|
err = WUPSConfigAPI_Category_AddItem(other_cat->getHandle(), unregisterTasksItem);
|
||||||
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err);
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) 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);
|
res = root.add(std::move(*other_cat), err);
|
||||||
if (!res) return report_error(err);
|
if (!res) return report_error(err);
|
||||||
|
|
||||||
|
|
@ -210,7 +226,7 @@ void Config::Init() {
|
||||||
if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void)report_error(cres);
|
if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void)report_error(cres);
|
||||||
|
|
||||||
WUPSStorageError res;
|
WUPSStorageError res;
|
||||||
// Try to get value from storage
|
// Try to get values from storage
|
||||||
res = WUPSStorageAPI::Get<bool>("connect_to_network", Config::connect_to_network);
|
res = WUPSStorageAPI::Get<bool>("connect_to_network", Config::connect_to_network);
|
||||||
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
||||||
DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create");
|
DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create");
|
||||||
|
|
@ -228,6 +244,16 @@ void Config::Init() {
|
||||||
}
|
}
|
||||||
else 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<bool>("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<bool>("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);
|
||||||
|
|
||||||
// Save storage
|
// Save storage
|
||||||
res = WUPSStorageAPI::SaveStorage();
|
res = WUPSStorageAPI::SaveStorage();
|
||||||
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ public:
|
||||||
// wups config items
|
// wups config items
|
||||||
static bool connect_to_network;
|
static bool connect_to_network;
|
||||||
|
|
||||||
|
static bool show_startup_toast;
|
||||||
|
|
||||||
// private stuff
|
// private stuff
|
||||||
static bool need_relaunch;
|
static bool need_relaunch;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ INITIALIZE_PLUGIN() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if using pretendo then (try to) apply the ssl patches
|
// 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() {
|
DEINITIALIZE_PLUGIN() {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <coreinit/dynload.h>
|
#include <coreinit/dynload.h>
|
||||||
|
|
||||||
static OSDynLoad_Module module;
|
static OSDynLoad_Module module;
|
||||||
static void (*moduleInitialize)(bool) = nullptr;
|
static void (*moduleInitialize)(bool, bool) = nullptr;
|
||||||
static InkayStatus (*moduleGetStatus)() = nullptr;
|
static InkayStatus (*moduleGetStatus)() = nullptr;
|
||||||
static void (*moduleSetPluginRunning)() = nullptr;
|
static void (*moduleSetPluginRunning)() = nullptr;
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ static const char *get_module_init_not_found_message() {
|
||||||
return get_config_strings(get_system_language()).module_init_not_found.data();
|
return get_config_strings(get_system_language()).module_init_not_found.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inkay_Initialize(bool apply_patches) {
|
void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
|
||||||
if (module) {
|
if (module) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ void Inkay_Initialize(bool apply_patches) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
moduleInitialize(apply_patches);
|
moduleInitialize(apply_patches, show_startup_toast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inkay_Finalize() {
|
void Inkay_Finalize() {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ enum class InkayStatus {
|
||||||
Error = -1 ///< Failed to retrieve the module status
|
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();
|
void Inkay_Finalize();
|
||||||
InkayStatus Inkay_GetStatus();
|
InkayStatus Inkay_GetStatus();
|
||||||
void Inkay_SetPluginRunning();
|
void Inkay_SetPluginRunning();
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
bool Config::connect_to_network = false;
|
bool Config::connect_to_network = false;
|
||||||
|
bool Config::show_startup_toast = false;
|
||||||
bool Config::initialized = false;
|
bool Config::initialized = false;
|
||||||
bool Config::shown_warning = false;
|
bool Config::shown_warning = false;
|
||||||
bool Config::plugin_is_loaded = false;
|
bool Config::plugin_is_loaded = false;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ public:
|
||||||
|
|
||||||
static bool connect_to_network;
|
static bool connect_to_network;
|
||||||
|
|
||||||
|
static bool show_startup_toast;
|
||||||
|
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
|
|
||||||
static bool shown_warning;
|
static bool shown_warning;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
.plugin_name="Inkay"
|
.plugin_name="Inkay"
|
||||||
,.network_category="Network selection"
|
,.network_category="Network selection"
|
||||||
,.connect_to_network_setting="Connect to Pretendo Network"
|
,.connect_to_network_setting="Connect to Pretendo Network"
|
||||||
|
,.show_startup_toast_setting="Show startup toast"
|
||||||
,.other_category="Other settings"
|
,.other_category="Other settings"
|
||||||
,.reset_wwp_setting="Reset Wara Wara Plaza"
|
,.reset_wwp_setting="Reset Wara Wara Plaza"
|
||||||
,.press_a_action="Press A"
|
,.press_a_action="Press A"
|
||||||
|
|
|
||||||
12
src/main.cpp
12
src/main.cpp
|
|
@ -122,10 +122,12 @@ static InkayStatus Inkay_GetStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Inkay_Initialize(bool apply_patches) {
|
static void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
|
||||||
if (Config::initialized)
|
if (Config::initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Config::show_startup_toast = show_startup_toast;
|
||||||
|
|
||||||
if (Config::block_initialize) {
|
if (Config::block_initialize) {
|
||||||
ShowNotification("Cannot load Inkay while the system is running. Please restart the console");
|
ShowNotification("Cannot load Inkay while the system is running. Please restart the console");
|
||||||
return;
|
return;
|
||||||
|
|
@ -150,12 +152,16 @@ static void Inkay_Initialize(bool apply_patches) {
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
|
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
|
||||||
|
|
||||||
ShowNotification(get_pretendo_message());
|
if (Config::show_startup_toast) {
|
||||||
|
ShowNotification(get_pretendo_message());
|
||||||
|
}
|
||||||
Config::initialized = true;
|
Config::initialized = true;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
|
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
|
||||||
|
|
||||||
ShowNotification(get_nintendo_network_message());
|
if(Config::show_startup_toast) {
|
||||||
|
ShowNotification(get_nintendo_network_message());
|
||||||
|
}
|
||||||
Config::initialized = true;
|
Config::initialized = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue