From bb28ba72b97010e00016e3e45875ae436e289a36 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 7 Jul 2019 09:49:33 +0800 Subject: [PATCH 01/11] extendKeyBoard --- API列表.txt | 1 - _docs/api.md | 1 - libs/actions.js | 9 --------- libs/control.js | 2 +- libs/core.js | 2 -- libs/ui.js | 1 - main.js | 2 +- 7 files changed, 2 insertions(+), 16 deletions(-) diff --git a/API列表.txt b/API列表.txt index 9c8b2129..52e1a2b0 100644 --- a/API列表.txt +++ b/API列表.txt @@ -56,7 +56,6 @@ core.platform.isPC (是否是电脑端) core.platform.isAndroid (是否是安卓端) core.platform.isIOS (是否是iOS端) core.platform.useLocalForage (是否开启了新版存档) -core.platform.extendKeyBoard (是否开启了拓展键盘) core.domStyle diff --git a/_docs/api.md b/_docs/api.md index 5bcbe0ed..980c3b3a 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -57,7 +57,6 @@ core.platform.isPC (是否是电脑端) core.platform.isAndroid (是否是安卓端) core.platform.isIOS (是否是iOS端) core.platform.useLocalForage (是否开启了新版存档) -core.platform.extendKeyBoard (是否开启了拓展键盘) core.domStyle diff --git a/libs/actions.js b/libs/actions.js index 51eefbab..09b44ce2 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1934,8 +1934,6 @@ actions.prototype._clickSwitchs = function (x, y) { case 7: return this._clickSwitchs_clickMove(); case 8: - return this._clickSwitchs_ExtendKeyboard(); - case 9: core.status.event.selection = 0; core.ui.drawSettings(); break; @@ -2000,13 +1998,6 @@ actions.prototype._clickSwitchs_clickMove = function () { core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_ExtendKeyboard = function () { - core.platform.extendKeyboard = !core.platform.extendKeyboard; - core.setLocalStorage('extendKeyboard', core.platform.extendKeyboard); - core.updateStatusBar(); - core.ui.drawSwitchs(); -} - ////// 系统设置界面时,放开某个键的操作 ////// actions.prototype._keyUpSwitchs = function (keycode) { if (keycode == 27 || keycode == 88) { diff --git a/libs/control.js b/libs/control.js index 50d25713..8c672646 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2465,7 +2465,7 @@ control.prototype.setToolbarButton = function (useButton) { } if (useButton == null) useButton = core.domStyle.toolbarBtn; - if (!core.domStyle.isVertical || !core.platform.extendKeyboard) useButton = false; + if (!core.domStyle.isVertical) useButton = false; core.domStyle.toolbarBtn = useButton; if (useButton) { diff --git a/libs/core.js b/libs/core.js index be98ccfe..6cbe83cf 100644 --- a/libs/core.js +++ b/libs/core.js @@ -72,7 +72,6 @@ function core() { 'isChrome': false, // 是否是Chrome 'supportCopy': false, // 是否支持复制到剪切板 'useLocalForage': true, - 'extendKeyboard': false, 'fileInput': null, // FileInput 'fileReader': null, // 是否支持FileReader @@ -285,7 +284,6 @@ core.prototype._init_platform = function () { core.platform.isQQ = /QQ/i.test(navigator.userAgent); core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent); this._init_checkLocalForage(); - core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false); if (window.FileReader) { core.platform.fileReader = new FileReader(); core.platform.fileReader.onload = function () { diff --git a/libs/ui.js b/libs/ui.js index 2050669b..e4e79e7d 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1507,7 +1507,6 @@ ui.prototype.drawSwitchs = function() { "领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), "新版存档: "+(core.platform.useLocalForage ? "[ON]":"[OFF]"), "单击瞬移: "+(!core.hasFlag("__noClickMove__") ? "[ON]":"[OFF]"), - "拓展键盘: "+(core.platform.extendKeyboard ? "[ON]":"[OFF]"), "返回主菜单" ]; this.drawChoices(null, choices); diff --git a/main.js b/main.js index e19c4143..fff02c79 100644 --- a/main.js +++ b/main.js @@ -642,7 +642,7 @@ main.statusBar.image.settings.onclick = function (e) { } ////// 点击工具栏时 ////// -main.dom.toolBar.onclick = function () { +main.dom.hard.onclick = function () { if (core.isReplaying()) return; main.core.control.setToolbarButton(!core.domStyle.toolbarBtn); From 0b5de8ccb106bfade19d6af977ee76565cba46b5 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 9 Jul 2019 12:52:40 +0800 Subject: [PATCH 02/11] css onChoice animate --- libs/control.js | 2 +- libs/ui.js | 2 -- main.js | 23 +++++++++++++++++++++-- styles.css | 25 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/libs/control.js b/libs/control.js index 8c672646..294a2adf 100644 --- a/libs/control.js +++ b/libs/control.js @@ -19,7 +19,7 @@ control.prototype._init = function () { this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime); this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave); this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate); - this.registerAnimationFrame("selector", false, this._animationFrame_selector); + //this.registerAnimationFrame("selector", false, this._animationFrame_selector); this.registerAnimationFrame("animate", true, this._animationFrame_animate); this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving); this.registerAnimationFrame("weather", true, this._animationFrame_weather); diff --git a/libs/ui.js b/libs/ui.js index e4e79e7d..7391eea5 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -640,7 +640,6 @@ ui.prototype._getPosition = function (content) { ui.prototype.drawWindowSelector = function(background, x, y, w, h) { w = Math.round(w), h = Math.round(h); var ctx = core.ui.createCanvas("_selector", x, y, w, h, 165); - ctx.canvas.style.opacity = 0.8; this._drawSelector(ctx, background, w, h); } @@ -662,7 +661,6 @@ ui.prototype._uievent_drawSelector = function (data) { var z = 136; if (core.dymCanvas.uievent) z = (parseInt(core.dymCanvas.uievent.canvas.style.zIndex) || 135) + 1; var ctx = core.createCanvas('_uievent_selector', x, y, w, h, z); - ctx.canvas.style.opacity = 0.8; this._drawSelector(ctx, background, w, h); } diff --git a/main.js b/main.js index fff02c79..32948c93 100644 --- a/main.js +++ b/main.js @@ -216,6 +216,7 @@ main.prototype.init = function (mode, callback) { })(span,value[1]); main.dom.levelChooseButtons.appendChild(span); }); + main.createOnChoiceAnimation(); main.loadJs('libs', main.loadList, function () { main.core = core; @@ -328,14 +329,32 @@ main.prototype.log = function (e) { } } +main.prototype.createOnChoiceAnimation = function () { + var borderColor = main.dom.startButtonGroup.style.caretColor || "rgb(255, 215, 0)"; + // get rgb value + var rgb = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+\s*)?\)$/.exec(borderColor); + if (rgb != null) { + var value = rgb[1] + ", " + rgb[2] + ", " + rgb[3]; + var style = document.createElement("style"); + style.type = 'text/css'; + var keyFrames = "onChoice { " + + "0% { border-color: rgba("+value+", 0.9); } " + + "50% { border-color: rgba("+value+", 0.3); } " + + "100% { border-color: rgba("+value+", 0.9); } " + + "}"; + style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames; + document.body.appendChild(style); + } +} + ////// 选项 ////// main.prototype.selectButton = function (index) { var select = function (children) { index = (index + children.length) % children.length; for (var i = 0;i < children.length; ++i) { - children[i].style.borderColor = 'transparent'; + children[i].classList.remove("onChoiceAnimate"); } - children[index].style.borderColor = main.dom.startButtonGroup.style.caretColor || '#FFD700'; + children[index].classList.add("onChoiceAnimate"); if (main.selectedButton == index) { children[index].click(); } diff --git a/styles.css b/styles.css index ccdb83cb..19d546ed 100644 --- a/styles.css +++ b/styles.css @@ -159,6 +159,11 @@ border-radius: 6px; } +.onChoiceAnimate { + animation: 2s ease-in-out 0s infinite normal none running; + animation-name: onChoice; +} + #floorMsgGroup { top: 3px; right: 3px; @@ -374,4 +379,22 @@ p#name { #inputNo { float:right; margin-right: 10%; -} \ No newline at end of file +} + +#_selector, #_uievent_selector { + animation: 2s ease-in-out 0s infinite normal none running; + animation-name: selector; +} + +@-webkit-keyframes selector { + 0% { opacity: 0.95; } + 50% { opacity: 0.55; } + 100% { opacity: 0.95; } +} + +@keyframes selector { + 0% { opacity: 0.95; } + 50% { opacity: 0.55; } + 100% { opacity: 0.95; } +} + From 9491ab92877d48e5497f0078b75967cdb423ea05 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 9 Jul 2019 16:08:44 +0800 Subject: [PATCH 03/11] drawTextBox next --- editor-mobile.html | 1 + editor.html | 1 + index.html | 1 + libs/control.js | 23 +++++------------------ libs/ui.js | 15 +++++++++++++-- main.js | 3 ++- styles.css | 34 ++++++++++++++++++++++++++++++---- 7 files changed, 53 insertions(+), 25 deletions(-) diff --git a/editor-mobile.html b/editor-mobile.html index d6ccc0ae..b8d2e0eb 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -515,6 +515,7 @@ 此浏览器不支持HTML5 +
diff --git a/libs/control.js b/libs/control.js index 294a2adf..a4aa24e4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -19,7 +19,6 @@ control.prototype._init = function () { this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime); this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave); this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate); - //this.registerAnimationFrame("selector", false, this._animationFrame_selector); this.registerAnimationFrame("animate", true, this._animationFrame_animate); this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving); this.registerAnimationFrame("weather", true, this._animationFrame_weather); @@ -151,23 +150,6 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) { core.animateFrame.globalTime = timestamp; } -control.prototype._animationFrame_selector = function (timestamp) { - if (timestamp - core.animateFrame.selectorTime <= 20) return; - var opacity = null; - if (core.dymCanvas._selector) opacity = parseFloat(core.dymCanvas._selector.canvas.style.opacity); - else if (core.dymCanvas._uievent_selector) opacity = parseFloat(core.dymCanvas._uievent_selector.canvas.style.opacity); - if (!core.isset(opacity)) return; - if (core.animateFrame.selectorUp) - opacity += 0.02; - else - opacity -= 0.02; - if (opacity > 0.95 || opacity < 0.55) - core.animateFrame.selectorUp = !core.animateFrame.selectorUp; - core.setOpacity("_selector", opacity); - core.setOpacity("_uievent_selector", opacity); - core.animateFrame.selectorTime = timestamp; -} - control.prototype._animationFrame_animate = function (timestamp) { if (timestamp - core.animateFrame.animateTime < 50 || !core.status.animateObjs || core.status.animateObjs.length == 0) return; core.clearMap('animate'); @@ -2648,6 +2630,11 @@ control.prototype._resize_canvas = function (obj) { canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px"; canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px"; } + // resize next + main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px"; + main.dom.next.style.borderBottomWidth = main.dom.next.style.borderRightWidth = 4 * core.domStyle.scale + "px"; + + } control.prototype._resize_statusBar = function (obj) { diff --git a/libs/ui.js b/libs/ui.js index 7391eea5..46738a4f 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -452,6 +452,7 @@ ui.prototype.closePanel = function () { ui.prototype.clearUI = function () { core.status.boxAnimateObjs = []; if (core.dymCanvas._selector) core.deleteCanvas("_selector"); + main.dom.next.style.display = 'none'; core.clearMap('ui'); core.setAlpha('ui', 1); } @@ -1117,10 +1118,20 @@ ui.prototype.drawTextBox = function(content, showAll) { var content_top = this._drawTextBox_drawTitleAndIcon(titleInfo, hPos, vPos, alpha); // Step 5: 绘制正文 - return this.drawTextContent('ui', content, { + var config = this.drawTextContent('ui', content, { left: hPos.content_left, top: content_top, maxWidth: hPos.validWidth, lineHeight: vPos.lineHeight, time: (showAll || textAttribute.time<=0 || core.status.event.id!='action')?0:textAttribute.time }); + + // Step 6: 绘制光标 + main.dom.next.style.display = 'block'; + main.dom.next.style.borderRightColor = main.dom.next.style.borderBottomColor = core.arrayToRGB(textAttribute.text); + main.dom.next.style.top = (vPos.bottom - 20) * core.domStyle.scale + "px"; + var left = (hPos.left + hPos.right) / 2; + if (pInfo.position == 'up' && pInfo.px != null && Math.abs(pInfo.px * 32 + 16 - left) < 50) + left = hPos.right - 64; + main.dom.next.style.left = left * core.domStyle.scale + "px"; + return config; } ui.prototype._drawTextBox_drawImages = function (content) { @@ -1168,7 +1179,7 @@ ui.prototype._drawTextBox_getHorizontalPosition = function (content, titleInfo, ui.prototype._drawTextBox_getVerticalPosition = function (content, titleInfo, posInfo, validWidth) { var textAttribute = core.status.textAttribute || core.initStatus.textAttribute; var lineHeight = textAttribute.textfont + 6; - var height = 30 + this.getTextContentHeight(content, { + var height = 45 + this.getTextContentHeight(content, { lineHeight: lineHeight, maxWidth: validWidth }); if (titleInfo.title) height += textAttribute.titlefont + 5; diff --git a/main.js b/main.js index 32948c93..1434550c 100644 --- a/main.js +++ b/main.js @@ -74,7 +74,8 @@ function main() { 'inputMessage': document.getElementById('inputMessage'), 'inputBox': document.getElementById('inputBox'), 'inputYes': document.getElementById('inputYes'), - 'inputNo': document.getElementById('inputNo') + 'inputNo': document.getElementById('inputNo'), + 'next': document.getElementById('next') }; this.mode = 'play'; this.loadList = [ diff --git a/styles.css b/styles.css index 19d546ed..3a428992 100644 --- a/styles.css +++ b/styles.css @@ -160,8 +160,7 @@ } .onChoiceAnimate { - animation: 2s ease-in-out 0s infinite normal none running; - animation-name: onChoice; + animation: onChoice 2s ease-in-out 0s infinite normal none running; } #floorMsgGroup { @@ -382,8 +381,7 @@ p#name { } #_selector, #_uievent_selector { - animation: 2s ease-in-out 0s infinite normal none running; - animation-name: selector; + animation: selector 2s ease-in-out 0s infinite normal none running; } @-webkit-keyframes selector { @@ -398,3 +396,31 @@ p#name { 100% { opacity: 0.95; } } +#next { + width: 5px; + height: 5px; + display: none; + position: absolute; + transform: rotate(45deg); + border-bottom-width: 4px; + border-bottom-style: solid; + border-right-width: 4px; + border-right-style: solid; + -webkit-animation: next .5s ease-in-out alternate infinite; + animation: next .5s ease-in-out alternate infinite; + left: 0; + top: 0; + opacity: 0.7; + z-index: 169; +} + +@-webkit-keyframes next { + 100% { + transform: rotate(45deg) translate(-3px, -3px); + } +} +@keyframes next { + 100% { + transform: rotate(45deg) translate(-3px, -3px); + } +} \ No newline at end of file From 83828e57a7f6d9b0e4b7bdc9067d3dcc405641ca Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 9 Jul 2019 16:22:57 +0800 Subject: [PATCH 04/11] drag bg/fg --- _server/editor.js | 36 ++++++++++++++++++++++++++++++++++++ _server/editor_unsorted_1.js | 5 ++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/_server/editor.js b/_server/editor.js index 033187da..cb7490a3 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -556,6 +556,42 @@ editor.prototype.exchangePos = function (startPos, endPos, callback) { }); } +editor.prototype.moveBgFg = function (startPos, endPos, name, callback) { + if (!startPos || !endPos || ["bgmap","fgmap"].indexOf(name)<0) return; + if (startPos.x == endPos.x && startPos.y == endPos.y) return; + editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x]; + editor[name][startPos.y][startPos.x] = 0; + editor.updateMap(); + editor.file.saveFloorFile(function (err) { + if (err) { + printe(err); + throw(err) + } + ;printf('移动图块成功'); + editor.drawPosSelection(); + if (callback) callback(); + }); +} + +editor.prototype.exchangeBgFg = function (startPos, endPos, name, callback) { + if (!startPos || !endPos || ["bgmap","fgmap"].indexOf(name)<0) return; + if (startPos.x == endPos.x && startPos.y == endPos.y) return; + var value = editor[name][endPos.y][endPos.x]; + editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x]; + editor[name][startPos.y][startPos.x] = value; + editor.updateMap(); + editor.file.saveFloorFile(function (err) { + if (err) { + printe(err); + throw(err) + } + ;printf('交换图块成功'); + editor.drawPosSelection(); + if (callback) callback(); + }); + +} + editor.prototype.clearPos = function (clearPos, pos, callback) { var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); pos = pos || editor.pos; diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 73955ab2..d3b4c5c0 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -209,7 +209,10 @@ editor.constructor.prototype.listen=function () { if (!selectBox.isSelected()) { //tip.whichShow(1); // editor.movePos(startPos, endPos); - editor.exchangePos(startPos, endPos); + if (editor.layerMod == 'map') + editor.exchangePos(startPos, endPos); + else + editor.exchangeBgFg(startPos, endPos, editor.layerMod); startPos = endPos = null; uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); return false; From 7de3964525a27a3e001416e23efb88cb17b4c255 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 9 Jul 2019 17:20:07 +0800 Subject: [PATCH 05/11] setBlock multiple locs --- _server/MotaAction.g4 | 60 ++++++++++++++++++++++++++++++------ _server/editor_blockly.js | 16 ++++++++-- _server/editor_unsorted_1.js | 5 ++- _server/editor_unsorted_3.js | 2 +- libs/events.js | 12 +++++--- 5 files changed, 76 insertions(+), 19 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 27bacb0f..4deab014 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -756,7 +756,7 @@ return code; */; setBlock_s - : '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline + : '转变图块为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline /* setBlock_s @@ -765,8 +765,21 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E colour : this.mapColor default : ["yellowDoor","","",""] var floorstr = ''; -if (PosString_0 && PosString_1) { - floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; +if (EvalString_1 && EvalString_2) { + var pattern1 = MotaActionFunctions.pattern.id; + if(pattern1.test(EvalString_1) || pattern1.test(EvalString_2)){ + EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1); + EvalString_2=MotaActionFunctions.PosString_pre(EvalString_2); + EvalString_1=[EvalString_1,EvalString_2] + } else { + var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; + if(!pattern2.test(EvalString_1) || !pattern2.test(EvalString_2))throw new Error('坐标格式错误,请右键点击帮助查看格式'); + EvalString_1=EvalString_1.split(','); + EvalString_2=EvalString_2.split(','); + if(EvalString_1.length!==EvalString_2.length)throw new Error('坐标格式错误,请右键点击帮助查看格式'); + for(var ii=0;ii Date: Tue, 9 Jul 2019 20:23:52 +0800 Subject: [PATCH 06/11] setViewport & moveViewport --- _server/MotaAction.g4 | 45 ++++++++++++++++++++++++++++++++++++++- _server/editor_blockly.js | 2 ++ libs/control.js | 43 +++++++++++++++++++++++++++++++++++++ libs/events.js | 17 ++++++++++++++- 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 4deab014..e7001609 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -293,6 +293,8 @@ action | changeFloor_s | changePos_0_s | changePos_1_s + | setViewport_s + | moveViewport_s | useItem_s | openShop_s | disableShop_s @@ -1241,6 +1243,38 @@ var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+async+'}, return code; */; +setViewport_s + : '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? Newline + + +/* setViewport_s +tooltip : setViewport: 设置视角 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 +default : ["",""] +colour : this.soundColor +var loc = ''; +if (PosString_0 && PosString_1) { + loc = ', "loc": ['+PosString_0+','+PosString_1+']'; +} +var code = '{"type": "setViewport"'+loc+'},\n'; +return code; +*/; + +moveViewport_s + : '移动视角' '动画时间' Int? '不等待执行完毕' Bool BGNL? StepString Newline + + +/* moveViewport_s +tooltip : moveViewport:移动视角 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=movehero%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%8B%87%E5%A3%AB +default : [300,false,"上右3下2左"] +colour : this.soundColor +Int_0 = Int_0!=='' ?(', "time": '+Int_0):''; +Bool_0 = Bool_0?', "async": true':''; +var code = '{"type": "moveViewport"'+Int_0+Bool_0+', "steps": '+JSON.stringify(StepString_0)+'},\n'; +return code; +*/; + showImage_s : '显示图片' '图片编号' Int '图片' EvalString BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline @@ -2993,6 +3027,15 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['animate_s'].xmlText([ data.name,animate_loc,data.async||false,this.next]); break; + case "setViewport": // 设置视角 + data.loc = data.loc||['','']; + this.next = MotaActionBlocks['setViewport_s'].xmlText([ + data.loc[0],data.loc[1],this.next]); + break; + case "moveViewport": // 移动视角 + this.next = MotaActionBlocks['moveViewport_s'].xmlText([ + data.time||0,data.async||false,this.StepString(data.steps),this.next]); + break; case "vibrate": // 画面震动 this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]); break; @@ -3547,7 +3590,7 @@ MotaActionFunctions.IdString_pre = function(IdString){ MotaActionFunctions.PosString_pre = function(PosString){ if (!PosString || /^-?\d+$/.test(PosString)) return PosString; - if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头'); + //if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头'); return '"'+PosString+'"'; } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 2f813293..1bdf8a76 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -150,6 +150,8 @@ editor_blockly = function () { MotaActionBlocks['waitAsync_s'].xmlText(), MotaActionBlocks['vibrate_s'].xmlText(), MotaActionBlocks['animate_s'].xmlText(), + MotaActionBlocks['setViewport_s'].xmlText(), + MotaActionBlocks['moveViewport_s'].xmlText(), MotaActionBlocks['showStatusBar_s'].xmlText(), MotaActionBlocks['hideStatusBar_s'].xmlText(), MotaActionBlocks['setCurtain_0_s'].xmlText(), diff --git a/libs/control.js b/libs/control.js index a4aa24e4..3823e105 100644 --- a/libs/control.js +++ b/libs/control.js @@ -779,6 +779,7 @@ control.prototype.drawHero = function (status, offset) { }); core.control.updateViewport(); + core.setGameCanvasTranslate('hero', 0, 0); } control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { @@ -852,6 +853,48 @@ control.prototype.updateViewport = function() { core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY); } +////// 设置视野范围 ////// +control.prototype.setViewport = function (x, y) { + core.bigmap.offsetX = core.clamp(x, 0, 32 * core.bigmap.width - core.__PIXELS__); + core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__); + this.updateViewport(); + // ------ hero层也需要! + var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__); + var hero_y = core.clamp((core.getHeroLoc('y') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.height-core.__PIXELS__); + core.control.setGameCanvasTranslate('hero', hero_x - core.bigmap.offsetX, hero_y - core.bigmap.offsetY); +} + +////// 移动视野范围 ////// +control.prototype.moveViewport = function (steps, time, callback) { + time = time || core.values.moveSpeed || 300; + var step = 0, moveSteps = (steps||[]).filter(function (t) { + return ['up','down','left','right'].indexOf(t)>=0; + }); + var animate=window.setInterval(function() { + if (moveSteps.length==0) { + delete core.animateFrame.asyncId[animate]; + clearInterval(animate); + if (callback) callback(); + } + else { + if (core.control._moveViewport_moving(++step, moveSteps)) + step = 0; + } + }, time / 16 / core.status.replay.speed); + + core.animateFrame.asyncId[animate] = true; +} + +control.prototype._moveViewport_moving = function (step, moveSteps) { + var direction = moveSteps[0], scan = core.utils.scan[direction]; + core.setViewport(core.bigmap.offsetX + 2 * scan.x, core.bigmap.offsetY + 2 * scan.y); + if (step == 16) { + moveSteps.shift(); + return true; + } + return false; +} + ////// 获得勇士面对位置的x坐标 ////// control.prototype.nextX = function(n) { if (n == null) n = 1; diff --git a/libs/events.js b/libs/events.js index bcb122cb..80f688b2 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1077,6 +1077,21 @@ events.prototype._action_animate = function (data, x, y, prefix) { this.__action_doAsyncFunc(data.async, core.drawAnimate, data.name, data.loc[0], data.loc[1]); } +events.prototype._action_setViewport = function (data, x, y, prefix) { + if (data.loc == null) { + core.drawHero(); + } + else { + var loc = this.__action_getLoc(data.loc, x, y, prefix); + core.setViewport(32 * loc[0], 32 * loc[1]); + } + core.doAction(); +} + +events.prototype._action_moveViewport = function (data, x, y, prefix) { + this.__action_doAsyncFunc(data.async, core.moveViewport, data.steps, data.time); +} + events.prototype._action_move = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, x, y, prefix); this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep); @@ -2268,7 +2283,7 @@ events.prototype._eventMoveHero_moving = function (step, moveSteps) { core.drawHero('leftFoot', 4 * o * step); } else if (step <= 8) { - core.drawHero('rightFoot', 4 * o * step); + core.drawHero('rightFoot', 4 * o * step);SGTM } if (step == 8) { core.setHeroLoc('x', x + o * core.utils.scan[direction].x, true); From 3a62d366e0c7d91411d3ab24a8803b7d28da12b9 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 10 Jul 2019 22:18:48 +0800 Subject: [PATCH 07/11] fix 263 bug --- _server/table/data.comment.js | 8 +++++++- libs/events.js | 4 ++-- project/data.js | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 3e1bacf1..0748cba5 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -554,11 +554,17 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_data": "如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙" }, "steelDoorWithoutKey": { - "_left": true, + "_leaf": true, "_type": "checkbox", "_bool": "bool", "_data": "铁门是否不需要钥匙开启。如果此项为true,则无需钥匙也可以开铁门。" }, + "itemFirstText": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "首次获得道具是否提示" + }, "equipment": { "_leaf": true, "_type": "checkbox", diff --git a/libs/events.js b/libs/events.js index 80f688b2..b5989364 100644 --- a/libs/events.js +++ b/libs/events.js @@ -462,7 +462,7 @@ events.prototype.getItem = function (id, num, x, y, callback) { // --- 首次获得道具的提示 if (!core.hasFlag("__itemHint__")) core.setFlag("__itemHint__", []); var itemHint = core.getFlag("__itemHint__"); - if (itemHint.indexOf(id) < 0 && itemCls != 'items') { + if (core.flags.itemFirstText && itemHint.indexOf(id) < 0 && itemCls != 'items') { var hint = core.material.items[id].text || "该道具暂无描述"; try { hint = core.replaceText(hint); @@ -2283,7 +2283,7 @@ events.prototype._eventMoveHero_moving = function (step, moveSteps) { core.drawHero('leftFoot', 4 * o * step); } else if (step <= 8) { - core.drawHero('rightFoot', 4 * o * step);SGTM + core.drawHero('rightFoot', 4 * o * step); } if (step == 8) { core.setHeroLoc('x', x + o * core.utils.scan[direction].x, true); diff --git a/project/data.js b/project/data.js index 29c59b80..f8ec9780 100644 --- a/project/data.js +++ b/project/data.js @@ -396,6 +396,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "snowFourDirections": false, "bigKeyIsBox": false, "steelDoorWithoutKey": false, + "itemFirstText": true, "equipment": false, "equipboxButton": false, "iconInEquipbox": false, From cd3c0e084d1352a5b16dec31d521b9f9d2d2647f Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 10 Jul 2019 23:41:00 +0800 Subject: [PATCH 08/11] hideStatusBar editor --- libs/control.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/control.js b/libs/control.js index 3823e105..081a82ec 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2368,6 +2368,7 @@ control.prototype._updateStatusBar_setToolboxIcon = function () { } control.prototype.showStatusBar = function () { + if (main.mode == 'editor') return; if (core.domStyle.showStatusBar) return; var statusItems = core.dom.status; core.domStyle.showStatusBar = true; @@ -2380,6 +2381,8 @@ control.prototype.showStatusBar = function () { } control.prototype.hideStatusBar = function (showToolbox) { + if (main.mode == 'editor') return; + // 如果原本就是隐藏的,则先显示 if (!core.domStyle.showStatusBar) this.showStatusBar(); From 2ea8b012a85ff0143289ed91e08de389649a3d7d Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 23 Jul 2019 14:49:05 +0800 Subject: [PATCH 09/11] v2.6.3 --- _server/editor_blockly.js | 5 +++-- libs/maps.js | 37 +++++++++++++++++++------------------ main.js | 3 +++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 1bdf8a76..7c87bf1e 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -762,7 +762,7 @@ function omitedcheckUpdateFunction(event) { "closeDoor_s": ["PosString_0", "PosString_1"], "show_s": ["EvalString_0", "EvalString_1", "IdString_0"], "hide_s": ["EvalString_0", "EvalString_1", "IdString_0"], - "setBlock_s": ["PosString_0", "PosString_1", "IdString_0"], + "setBlock_s": ["EvalString_1", "EvalString_2", "IdString_0"], "move_s": ["PosString_0", "PosString_1"], "jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点 "showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"], @@ -772,7 +772,8 @@ function omitedcheckUpdateFunction(event) { "hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"], "trigger_s": ["PosString_0", "PosString_1"], "insert_2_s": ["PosString_0", "PosString_1", "IdString_0"], - "animate_s": ["EvalString_0", "EvalString_0"] + "animate_s": ["EvalString_0", "EvalString_0"], + "setViewport_s": ["PosString_0", "PosString_1"] } editor_blockly.selectPoint = function () { diff --git a/libs/maps.js b/libs/maps.js index 3cda4b57..71f8cf36 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -939,24 +939,25 @@ maps.prototype._drawFloorImage = function (ctx, name, type, image, offsetX, widt ////// 绘制Autotile ////// maps.prototype._drawAutotile = function (ctx, mapArr, block, size, left, top, status) { - var indexArrs = [ //16种组合的图块索引数组; // 将autotile分割成48块16*16的小块; 数组索引即对应各个小块 - // +----+----+----+----+----+----+ - [10, 9, 4, 3], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 | - [10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+ - [10, 9, 18, 3], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 | - [10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+ - [10, 43, 4, 3], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 | - [10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+ - [10, 7, 2, 3], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 | - [10, 31, 16, 5], //7 bin:0111 +----+----+----+----+----+----+ - [48, 9, 4, 3], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 | - [8, 9, 4, 1], //9 bin:1001 +----+----+----+----+----+----+ - [36, 9, 30, 3], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 | - [36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+ - [46, 45, 4, 3], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 | - [46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+ - [12, 45, 30, 3], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 | - [34, 33, 28, 27] //15 bin:1111 +----+----+----+----+----+----+ + var indexArrs = [ //16种组合的图块索引数组; + // 将autotile分割成48块16*16的小块; 数组索引即对应各个小块 + // +----+----+----+----+----+----+ + [10, 9, 4, 3], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 | + [10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+ + [10, 9, 18, 3], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 | + [10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+ + [10, 43, 4, 3], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 | + [10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+ + [10, 43, 18, 3], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 | + [10, 31, 16, 5], //7 bin:0111 +----+----+----+----+----+----+ + [48, 9, 4, 3], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 | + [48, 9, 4, 13], //9 bin:1001 +----+----+----+----+----+----+ + [36, 9, 30, 3], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 | + [36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+ + [46, 45, 4, 3], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 | + [46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+ + [12, 45, 30, 3], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 | + [20, 23, 38, 41] //15 bin:1111 +----+----+----+----+----+----+ ]; // 开始绘制autotile diff --git a/main.js b/main.js index 1434550c..e2c8cf15 100644 --- a/main.js +++ b/main.js @@ -403,6 +403,9 @@ main.dom.body.onkeyup = function(e) { main.selectButton((main.selectedButton||0) + 1); else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space main.selectButton(main.selectedButton); + else if (e.keyCode == 27 && main.dom.levelChooseButtons.style.display == 'block') { // ESC + main.core.showStartAnimate(true); + } e.stopPropagation(); return; } From 36cdcd0dbdf736bbb71b13d7fa73349557ee9210 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 24 Jul 2019 10:46:22 +0800 Subject: [PATCH 10/11] Fix awesomplete keydown --- _server/editor_blockly.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 7c87bf1e..4c6d5257 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -948,6 +948,17 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { } } else { + + htmlInput.onkeydown = function (e) { + if (e.keyCode == 13 && awesomplete.opened && awesomplete.selected) { + e.stopPropagation(); + e.stopImmediatePropagation(); + e.preventDefault(); + awesomplete.select(); + return false; + } + } + // --- awesomplete var awesomplete = new Awesomplete(htmlInput, { minChars: 4, From e59898db2b0ce5e09a81bcaca823aecf95e535fb Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 24 Jul 2019 18:12:42 +0800 Subject: [PATCH 11/11] V2.6.3 --- README.md | 11 ++++++----- libs/actions.js | 4 ++-- libs/control.js | 5 +++-- 更新说明.txt | 5 +++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4d83c518..7ccf34ca 100644 --- a/README.md +++ b/README.md @@ -55,17 +55,18 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! ## 更新说明 -### 2019.7.5 V2.6.3 +### 2019.7.24 V2.6.3 -* [x] 标题界面大幅美化,支持键盘开始游戏 +* [x] 标题界面大幅美化,增加闪烁光标,支持键盘开始游戏 * [x] 事件编辑器支持自动补全,能对flag和API列表等进行补全 * [x] 剧情文本中\\c修改字体大小,\\d和\\e切换粗体和斜体 -* [x] 可以指定每个选择项的出现条件,动态生成 +* [x] 事件:设置视角&移动视角 +* [x] 可以指定显示选择项的出现条件并动态生成 * [x] 楼层传送器的平面传送模式(哪里离开飞回到哪里) -* [x] UI绘制事件增添绘制圆(边框),且可直接双击预览 +* [x] UI绘制事件增添绘制圆和绘制圆边框 +* [x] 所有的UI绘制事件均可以双击预览 * [x] 播放BGM事件可以一直持续播放直到下次调用 * [x] \f立绘支持alpha值 -* [x] 只有一个全局商店时V键能直接打开 * [x] 支持在脚本编辑中直接flags.xxx调用自定义变量 * [x] 首次获得道具将给予提示 * [x] 等待用户操作支持滚轮,视为PgUp和PgDn diff --git a/libs/actions.js b/libs/actions.js index 09b44ce2..648b8dd6 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -137,7 +137,7 @@ actions.prototype._sys_onkeyDown = function (e) { return; } } - e.preventDefault(); + if (e.preventDefault) e.preventDefault(); core.status.holdingKeys.push(e.keyCode); this.pressKey(e.keyCode); } else { @@ -199,7 +199,7 @@ actions.prototype._sys_onkeyUp = function (e) { break; } } - e.preventDefault(); + if (e.preventDefault) e.preventDefault(); this.keyUp(e.keyCode, e.altKey); } else { if (e.keyCode == 17) core.status.ctrlDown = false; diff --git a/libs/control.js b/libs/control.js index 081a82ec..e6d297bc 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1236,7 +1236,7 @@ control.prototype.bookReplay = function () { // 从“浏览地图”页面打开 if (core.status.event.id=='viewMaps') - core.status.event.selection = core.status.event.data; + core.status.event.ui = core.status.event.data; core.lockControl(); core.status.event.id='book'; @@ -2386,6 +2386,7 @@ control.prototype.hideStatusBar = function (showToolbox) { // 如果原本就是隐藏的,则先显示 if (!core.domStyle.showStatusBar) this.showStatusBar(); + if (core.isReplaying()) showToolbox = true; var statusItems = core.dom.status, toolItems = core.dom.tools; core.domStyle.showStatusBar = false; @@ -2493,7 +2494,7 @@ control.prototype.setToolbarButton = function (useButton) { } if (useButton == null) useButton = core.domStyle.toolbarBtn; - if (!core.domStyle.isVertical) useButton = false; + if (!core.domStyle.isVertical || core.isReplaying()) useButton = false; core.domStyle.toolbarBtn = useButton; if (useButton) { diff --git a/更新说明.txt b/更新说明.txt index 8e690e8e..8b3e2419 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,9 +1,10 @@ HTML5魔塔样板V2.6.3 -标题界面大幅美化,支持键盘开始游戏 +标题界面大幅美化,增加闪烁光标,支持键盘开始游戏 事件编辑器支持自动补全,能对flag和API列表等进行补全 剧情文本中\\c修改字体大小,\\d和\\e切换粗体和斜体 -可以指定每个选择项的出现条件,动态生成 +事件:设置视角&移动视角 +可以指定显示选择项的出现条件并动态生成 楼层传送器的平面传送模式(哪里离开飞回到哪里) UI绘制事件增添绘制圆和绘制圆边框 所有的UI绘制事件均可以双击预览