diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..792dce0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: Inkay-CI +permissions: + contents: read + +on: +- push +- pull_request + +jobs: + build-inkay: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v7 + - name: build toolchain container + run: docker build . -t builder + - uses: ammaraskar/gcc-problem-matcher@master + - name: build Inkay + run: docker run --rm -v ${PWD}:/app -w /app builder + - uses: actions/upload-artifact@v7 + with: + name: inkay + path: dist/ diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..e0192d2 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,101 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '25 19 * * 2' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: actions + build-mode: none + - language: c-cpp + build-mode: none + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - name: Run manual build steps + if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{matrix.language}}" diff --git a/Dockerfile b/Dockerfile index d45375f..7583bee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/wiiu-env/devkitppc:20250608 +FROM ghcr.io/wiiu-env/devkitppc:20260504 COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO diff --git a/common/lang.cpp b/common/lang.cpp index 3f32b17..ac39d15 100644 --- a/common/lang.cpp +++ b/common/lang.cpp @@ -4,41 +4,47 @@ #include "lang.h" -config_strings get_config_strings(nn::swkbd::LanguageType language) { +config_strings get_config_strings(inkay_language language) { switch (language) { - case nn::swkbd::LanguageType::English: + case inkay_language::English: default: return { #include "en_US.lang" }; - case nn::swkbd::LanguageType::Spanish: return { + case inkay_language::Spanish: return { #include "es_ES.lang" }; - case nn::swkbd::LanguageType::French: return { + case inkay_language::French: return { #include "fr_FR.lang" }; - case nn::swkbd::LanguageType::Italian: return { + case inkay_language::Italian: return { #include "it_IT.lang" }; - case nn::swkbd::LanguageType::German: return { + case inkay_language::German: return { #include "de_DE.lang" }; - case nn::swkbd::LanguageType::SimplifiedChinese: return { + case inkay_language::SimplifiedChinese: return { #include "zh_CN.lang" }; - case nn::swkbd::LanguageType::TraditionalChinese: return { + case inkay_language::TraditionalChinese: return { #include "zh_Hant.lang" }; - case nn::swkbd::LanguageType::Portuguese: return { + case inkay_language::Portuguese: return { #include "pt_BR.lang" }; - case nn::swkbd::LanguageType::Japanese: return { + case inkay_language::Japanese: return { #include "ja_JP.lang" }; - case nn::swkbd::LanguageType::Dutch: return { + case inkay_language::Dutch: return { #include "nl_NL.lang" }; - case nn::swkbd::LanguageType::Russian: return { + case inkay_language::Russian: return { #include "ru_RU.lang" }; + case inkay_language::Korean: return { +#include "ko_KR.lang" + }; + case inkay_language::EnUwU: return { +#include "en@uwu.lang" + }; } } diff --git a/common/lang.h b/common/lang.h index 6e557fe..d004ef8 100644 --- a/common/lang.h +++ b/common/lang.h @@ -1,12 +1,32 @@ #pragma once #include -#include + +enum inkay_language { + // Wii U System Languages + Japanese = 0, + English, + French, + German, + Italian, + Spanish, + SimplifiedChinese, + Korean, + Dutch, + Portuguese, + Russian, + TraditionalChinese, + Invalid, + // Custom Languages + System, + EnUwU, +}; 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; @@ -17,6 +37,11 @@ struct config_strings { std::string_view multiplayer_port_display; std::string_view module_not_found; std::string_view module_init_not_found; + std::string_view setting_yes; + std::string_view setting_no; + std::string_view language_setting; + std::string_view language_name; + std::string_view system_language; }; -config_strings get_config_strings(nn::swkbd::LanguageType language); +config_strings get_config_strings(inkay_language language); diff --git a/common/sysconfig.cpp b/common/sysconfig.cpp index ec56614..bb13d4b 100644 --- a/common/sysconfig.cpp +++ b/common/sysconfig.cpp @@ -53,7 +53,7 @@ nn::swkbd::LanguageType get_system_language() { return nn::swkbd::LanguageType::English; } - DEBUG_FUNCTION_LINE_VERBOSE("System language found: %d", language); + DEBUG_FUNCTION_LINE_VERBOSE("System language found: %d", static_cast(language)); cached_language = language; return language; } @@ -80,7 +80,7 @@ static void get_mcp_config() { mcp_os_version = os_version; DEBUG_FUNCTION_LINE_VERBOSE("Running on %d.%d.%d%c; %s%s", - os_version.major, os_version.minor, os_version.patch, os_version.region + os_version.major, os_version.minor, os_version.patch, os_version.region, config.code_id, config.serial_id ); } diff --git a/plugin/src/config.cpp b/plugin/src/config.cpp index 98c2323..21d4146 100644 --- a/plugin/src/config.cpp +++ b/plugin/src/config.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -39,12 +40,15 @@ 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; +uint32_t Config::language = 13; +inkay_language Config::current_language = English; -static WUPSConfigAPICallbackStatus report_error(WUPSConfigAPIStatus err) { - DEBUG_FUNCTION_LINE_VERBOSE("WUPS config error: %s", WUPSConfigAPI_GetStatusStr(err)); +static WUPSConfigAPICallbackStatus report_error(WUPSConfigAPIStatus err, int line) { + DEBUG_FUNCTION_LINE_VERBOSE("WUPS config error: %s (L%04d)", WUPSConfigAPI_GetStatusStr(err), line); return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; } @@ -52,43 +56,63 @@ static void report_storage_error(WUPSStorageError err) { DEBUG_FUNCTION_LINE_VERBOSE("WUPS storage error: %s", WUPSStorageAPI_GetStatusStr(err)); } -static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value) { +static void connect_to_network_changed(ConfigItemBoolean *item, bool new_value) { DEBUG_FUNCTION_LINE_VERBOSE("connect_to_network changed to: %d", new_value); if (new_value != Config::connect_to_network) { Config::need_relaunch = true; } Config::connect_to_network = new_value; - WUPSStorageError res; - res = WUPSStorageAPI::Store("connect_to_network", Config::connect_to_network); + WUPSStorageError res = WUPSStorageAPI_StoreBool(nullptr, "connect_to_network", Config::connect_to_network); + if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); +} + +static void language_changed(ConfigItemMultipleValues *item, uint32_t new_value) { + DEBUG_FUNCTION_LINE_VERBOSE("language changed to: %d", new_value); + if (new_value != Config::language) { + if (new_value == inkay_language::System) + Config::current_language = (inkay_language) get_system_language(); + else + Config::current_language = (inkay_language) new_value; + } + Config::language = new_value; + + WUPSStorageError res = WUPSStorageAPI_StoreU32(nullptr, "language", Config::language); + 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 = WUPSStorageAPI_StoreBool(nullptr, "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)) { - + if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && ( + (input.buttons_d & WUPS_CONFIG_BUTTON_A) == WUPS_CONFIG_BUTTON_A)) { nn::act::Initialize(); Initialize__Q2_2nn4bossFv(); - for (uint8_t i = 1; i <= nn::act::GetNumOfAccounts(); i++) - { - if (nn::act::IsSlotOccupied(i) && nn::act::IsNetworkAccountEx(i)) - { - nn::boss::Task task{}; - nn::act::PersistentId persistentId = nn::act::GetPersistentIdEx(i); + for (uint8_t i = 1; i <= nn::act::GetNumOfAccounts(); i++) { + if (nn::act::IsSlotOccupied(i) && nn::act::IsNetworkAccountEx(i)) { + nn::boss::Task task{}; + nn::act::PersistentId persistentId = nn::act::GetPersistentIdEx(i); - __ct__Q3_2nn4boss4TaskFv(&task); - Initialize__Q3_2nn4boss4TaskFPCcUi(&task, "oltopic", persistentId); + __ct__Q3_2nn4boss4TaskFv(&task); + Initialize__Q3_2nn4boss4TaskFPCcUi(&task, "oltopic", persistentId); - // bypasses compiler warning about unused variable - #ifdef DEBUG - uint32_t res = Unregister__Q3_2nn4boss4TaskFv(&task); - DEBUG_FUNCTION_LINE_VERBOSE("Unregistered oltopic for: SlotNo %d | Persistent ID %08x -> 0x%08x", i, persistentId, res); - #else - Unregister__Q3_2nn4boss4TaskFv(&task); - #endif - } - } + // bypasses compiler warning about unused variable +#ifdef DEBUG + uint32_t res = Unregister__Q3_2nn4boss4TaskFv(&task); + DEBUG_FUNCTION_LINE_VERBOSE("Unregistered oltopic for: SlotNo %d | Persistent ID %08x -> 0x%08x", i, + persistentId, res); +#else + Unregister__Q3_2nn4boss4TaskFv(&task); +#endif + } + } Finalize__Q2_2nn4bossFv(); nn::act::Finalize(); @@ -108,89 +132,141 @@ static int32_t unregister_task_item_get_display_value(void *context, char *out_b } } - if ((int)string.length() > out_size - 1) return -1; + if ((int) string.length() > out_size - 1) return -1; string.copy(out_buf, string.length()); out_buf[string.length()] = '\0'; return 0; } -static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) { +static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle root_cat) { WUPSConfigAPIStatus err; - bool res; uint64_t current_title_id = OSGetTitleID(); uint64_t wiiu_menu_tid = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_WII_U_MENU); Config::is_wiiu_menu = (current_title_id == wiiu_menu_tid); // get translation strings - strings = get_config_strings(get_system_language()); + strings = get_config_strings(Config::current_language); - // create root config category - WUPSConfigCategory root = WUPSConfigCategory(rootHandle); + // Network submenu + // Connect to Pretendo Network Yes/No + // Using UDP port 5000 for multiplayer - auto network_cat = WUPSConfigCategory::Create(strings.network_category, err); - if (!network_cat) return report_error(err); + WUPSConfigCategoryHandle network_cat; + err = WUPSConfigAPI_Category_Create({strings.network_category.data()}, &network_cat); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - // config id display name default current value changed callback - auto connect_item = WUPSConfigItemBoolean::Create("connect_to_network", strings.connect_to_network_setting, true, Config::connect_to_network, &connect_to_network_changed, err); - if (!connect_item) return report_error(err); + WUPSConfigItemHandle connect_item; + err = WUPSConfigItemBoolean_CreateEx( + "connect_to_network", strings.connect_to_network_setting.data(), true, Config::connect_to_network, + &connect_to_network_changed, strings.setting_yes.data(), strings.setting_no.data(), &connect_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - res = network_cat->add(std::move(*connect_item), err); - if (!res) return report_error(err); + err = WUPSConfigAPI_Category_AddItem(network_cat, connect_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - { - uint16_t port = get_console_peertopeer_port(); - char buffer[256]; - snprintf(buffer, sizeof(buffer), strings.multiplayer_port_display.data(), port); - auto multiplayer_port_display = WUPSConfigItemStub::Create(buffer, err); - if (!multiplayer_port_display) return report_error(err); + const uint16_t port = get_console_peertopeer_port(); + char buffer[256]; + snprintf(buffer, sizeof(buffer), strings.multiplayer_port_display.data(), port); - res = network_cat->add(std::move(*multiplayer_port_display), err); - if (!res) return report_error(err); - } + WUPSConfigItemHandle multiplayer_port_display; + err = WUPSConfigItemStub_Create(buffer, &multiplayer_port_display); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - res = root.add(std::move(*network_cat), err); - if (!res) return report_error(err); + err = WUPSConfigAPI_Category_AddItem(network_cat, multiplayer_port_display); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - auto other_cat = WUPSConfigCategory::Create(strings.other_category, err); - if (!other_cat) return report_error(err); + // Add to root and finish + err = WUPSConfigAPI_Category_AddCategory(root_cat, network_cat); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - WUPSConfigAPIItemCallbacksV2 unregisterTasksItemCallbacks = { - .getCurrentValueDisplay = unregister_task_item_get_display_value, - .getCurrentValueSelectedDisplay = unregister_task_item_get_display_value, - .onSelected = nullptr, - .restoreDefault = nullptr, - .isMovementAllowed = nullptr, - .onCloseCallback = nullptr, - .onInput = unregister_task_item_on_input_cb, - .onInputEx = nullptr, - .onDelete = nullptr - }; + // Other category + // Reset Wara Wara Plaza Press A + // Language English/Spanish/etc.. + // Show startup toast Yes/No - WUPSConfigAPIItemOptionsV2 unregisterTasksItemOptions = { - .displayName = strings.reset_wwp_setting.data(), - .context = nullptr, - .callbacks = unregisterTasksItemCallbacks, - }; + WUPSConfigCategoryHandle other_cat; + err = WUPSConfigAPI_Category_Create({strings.other_category.data()}, &other_cat); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); WUPSConfigItemHandle unregisterTasksItem; - err = WUPSConfigAPI_Item_Create(unregisterTasksItemOptions, &unregisterTasksItem); - if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err); + err = WUPSConfigAPI_Item_Create({ + .displayName = strings.reset_wwp_setting.data(), + .context = nullptr, + .callbacks = { + .getCurrentValueDisplay = unregister_task_item_get_display_value, + .getCurrentValueSelectedDisplay = unregister_task_item_get_display_value, + .onSelected = nullptr, + .restoreDefault = nullptr, + .isMovementAllowed = nullptr, + .onCloseCallback = nullptr, + .onInput = unregister_task_item_on_input_cb, + .onInputEx = nullptr, + .onDelete = nullptr + }, + }, &unregisterTasksItem); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - err = WUPSConfigAPI_Category_AddItem(other_cat->getHandle(), unregisterTasksItem); - if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err); + err = WUPSConfigAPI_Category_AddItem(other_cat, unregisterTasksItem); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); - res = root.add(std::move(*other_cat), err); - if (!res) return report_error(err); + // TODO localise these! + constexpr std::array languages = { + { + {0, "Japanese"}, + {1, "English"}, + {2, "French"}, + {3, "German"}, + {4, "Italian"}, + {5, "Spanish"}, + {6, "Simplified Chinese"}, + {7, "Korean"}, + {8, "Dutch"}, + {9, "Portuguese"}, + {10, "Russian"}, + {11, "Traditional Chinese"}, + {13, "System"}, + {14, "English (UwU)"}, + } + }; + + constexpr auto find_lang = [languages](const uint32_t lang) -> int { + return std::ranges::find_if(languages, [lang](auto const l) { return l.value == lang; }) - + std::begin(languages); + }; + constexpr int system_language = find_lang(13 /* System */); + const int current_language = find_lang(Config::language); + + WUPSConfigItemHandle language_item; + err = WUPSConfigItemMultipleValues_Create("language", strings.language_setting.data(), system_language, + current_language, + const_cast(languages.data()), // Yikes! + languages.size(), &language_changed, &language_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); + + err = WUPSConfigAPI_Category_AddItem(other_cat, language_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); + + WUPSConfigItemHandle startup_toast_item; + err = WUPSConfigItemBoolean_CreateEx("show_startup_toast", strings.show_startup_toast_setting.data(), true, + Config::show_startup_toast, &show_startup_toast_changed, + strings.setting_yes.data(), strings.setting_no.data(), &startup_toast_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); + + err = WUPSConfigAPI_Category_AddItem(other_cat, startup_toast_item); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); + + // finish up + err = WUPSConfigAPI_Category_AddCategory(root_cat, other_cat); + if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__); return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; } static void ConfigMenuClosedCallback() { // Save all changes - WUPSStorageError res; - res = WUPSStorageAPI::SaveStorage(); + WUPSStorageError res = WUPSStorageAPI_SaveStorage(false); if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); if (Config::need_relaunch) { @@ -202,33 +278,54 @@ static void ConfigMenuClosedCallback() { } void Config::Init() { - WUPSConfigAPIStatus cres; - // Init the config api - WUPSConfigAPIOptionsV1 configOptions = { .name = "Inkay" }; - cres = WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback); - if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void)report_error(cres); + WUPSConfigAPIStatus cres = + WUPSConfigAPI_Init({.name = "Inkay"}, ConfigMenuOpenedCallback, ConfigMenuClosedCallback); + if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void) report_error(cres, __LINE__); WUPSStorageError res; - // Try to get value from storage - res = WUPSStorageAPI::Get("connect_to_network", Config::connect_to_network); + // Try to get values from storage + res = WUPSStorageAPI_GetBool(nullptr, "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"); + DEBUG_FUNCTION_LINE_VERBOSE("Connect to network value not found, attempting to migrate/create"); bool skipPatches = false; - if (WUPSStorageAPI::Get("skipPatches", skipPatches) == WUPS_STORAGE_ERROR_SUCCESS) { + if (WUPSStorageAPI_GetBool(nullptr, "skipPatches", &skipPatches) == WUPS_STORAGE_ERROR_SUCCESS) { // Migrate old config value Config::connect_to_network = !skipPatches; - WUPSStorageAPI::DeleteItem("skipPatches"); + WUPSStorageAPI_DeleteItem(nullptr, "skipPatches"); } - + // Add the value to the storage if it's missing. - res = WUPSStorageAPI::Store("connect_to_network", connect_to_network); + res = WUPSStorageAPI_StoreBool(nullptr, "connect_to_network", connect_to_network); if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); - } - 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_GetU32(nullptr, "language", &Config::language); + if (res == WUPS_STORAGE_ERROR_NOT_FOUND) { + DEBUG_FUNCTION_LINE_VERBOSE("Language value not found, attempting to create"); + + // Add the value to the storage. + res = WUPSStorageAPI_StoreU32(nullptr, "language", Config::language); + 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_GetBool(nullptr, "show_startup_toast", &Config::show_startup_toast); + if (res == WUPS_STORAGE_ERROR_NOT_FOUND) { + DEBUG_FUNCTION_LINE_VERBOSE("Show startup toast value not found, attempting to create"); + + // Add the value to the storage if it's missing. + res = WUPSStorageAPI_StoreBool(nullptr, "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) + Config::current_language = (inkay_language) get_system_language(); + else + Config::current_language = (inkay_language) Config::language; // Save storage - res = WUPSStorageAPI::SaveStorage(); + res = WUPSStorageAPI_SaveStorage(false); if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res); } diff --git a/plugin/src/config.h b/plugin/src/config.h index 0928d5e..a2c97d5 100644 --- a/plugin/src/config.h +++ b/plugin/src/config.h @@ -5,12 +5,18 @@ #ifndef INKAY_CONFIG_H #define INKAY_CONFIG_H +#include +#include "lang.h" + class Config { public: static void Init(); // wups config items static bool connect_to_network; + static uint32_t language; + + static bool show_startup_toast; // private stuff static bool need_relaunch; @@ -18,6 +24,7 @@ public: // private stuff static bool is_wiiu_menu; + static inkay_language current_language; static bool unregister_task_item_pressed; }; diff --git a/plugin/src/main.cpp b/plugin/src/main.cpp index 7d3ad2e..ccff31a 100644 --- a/plugin/src/main.cpp +++ b/plugin/src/main.cpp @@ -26,7 +26,7 @@ #include #include "module.h" -#define INKAY_VERSION "v3.0.0" +#define INKAY_VERSION "v3.1.0" /** Mandatory plugin information. @@ -104,7 +104,6 @@ void splatoon_patcher(){ INITIALIZE_PLUGIN() { WHBLogCafeInit(); - WHBLogUdpInit(); Config::Init(); @@ -113,7 +112,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() { @@ -121,7 +120,6 @@ DEINITIALIZE_PLUGIN() { NotificationModule_DeInitLibrary(); WHBLogCafeDeinit(); - WHBLogUdpDeinit(); } ON_APPLICATION_START() { diff --git a/plugin/src/module.cpp b/plugin/src/module.cpp index c20d980..8a550f7 100644 --- a/plugin/src/module.cpp +++ b/plugin/src/module.cpp @@ -18,25 +18,25 @@ #include "Notification.h" #include "utils/logger.h" -#include "sysconfig.h" +#include "config.h" #include "lang.h" #include static OSDynLoad_Module module; -static void (*moduleInitialize)(bool) = nullptr; +static void (*moduleInitialize)(bool, bool, inkay_language) = nullptr; static InkayStatus (*moduleGetStatus)() = nullptr; static void (*moduleSetPluginRunning)() = nullptr; static const char *get_module_not_found_message() { - return get_config_strings(get_system_language()).module_not_found.data(); + return get_config_strings(Config::current_language).module_not_found.data(); } 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(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; } @@ -48,13 +48,13 @@ void Inkay_Initialize(bool apply_patches) { } if (OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_Initialize", reinterpret_cast(&moduleInitialize)) != OS_DYNLOAD_OK) { - DEBUG_FUNCTION_LINE("Failed to find initialization function"); + DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_Initialize"); ShowNotification(get_module_init_not_found_message()); OSDynLoad_Release(module); return; } - - moduleInitialize(apply_patches); + + moduleInitialize(apply_patches, show_startup_toast, Config::current_language); } void Inkay_Finalize() { @@ -72,7 +72,7 @@ InkayStatus Inkay_GetStatus() { } if (!moduleGetStatus && OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_GetStatus", reinterpret_cast(&moduleGetStatus)) != OS_DYNLOAD_OK) { - DEBUG_FUNCTION_LINE("Failed to find status function"); + DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_GetStatus"); return InkayStatus::Error; } @@ -85,7 +85,7 @@ void Inkay_SetPluginRunning() { } if (!moduleSetPluginRunning && OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_SetPluginRunning", reinterpret_cast(&moduleSetPluginRunning)) != OS_DYNLOAD_OK) { - DEBUG_FUNCTION_LINE("Failed to find \"Inkay_SetPluginRunning\" function"); + DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_SetPluginRunning"); return; } 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/de_DE.lang b/src/lang/de_DE.lang index 106ee37..0228aa0 100644 --- a/src/lang/de_DE.lang +++ b/src/lang/de_DE.lang @@ -11,3 +11,8 @@ ,.multiplayer_port_display="Nutze UDP Port %hu für Mehrspieler" ,.module_not_found="SPFN Patch fehlgeschlagen - nutze Aroma Updater zum Reparieren (686-1001 Module missing)" ,.module_init_not_found="SPFN Patch fehlgeschlagen - nutze Aroma Updater zum Reparieren (686-1002 Module init)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Deutsch" +,.system_language="" diff --git a/src/lang/en@uwu.lang b/src/lang/en@uwu.lang index 3e55000..26abcc4 100644 --- a/src/lang/en@uwu.lang +++ b/src/lang/en@uwu.lang @@ -1,8 +1,7 @@ - - .plugin_name="Inky ^w^" ,.network_category="Newowk sewectiown! :3" ,.connect_to_network_setting="use dah pretender!!!!" +,.show_startup_toast_setting="show da deets :3" ,.other_category="oth3r stuffzz" ,.reset_wwp_setting="warah wara go BYEBYE x3c" ,.press_a_action="Press A plz?" @@ -13,3 +12,8 @@ ,.multiplayer_port_display="mah secret word is %hu... ur modem will know" ,.module_not_found="oh noez! pls get aroma updater help :( (686-1001 Module missing)" ,.module_init_not_found="oh noez! pls get aroma updater help :( (686-1002 Module init)" +,.setting_yes="yaah!" +,.setting_no="nu >w<" +,.language_setting="spek..." +,.language_name="kitteh speak!!" +,.system_language="System" diff --git a/src/lang/en_US.lang b/src/lang/en_US.lang index 389fa6e..8e658d5 100644 --- a/src/lang/en_US.lang +++ b/src/lang/en_US.lang @@ -1,6 +1,8 @@ .plugin_name="Malamar" ,.network_category="Network selection" ,.connect_to_network_setting="Connect to SPFN" +,.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" @@ -11,3 +13,8 @@ ,.multiplayer_port_display="Using UDP port %hu for multiplayer" ,.module_not_found="SPFN patch failed - use Aroma Updater to repair (686-1001 Module missing)" ,.module_init_not_found="SPFN patch failed - use Aroma Updater to repair (686-1002 Module init)" +,.setting_yes="Yes" +,.setting_no="No" +,.language_setting="Language" +,.language_name="English" +,.system_language="System" diff --git a/src/lang/es_ES.lang b/src/lang/es_ES.lang index 2c98b40..c8797a0 100644 --- a/src/lang/es_ES.lang +++ b/src/lang/es_ES.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Seleccionar red" ,.connect_to_network_setting="Conectar a SPFN" +,.show_startup_toast_setting="" ,.other_category="Otros ajustes" ,.reset_wwp_setting="Restablecer Plaza Wara Wara" ,.press_a_action="Pulsa A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="Usando puerto UDP %hu para multijugador" ,.module_not_found="Ha fallado el parche SPFN - usa Aroma Updater para repararlo (686-1001 Falta un módulo)" ,.module_init_not_found="Ha fallado el parche SPFN - usa Aroma Updater para repararlo (686-1002 Inicialización del módulo)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Español" +,.system_language="" diff --git a/src/lang/fr_FR.lang b/src/lang/fr_FR.lang index 58204e1..bd7de8e 100644 --- a/src/lang/fr_FR.lang +++ b/src/lang/fr_FR.lang @@ -11,3 +11,8 @@ ,.multiplayer_port_display="Le port UDP %hu sera utilisé pour le multijoueur" ,.module_not_found="Le patch SPFN a rencontré un problème, veuillez le réparer avec Aroma Updater (686-1001 Module missing)" ,.module_init_not_found="Le patch SPFN a rencontré un problème, veuillez le réparer avec Aroma Updater (686-1002 Module init)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Français" +,.system_language="" diff --git a/src/lang/it_IT.lang b/src/lang/it_IT.lang index 9f49582..55a1b62 100644 --- a/src/lang/it_IT.lang +++ b/src/lang/it_IT.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Seleziona la rete" ,.connect_to_network_setting="Connettiti a SPFN" +,.show_startup_toast_setting="" ,.other_category="Altre impostazioni" ,.reset_wwp_setting="Ripristina Wara Wara Plaza" ,.press_a_action="Premi A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="È in uso la porta UDP %hu per il multigiocatore" ,.module_not_found="Patch di SPFN fallita - usa Aroma Updater per correggere (686-1001 Modulo mancante)" ,.module_init_not_found="Patch di SPFN fallita - usa Aroma Updater per correggere (686-1002 Module init)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Italiano" +,.system_language="" diff --git a/src/lang/ja_JP.lang b/src/lang/ja_JP.lang index 73a419f..f3224fb 100644 --- a/src/lang/ja_JP.lang +++ b/src/lang/ja_JP.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="ネットワークの選択" ,.connect_to_network_setting="SPFNネットワークに接続する" +,.show_startup_toast_setting="" ,.other_category="その他の設定" ,.reset_wwp_setting="わらわら広場をリセット" ,.press_a_action="Aボタンを押そう" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="マルチプレイに UDPポート %hu を使用します" ,.module_not_found="SPFN パッチに失敗しました。Aroma Updaterを使用して解決してみてください。(686-1001 Module missing)" ,.module_init_not_found="SPFN パッチに失敗しました。Aroma Updaterを使用して解決してみてください。(686-1002 Module init)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="日本語" +,.system_language="" diff --git a/src/lang/ko_KR.lang b/src/lang/ko_KR.lang new file mode 100644 index 0000000..b732072 --- /dev/null +++ b/src/lang/ko_KR.lang @@ -0,0 +1,19 @@ +.plugin_name="Inkay" +,.network_category="네트워크 선택" +,.connect_to_network_setting="Pretendo Network 사용" +,.show_startup_toast_setting="" +,.other_category="기타 설정" +,.reset_wwp_setting="Wara Wara Plaza 초기화" +,.press_a_action="A 버튼을 누르세요" +,.restart_to_apply_action="재시작 후 적용" +,.need_menu_action="Wii U 메뉴에서만" +,.using_nintendo_network="Nintendo Network 사용 중" +,.using_pretendo_network="Pretendo Network 사용 중" +,.multiplayer_port_display="멀티플레이어에 UDP 포트 %hu을(를) 사용합니다" +,.module_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1001 모듈 없음)" +,.module_init_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1002 모듈 초기화)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="한국어" +,.system_language="" diff --git a/src/lang/nl_NL.lang b/src/lang/nl_NL.lang index 65d51fb..1cf6c47 100644 --- a/src/lang/nl_NL.lang +++ b/src/lang/nl_NL.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Netwerkselectie" ,.connect_to_network_setting="Verbind met het SPFN-netwerk" +,.show_startup_toast_setting="" ,.other_category="Overige instellingen" ,.reset_wwp_setting="Reset het Wara Wara Plaza" ,.press_a_action="Druk A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="Gebruikt UDP port %hu voor multiplayer" ,.module_not_found="SPFN patch mislukt - gebruik Aroma Updater om het te herstellen (686-1001 Module ontbreekt)" ,.module_init_not_found="SPFN patch mislukt - gebruik Aroma Updater om het te herstellen (686-1002 Module init)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Nederlands" +,.system_language="" diff --git a/src/lang/pt_BR.lang b/src/lang/pt_BR.lang index a776724..0bce9df 100644 --- a/src/lang/pt_BR.lang +++ b/src/lang/pt_BR.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Selecionar rede" ,.connect_to_network_setting="Conecta-se à SPFN" +,.show_startup_toast_setting="" ,.other_category="Outras configurações" ,.reset_wwp_setting="Resetar Wara Wara Plaza" ,.press_a_action="Aperte A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="Usando UDP port %hu para a jogatina multiplayer" ,.module_not_found="Atualização do SPFN falhou - use o Aroma Updater para corrigir (686-1001 Módulo faltando)" ,.module_init_not_found="Atualização do SPFN falhou - use o Aroma Updater para corrigir (686-1002 Módulo de início)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Português" +,.system_language="" diff --git a/src/lang/ru_RU.lang b/src/lang/ru_RU.lang index a1a8451..6be20f5 100644 --- a/src/lang/ru_RU.lang +++ b/src/lang/ru_RU.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="Выбор сети" ,.connect_to_network_setting="Подключиться к SPFN" +,.show_startup_toast_setting="" ,.other_category="Другие настройки" ,.reset_wwp_setting="Сбросить Wara Wara Plaza" ,.press_a_action="Нажмите A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="Используем UDP-порт %hu для сетевой игры" ,.module_not_found="Ошибка установки патча SPFN - для восстановления, запустите Aroma Updater (686-1001 Модуль отсутствует)" ,.module_init_not_found="Ошибка установки патча SPFN - для восстановления, запустите Aroma Updater (686-1002 Инициализация модуля)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="Русский язык" +,.system_language="" diff --git a/src/lang/zh_CN.lang b/src/lang/zh_CN.lang index f9b5eec..a49aa85 100644 --- a/src/lang/zh_CN.lang +++ b/src/lang/zh_CN.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="选择网络" ,.connect_to_network_setting="连接到SPFN" +,.connect_to_network_setting="连接到Pretendo Network" ,.other_category="其他设置" ,.reset_wwp_setting="重置Wara Wara Plaza" ,.press_a_action="请按 A" @@ -11,3 +12,8 @@ ,.multiplayer_port_display="多人游戏使用 UDP 端口 %hu" ,.module_not_found="SPFN 补丁失败 - 使用 Aroma Updater 修复(686-1001 模块丢失)" ,.module_init_not_found="SPFN 补丁失败 - 使用 Aroma Updater 修复(686-1002 模块初始化)" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="中文(简体)" +,.system_language="" diff --git a/src/lang/zh_Hant.lang b/src/lang/zh_Hant.lang index 8d550f7..e1052e8 100644 --- a/src/lang/zh_Hant.lang +++ b/src/lang/zh_Hant.lang @@ -1,6 +1,7 @@ .plugin_name="Inkay" ,.network_category="選擇網路" ,.connect_to_network_setting="連接到SPFN" +,.show_startup_toast_setting="" ,.other_category="其他設定" ,.reset_wwp_setting="重置Wara Wara Plaza" ,.press_a_action="請按 A" @@ -11,3 +12,9 @@ ,.multiplayer_port_display="Using UDP port %hu for multiplayer" ,.module_not_found="SPFN patch failed - use Aroma Updater to repair (686-1001 Module missing)" ,.module_init_not_found="SPFN patch failed - use Aroma Updater to repair (686-1002 Module init)" +,.multiplayer_port_display="使用 UDP 端口 %hu 進行多人遊戲" +,.setting_yes="" +,.setting_no="" +,.language_setting="" +,.language_name="中文(繁體)" +,.system_language="" diff --git a/src/main.cpp b/src/main.cpp index 1e83168..5d03f81 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ #include "ca_pem.h" -#define INKAY_VERSION "v3.0.0" +#define INKAY_VERSION "v3.1.0" /** Mandatory plugin information. @@ -93,18 +93,18 @@ static bool is555(MCPSystemVersion version) { return (version.major == 5) && (version.minor == 5) && (version.patch >= 5); } -static const char *get_nintendo_network_message() { +static const char *get_nintendo_network_message(inkay_language language) { // TL note: "Nintendo Network" is a proper noun - "Network" is part of the name // TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are // only specifying what we'll *attempt* to connect to - return get_config_strings(get_system_language()).using_nintendo_network.data(); + return get_config_strings(language).using_nintendo_network.data(); } -static const char *get_pretendo_message() { +static const char *get_pretendo_message(inkay_language language) { // TL note: "Pretendo Network" is also a proper noun - though "Pretendo" alone can refer to us as a project // TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are // only specifying what we'll *attempt* to connect to - return get_config_strings(get_system_language()).using_pretendo_network.data(); + return get_config_strings(language).using_pretendo_network.data(); } static void Inkay_SetPluginRunning() { @@ -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, 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) { DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully."); - ShowNotification(get_pretendo_message()); + 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()); + if(Config::show_startup_toast) { + ShowNotification(get_nintendo_network_message(language)); + } Config::initialized = true; return; } diff --git a/src/utils/replace_mem.cpp b/src/utils/replace_mem.cpp index 03e94b2..1c7003b 100644 --- a/src/utils/replace_mem.cpp +++ b/src/utils/replace_mem.cpp @@ -85,7 +85,6 @@ bool replace_unsigned(U *addr, U original_value, U new_value) { ); DCFlushRange(addr, sizeof(new_value)); - DEBUG_FUNCTION_LINE_VERBOSE("%08x is now %08x", inst, *inst); return *addr == new_value; } template bool replace_unsigned(uint64_t *, uint64_t, uint64_t);