/* * @Author: CGT (caogtaa@gmail.com) * @Date: 2020-01-16 22:09:21 * @Last Modified by: CGT (caogtaa@gmail.com) * @Last Modified time: 2020-01-16 23:45:39 */ 'use strict'; let _config = {}; Editor.Panel.extend({ // css style for panel style: ` :host { margin: 5px; } :host ui-input { width: 100%; } h2 { color: #f90; } ul { list-style-type: none; padding-inline-start: 20px; } ul.root { padding-inline-start: 15px; } ul li { padding: 2px 10px 1px 0; text-align: -webkit-match-parent; color: #ccc; border-bottom: 1px solid #454545; box-sizing: border-box; } span.selected { background: #555; } .caret { cursor: pointer; user-select: none; width: 12px; display: inline-block; } .caret-holder { width: 12px; display: inline-block; } .caret::before { content: "\\25B6"; color: #ccc; display: inline-block; margin-right: 6px; } .caret-down::before { transform: rotate(90deg); } .nested { display: none; } .collapsed { } .active:not(.collapsed) { display: block; } `, // html template for panel template: `

先选择游戏类型,再选择学期-课程-关卡

导入关卡 导出关卡 保存关卡 导入背景动画 保存背景动画

导入引导 导出引导 保存引导 播放引导 暂停引导 重置引导 单独播放
导入讲解 导出讲解 保存讲解
`, // element and variable binding $: {}, // method executed when template and styles are successfully loaded and initialized ready() { const fs = require('fs'); let temp = Editor.Project.path + '/temp/temp_game_edit_config.json'; let configPath = temp; if (!fs.existsSync(temp)) { // read default config configPath = Editor.url('packages://cc-ext-scene-menu/temp_game_edit_config.json'); } let saveConfig = () => { let data = JSON.stringify(_config, null, 4); fs.writeFile(temp, data, function (err) { if (err) { Editor.log('保存当前导出记录失败:' + err); return; } }); }; let initWindow = (config) => { _config = config; _config.guidePage = 1 new window.Vue({ el: this.shadowRoot, data: { d: { config: _config, loaded: true, } }, methods: { onImportConfirm(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'importGame', _config, (err) => { if (err) Editor.error(err); }); }, onOutConfirm(e) { saveConfig(); Editor.Scene.callSceneScript('cc-ext-scene-menu', 'outGameJson', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onSaveGameConfirm(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'saveGameJson', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onWordChange(e) { e.target.parentElement.getElementsByTagName("ui-prop")[0].name = _config.word ? _config.word.charCodeAt() : '' }, onInBgAni(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'inBgAni', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onOutBgAni(e) { saveConfig(); Editor.Scene.callSceneScript('cc-ext-scene-menu', 'outBgAni', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onTypeChange(e) { Editor.log(`导入关卡选择的版本: ${_config.gameType}`) }, onSemeIDChange(e) { Editor.log(`导入关卡选择的学期: ${_config.semeID}`) }, onModeIDChange(e) { Editor.log(`导入关卡选择的模板: ${_config.modeID}`) }, onGuideImport(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'guideImport', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onGuideOut(e) { saveConfig(); Editor.Scene.callSceneScript('cc-ext-scene-menu', 'guideOut', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onSaveGuide(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'savaGuide', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onPlayGuide(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'playGuide', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onPauseGuide(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'pauseGuide', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onResetGuide(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'resetGuide', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onGuidePageChange(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'guidePageChange', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onPlayNodeGuide(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'playNodeGuide', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onTeacherImport(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'teacherImport', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onTeacherOut(e) { saveConfig(); Editor.Scene.callSceneScript('cc-ext-scene-menu', 'teacherOut', _config, (err) => { if (err) Editor.error(err); }, 20000); }, onTeacherSave(e) { Editor.Scene.callSceneScript('cc-ext-scene-menu', 'savaTeacher', _config, (err) => { if (err) Editor.error(err); }, 20000); }, } }); }; fs.readFile(configPath, function (err, data) { if (err) { // file not exists initWindow([]); return; } let config = []; try { config = JSON.parse(data); // Editor.log(`index.js read data: ${data}`); } catch (err) { } finally { initWindow(config); } }); }, // register your ipc messages here messages: {} });