2022-04-05 10:40:31 +00:00
|
|
|
const PACKAGE_NAME = "uuidconvert";
|
|
|
|
const fs = require("fs");
|
|
|
|
|
2022-03-31 00:57:26 +00:00
|
|
|
Editor.Panel.extend({
|
2022-08-18 04:09:30 +00:00
|
|
|
style: fs.readFileSync(Editor.url(`packages://${PACKAGE_NAME}/static/style/default/index.css`), 'utf-8')
|
|
|
|
.concat(fs.readFileSync(Editor.url(`packages://${PACKAGE_NAME}/static/style/default/bootstrap.min.css`), 'utf-8')),
|
2022-04-05 10:40:31 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
template: fs.readFileSync(
|
|
|
|
Editor.url(`packages://${PACKAGE_NAME}/index.html`), 'utf-8'),
|
2022-04-05 10:40:31 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
$: {
|
|
|
|
run: '#run',
|
|
|
|
uuid: '#uuid',
|
|
|
|
asset: '#asset',
|
|
|
|
asset2: '#asset2',
|
|
|
|
source: '#source',
|
|
|
|
isReplaceResource: '#isReplaceResource',
|
|
|
|
ReplaceResource: '#ReplaceResource',
|
|
|
|
ReplaceResource1: '#ReplaceResource1',
|
|
|
|
ReplaceResource2: '#ReplaceResource2',
|
|
|
|
},
|
2022-04-05 10:40:31 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
ready() {
|
|
|
|
this.$run.addEventListener("confirm", this.methods.run.bind(this));
|
|
|
|
this.$isReplaceResource.addEventListener("change", this.methods.setReplaceResource.bind(this));
|
|
|
|
},
|
2022-04-05 10:40:31 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
methods: {
|
|
|
|
run() {
|
|
|
|
let uuid = "";
|
|
|
|
// Editor.log(`$asset: ${this.$asset.value}`);
|
|
|
|
if (!this.$uuid.value) {
|
|
|
|
if (!this.$asset.value) {
|
|
|
|
Editor.error("請輸入要轉換的UUID");
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
uuid = this.$asset.value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uuid = this.$uuid.value;
|
|
|
|
}
|
|
|
|
let ReplaceResource = this.$isReplaceResource.value;
|
|
|
|
if (ReplaceResource) {
|
|
|
|
// if (!this.$asset2.value) {
|
|
|
|
// Editor.error("請輸入要取代的資源");
|
|
|
|
// return;
|
|
|
|
// } else if (!this.$source.value) {
|
|
|
|
// Editor.error("請輸入要取代的檔案");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
Editor.Ipc.sendToMain("uuidconvert:replaceResource", uuid, this.$asset2.value, this.$source.value);
|
|
|
|
} else {
|
|
|
|
Editor.Ipc.sendToMain("uuidconvert:run-click", uuid);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setReplaceResource() {
|
|
|
|
// Editor.log(`$isReplaceResource: ${this.$isReplaceResource.value}`);
|
|
|
|
let ReplaceResource = this.$isReplaceResource.value;
|
|
|
|
this.$ReplaceResource.style.display = ReplaceResource ? "" : "none";
|
|
|
|
this.$ReplaceResource1.style.display = ReplaceResource ? "none" : "";
|
|
|
|
this.$ReplaceResource2.style.display = ReplaceResource ? "" : "none";
|
|
|
|
},
|
|
|
|
},
|
2022-04-05 10:40:31 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
messages: {
|
|
|
|
}
|
2022-03-31 00:57:26 +00:00
|
|
|
});
|