Skip to content

Commit

Permalink
feat: add Reset setting setting
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 4, 2024
1 parent 10a4972 commit 2368f6a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
patchAppWithRipLibs,
patchAppArscLib,
resetPatchOptions,
resetSettings,
selectApp,
selectAppVersion,
selectPatches,
Expand Down Expand Up @@ -208,6 +209,9 @@ wsServer.on('connection', (ws) => {
case 'resetPatchOptions':
await resetPatchOptions(ws);
break;
case 'resetSettings':
await resetSettings(ws);
break;
case 'selectApp':
selectApp(message);
break;
Expand Down
6 changes: 6 additions & 0 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ function resetPatchOptions() {
sendCommand({ event: 'resetPatchOptions' });
}

function resetSettings() {
sendCommand({ event: 'resetSettings' });
disableARSCLib();
setSourcesRVX();
}

function setSourcesPreReleases() {
const prereleases = document.getElementById('pre-releases').value + '';

Expand Down
13 changes: 13 additions & 0 deletions public/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ <h3>
autocomplete="off" /><span class="slider"></span
></label>
</div>
<div class="option">
<h3>
<i class="fa-solid fa-backward"></i>Reset settings
</h3>

<p>
Resets the source and selected patch list.
<br /><br />Try this if the patch is excluded even though you included it.
</p>
<button class="highlighted" onclick="resetSettings();">
Reset
</button>
</div>
<div id="src" class="option">
<h3><i class="fa-solid fa-server"></i>Sources</h3>

Expand Down
4 changes: 4 additions & 0 deletions public/styles/fontawesome.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
content: '\f7d9';
}

.fa-backward:before {
content: '\f04a';
}

.fa-download:before {
content: '\f019';
}
Expand Down
4 changes: 2 additions & 2 deletions utils/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function getSettings() {
return settings;
}

function resetSettings() {
function resetPatchesSources(ws) {
rmSync('settings.json', { recursive: true, force: true });
createSettingsFile();
}
Expand All @@ -101,6 +101,6 @@ module.exports = {
getPatchList,
writePatches,
getSources,
resetSettings,
resetPatchesSources,
writeSources
};
2 changes: 2 additions & 0 deletions wsEvents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const patchApp = require('./patchApp.js');
const patchAppWithRipLibs = require('./patchAppWithRipLibs.js');
const patchAppArscLib = require('./patchAppArscLib.js');
const resetPatchOptions = require('./resetPatchOptions.js');
const resetSettings = require('./resetSettings.js');
const selectApp = require('./selectApp.js');
const selectAppVersion = require('./selectAppVersion.js');
const selectPatches = require('./selectPatches.js');
Expand All @@ -30,6 +31,7 @@ module.exports = {
patchAppWithRipLibs,
patchAppArscLib,
resetPatchOptions,
resetSettings,
selectApp,
selectAppVersion,
selectPatches,
Expand Down
9 changes: 9 additions & 0 deletions wsEvents/resetSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { resetPatchesSources } = require('../utils/Settings.js');

/**
* @param {import('ws').WebSocket} ws
*/

module.exports = function resetSettings(ws) {
resetPatchesSources(ws);
};

0 comments on commit 2368f6a

Please sign in to comment.