gctGenerator/docs/.vuepress/components/Generator.vue

294 lines
7.6 KiB
Vue
Raw Normal View History

2020-06-28 06:33:20 +09:00
<template>
<div>
<section class="config">
<div>
<span>Game Version:</span>
2020-06-29 00:35:18 +09:00
<VersionSelect :onChange="onVersionChanged" :selectedValue="selectedVersion" />
2020-06-28 06:33:20 +09:00
</div>
<div>
<span>Download Format:</span>
2020-06-29 00:35:18 +09:00
<FormatSelect :onChange="onFormatChanged" :selectedValue="selectedFormat" />
2020-06-28 06:33:20 +09:00
</div>
2020-06-28 07:05:33 +09:00
<div>
<span>Use Stage Loader:</span>
2020-06-28 09:31:31 +09:00
<SelectComponent
:options="useStageLoaderOptions"
:onChange="onStageLoaderChanged"
2020-06-28 10:45:44 +09:00
:value="useStageLoader"
2020-06-28 09:31:31 +09:00
/>
2020-06-28 07:05:33 +09:00
</div>
2020-06-28 06:33:20 +09:00
<div>
<span>Download:</span>
<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>
2020-06-29 00:59:22 +09:00
<div v-if="isLoading" class="loading-overlay">
<div class="spinner"></div>
</div>
2020-06-28 06:33:20 +09:00
</section>
2020-06-28 10:45:44 +09:00
<br />
<hr />
2020-06-28 06:33:20 +09:00
<section>
<div v-if="codes && codes.length > 0">
<h3>Available Codes</h3>
<CodeList
:codes="codes"
:onSelectionChanged="onCheatSelectionChanged"
:onInspect="inspect"
/>
</div>
2020-06-29 00:35:18 +09:00
<div class="prevent-shrink" v-if="codes && codes.length > 0 && useStageLoader">
2020-06-28 07:05:33 +09:00
<h3>Stage Loader</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">
<h3>Help</h3>
<CodeInfo v-if="!!inspectingCode" :code="inspectingCode" />
<div v-else>Select your codes from the list on the left.</div>
</div>
<div v-if="selectedVersion == null" class="help">
2020-07-01 04:08:00 +09:00
<h1>Super Mario Sunshine Practice File Generator</h1>
2020-06-28 06:33:20 +09:00
<div>
<p>
2020-06-29 00:35:18 +09:00
This is a cheatfile generator for Super Mario Sunshine speedrun practice. If this is
your first time using the generator we highly recommend to check out the
2020-06-30 06:16:47 +09:00
<a href="/guide.html" target="_blank">guide</a> first. Visit the
<a href="/guide.html#troubleshooting" target="_blank">the troubleshooting section</a>
2020-06-28 06:33:20 +09:00
if you encounter any issues.
</p>
<div>
2020-07-01 04:08:00 +09:00
<h3>The SMS Speedrunning Community</h3>
2020-06-28 06:33:20 +09:00
<ul>
<li>
2020-06-29 00:35:18 +09:00
<a href="https://discord.gg/9dGJWEc" target="_blank" rel="noopener">Discord</a>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-06-30 06:16:47 +09:00
<a href="https://speedrun.com/sms" target="_blank" rel="noopener"
>Speedrun.com Leaderboards</a
>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-06-30 06:16:47 +09:00
<a href="https://twitter.com/SMSCommunity" target="_blank" rel="noopener"
>Twitter: @SMSCommunity</a
>
2020-06-28 06:33:20 +09:00
</li>
<li>
2020-06-30 06:16:47 +09:00
<a href="https://www.twitch.tv/SunshineCommunity" target="_blank" rel="noopener"
>Twitch: SunshineCommunity</a
>
2020-06-28 06:33:20 +09:00
</li>
</ul>
</div>
<div>
<p>
GCT Generator &copy; 2017 - {{ new Date().getFullYear() }}
2020-06-30 06:16:47 +09:00
<a href="https://twitter.com/psychonauter" target="_blank" rel="noopener"
>Psychonauter</a
>,
2020-06-29 00:35:18 +09:00
<a href="https://twitter.com/Qbe_Root" target="_blank" rel="noopener">Noki Doki</a>
2020-06-28 06:33:20 +09:00
and
2020-06-30 06:16:47 +09:00
<a href="https://twitter.com/srlMilk" target="_blank" rel="noopener">Milk</a>. The
2020-06-29 00:35:18 +09:00
source code is available on
2020-06-30 06:16:47 +09:00
<a href="https://github.com/BitPatty/gctGenerator" target="_blank" rel="noopener"
>Github</a
>.
</p>
<p>
Found a bug? Post a message on the SMS Discord (#hacking) and tag psy#1363. During the
transition the old site will still be available at
<a href="https://old.gct.zint.ch" target="_blank" rel="noopener"
>https://old.gct.zint.ch</a
>.
2020-06-28 06:33:20 +09:00
</p>
</div>
</div>
</div>
</section>
</div>
</template>
<script>
// Components
2020-06-29 00:35:18 +09:00
import VersionSelect from './VersionSelect';
import FormatSelect from './FormatSelect';
import SelectComponent from './SelectComponent';
import StageLoader from './StageLoader';
import CodeInfo from './CodeInfo';
import CodeList from './CodeList';
import DownloadButton from './DownloadButton';
2020-06-28 06:33:20 +09:00
// Data
2020-06-29 00:35:18 +09:00
import gameVersions from '../data/gameVersions.json';
2020-06-28 06:33:20 +09:00
2020-06-28 10:45:44 +09:00
// Util
2020-06-29 00:35:18 +09:00
import parseXml from './scripts/parseXml';
2020-06-28 06:33:20 +09:00
// Libs
2020-06-29 00:35:18 +09:00
import axios from 'axios';
2020-06-28 06:33:20 +09:00
export default {
mounted() {
Promise.all(
2020-06-29 00:35:18 +09:00
gameVersions.map(async v => ({
2020-06-28 06:33:20 +09:00
identifier: v.identifier,
cheats: parseXml((await axios.get(`/codes/${v.identifier}.xml`)).data),
2020-06-28 09:31:31 +09:00
fastCodes: (await axios.get(`/codes/fast/${v.identifier}.json`)).data,
2020-06-29 00:35:18 +09:00
})),
2020-06-28 06:33:20 +09:00
)
2020-06-29 00:35:18 +09:00
.then(codes => {
localStorage.setItem('codes', JSON.stringify(codes));
2020-06-28 06:33:20 +09:00
this.isLoading = false;
})
2020-06-29 00:35:18 +09:00
.catch(err => {
if (localStorage.getItem('codes') != null) this.isLoading = false;
2020-06-28 06:33:20 +09:00
});
},
data() {
return {
isLoading: true,
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: [],
2020-06-28 07:05:33 +09:00
useStageLoaderOptions: [
2020-06-29 00:35:18 +09:00
{ value: false, label: 'No' },
{ value: true, label: 'Yes' },
2020-06-28 09:31:31 +09:00
],
2020-06-28 06:33:20 +09:00
};
},
methods: {
onVersionChanged(e) {
this.selectedVersion = e;
this.selectedCheats = [];
2020-06-29 00:35:18 +09:00
const storedCodes = JSON.parse(localStorage.getItem('codes'));
this.codes = storedCodes.find(c => c.identifier === e).cheats;
this.stageLoaderCodes = storedCodes.find(c => c.identifier === e).fastCodes;
2020-06-28 06:33:20 +09:00
this.inspectingCode = null;
},
onFormatChanged(e) {
this.selectedFormat = e;
},
2020-06-28 07:05:33 +09:00
onStageLoaderChanged(e) {
2020-06-29 00:35:18 +09:00
this.useStageLoader = e === true || e === 'true';
2020-06-28 10:45:44 +09:00
if (!this.useStageLoader) this.selectedStageLoader = null;
2020-06-28 07:05:33 +09:00
},
2020-06-28 06:33:20 +09:00
onCheatSelectionChanged(e) {
this.selectedCheats = e;
},
2020-06-28 10:45:44 +09:00
onStageLoaderCodeChanged(e) {
this.selectedStageLoader = e;
},
2020-06-28 06:33:20 +09:00
inspect(code) {
this.inspectingCode = code;
2020-06-28 09:31:31 +09:00
},
},
2020-06-28 06:33:20 +09:00
};
</script>
<style scoped>
section {
display: flex;
flex-wrap: nowrap;
}
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 {
position: relative;
}
.config .loading-overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
2020-06-29 01:22:38 +09:00
z-index: 15;
2020-06-29 00:35:18 +09:00
text-align: center;
background: #ffffff44;
background-color: rgba(255, 255, 255, 0.7);
2020-06-29 00:59:22 +09:00
margin-left: -1px;
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 {
text-align: left;
}
.spinner {
display: inline-block;
}
.spinner:after {
content: ' ';
display: block;
width: 32px;
height: 32px;
border-radius: 50%;
border: 6px solid #fff;
border-color: #2eb9e2 transparent #2eb9e2 transparent;
animation: spinner 1.2s linear infinite;
}
@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>