Skip to content

Commit

Permalink
OptionsTab: add reset settings option.
Browse files Browse the repository at this point in the history
Other changes include:

* gamecard: set GameCardStatus_Processing as the current gamecard status before calling gamecardLoadInfo().

* workflow: try to fix the missing commit tag issue.
  • Loading branch information
DarkMatterCore committed May 1, 2024
1 parent 50deeeb commit 1ff3df4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion romfs/i18n/en-US/options_tab.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand All @@ -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."
}
}
18 changes: 13 additions & 5 deletions source/core/gamecard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -706,6 +715,8 @@ static void gamecardDetectionThreadFunc(void *arg)
}

utilsAppletLoopDelay();

gc_inserted = gamecardIsInserted();
}

/* Load gamecard info (if applicable). */
Expand Down Expand Up @@ -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. */
Expand Down
13 changes: 13 additions & 0 deletions source/views/options_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1ff3df4

Please sign in to comment.