From 1ff3df4ecaeea7ab345710dfbf53b491d68a193d Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Wed, 1 May 2024 12:50:36 +0200 Subject: [PATCH] OptionsTab: add reset settings option. Other changes include: * gamecard: set GameCardStatus_Processing as the current gamecard status before calling gamecardLoadInfo(). * workflow: try to fix the missing commit tag issue. --- .github/workflows/rewrite.yml | 18 +++++++++--------- romfs/i18n/en-US/options_tab.json | 8 +++++++- source/core/gamecard.c | 18 +++++++++++++----- source/views/options_tab.cpp | 13 +++++++++++++ 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.github/workflows/rewrite.yml b/.github/workflows/rewrite.yml index 370bb71..59c14fb 100644 --- a/.github/workflows/rewrite.yml +++ b/.github/workflows/rewrite.yml @@ -35,7 +35,7 @@ jobs: - name: Set environment variables run: | - echo "nxdt_commit=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV + echo "NXDT_COMMIT=${GITHUB_SHA::7}" >> $GITHUB_ENV - name: Set workspace permissions run: chmod 777 -R "$GITHUB_WORKSPACE" @@ -66,27 +66,27 @@ jobs: # run: | # make -j8 PREFIX="ccache aarch64-none-elf-" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: nxdt_rw_poc-${{ env.nxdt_commit }}.nro + name: nxdt_rw_poc-${{ env.NXDT_COMMIT }}.nro path: code_templates/tmp/nxdt_rw_poc.nro if-no-files-found: error - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: nxdt_rw_poc-${{ env.nxdt_commit }}.elf + name: nxdt_rw_poc-${{ env.NXDT_COMMIT }}.elf path: code_templates/tmp/nxdt_rw_poc.elf if-no-files-found: error - #- uses: actions/upload-artifact@v3 + #- uses: actions/upload-artifact@v4 # with: - # name: nxdumptool-rewrite-${{ env.nxdt_commit }}-WIP_UI.nro + # name: nxdumptool-rewrite-${{ env.NXDT_COMMIT }}-WIP_UI.nro # path: nxdumptool.nro # if-no-files-found: error - #- uses: actions/upload-artifact@v3 + #- uses: actions/upload-artifact@v4 # with: - # name: nxdumptool-rewrite-${{ env.nxdt_commit }}-WIP_UI.elf + # name: nxdumptool-rewrite-${{ env.NXDT_COMMIT }}-WIP_UI.elf # path: nxdumptool.elf # if-no-files-found: error diff --git a/romfs/i18n/en-US/options_tab.json b/romfs/i18n/en-US/options_tab.json index 319e139..40ad4e9 100644 --- a/romfs/i18n/en-US/options_tab.json +++ b/romfs/i18n/en-US/options_tab.json @@ -34,6 +34,11 @@ } }, + "reset_settings": { + "label": "Reset settings", + "description": "Resets all settings to their default values, including the ones not reflected in this menu (e.g. dump options, etc.)." + }, + "notifications": { "no_ums_devices": "No USB Mass Storage devices available.", "ums_device_unmount_success": "USB Mass Storage device successfully unmounted!", @@ -45,6 +50,7 @@ "already_updated": "The application has already been updated. Please reload.", "github_json_failed": "Failed to download or parse GitHub release JSON!", "up_to_date": "The application is up to date!", - "app_updated": "Application successfully updated! Please reload for the changes to take effect." + "app_updated": "Application successfully updated! Please reload for the changes to take effect.", + "settings_reset": "User settings have been reset." } } diff --git a/source/core/gamecard.c b/source/core/gamecard.c index 52851f8..05897f0 100644 --- a/source/core/gamecard.c +++ b/source/core/gamecard.c @@ -670,7 +670,12 @@ static void gamecardDetectionThreadFunc(void *arg) /* Load gamecard info right away if a gamecard is inserted, then signal the user mode gamecard status change event. */ SCOPED_LOCK(&g_gameCardMutex) { - if (gamecardIsInserted()) gamecardLoadInfo(); + if (gamecardIsInserted()) + { + atomic_store(&g_gameCardStatus, GameCardStatus_Processing); + gamecardLoadInfo(); + } + ueventSignal(&g_gameCardStatusChangeEvent); } @@ -688,13 +693,17 @@ static void gamecardDetectionThreadFunc(void *arg) /* Free gamecard info before proceeding. */ gamecardFreeInfo(true); + /* Set initial gamecard status. */ + bool gc_inserted = gamecardIsInserted(); + atomic_store(&g_gameCardStatus, gc_inserted ? GameCardStatus_Processing : GameCardStatus_NotInserted); + /* Delay gamecard access by GAMECARD_ACCESS_DELAY full seconds. This is done to to avoid conflicts with HOS / sysmodules. */ /* We will periodically check if the gamecard is still inserted during this period. */ /* If the gamecard is taken out before reaching the length of the delay, we won't try to access it. */ time_t start = time(NULL); bool gc_delay_passed = false; - while(gamecardIsInserted()) + while(gc_inserted) { time_t now = time(NULL); time_t diff = (now - start); @@ -706,6 +715,8 @@ static void gamecardDetectionThreadFunc(void *arg) } utilsAppletLoopDelay(); + + gc_inserted = gamecardIsInserted(); } /* Load gamecard info (if applicable). */ @@ -738,9 +749,6 @@ static void gamecardLoadInfo(void) u32 root_hfs_entry_count = 0, root_hfs_name_table_size = 0; char *root_hfs_name_table = NULL; - /* Set initial gamecard status. */ - atomic_store(&g_gameCardStatus, GameCardStatus_Processing); - /* Read gamecard header. */ /* This step *will* fail if the running CFW enabled the "nogc" patch. */ /* gamecardGetHandleAndStorage() takes care of updating the gamecard status accordingly if this happens. */ diff --git a/source/views/options_tab.cpp b/source/views/options_tab.cpp index c64fce8..5683b4c 100644 --- a/source/views/options_tab.cpp +++ b/source/views/options_tab.cpp @@ -428,6 +428,19 @@ namespace nxdt::views }); this->addView(update_app); + + /* Reset settings. */ + brls::ListItem *reset_settings = new brls::ListItem("options_tab/reset_settings/label"_i18n, "options_tab/reset_settings/description"_i18n); + + reset_settings->getClickEvent()->subscribe([this](brls::View* view) { + if (!this->display_notification) return; + + configResetSettings(); + + this->DisplayNotification("options_tab/notifications/settings_reset"_i18n); + }); + + this->addView(reset_settings); } OptionsTab::~OptionsTab()