Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jozz024 committed Sep 5, 2021
2 parents 6e7c8d6 + 16fe32e commit f83496c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# UNSTABLE BRANCH - THINGS MAY BREAK

[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/J3J8Y3EA)

### Amiibox Homepage & Download Link: https://fudgepop01.github.io/amiibox/
Expand Down
29 changes: 27 additions & 2 deletions src/components/Entrance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let readFile = promisify(fs.readFile);
const dispatch = createEventDispatcher();
async function setKeys() {
let keyPath = (await remote.dialog.showOpenDialog({
message: 'select key_retail.bin'
Expand All @@ -30,6 +30,15 @@
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, JSON.stringify(config, null, 2), 'utf8');
needsKeys = false;
}
async function setAbilities() {
let abilityPath = (await remote.dialog.showOpenDialog({
message: 'select abilities.txt'
})).filePaths[0];
config.abilities = abilityPath;
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, JSON.stringify(config, null, 2), 'utf8');
}
async function setRegions() {
let regionPath = (await remote.dialog.showOpenDialog({
Expand All @@ -53,6 +62,19 @@
config.regions = '__DEFAULT__';
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, JSON.stringify(config, null, 2), 'utf8');
}
async function setAbilitiesToDefualt() {
const confirmation = await remote.dialog.showMessageBox({
type: "question",
buttons: ["cancel", "ok"],
title: 'confirmation',
message: "are you sure you wish to reset the abilities to default?"
})[0];
if (confirmation === 0) return;
config.abilities = '__DEFAULT__';
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, JSON.stringify(config, null, 2), 'utf8');
}
let config;
let needsKeys;
Expand All @@ -62,12 +84,13 @@
console.log(await readFile(`${remote.app.getPath('userData')}/PATHS.json`, 'utf8'));
}
catch (e) {
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, '{"keys":"UNCONFIGURED","regions":"__DEFAULT__"}', 'utf8');
await writeFile(`${remote.app.getPath('userData')}/PATHS.json`, '{"keys":"UNCONFIGURED","regions":"__DEFAULT__","abilities":"__DEFAULT__"}', 'utf8');
}
config = JSON.parse(await readFile(`${remote.app.getPath('userData')}/PATHS.json`, 'utf8'));
if (!FULL_TOGGLE) config.regions = '__default__';
needsKeys = (config.keys === "UNCONFIGURED");
config.abilities = 'DEFAULT_ABILITIES';
})
</script>

Expand Down Expand Up @@ -115,6 +138,8 @@
<div class="ui container">
<div class={`${needsKeys ? 'massive' : 'small'} ui fluid buttons`}>
<button class={`enter-btn ui ${needsKeys ? '' : 'basic'} red button`} on:click={() => setKeys()}>select keys</button>
<button class={"enter-btn ui basic red button"} on:click={() => setAbilities()}>select ability file</button>
<button class={"enter-btn ui basic red button"} on:click={() => setAbilitiesToDefualt()}>RESET ability config</button>
{#if FULL_TOGGLE}
<button class={"enter-btn ui basic red button"} on:click={() => setRegions()}>select region config</button>
<button class={"enter-btn ui basic red button"} on:click={() => setRegionsToDefualt()}>RESET region config</button>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
let config = JSON.parse(await readFile(`${remote.app.getPath('userData')}/PATHS.json`, 'utf8'));
if (!FULL_TOGGLE) config.regions = '__default__';
if (config.keys !== 'UNCONFIGURED') keys = config.keys;
abilities = (await readFile(`${__dirname}/amiibo/abilities.txt`, 'utf8')).split(EOL);
if (config.abilities == '__DEFAULT__') { abilities = (await readFile(`${__dirname}/amiibo/abilities.txt`, 'utf8')).split(EOL)}
else abilities = (await readFile(config.abilities, 'utf8')).split(EOL);
const splitted = (await readFile(
config.regions === '__DEFAULT__'
? `${__dirname}/amiibo/regions.txt`
Expand Down

0 comments on commit f83496c

Please sign in to comment.