"use strict"; const EditorAPI = require('./src/main/editor-api'); // ------------decode-uuid const BASE64_KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; const values = new Array(123); // max char code in base64Keys for (let i = 0; i < 123; ++i) { values[i] = 64; } // fill with placeholder('=') index for (let i = 0; i < 64; ++i) { values[BASE64_KEYS.charCodeAt(i)] = i; } // decoded value indexed by base64 char code const BASE64_VALUES = values; const HexChars = '0123456789abcdef'.split(''); const _t = ['', '', '', '']; const UuidTemplate = _t.concat(_t, '-', _t, '-', _t, '-', _t, '-', _t, _t, _t); const Indices = UuidTemplate.map((x, i) => x === '-' ? NaN : i).filter(isFinite); let HexMap = {} { for (let i = 0; i < HexChars.length; i++) { let char = HexChars[i] HexMap[char] = i } } module.exports = { load() { this.init(); }, unload() { // Editor.log("卸載執行"); }, /** 初始化 */ init() { // this.createDirectory(); }, /** 創建Spine節點 */ uuidconvert(...args) { let self = this; try { let needconvertuuid = args[0]; let uuid; let long_uuid; let short_uuid; if (needconvertuuid.indexOf("-") === -1) { // let convertuuid = this.decodeUuid(needconvertuuid); let convertuuid = EditorAPI.decompressUuid(needconvertuuid); uuid = convertuuid; short_uuid = needconvertuuid; long_uuid = convertuuid; } else { // let convertuuid = this.compressUuid(needconvertuuid); let convertuuid = EditorAPI.compressUuid(needconvertuuid); uuid = needconvertuuid; short_uuid = convertuuid; long_uuid = needconvertuuid; } Editor.log('short uuid', short_uuid); Editor.log('long uuid', long_uuid); Editor.Ipc.sendToAll('assets:hint', uuid); Editor.log('path: ', Editor.assetdb.uuidToUrl(uuid)); } catch (error) { Editor.log(`uuidconvert error: ${error}`); } }, messages: { /** 打開面板 */ "open-panel"() { Editor.Panel.open("uuidconvert"); }, /** 保存按鈕點擊 */ "run-click"(event, ...args) { this.uuidconvert(...args); }, // /** 面板加載完成 */ // "panel-load-finish"(evnet, ...args) { // Editor.Scene.callSceneScript("uuidconvert", "get-default-info", { args: args }, function (err, response) { // // Editor.log("callSceneScript: " + response); // Editor.Ipc.sendToPanel("uuidconvert", "setDefault", response); // }); // }, }, }