gctGenerator/docs/.vuepress/components/DownloadButton.vue

52 lines
1.2 KiB
Vue
Raw Normal View History

2020-06-28 06:33:20 +09:00
<template>
2020-06-28 10:45:44 +09:00
<ButtonComponent
label="Download"
:onClick="onClick"
:disabled="(!codes || codes.length === 0) && !stageLoaderCode"
/>
2020-06-28 06:33:20 +09:00
</template>
<script>
2020-06-28 07:05:33 +09:00
import ButtonComponent from "./ButtonComponent";
2020-06-28 06:33:20 +09:00
import CodeFormatter from "./scripts/codeFormatter";
export default {
props: {
codes: { type: Array },
2020-06-28 10:45:44 +09:00
stageLoaderCode: { type: String },
2020-06-28 06:33:20 +09:00
format: { type: String },
2020-06-28 10:45:44 +09:00
versionIdentifier: { type: String },
2020-06-28 06:33:20 +09:00
},
methods: {
onClick() {
2020-06-28 10:45:44 +09:00
if (!(this.codes || this.codes.length === 0) && !this.stageLoaderCode) {
2020-06-28 06:33:20 +09:00
return;
}
2020-06-28 10:45:44 +09:00
const c = [...(this.codes ?? [])];
if (this.stageLoaderCode)
c.push({
title: "Stage List Loader",
author: "Noki Doki",
date: "-",
version: "",
source: this.stageLoaderCode,
});
2020-06-28 06:33:20 +09:00
console.log(`Preparing download for ${this.format}`);
switch (this.format) {
case "gct":
2020-06-28 10:45:44 +09:00
CodeFormatter.generateGCT(c, this.versionIdentifier);
2020-06-28 06:33:20 +09:00
break;
case "dolphin":
2020-06-28 10:45:44 +09:00
CodeFormatter.generateDolphinINI(c, this.versionIdentifier);
2020-06-28 06:33:20 +09:00
break;
case "gcm":
2020-06-28 10:45:44 +09:00
CodeFormatter.generateCheatManagerTXT(c, this.versionIdentifier);
2020-06-28 06:33:20 +09:00
break;
}
2020-06-28 10:45:44 +09:00
},
},
2020-06-28 06:33:20 +09:00
};
</script>