restore route deletion

This commit is contained in:
Matteias Collet 2020-06-28 01:50:25 +02:00
parent 89412a224c
commit 8c79cb27b2
3 changed files with 123 additions and 22 deletions

View file

@ -36,7 +36,7 @@
</div> </div>
<div v-if="codes && codes.length > 0 && useStageLoader"> <div v-if="codes && codes.length > 0 && useStageLoader">
<h3>Stage Loader</h3> <h3>Stage Loader</h3>
<StageLoader /> <StageLoader :fastCodes="stageLoaderCodes" />
</div> </div>
<div v-if="codes && codes.length > 0" class="help"> <div v-if="codes && codes.length > 0" class="help">
@ -153,10 +153,12 @@ export default {
isLoading: true, isLoading: true,
codes: [], codes: [],
selectedCheats: [], selectedCheats: [],
selectedStageLoader: null,
inspectingCode: null, inspectingCode: null,
selectedVersion: null, selectedVersion: null,
selectedFormat: null, selectedFormat: null,
useStageLoader: false, useStageLoader: false,
stageLoaderCodes: [],
useStageLoaderOptions: [ useStageLoaderOptions: [
{ value: false, label: "No" }, { value: false, label: "No" },
{ value: true, label: "Yes" } { value: true, label: "Yes" }
@ -169,6 +171,9 @@ export default {
this.selectedCheats = []; this.selectedCheats = [];
const storedCodes = JSON.parse(localStorage.getItem("codes")); const storedCodes = JSON.parse(localStorage.getItem("codes"));
this.codes = storedCodes.find(c => c.identifier === e).cheats; this.codes = storedCodes.find(c => c.identifier === e).cheats;
this.stageLoaderCodes = storedCodes.find(
c => c.identifier === e
).fastCodes;
this.inspectingCode = null; this.inspectingCode = null;
}, },
onFormatChanged(e) { onFormatChanged(e) {

View file

@ -1,7 +1,7 @@
<template> <template>
<div class="select-wrapper"> <div class="select-wrapper">
<select @change="(e) => this.onChange(e.target.value)" autocomplete="off"> <select @change="onValueChanged" autocomplete="off" v-model="selectedValue">
<option v-if="placeholder != null" selected disabled> <option v-if="placeholder != null" value="placeholder" selected disabled>
{{ {{
placeholder placeholder
}} }}
@ -10,7 +10,7 @@
<option <option
v-for="option in optGroup.options" v-for="option in optGroup.options"
:value="option.value" :value="option.value"
:selected="selectedValue && option.value === selectedValue" :selected="selectedValue && option.value === selectedValue && !resetOnSelect"
>{{ option.label }}</option> >{{ option.label }}</option>
</optgroup> </optgroup>
</select> </select>
@ -26,7 +26,14 @@ export default {
onChange: { type: Function } onChange: { type: Function }
}, },
data() { data() {
return {}; return {
generation: 2
};
},
methods: {
onValueChanged(e) {
this.onChange(e.target.value);
}
} }
}; };
</script> </script>

View file

@ -2,31 +2,54 @@
<div> <div>
<div class="config"> <div class="config">
<span>Remove Dialogue:</span> <span>Remove Dialogue:</span>
<SelectComponent :options="removeDialogueOptions" :onChange="onRemoveDialogueChanged" /> <SelectComponent
:options="removeDialogueOptions"
:onChange="onRemoveDialogueSelectionChanged"
:selectedValue="removeDialogSelection"
/>
</div> </div>
<div class="config"> <div class="config">
<span>Skippable FMVs:</span> <span>Skippable FMVs:</span>
<SelectComponent :options="skippableFMVsOptions" :onChange="onSkippableFMVsChanged" /> <SelectComponent
:options="skippableFMVsOptions"
:onChange="onSkippableFMVsSelectionChanged"
:selectedValue="skippableFMVsSelection"
/>
</div> </div>
<div class="config"> <div class="config">
<span>Level Order:</span> <span>Level Order:</span>
<SelectComponent :options="levelOrderOptions" :onChange="onLevelOrderChanged" /> <SelectComponent
:options="levelOrderOptions"
:onChange="onLevelOrderSelectionChanged"
:selectedValue="levelOrderSelection"
/>
</div> </div>
<div class="config"> <div class="config">
<span>Post Game:</span> <span>Post Game:</span>
<SelectComponent :options="postGameOptions" :onChange="onPostGameSelectionChanged" /> <SelectComponent
:options="postGameOptions"
:onChange="onPostGameSelectionChanged"
:selectedValue="postGameSelection"
/>
</div> </div>
<div> <div class="config">
<ul id="route_levels"> <span>Route:</span>
<li draggable="false"> <ul class="level-select">
<!-- <div class="route_drag">&#8801;</div> --> <li v-for="(level, index) in selectedRoute">
<div class="route-drag">&#8801;</div>
<GroupSelectComponent <GroupSelectComponent
placeholder="Choose a level.." :selectedValue="level.value"
:optGroups="stageLoaderLevelOptions" :optGroups="stageLoaderLevelOptions"
:onClick="onStageLoaderLevelSelected" :onChange="e => onStageLoaderLevelChanged(index, e)"
/> />
<!-- <button type="button" class="route_remove">&#215;</button> --> <button @click="onLevelDeleted(index)" type="button" class="route-remove">&#215;</button>
</li> </li>
<GroupSelectComponent
placeholder="Choose a level.."
:optGroups="stageLoaderLevelOptions"
:onChange="onStageLoaderLevelSelected"
selectedValue="placeholder"
/>
</ul> </ul>
</div> </div>
<div class="config"> <div class="config">
@ -37,6 +60,8 @@
placeholder="Load a preset.." placeholder="Load a preset.."
:optGroups="stageLoaderPresetOptions" :optGroups="stageLoaderPresetOptions"
:onChange="onStageLoaderPresetSelected" :onChange="onStageLoaderPresetSelected"
:resetOnSelect="true"
selectedValue="placeholder"
/> />
</div> </div>
</div> </div>
@ -53,8 +78,12 @@ import stageLoaderLevels from "../data/stageLoaderLevels.json";
import stageLoaderPresets from "../data/stageLoaderPresets.json"; import stageLoaderPresets from "../data/stageLoaderPresets.json";
export default { export default {
props: {
fastCodes: { type: Object }
},
data() { data() {
return { return {
selectedRoute: [],
stageLoaderLevelOptions: stageLoaderLevels, stageLoaderLevelOptions: stageLoaderLevels,
stageLoaderPresetOptions: stageLoaderPresets, stageLoaderPresetOptions: stageLoaderPresets,
removeDialogueOptions: [ removeDialogueOptions: [
@ -85,26 +114,58 @@ export default {
}; };
}, },
methods: { methods: {
onRemoveDialogueChanged(e) { onRemoveDialogueSelectionChanged(e) {
this.removeDialogSelection = e; this.removeDialogSelection = e;
}, },
onSkippableFMVsChanged(e) { onSkippableFMVsSelectionChanged(e) {
this.skippableFMVsSelection = e; this.skippableFMVsSelection = e;
}, },
onLevelOrderChanged(e) { onLevelOrderSelectionChanged(e) {
this.levelOrderSelection = e; this.levelOrderSelection = e;
}, },
onPostGameSelectionChanged(e) { onPostGameSelectionChanged(e) {
this.postGameSelection = e; this.postGameSelection = e;
}, },
onStageLoaderLevelSelected(e) { onStageLoaderLevelSelected(e) {
return; this.selectedRoute.push({
value: e
});
},
onStageLoaderLevelChanged(index, e) {
this.selectedRoute[index] = {
value: e
};
},
onLevelDeleted(e) {
this.selectedRoute.splice(e, 1);
}, },
onStageLoaderPresetSelected(e) { onStageLoaderPresetSelected(e) {
return; if (
this.selectedRoute?.length > 0 &&
!confirm("Loading a preset will erase your current list. Continue?")
) {
return;
}
const preset = e.split(";")[0];
const ending = e.split(";")[1];
const newRoute = [];
for (let i = 0; i <= preset.length - 4; i += 4)
newRoute.push({ value: preset.substr(i, 4) });
this.selectedRoute = newRoute;
this.postGameSelection = ending;
}, },
onClearList() { onClearList() {
return; if (
this.selectedRoute?.length > 0 &&
!confirm("Do you really want to clear the list?")
)
return;
this.selectedRoute = [];
} }
} }
}; };
@ -117,7 +178,35 @@ export default {
padding-left: 2px; padding-left: 2px;
} }
.config:not(:first-child) span {
margin-top: 10px;
}
.config select { .config select {
width: 100%; width: 100%;
} }
ul {
list-style: none;
padding-left: 0;
}
ul li {
display: flex;
flex-wrap: nowrap;
}
.route-drag {
margin-right: 5px;
cursor: pointer;
}
.route-remove {
margin-left: 3px;
background: transparent;
border: none;
font-size: 1.2rem;
color: red;
cursor: pointer;
}
</style> </style>