From d2f2b8ce39091e43fcaa9dd0470707cb6cd749c6 Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Sun, 5 Jan 2020 10:46:45 +0800 Subject: [PATCH 1/8] calValue for reason --- project/functions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/project/functions.js b/project/functions.js index e094e708..24f49199 100644 --- a/project/functions.js +++ b/project/functions.js @@ -93,6 +93,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.deleteAllCanvas(); // 删除所有创建的画布 core.dom.gif2.innerHTML = ""; } + reason = core.calValue(reason); core.drawText([ "\t[" + (reason || "恭喜通关") + "]你的分数是${status:hp}。" ], function () { From 99a247a29cece6db04329a8c617ce28633bfe8ed Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Tue, 21 Jan 2020 22:37:34 +0800 Subject: [PATCH 2/8] fix loader.js --- libs/loader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/loader.js b/libs/loader.js index 5231f8d8..57421549 100644 --- a/libs/loader.js +++ b/libs/loader.js @@ -52,7 +52,7 @@ loader.prototype._loadIcons = function () { loader.prototype._loadMaterialImages = function (callback) { this._setStartLoadTipText("正在加载资源文件..."); if (main.useCompress) { - this.loadImagesFromZip('project/images/materials.zip', core.materials, core.material.images, callback); + this.loadImagesFromZip('project/images/materials.h5data', core.materials, core.material.images, callback); } else { this.loadImages(core.materials, core.material.images, callback); } @@ -67,7 +67,7 @@ loader.prototype._loadExtraImages = function (callback) { this._setStartLoadTipText("正在加载图片文件..."); if (main.useCompress) { - this.loadImagesFromZip('project/images/images.zip', images, core.material.images.images, callback); + this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, callback); } else { this.loadImages(images, core.material.images.images, callback); } @@ -90,7 +90,7 @@ loader.prototype._loadAutotiles = function (callback) { } this._setStartLoadTipText("正在加载自动元件..."); if (main.useCompress) { - this.loadImagesFromZip('project/images/autotiles.zip', keys, autotiles, _callback); + this.loadImagesFromZip('project/images/autotiles.h5data', keys, autotiles, _callback); } else { this.loadImages(keys, autotiles, _callback); } @@ -114,7 +114,7 @@ loader.prototype._loadTilesets = function (callback) { } this._setStartLoadTipText("正在加载额外素材..."); if (main.useCompress) { - this.loadImagesFromZip('project/images/tilesets.zip', core.tilesets, core.material.images.tilesets, _callback); + this.loadImagesFromZip('project/images/tilesets.h5data', core.tilesets, core.material.images.tilesets, _callback); } else { this.loadImages(core.tilesets, core.material.images.tilesets, _callback); } @@ -199,7 +199,7 @@ loader.prototype.loadImage = function (imgName, callback) { loader.prototype._loadAnimates = function () { this._setStartLoadTipText("正在加载动画文件..."); if (main.useCompress) { - core.unzip('project/animates/animates.zip?v=' + main.version, function (animates) { + core.unzip('project/animates/animates.h5data?v=' + main.version, function (animates) { for (var name in animates) { if (name.endsWith(".animate")) { var t = name.substring(0, name.length - 8); @@ -276,7 +276,7 @@ loader.prototype._loadMusic = function () { this._setStartLoadTipText("正在加载音效文件..."); if (main.useCompress && core.musicStatus.audioContext) { - core.unzip('project/sounds/sounds.zip?v=' + main.version, function (data) { + core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) { for (var name in data) { if (core.sounds.indexOf(name) >= 0) { core.loader._loadOneSound_decodeData(name, data[name]); From 4e648a0537dfa81d2539166a1e0fcc7fcf205a23 Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Tue, 21 Jan 2020 22:39:39 +0800 Subject: [PATCH 3/8] fix zip --- libs/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils.js b/libs/utils.js index ad66b4d3..15cbc37d 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -1179,7 +1179,7 @@ utils.prototype.unzip = function (blobOrUrl, success, error, convertToText, onpr if (typeof blobOrUrl == 'string') { return core.http('GET', blobOrUrl, null, function (data) { core.unzip(data, success, error, convertToText); - }, _error, 'application/zip', 'blob', onprogress); + }, _error, null, 'blob', onprogress); } if (!(blobOrUrl instanceof Blob)) { From 918140f67ca16ff1e750bfb7af478096ff6c84d0 Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Wed, 22 Jan 2020 09:36:16 +0800 Subject: [PATCH 4/8] config.json --- _server/config.json | 1 + _server/editor.js | 38 ++++++++++++++++++--------------- _server/editor_blockly.js | 4 ++-- _server/editor_config.js | 34 +++++++++++++++++++++++++++++ _server/editor_listen.js | 2 +- _server/editor_mappanel.js | 6 +++--- _server/editor_materialpanel.js | 12 ++++++----- _server/editor_ui.js | 2 +- editor-mobile.html | 1 + editor.html | 1 + 10 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 _server/config.json create mode 100644 _server/editor_config.js diff --git a/_server/config.json b/_server/config.json new file mode 100644 index 00000000..8ef9802a --- /dev/null +++ b/_server/config.json @@ -0,0 +1 @@ +{"lastUsed":[],"foldPerCol":50,"folded":false} \ No newline at end of file diff --git a/_server/editor.js b/_server/editor.js index 8cec0a7d..7ddc0f60 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -151,17 +151,20 @@ editor.prototype.init = function (callback) { editor.airwallImg.src = './project/images/airwall.png'; main.init('editor', function () { - editor_util_wrapper(editor); - editor_game_wrapper(editor, main, core); - editor_file_wrapper(editor); - editor_table_wrapper(editor); - editor_ui_wrapper(editor); - editor_mappanel_wrapper(editor); - editor_datapanel_wrapper(editor); - editor_materialpanel_wrapper(editor); - editor_listen_wrapper(editor); - editor.printe=printe; - afterMainInit(); + editor.config = new editor_config(); + editor.config.load(function() { + editor_util_wrapper(editor); + editor_game_wrapper(editor, main, core); + editor_file_wrapper(editor); + editor_table_wrapper(editor); + editor_ui_wrapper(editor); + editor_mappanel_wrapper(editor); + editor_datapanel_wrapper(editor); + editor_materialpanel_wrapper(editor); + editor_listen_wrapper(editor); + editor.printe=printe; + afterMainInit(); + }) }); var afterMainInit = function () { @@ -174,7 +177,7 @@ editor.prototype.init = function (callback) { editor_mode = editor_mode(editor); editor.mode = editor_mode; core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps)); - var lastFloorId = core.getLocalStorage('editorLastFloorId', core.status.floorId); + var lastFloorId = editor.config.get('editorLastFloorId', core.status.floorId); if (core.floorIds.indexOf(lastFloorId) < 0) lastFloorId = core.status.floorId; core.changeFloor(lastFloorId, null, core.firstData.hero.loc, null, function () { afterCoreReset(); @@ -274,8 +277,9 @@ editor.prototype.changeFloor = function (floorId, callback) { var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0; editor.setViewport(x, y); - core.setLocalStorage('editorLastFloorId', floorId); - if (callback) callback(); + editor.config.set('editorLastFloorId', floorId, function() { + if (callback) callback(); + }); }); } @@ -448,11 +452,11 @@ editor.prototype.drawInitData = function (icons) { var maxHeight = 700; var sumWidth = 0; editor.widthsX = {}; - editor.uivalues.folded = core.getLocalStorage('folded', false); + editor.uivalues.folded = editor.config.get('folded', false); // editor.uivalues.folded = true; - editor.uivalues.foldPerCol = core.getLocalStorage('foldPerCol', 50); + editor.uivalues.foldPerCol = editor.config.get('foldPerCol', 50); // var imgNames = Object.keys(images); //还是固定顺序吧; - editor.uivalues.lastUsed = core.getLocalStorage("lastUsed", []); + editor.uivalues.lastUsed = editor.config.get("lastUsed", []); var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"]; for (var ii = 0; ii < imgNames.length; ii++) { diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 090ba314..aa221608 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -492,13 +492,13 @@ function omitedcheckUpdateFunction(event) { `; /////////////////initscript end ///////////////////////////// - editor.uivalues.disableBlocklyReplace = core.getLocalStorage("disableBlocklyReplace", false); + editor.uivalues.disableBlocklyReplace = editor.config.get("disableBlocklyReplace", false); var replaceCheckbox = document.getElementById('blocklyReplace'); replaceCheckbox.checked = !editor.uivalues.disableBlocklyReplace; editor_blockly.triggerReplace = function () { editor.uivalues.disableBlocklyReplace = !replaceCheckbox.checked; - core.setLocalStorage("disableBlocklyReplace", !replaceCheckbox.checked); + editor.config.set("disableBlocklyReplace", !replaceCheckbox.checked); if (MotaActionFunctions) MotaActionFunctions.disableReplace = !replaceCheckbox.checked; alert("已" + (replaceCheckbox.checked ? "开启" : "关闭") + "中文变量名替换!\n关闭并重开事件编辑器以生效。"); } diff --git a/_server/editor_config.js b/_server/editor_config.js new file mode 100644 index 00000000..016b316c --- /dev/null +++ b/_server/editor_config.js @@ -0,0 +1,34 @@ +function editor_config() { + this.address = "_server/config.json"; +} + +editor_config.prototype.load = function(callback) { + var _this = this; + fs.readFile(this.address, "utf-8", function(e, d) { + if (e) { + console.warn("无法读取配置文件, 已重新生成"); + _this.config = {}; + _this.save(callback); + } else { + _this.config = JSON.parse(d); + if (callback) callback(); + } + }); +} + +editor_config.prototype.get = function(key, defaultValue) { + value = this.config[key]; + return value != null ? value : defaultValue; +} + +editor_config.prototype.set = function(key, value, callback) { + this.config[key] = value; + if (callback !== false) this.save(callback); +} + +editor_config.prototype.save = function(callback) { + fs.writeFile(this.address, JSON.stringify(this.config) ,'utf-8', function(e) { + if (e) alert("写入配置文件失败"); + if (callback instanceof Function) callback(); + }) +} diff --git a/_server/editor_listen.js b/_server/editor_listen.js index 970111b7..31825aa5 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -15,7 +15,7 @@ editor_listen_wrapper = function (editor) { editor.dom.mid.onmousewheel = editor.uifunctions.map_mousewheel - editor.uivalues.shortcut = core.getLocalStorage('shortcut', { 48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0 }); + editor.uivalues.shortcut = editor.config.get('shortcut', { 48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0 }); editor.dom.body.onkeydown = editor.uifunctions.body_shortcut editor.uivalues.scrollBarHeight = editor.uifunctions.getScrollBarHeight(); diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index d4546c44..9068eff9 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -253,7 +253,7 @@ editor_mappanel_wrapper = function (editor) { // console.log(editor.map); if (editor.info.y != null) { editor.uivalues.lastUsed = [editor.info].concat(editor.uivalues.lastUsed.filter(function (e) { return e.id != editor.info.id})); - core.setLocalStorage("lastUsed", editor.uivalues.lastUsed); + editor.config.set("lastUsed", editor.uivalues.lastUsed); } editor.updateMap(); editor.uivalues.holdingPath = 0; @@ -601,9 +601,9 @@ editor_mappanel_wrapper = function (editor) { * 切换画笔模式 */ editor.uifunctions.brushMod3_onchange = function () { - if (!core.getLocalStorage('alertTileMode') && + if (!editor.config.get('alertTileMode') && !confirm("从V2.6.6开始,tileset贴图模式已被废弃。\n请右键额外素材,并输入所需要绘制的宽高,然后单击地图以绘制一个区域。\n\n点取消将不再显示此提示。")) { - core.setLocalStorage('alertTileMode', true); + editor.config.set('alertTileMode', true); } // tip.showHelp(5) tip.isSelectedBlock(false) diff --git a/_server/editor_materialpanel.js b/_server/editor_materialpanel.js index 6b81cf1e..ea7dcced 100644 --- a/_server/editor_materialpanel.js +++ b/_server/editor_materialpanel.js @@ -31,15 +31,17 @@ editor_materialpanel_wrapper = function (editor) { editor.uifunctions.fold_material_click = function () { if (editor.uivalues.folded) { if (confirm("你想要展开素材吗?\n展开模式下将显示全素材内容。")) { - core.setLocalStorage('folded', false); - window.location.reload(); + editor.config.set('folded', false, function() { + window.location.reload(); + }); } } else { var perCol = parseInt(prompt("请输入折叠素材模式下每列的个数:", "50")) || 0; if (perCol > 0) { - core.setLocalStorage('foldPerCol', perCol); - core.setLocalStorage('folded', true); - window.location.reload(); + editor.config.set('foldPerCol', perCol, false); + editor.config.set('folded', false, function() { + window.location.reload(); + }); } } } diff --git a/_server/editor_ui.js b/_server/editor_ui.js index cadd3b2f..4a5e4386 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -219,7 +219,7 @@ editor_ui_wrapper = function (editor) { if (infoToSave == JSON.stringify({})) return; editor.uivalues.shortcut[e.keyCode] = JSON.parse(infoToSave); printf('已保存该快捷图块, 数字键 ' + (e.keyCode - 48) + ' 使用.') - core.setLocalStorage('shortcut', editor.uivalues.shortcut); + editor.config.set('shortcut', editor.uivalues.shortcut); return; } //ctrl + 0~9 切换到快捷图块 diff --git a/editor-mobile.html b/editor-mobile.html index 6946dedf..45fe1dce 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -584,6 +584,7 @@ + diff --git a/editor.html b/editor.html index 95ab78f7..0e26d46f 100644 --- a/editor.html +++ b/editor.html @@ -568,6 +568,7 @@ + From 2edb933e659a6780bc8206cf0da450e2cf8c4b03 Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Wed, 22 Jan 2020 09:38:52 +0800 Subject: [PATCH 5/8] fix reason --- project/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/functions.js b/project/functions.js index 0a106929..c93f4dd3 100644 --- a/project/functions.js +++ b/project/functions.js @@ -93,7 +93,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.deleteAllCanvas(); // 删除所有创建的画布 core.dom.gif2.innerHTML = ""; } - reason = core.calValue(reason); + reason = core.replaceText(reason); core.drawText([ "\t[" + (reason || "恭喜通关") + "]你的分数是${status:hp}。" ], function () { From 4ef8c59c7cfbbfafbad206954f0f2c52badce2ae Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Wed, 22 Jan 2020 09:45:01 +0800 Subject: [PATCH 6/8] complete config.json --- _server/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_server/config.json b/_server/config.json index 8ef9802a..e535834e 100644 --- a/_server/config.json +++ b/_server/config.json @@ -1 +1 @@ -{"lastUsed":[],"foldPerCol":50,"folded":false} \ No newline at end of file +{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0},"alertTileMode":true} \ No newline at end of file From 7ff1ac3b1b0bf90d2bf0ba6d4b3d4649f366c37c Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Wed, 22 Jan 2020 09:46:04 +0800 Subject: [PATCH 7/8] delete alertTiled --- _server/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_server/config.json b/_server/config.json index e535834e..9c9888dc 100644 --- a/_server/config.json +++ b/_server/config.json @@ -1 +1 @@ -{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0},"alertTileMode":true} \ No newline at end of file +{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}} \ No newline at end of file From 95c0dce37b6e8c7a25f1bc9308e8d359a4faf2f4 Mon Sep 17 00:00:00 2001 From: tocque <364004564@qq.com> Date: Thu, 23 Jan 2020 10:14:22 +0800 Subject: [PATCH 8/8] fix config --- _server/config.json | 2 +- _server/editor_materialpanel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_server/config.json b/_server/config.json index 9c9888dc..fe6a45a9 100644 --- a/_server/config.json +++ b/_server/config.json @@ -1 +1 @@ -{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}} \ No newline at end of file +{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":null,"disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}} \ No newline at end of file diff --git a/_server/editor_materialpanel.js b/_server/editor_materialpanel.js index ea7dcced..ca3713fb 100644 --- a/_server/editor_materialpanel.js +++ b/_server/editor_materialpanel.js @@ -39,7 +39,7 @@ editor_materialpanel_wrapper = function (editor) { var perCol = parseInt(prompt("请输入折叠素材模式下每列的个数:", "50")) || 0; if (perCol > 0) { editor.config.set('foldPerCol', perCol, false); - editor.config.set('folded', false, function() { + editor.config.set('folded', true, function() { window.location.reload(); }); }