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

42 lines
983 B
Vue
Raw Normal View History

2020-06-28 06:33:20 +09:00
<template>
2020-06-28 07:05:33 +09:00
<ButtonComponent label="Download" :onClick="onClick" :disabled="!codes || codes.length === 0" />
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 },
format: { type: String },
2020-06-28 07:05:33 +09:00
versionIdentifier: { type: String }
2020-06-28 06:33:20 +09:00
},
methods: {
onClick() {
if (!this.codes || this.codes.length === 0) {
return;
}
console.log(`Preparing download for ${this.format}`);
switch (this.format) {
case "gct":
CodeFormatter.generateGCT(this.codes, this.versionIdentifier);
break;
case "dolphin":
CodeFormatter.generateDolphinINI(this.codes, this.versionIdentifier);
break;
case "gcm":
CodeFormatter.generateCheatManagerTXT(
this.codes,
this.versionIdentifier
);
break;
}
2020-06-28 07:05:33 +09:00
}
}
2020-06-28 06:33:20 +09:00
};
</script>