2020-06-28 06:33:20 +09:00
|
|
|
<template>
|
2021-10-10 22:45:53 +09:00
|
|
|
<div>
|
2022-02-22 12:40:14 +09:00
|
|
|
<CustomCodeModal
|
|
|
|
v-if="customCodeInEditMode"
|
|
|
|
:onCancel="closeCustomClodeModal"
|
|
|
|
:onSave="saveCustomCode"
|
|
|
|
:identifier="customCodeInEditMode.identifier"
|
|
|
|
:initialValue="customCodeInEditMode.value"
|
|
|
|
:initialTitle="customCodeInEditMode.title"
|
|
|
|
/>
|
2021-10-10 22:45:53 +09:00
|
|
|
<div class="preset-select">
|
|
|
|
<SelectComponent
|
|
|
|
:options="getPresetOptions()"
|
|
|
|
:onChange="(v) => loadPreset(v)"
|
|
|
|
:placeholder="getPresetPlaceholder()"
|
|
|
|
:key="generation"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-for="category in codeCategories" v-bind:key="category.identifier" class="code-group">
|
2022-02-22 12:40:14 +09:00
|
|
|
<div class="category-title">
|
|
|
|
<span>{{ getCategoryTitle(category) }}</span>
|
|
|
|
<ButtonComponent
|
|
|
|
:small="true"
|
|
|
|
v-if="category.identifier === 'custom'"
|
|
|
|
className="btn-add-custom-code"
|
|
|
|
label="+"
|
|
|
|
:onClick="initCustomCodeModal"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-10-10 22:45:53 +09:00
|
|
|
<ul>
|
|
|
|
<li
|
|
|
|
v-for="(code, idx) in availableCodes.filter((c) => c.category === category.identifier)"
|
2022-02-22 12:40:14 +09:00
|
|
|
v-bind:key="code.identifier ? code.identifier : idx"
|
2021-10-10 22:45:53 +09:00
|
|
|
:class="code.selected ? 'checked' : code.disabled ? 'disabled' : ''"
|
|
|
|
@click="toggle(code)"
|
|
|
|
@mouseover="inspect(code)"
|
|
|
|
>
|
2022-02-22 12:40:14 +09:00
|
|
|
<span>
|
|
|
|
{{ getCodeTitle(code) }}
|
|
|
|
</span>
|
|
|
|
<div class="code-menu">
|
|
|
|
<button
|
|
|
|
v-if="code.identifier != null && code.category === 'custom'"
|
|
|
|
type="button"
|
|
|
|
class="btn-edit-custom-code"
|
|
|
|
@click="(e) => deleteCustomCode(e, code.identifier)"
|
|
|
|
>
|
|
|
|
×
|
|
|
|
</button>
|
|
|
|
</div>
|
2021-10-10 22:45:53 +09:00
|
|
|
</li>
|
|
|
|
<li
|
|
|
|
v-if="category.identifier === 'loader'"
|
|
|
|
:class="stageLoaderSelected ? 'checked' : ''"
|
|
|
|
@click="toggleStageLoader()"
|
|
|
|
@mouseover="showStageLoaderHelp()"
|
|
|
|
>
|
|
|
|
{{ getStageLoaderLabel() }}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-06-28 06:33:20 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-10-10 22:45:53 +09:00
|
|
|
import { translateCode, translate } from '../i18n/localeHelper';
|
|
|
|
import codeCategories from '../data/codeCategories.json';
|
|
|
|
import presetCategories from '../data/presetCategories.json';
|
2023-02-11 16:59:34 +09:00
|
|
|
import {lskeyLDC} from './DownloadButton.vue';
|
2020-07-03 10:42:43 +09:00
|
|
|
|
2020-06-28 06:33:20 +09:00
|
|
|
export default {
|
|
|
|
props: {
|
2022-02-22 12:40:14 +09:00
|
|
|
version: { type: String },
|
2020-06-28 06:33:20 +09:00
|
|
|
codes: { type: Array },
|
|
|
|
onSelectionChanged: { type: Function },
|
|
|
|
onInspect: { type: Function },
|
2021-10-10 22:45:53 +09:00
|
|
|
onStageLoaderToggle: { type: Function },
|
|
|
|
onInspectStageLoader: { type: Function },
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.populate();
|
|
|
|
},
|
|
|
|
watch: {
|
2020-07-01 14:26:48 +09:00
|
|
|
codes: function () {
|
2020-06-28 06:33:20 +09:00
|
|
|
this.populate();
|
2021-10-10 22:45:53 +09:00
|
|
|
this.unselectStageLoader();
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-02-22 12:40:14 +09:00
|
|
|
customCodes: [],
|
|
|
|
customCodeInEditMode: null,
|
2020-06-28 06:33:20 +09:00
|
|
|
availableCodes: [],
|
2021-10-10 22:45:53 +09:00
|
|
|
codeCategories,
|
|
|
|
presetCategories,
|
|
|
|
stageLoaderSelected: false,
|
|
|
|
generation: 0,
|
2020-06-28 06:33:20 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2021-10-10 22:45:53 +09:00
|
|
|
getPresetOptions() {
|
2023-02-11 16:59:34 +09:00
|
|
|
return [
|
|
|
|
...presetCategories.map((c) => ({
|
|
|
|
label: c.i18nKey,
|
|
|
|
value: c.identifier,
|
|
|
|
})),
|
|
|
|
{
|
|
|
|
label: 'generatorconfig.presets.@lastDLCodes',
|
|
|
|
value: lskeyLDC,
|
|
|
|
},
|
|
|
|
];
|
2021-10-10 22:45:53 +09:00
|
|
|
},
|
2022-02-22 09:25:49 +09:00
|
|
|
emitChangeEvent() {
|
|
|
|
const selectedCodes = this.availableCodes.filter((c) => c.selected);
|
2022-03-24 16:55:08 +09:00
|
|
|
// add dependencies
|
|
|
|
const deps = new Set(selectedCodes.flatMap(c => c.dependencies));
|
2023-10-16 16:47:26 +09:00
|
|
|
selectedCodes.push(...this.availableCodes.filter(c => !c.selected && deps.has(c.id)));
|
2022-03-24 16:55:08 +09:00
|
|
|
// emit
|
2022-02-22 09:25:49 +09:00
|
|
|
this.onSelectionChanged(selectedCodes);
|
|
|
|
},
|
2021-10-10 22:45:53 +09:00
|
|
|
loadPreset(identifier) {
|
|
|
|
if (
|
|
|
|
(this.stageLoaderSelected || this.availableCodes.find((c) => c.selected)) &&
|
|
|
|
!confirm(translate('common.selectionreset', this.$lang))
|
|
|
|
) {
|
|
|
|
this.generation++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-11 16:59:34 +09:00
|
|
|
if (identifier === lskeyLDC) {
|
|
|
|
// previous downloaded code
|
|
|
|
let titles = new Set();
|
|
|
|
try {
|
|
|
|
const o = JSON.parse(localStorage.getItem(lskeyLDC));
|
|
|
|
if (o instanceof Array) {
|
|
|
|
titles = new Set(o);
|
|
|
|
}
|
|
|
|
} catch {}
|
|
|
|
for (const code of this.availableCodes) {
|
|
|
|
code.selected = titles.has(code.title.find(o => o.lang === 'en-US').content);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// regular preset
|
|
|
|
for (const code of this.availableCodes) {
|
|
|
|
code.selected = code.presets.includes(identifier);
|
|
|
|
}
|
2021-10-10 22:45:53 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
this.unselectStageLoader();
|
|
|
|
this.refreshDisabledCodes();
|
2022-02-22 09:25:49 +09:00
|
|
|
this.emitChangeEvent();
|
2021-10-10 22:45:53 +09:00
|
|
|
this.generation++;
|
|
|
|
},
|
|
|
|
getPresetPlaceholder() {
|
|
|
|
return translate('common.loadpresetplaceholder', this.$lang);
|
|
|
|
},
|
|
|
|
unselectStageLoader() {
|
|
|
|
if (this.stageLoaderSelected) {
|
|
|
|
this.stageLoaderSelected = false;
|
|
|
|
this.onStageLoaderToggle(false);
|
|
|
|
}
|
|
|
|
},
|
2020-07-03 10:42:43 +09:00
|
|
|
getCodeTitle(code) {
|
|
|
|
return translateCode(code, this.$lang).title;
|
|
|
|
},
|
2021-10-10 22:45:53 +09:00
|
|
|
getCategoryTitle(category) {
|
|
|
|
return translate(category.i18nKey, this.$lang);
|
|
|
|
},
|
|
|
|
getStageLoaderLabel() {
|
|
|
|
return translate('headers.stageloader', this.$lang);
|
|
|
|
},
|
|
|
|
toggleStageLoader() {
|
|
|
|
for (const c of this.availableCodes.filter((c) => c.category === 'loader' && c.selected)) {
|
|
|
|
c.selected = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newState = !this.stageLoaderSelected;
|
|
|
|
this.stageLoaderSelected = newState;
|
|
|
|
this.onStageLoaderToggle(newState);
|
|
|
|
this.refreshDisabledCodes();
|
2022-02-22 09:25:49 +09:00
|
|
|
this.emitChangeEvent();
|
2021-10-10 22:45:53 +09:00
|
|
|
},
|
|
|
|
refreshDisabledCodes() {
|
2021-11-20 04:08:01 +09:00
|
|
|
for (const code of this.availableCodes) {
|
|
|
|
if (code.dependsOn) {
|
|
|
|
if (code.dependsOn === 'loader' && this.stageLoaderSelected) {
|
|
|
|
code.disabled = false;
|
|
|
|
} else if (
|
|
|
|
!this.availableCodes.some((c) => c.selected && c.category === code.dependsOn)
|
|
|
|
) {
|
|
|
|
code.disabled = true;
|
|
|
|
code.selected = false;
|
|
|
|
} else {
|
|
|
|
code.disabled = false;
|
2021-10-10 22:45:53 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-02-22 12:40:14 +09:00
|
|
|
initCustomCodeModal() {
|
|
|
|
this.customCodeInEditMode = {
|
|
|
|
identifier: btoa(new Date().toISOString()),
|
|
|
|
title: undefined,
|
|
|
|
value: undefined,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
closeCustomClodeModal() {
|
|
|
|
this.customCodeInEditMode = null;
|
|
|
|
},
|
|
|
|
deleteCustomCode(e, identifier) {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.customCodes = this.customCodes.filter((c) => c.identifier !== identifier);
|
|
|
|
localStorage.setItem('custom-codes', JSON.stringify(this.customCodes));
|
|
|
|
this.availableCodes = this.availableCodes.filter((c) => c.identifier !== identifier);
|
|
|
|
this.emitChangeEvent();
|
|
|
|
},
|
|
|
|
saveCustomCode(identifier, title, value) {
|
|
|
|
const updatedCode = {
|
|
|
|
identifier,
|
|
|
|
author: '-',
|
|
|
|
title: [
|
|
|
|
{
|
|
|
|
lang: 'en-US',
|
|
|
|
content: title,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
description: [
|
|
|
|
{
|
|
|
|
lang: 'en-US',
|
|
|
|
content: '-',
|
|
|
|
html: '<p>-</p>',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
version: '-',
|
|
|
|
date: new Date().toLocaleDateString('en-US', {
|
|
|
|
month: 'short',
|
|
|
|
day: '2-digit',
|
|
|
|
year: 'numeric',
|
|
|
|
}),
|
|
|
|
source: value,
|
|
|
|
presets: [],
|
|
|
|
category: 'custom',
|
|
|
|
dependsOn: null,
|
|
|
|
createdOnVersion: this.version,
|
|
|
|
};
|
|
|
|
this.customCodes = [
|
|
|
|
...this.customCodes.filter((c) => c.identifier !== identifier),
|
|
|
|
updatedCode,
|
|
|
|
];
|
|
|
|
|
|
|
|
localStorage.setItem('custom-codes', JSON.stringify(this.customCodes));
|
|
|
|
this.availableCodes = [
|
|
|
|
...this.availableCodes.filter((c) => c.identifier !== identifier),
|
|
|
|
{ ...updatedCode, selected: false },
|
|
|
|
];
|
|
|
|
this.closeCustomClodeModal();
|
|
|
|
},
|
2020-06-28 06:33:20 +09:00
|
|
|
toggle(code) {
|
2021-10-10 22:45:53 +09:00
|
|
|
if (!code.selected && codeCategories.find((c) => c.identifier === code.category).exclusive) {
|
|
|
|
for (const availableCode of this.availableCodes.filter(
|
|
|
|
(c) => c.category === code.category && c.selected,
|
|
|
|
)) {
|
|
|
|
availableCode.selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!code.selected && code.category === 'loader' && this.stageLoaderSelected) {
|
|
|
|
this.stageLoaderSelected = false;
|
|
|
|
this.onStageLoaderToggle(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
code.selected = code.disabled ? false : !code.selected;
|
|
|
|
this.refreshDisabledCodes();
|
2022-02-22 09:25:49 +09:00
|
|
|
this.emitChangeEvent();
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
|
|
|
populate() {
|
2022-02-22 12:40:14 +09:00
|
|
|
const storedCustomCodes = localStorage.getItem('custom-codes');
|
|
|
|
|
|
|
|
if (storedCustomCodes) {
|
|
|
|
try {
|
|
|
|
const parsedCodes = JSON.parse(storedCustomCodes);
|
|
|
|
this.customCodes = parsedCodes;
|
|
|
|
} catch (err) {
|
|
|
|
this.customCodes = [];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.customCodes = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
this.availableCodes = [
|
|
|
|
...this.codes.map((c) => ({ ...c, selected: false })),
|
|
|
|
...this.customCodes.map((c) => ({ ...c, selected: false })),
|
|
|
|
];
|
|
|
|
|
2021-10-10 22:45:53 +09:00
|
|
|
this.refreshDisabledCodes();
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
|
|
|
inspect(code) {
|
|
|
|
this.onInspect(code);
|
|
|
|
},
|
2021-10-10 22:45:53 +09:00
|
|
|
showStageLoaderHelp() {
|
|
|
|
this.onInspectStageLoader();
|
|
|
|
},
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2021-10-10 22:45:53 +09:00
|
|
|
.category-title {
|
2022-02-22 12:40:14 +09:00
|
|
|
position: relative;
|
2021-10-10 22:45:53 +09:00
|
|
|
color: white;
|
|
|
|
font-weight: 500;
|
|
|
|
text-align: center;
|
|
|
|
background: #383838b5;
|
2022-02-22 12:40:14 +09:00
|
|
|
padding: 2px;
|
2021-10-10 22:45:53 +09:00
|
|
|
margin-bottom: 0;
|
2022-02-22 12:40:14 +09:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: auto min-content;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-add-custom-code {
|
|
|
|
min-width: unset;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-edit-custom-code {
|
|
|
|
background: transparent;
|
|
|
|
border: none;
|
|
|
|
font-size: 1.2em;
|
|
|
|
font-weight: bold;
|
|
|
|
color: red;
|
|
|
|
cursor: pointer;
|
2021-10-10 22:45:53 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
.category-title ~ ul {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.preset-select {
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.code-group {
|
|
|
|
border: 1px solid #d7d7d7;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.code-group ul {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
2020-06-28 06:33:20 +09:00
|
|
|
ul {
|
|
|
|
list-style-type: none;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul li {
|
|
|
|
cursor: pointer;
|
|
|
|
color: #262626;
|
|
|
|
transition: 0.1s;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-ms-user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
outline: none;
|
|
|
|
display: block;
|
2022-02-22 12:40:14 +09:00
|
|
|
overflow: hidden;
|
|
|
|
padding-right: 5px;
|
|
|
|
min-width: 260px;
|
|
|
|
max-width: 260px;
|
2020-06-29 00:35:18 +09:00
|
|
|
text-align: left;
|
2022-02-22 12:40:14 +09:00
|
|
|
position: relative;
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: auto min-content min-content;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul li > span {
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-06-28 06:33:20 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
ul li:nth-child(odd) {
|
2021-11-05 10:39:04 +09:00
|
|
|
background: #f3f3f3;
|
2020-06-28 06:33:20 +09:00
|
|
|
}
|
|
|
|
|
2021-10-10 22:45:53 +09:00
|
|
|
ul li:not(.disabled):hover {
|
2020-06-28 06:33:20 +09:00
|
|
|
background: #3eaf7c;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul li.checked:hover {
|
|
|
|
background: #3eaf7c;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul li.checked {
|
|
|
|
background: #434343;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
2021-10-10 22:45:53 +09:00
|
|
|
ul li.disabled {
|
|
|
|
background: #c7c7c7;
|
|
|
|
color: #767676;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul li.disabled:hover {
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
|
|
|
|
2020-06-28 06:33:20 +09:00
|
|
|
li {
|
|
|
|
position: relative;
|
|
|
|
padding-left: 26px;
|
|
|
|
}
|
|
|
|
|
|
|
|
li::before {
|
2020-06-29 00:35:18 +09:00
|
|
|
content: '';
|
2020-06-28 06:33:20 +09:00
|
|
|
position: absolute;
|
2021-11-05 10:39:04 +09:00
|
|
|
border-color: #e7e7e7;
|
2020-06-28 06:33:20 +09:00
|
|
|
border-style: solid;
|
|
|
|
border-width: 2px;
|
|
|
|
border-radius: 50%;
|
|
|
|
left: 6px;
|
|
|
|
top: 6px;
|
|
|
|
height: 10px;
|
|
|
|
width: 10px;
|
|
|
|
}
|
|
|
|
|
2021-10-10 22:45:53 +09:00
|
|
|
li:not(.disabled):not(.checked):hover::before {
|
2020-06-28 06:33:20 +09:00
|
|
|
border-color: #fff;
|
2020-06-29 00:35:18 +09:00
|
|
|
background-color: #1fa76e;
|
2020-06-28 06:33:20 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
li.checked::before {
|
|
|
|
border-color: #fff;
|
|
|
|
background-color: #d85e55;
|
|
|
|
}
|
2020-06-29 00:35:18 +09:00
|
|
|
|
2022-02-22 12:40:14 +09:00
|
|
|
@media screen and (max-width: 1100px) {
|
2020-06-29 00:35:18 +09:00
|
|
|
ul li {
|
2022-02-22 12:40:14 +09:00
|
|
|
max-width: 100%;
|
2020-06-29 00:35:18 +09:00
|
|
|
}
|
|
|
|
}
|
2020-06-28 06:33:20 +09:00
|
|
|
</style>
|