gctGenerator/site/.vuepress/components/Generator.vue

310 lines
8.2 KiB
Vue
Raw Normal View History

2020-06-28 06:33:20 +09:00
<template>
<div>
<section class="config">
<div>
2020-07-10 07:57:16 +09:00
<span>{{ getLabel('generatorconfig.gameversion.label') }}</span>
<VersionSelect
:onChange="onVersionChanged"
:selectedValue="selectedVersion"
:key="generation"
/>
2020-06-28 06:33:20 +09:00
</div>
<div>
2020-07-10 07:57:16 +09:00
<span>{{ getLabel('generatorconfig.downloadformat.label') }}</span>
2020-06-29 00:35:18 +09:00
<FormatSelect :onChange="onFormatChanged" :selectedValue="selectedFormat" />
2020-06-28 06:33:20 +09:00
</div>
<div>
2020-07-03 10:42:43 +09:00
<span>{{ getLabel('common.download') }}</span>
2020-06-28 06:33:20 +09:00
<DownloadButton
:codes="selectedCheats"
2020-06-28 10:45:44 +09:00
:stageLoaderCode="selectedStageLoader"
2020-06-28 06:33:20 +09:00
:versionIdentifier="selectedVersion"
:format="selectedFormat"
/>
</div>
</section>
<section>
<div v-if="codes && codes.length > 0">
2020-07-03 10:42:43 +09:00
<h3>{{ getLabel('headers.codelist') }}</h3>
2020-06-28 06:33:20 +09:00
<CodeList
2022-02-22 12:40:14 +09:00
:version="selectedVersion"
:onStageLoaderToggle="onStageLoaderToggle"
2020-06-28 06:33:20 +09:00
:codes="codes"
:onSelectionChanged="onCheatSelectionChanged"
:onInspect="inspect"
:onInspectStageLoader="displayStageLoaderHelp"
2020-06-28 06:33:20 +09:00
/>
</div>
2020-06-29 00:35:18 +09:00
<div class="prevent-shrink" v-if="codes && codes.length > 0 && useStageLoader">
2020-07-03 10:42:43 +09:00
<h3>{{ getLabel('headers.stageloader') }}</h3>
2020-06-29 00:35:18 +09:00
<StageLoader :fastCodes="stageLoaderCodes" :onChange="onStageLoaderCodeChanged" />
2020-06-28 07:05:33 +09:00
</div>
2020-06-28 06:33:20 +09:00
<div v-if="codes && codes.length > 0" class="help">
2020-07-03 10:42:43 +09:00
<h3>{{ getLabel('headers.help') }}</h3>
2022-10-07 23:02:40 +09:00
<CodeInfo v-if="!!inspectingCode" :code="inspectingCode" :version="selectedVersion"
:previewConfig="previewConfig" @config="onCodeConfigChanged" />
<div v-else-if="showStageLoaderHelp">
<h3>{{ getLabel('headers.stageloader') }}</h3>
<div>
{{ getLabel('stageloader.help') }}
</div>
</div>
2020-07-03 10:42:43 +09:00
<div v-else>{{ getLabel('misc.defaulthelpmessage') }}</div>
2020-06-28 06:33:20 +09:00
</div>
<div v-if="selectedVersion == null" class="help">
2020-07-03 10:42:43 +09:00
<h1>{{ getLabel('landingpage.title') }}</h1>
2020-06-28 06:33:20 +09:00
<div>
2020-07-03 10:42:43 +09:00
<p v-html="getLabel('landingpage.summary')" />
2020-06-28 06:33:20 +09:00
<div>
2020-07-03 10:42:43 +09:00
<h3>{{ getLabel('landingpage.community') }}</h3>
2020-06-28 06:33:20 +09:00
<ul>
<li>
2020-09-25 02:18:54 +09:00
<a :href="getLabel('landingpage.links.discordlink')" target="_blank" rel="noopener">
2020-07-10 07:59:26 +09:00
{{ getLabel('landingpage.links.discord') }}
2020-07-10 07:57:16 +09:00
</a>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-07-10 07:57:16 +09:00
<a href="https://speedrun.com/sms" target="_blank" rel="noopener">
2020-07-10 07:59:26 +09:00
{{ getLabel('landingpage.links.src') }}
2020-07-10 07:57:16 +09:00
</a>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-07-10 07:57:16 +09:00
<a href="https://twitter.com/SMSCommunity" target="_blank" rel="noopener">
2020-07-10 07:59:26 +09:00
{{ getLabel('landingpage.links.twitter') }}
2020-07-10 07:57:16 +09:00
</a>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-07-10 07:57:16 +09:00
<a href="https://www.twitch.tv/SunshineCommunity" target="_blank" rel="noopener">
2020-07-10 07:59:26 +09:00
{{ getLabel('landingpage.links.twitch') }}
2020-07-10 07:57:16 +09:00
</a>
2020-06-28 06:33:20 +09:00
</li>
</ul>
</div>
<div>
<p>
GCT Generator &copy; 2017 - {{ new Date().getFullYear() }}
2020-07-10 07:59:26 +09:00
<a href="https://twitter.com/psychonauter" target="_blank" rel="noopener"
>Psychonauter</a
>,
2022-04-24 05:22:36 +09:00
<a href="https://twitter.com/Qbe_Root" target="_blank" rel="noopener">Noki Doki</a>,
<a href="https://twitter.com/sup39x1207" target="_blank" rel="noopener">sup39</a>
2020-07-10 11:27:15 +09:00
&amp;
<a href="https://twitter.com/srlMilk" target="_blank" rel="noopener">Milk</a>.
2020-06-30 06:16:47 +09:00
</p>
2020-06-28 06:33:20 +09:00
</div>
<div class="centered">
2020-12-31 19:55:12 +09:00
<a href="/">English</a> | <a href="/ja">日本語</a> | <a href="/de">Deutsch</a> |
<a href="/fr">Français</a>
</div>
2020-06-28 06:33:20 +09:00
</div>
</div>
</section>
</div>
</template>
<script>
// Data
2020-06-29 00:35:18 +09:00
import gameVersions from '../data/gameVersions.json';
import codeCategories from '../data/codeCategories.json';
2020-06-28 06:33:20 +09:00
2020-07-10 07:57:16 +09:00
// Util
2020-07-03 10:42:43 +09:00
import { translate } from '../i18n/localeHelper';
2022-10-07 23:02:40 +09:00
// Code Configs
import {getConfigs} from './codes/preview.js';
2022-10-07 23:02:40 +09:00
2020-06-28 06:33:20 +09:00
export default {
data() {
return {
codes: [],
selectedCheats: [],
2020-06-28 08:50:25 +09:00
selectedStageLoader: null,
2020-06-28 06:33:20 +09:00
inspectingCode: null,
selectedVersion: null,
2020-06-29 00:35:18 +09:00
selectedFormat: 'gct',
2020-06-28 07:05:33 +09:00
useStageLoader: false,
2020-06-28 08:50:25 +09:00
stageLoaderCodes: [],
showStageLoaderHelp: false,
generation: 0,
2022-10-07 23:02:40 +09:00
codeConfigs: {},
};
},
2020-06-28 06:33:20 +09:00
methods: {
2020-07-03 10:42:43 +09:00
getLabel(key) {
return translate(key, this.$lang);
},
2020-06-28 06:33:20 +09:00
onVersionChanged(e) {
if (
this.selectedCheats.length > 0 &&
!confirm(translate('common.selectionreset', this.$lang))
) {
this.generation++;
return;
}
2020-06-28 06:33:20 +09:00
this.selectedVersion = e;
this.selectedCheats = [];
2020-07-01 14:26:48 +09:00
this.codes = gameVersions.find((c) => c.identifier === e).codes;
this.stageLoaderCodes = gameVersions.find((c) => c.identifier === e).fastCode;
2020-06-28 06:33:20 +09:00
this.inspectingCode = null;
this.showStageLoaderHelp = false;
2021-06-11 08:28:34 +09:00
try {
window._paq.push([
'trackEvent',
'GCT Generator',
'Change Version',
JSON.stringify({ version: e }),
]);
} catch {}
// update config for preview
this.codeConfigs = getConfigs(e);
2020-06-28 06:33:20 +09:00
},
onFormatChanged(e) {
this.selectedFormat = e;
2021-06-11 08:28:34 +09:00
try {
window._paq.push([
'trackEvent',
'GCT Generator',
'Change Format',
JSON.stringify({ format: e }),
]);
} catch {}
2020-06-28 06:33:20 +09:00
},
onStageLoaderToggle(enabled) {
this.useStageLoader = enabled;
2020-06-28 10:45:44 +09:00
if (!this.useStageLoader) this.selectedStageLoader = null;
2021-06-11 08:28:34 +09:00
try {
window._paq.push([
'trackEvent',
'GCT Generator',
'Change StageLoader State',
JSON.stringify({ enabled }),
2021-06-11 08:28:34 +09:00
]);
} catch {}
2020-06-28 07:05:33 +09:00
},
2020-06-28 06:33:20 +09:00
onCheatSelectionChanged(e) {
this.selectedCheats = e;
2021-06-11 08:28:34 +09:00
try {
window._paq.push(['trackEvent', 'GCT Generator', 'Change Cheat Selection', '']);
} catch {}
2020-06-28 06:33:20 +09:00
},
2020-06-28 10:45:44 +09:00
onStageLoaderCodeChanged(e) {
this.selectedStageLoader = e;
},
displayStageLoaderHelp() {
this.inspectingCode = null;
this.showStageLoaderHelp = true;
},
2020-06-28 06:33:20 +09:00
inspect(code) {
this.showStageLoaderHelp = false;
2020-06-28 06:33:20 +09:00
this.inspectingCode = code;
2020-06-28 09:31:31 +09:00
},
2022-10-07 23:02:40 +09:00
onCodeConfigChanged(e) {
this.codeConfigs = {...this.codeConfigs, ...e};
},
2020-06-28 09:31:31 +09:00
},
computed: {
previewConfig() {
const {id, category} = this.inspectingCode ?? {};
const {exclusive} = codeCategories.find((c) => c.identifier === category) ?? {};
const ids = new Set(this.selectedCheats
.filter(code => !(code.category === category && exclusive))
.map(code => code.id));
ids.add(id);
return {
...Object.fromEntries(Object.entries(this.codeConfigs).filter(([id]) => ids.has(id))),
_version: this.selectedVersion,
};
},
},
2020-06-28 06:33:20 +09:00
};
</script>
<style scoped>
section {
display: flex;
flex-wrap: nowrap;
position: relative;
2020-06-28 06:33:20 +09:00
}
2020-06-28 09:31:31 +09:00
.prevent-shrink {
flex-shrink: 0;
}
2020-06-28 06:33:20 +09:00
section > div {
display: inline-block;
vertical-align: top;
}
section > div:not(:first-child) {
margin-left: 20px;
}
2020-06-29 00:35:18 +09:00
.config {
2022-02-22 09:25:49 +09:00
position: sticky;
top: 58px;
z-index: 999;
padding: 16px 0px;
background: white;
border-bottom: 1px solid #dfdfdf;
2020-06-29 00:35:18 +09:00
}
2020-06-28 06:33:20 +09:00
.config span {
display: block;
margin-bottom: 10px;
padding-left: 2px;
}
2020-06-29 00:35:18 +09:00
.help {
position: sticky;
2022-02-22 09:25:49 +09:00
top: 90px;
2020-06-29 00:35:18 +09:00
text-align: left;
align-self: flex-start;
width: 100%;
2020-06-29 00:35:18 +09:00
}
2020-07-15 02:45:47 +09:00
.centered {
width: 100%;
text-align: center;
}
2020-06-29 00:35:18 +09:00
@keyframes spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
.config .loading-overlay {
-webkit-backdrop-filter: blur(1px);
backdrop-filter: blur(1px);
}
}
@media screen and (max-width: 1100px) {
section {
flex-wrap: wrap;
display: block;
margin-left: 0px;
text-align: center;
}
section > div,
section > div:not(:first-child) {
margin-left: 0px;
width: 100%;
}
}
2020-06-28 06:33:20 +09:00
</style>
<style>
body {
2020-06-30 08:38:53 +09:00
overflow-y: scroll;
2020-06-28 06:33:20 +09:00
}
</style>