diff --git a/API列表.txt b/API列表.txt index 4ed96670..167b2ad0 100644 --- a/API列表.txt +++ b/API列表.txt @@ -2084,7 +2084,7 @@ num如果设置大于0,则生成一个[0, num-1]之间的数;否则生成一 即先生成一个真随机数,根据该数来推进伪随机的种子,这样就可以放心调用core.rand()啦。 -core.readFile(success, error) +core.readFile(success, error, accept) 读取一个本地文件内容。success和error分别为读取成功或失败的回调函数。 iOS平台暂不支持读取文件操作。 diff --git a/_docs/api.md b/_docs/api.md index af6bc655..63eaa3d4 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -2102,8 +2102,9 @@ num如果设置大于0,则生成一个[0, num-1]之间的数;否则生成一 即先生成一个真随机数,根据该数来推进伪随机的种子,这样就可以放心调用core.rand()啦。 -core.readFile(success, error) +core.readFile(success, error, accept) 读取一个本地文件内容。success和error分别为读取成功或失败的回调函数。 +accept如果设置则控制能选择的文件类型。 iOS平台暂不支持读取文件操作。 diff --git a/_docs/start.md b/_docs/start.md index ced7faa1..8db27c1c 100644 --- a/_docs/start.md +++ b/_docs/start.md @@ -235,7 +235,7 @@ HTML5的塔都是可以进行控制台调试的。 ## 编辑器的基本操作 -- **Alt+0~9, Ctrl+0~9** 保存和读取当前选中图块 +- **Alt+0~9, 0~9** 保存和读取当前选中图块 - **W/A/S/D** 移动大地图 - **Ctrl+Z** 撤销上次绘图 - **Ctrl+Y** 重做上次绘图 diff --git a/_server/editor_datapanel.js b/_server/editor_datapanel.js index 5e1baa46..08678104 100644 --- a/_server/editor_datapanel.js +++ b/_server/editor_datapanel.js @@ -511,7 +511,7 @@ editor_datapanel_wrapper = function (editor) { editor.dom.selectAppend.onchange(); }); }); - }, null, 'img'); + }, null, 'image/*', 'img'); return; } diff --git a/_server/editor_game.js b/_server/editor_game.js index 27c51001..4690f17c 100644 --- a/_server/editor_game.js +++ b/_server/editor_game.js @@ -115,10 +115,12 @@ editor_game_wrapper = function (editor, main, core) { var img = core.material.images.tilesets[imgName]; var width = Math.floor(img.width / 32), height = Math.floor(img.height / 32); if (img.width % 32 || img.height % 32) { - alert(imgName + '的长或宽不是32的整数倍, 请修改后刷新页面'); + // alert(imgName + '的长或宽不是32的整数倍, 请修改后刷新页面'); + console.warn(imgName + '的长或宽不是32的整数倍, 请修改后刷新页面'); } if (img.width * img.height > 32 * 32 * 3000) { - alert(imgName + '上的图块数量超过了3000,请修改后刷新页面'); + // alert(imgName + '上的图块数量超过了3000,请修改后刷新页面'); + console.warn(imgName + '上的图块数量超过了3000,请修改后刷新页面'); } for (var id = startOffset; id < startOffset + width * height; id++) { var x = (id - startOffset) % width, y = parseInt((id - startOffset) / width); diff --git a/_server/editor_legacy.js b/_server/editor_legacy.js index 1313ebbc..7242553c 100644 --- a/_server/editor_legacy.js +++ b/_server/editor_legacy.js @@ -217,7 +217,8 @@ tip.showHelp = function(value) { 'ESC或点击空白处可以自动保存当前修改', 'H键可以打开操作帮助哦', 'tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域', - '可以拖动地图上的图块和事件,或按Ctrl+C, Ctrl+X和Ctrl+V进行复制,剪切和粘贴,Delete删除' + '可以拖动地图上的图块和事件,或按Ctrl+C, Ctrl+X和Ctrl+V进行复制,剪切和粘贴,Delete删除', + 'Alt+数字键保存图块,数字键读取保存的图块', ]; if (value == null) value = Math.floor(Math.random() * tips.length); printf('tips: ' + tips[value]) diff --git a/_server/editor_ui.js b/_server/editor_ui.js index 589b19d0..a82601e3 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -111,11 +111,6 @@ editor_ui_wrapper = function (editor) { if (editor_multi.id != "" || editor_blockly.id != "") return; - // 禁止快捷键的默认行为 - if (e.ctrlKey && [89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) - e.preventDefault(); - if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) - e.preventDefault(); //Ctrl+z 撤销上一步undo if (e.keyCode == 90 && e.ctrlKey && editor.uivalues.preMapData && editor.uivalues.currDrawData.pos.length && selectBox.isSelected()) { editor.map = JSON.parse(JSON.stringify(editor.uivalues.preMapData.map)); @@ -153,22 +148,10 @@ editor_ui_wrapper = function (editor) { } return; } - //ctrl + 0~9 切换到快捷图块 - if (e.ctrlKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) { - editor.setSelectBoxFromInfo(JSON.parse(JSON.stringify(editor.uivalues.shortcut[e.keyCode] || 0))); - return; - } - //alt + 0~9 改变快捷图块 - if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) { - var infoToSave = JSON.stringify(editor.info || 0); - if (infoToSave == JSON.stringify({})) return; - editor.uivalues.shortcut[e.keyCode] = JSON.parse(infoToSave); - printf('已保存该快捷图块, ctrl + ' + (e.keyCode - 48) + ' 使用.') - core.setLocalStorage('shortcut', editor.uivalues.shortcut); - return; - } + var focusElement = document.activeElement; - if (!focusElement || focusElement.tagName.toLowerCase() == 'body') { + if (!focusElement || focusElement.tagName.toLowerCase() == 'body' + || focusElement.id == 'selectFloor') { // Ctrl+C, Ctrl+X, Ctrl+V if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { e.preventDefault(); @@ -223,6 +206,20 @@ editor_ui_wrapper = function (editor) { editor.info = {}; return; } + //alt + 0~9 改变快捷图块 + if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) { + var infoToSave = JSON.stringify(editor.info || 0); + if (infoToSave == JSON.stringify({})) return; + editor.uivalues.shortcut[e.keyCode] = JSON.parse(infoToSave); + printf('已保存该快捷图块, 数字键 ' + (e.keyCode - 48) + ' 使用.') + core.setLocalStorage('shortcut', editor.uivalues.shortcut); + return; + } + //ctrl + 0~9 切换到快捷图块 + if ([48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) { + editor.setSelectBoxFromInfo(JSON.parse(JSON.stringify(editor.uivalues.shortcut[e.keyCode] || 0))); + return; + } switch (e.keyCode) { // WASD case 87: editor.moveViewport(0, -1); break; @@ -256,7 +253,7 @@ editor_ui_wrapper = function (editor) { "双击地图:选中对应点的素材\n" + "右键地图:弹出菜单栏\n" + "Alt+0~9:保存当前使用的图块\n" + - "Ctrl+0~9:选中保存的图块\n" + + "0~9:选中保存的图块\n" + "Ctrl+Z / Ctrl+Y:撤销/重做上次绘制\n" + "Ctrl+S:事件与脚本编辑器的保存并退出\n" + "双击事件编辑器:长文本编辑/脚本编辑/地图选点/UI绘制预览" diff --git a/libs/actions.js b/libs/actions.js index 7caba11d..1a8597dd 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -2103,7 +2103,7 @@ actions.prototype._clickSyncSave_readFile = function () { if (obj.version != core.firstData.version) return alert("游戏版本不一致!"); if (!obj.data) return alert("无效的存档!"); core.control._syncLoad_write(obj.data); - }); + }, null, ".h5save"); } actions.prototype._clickSyncSave_replay = function () { diff --git a/libs/control.js b/libs/control.js index 6f0a3854..5f7b5e6b 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1122,7 +1122,7 @@ control.prototype.chooseReplayFile = function () { return; } _replay(); - }); + }, null, ".h5route"); } ////// 开始播放 ////// diff --git a/libs/ui.js b/libs/ui.js index 5491449f..a1b88121 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -459,7 +459,7 @@ ui.prototype.clearUI = function () { ////// 左上角绘制一段提示 ////// ui.prototype.drawTip = function (text, id, clear) { - if (clear) this.clearTip(); + this.clearTip(); var one = { text: text, textX: 21, diff --git a/libs/utils.js b/libs/utils.js index dd46d468..67ada600 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -761,7 +761,7 @@ utils.prototype.__next_rand = function (_rand) { } ////// 读取一个本地文件内容 ////// -utils.prototype.readFile = function (success, error, readType) { +utils.prototype.readFile = function (success, error, accept, readType) { core.platform.successCallback = success; core.platform.errorCallback = error; @@ -800,6 +800,7 @@ utils.prototype.readFile = function (success, error, readType) { else core.platform.fileReader.readAsDataURL(core.platform.fileInput.files[0]); core.platform.fileInput.value = ''; } + if (accept) core.platform.fileInput.accept = accept; } core.platform.fileInput.click();