diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 6dfaeebe..77f19381 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -688,7 +688,6 @@ action | callLoad_s | previewUI_s | clearMap_s - | clearMap_1_s | setAttribute_s | fillText_s | fillBoldText_s @@ -1769,7 +1768,7 @@ return code; showTextImage_s : '显示图片化文本' '文本内容' EvalString BGNL? - '图片编号' Int '起点像素' 'x' PosString 'y' PosString '行距' Number '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline + '图片编号' Int '起点像素' 'x' PosString 'y' PosString '行距' Number '翻转' Reverse_List '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline /* showTextImage_s @@ -1777,10 +1776,13 @@ tooltip : showTextImage:显示图片化文本 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showTextImage%ef%bc%9a%e6%98%be%e7%a4%ba%e6%96%87%e6%9c%ac%e5%8c%96%e5%9b%be%e7%89%87 doubleclicktext : EvalString_0 colour : this.printColor -default : ["可以使用setText事件来控制字体、颜色、大小、偏移量等",1,"0","0",1.4,1,0,false] +default : ["可以使用setText事件来控制字体、颜色、大小、偏移量等",1,"0","0",1.4,"null",1,0,false] if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; var async = Bool_0?', "async": true':''; -var code = '{"type": "showTextImage", "code": '+Int_0+', "text": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "lineHeight": '+Number_0+', "opacity": '+Number_1+', "time": '+Int_1+async+'},\n'; +var code = '{"type": "showTextImage", "code": '+Int_0+', "text": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "lineHeight": '+Number_0+Reverse_List_0+', "opacity": '+Number_1+', "time": '+Int_1+async+'},\n'; return code; */; @@ -1800,7 +1802,7 @@ return code; */; showGif_s - : '显示动图' EvalString? '起点像素位置' 'x' PosString? 'y' PosString? Newline + : '显示或清除动图' EvalString? '起点像素位置' 'x' PosString? 'y' PosString? Newline /* showGif_s @@ -2501,29 +2503,19 @@ return code; clearMap_s - : '清除画布' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline + : '清除画布' '起点像素' 'x' PosString? 'y' PosString? '宽' PosString? '高' PosString? Newline /* clearMap_s tooltip : clearMap: 清除画布 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 colour : this.subColor -default : ["0", "0", "100", "100"] +default : ["", "", "", ""] previewBlock : true -var code = '{"type": "clearMap", "x": ' + PosString_0 + ', "y": ' + PosString_1 + - ', "width": ' + PosString_2 + ', "height": ' + PosString_3 + '},\n'; -return code; -*/; - - -clearMap_1_s - : '清空画布' Newline - -/* clearMap_1_s -tooltip : clearMap: 清除画布 -helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 -previewBlock : true -colour : this.subColor -var code = '{"type": "clearMap"},\n'; +PosString_0 = PosString_0 && (', "x": ' + PosString_0); +PosString_1 = PosString_1 && (', "y": ' + PosString_1); +PosString_2 = PosString_2 && (', "width": ' + PosString_2); +PosString_3 = PosString_3 && (', "height": ' + PosString_3); +var code = '{"type": "clearMap"'+PosString_0+PosString_1+PosString_2+PosString_3+'},\n'; return code; */; @@ -2606,33 +2598,35 @@ return code; */; fillRect_s - : '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '颜色' ColorString? Colour Newline + : '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '旋转度数' PosString? '颜色' ColorString? Colour Newline /* fillRect_s tooltip : fillRect:绘制矩形 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2 colour : this.subColor previewBlock : true -default : ["0","0","flag:x","300","","",null] +default : ["0","0","flag:x","300","","","","rgba(255,255,255,1)"] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; PosString_4 = PosString_4 ? (', "radius": '+PosString_4) : ''; -var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+ColorString_0+'},\n'; +PosString_5 = PosString_5 ? (', "angle": ' + PosString_5) : ''; +var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+PosString_5+ColorString_0+'},\n'; return code; */; strokeRect_s - : '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline + : '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '旋转度数' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline /* strokeRect_s tooltip : strokeRect:绘制矩形边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2%e8%be%b9%e6%a1%86 colour : this.subColor previewBlock : true -default : ["0","0","flag:x","300","","",null,""] +default : ["0","0","flag:x","300","","","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; PosString_4 = PosString_4 ? (', "radius": '+PosString_4) : ''; -var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+ColorString_0+IntString_0+'},\n'; +PosString_5 = PosString_5 ? (', "angle": ' + PosString_5) : ''; +var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+PosString_5+ColorString_0+IntString_0+'},\n'; return code; */; @@ -2644,7 +2638,7 @@ tooltip : drawLine:绘制线段 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawLine%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ba%bf%e6%ae%b5 colour : this.subColor previewBlock : true -default : ["0","0","flag:x","300","",null,""] +default : ["0","0","flag:x","300","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; var code = '{"type": "drawLine", "x1": '+PosString_0+', "y1": '+PosString_1+', "x2": '+PosString_2+', "y2": '+PosString_3+ColorString_0+IntString_0+'},\n'; @@ -2659,7 +2653,7 @@ tooltip : drawArrow:绘制箭头 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawArrow%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ae%ad%e5%a4%b4 colour : this.subColor previewBlock : true -default : ["0","0","flag:x","300","",null,""] +default : ["0","0","flag:x","300","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; var code = '{"type": "drawArrow", "x1": '+PosString_0+', "y1": '+PosString_1+', "x2": '+PosString_2+', "y2": '+PosString_3+ColorString_0+IntString_0+'},\n'; @@ -2675,7 +2669,7 @@ tooltip : fillPolygon:绘制多边形 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillPolygon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%be%b9%e5%bd%a2 colour : this.subColor previewBlock : true -default : ["0,0,100","0,100,0","",null] +default : ["0,0,100","0,100,0","","rgba(255,255,255,1)"] var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; if(!pattern2.test(EvalString_0) || !pattern2.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式'); EvalString_0=EvalString_0.split(','); @@ -2696,7 +2690,7 @@ tooltip : strokePolygon:绘制多边形边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokePolygon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%be%b9%e5%bd%a2%e8%be%b9%e6%a1%86 colour : this.subColor previewBlock : true -default : ["0,0,100","0,100,0","",null,""] +default : ["0,0,100","0,100,0","","rgba(255,255,255,1)",""] var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; if(!pattern2.test(EvalString_0) || !pattern2.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式'); EvalString_0=EvalString_0.split(','); @@ -2710,14 +2704,14 @@ return code; */; fillEllipse_s - : '绘制椭圆' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour Newline + : '绘制椭圆' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '旋转度数' PosString? '颜色' ColorString? Colour Newline /* fillEllipse_s tooltip : fillEllipse:绘制椭圆 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 colour : this.subColor previewBlock : true -default : ["0","0","100","100","0","",null] +default : ["0","0","100","100","0","","rgba(255,255,255,1)"] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; var code = '{"type": "fillEllipse", "x": '+PosString_0+', "y": '+PosString_1+', "a": '+PosString_2+', "b": '+PosString_3+PosString_4+ColorString_0+'},\n'; @@ -2725,14 +2719,14 @@ return code; */; strokeEllipse_s - : '绘制椭圆边框' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline + : '绘制椭圆边框' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '旋转度数' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline /* strokeEllipse_s tooltip : strokeEllipse:绘制椭圆边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86%e8%be%b9%e6%a1%86 colour : this.subColor previewBlock : true -default : ["0","0","100","100","0","",null,""] +default : ["0","0","100","100","0","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; @@ -2747,7 +2741,7 @@ fillArc_s tooltip : fillArc:绘制扇形 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 colour : this.subColor -default : ["0","0","100","0","90","",null,""] +default : ["0","0","100","0","90","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; var code = '{"type": "fillArc", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+', "start": '+PosString_3+', "end": '+PosString_4+ColorString_0+'},\n'; return code; @@ -2761,7 +2755,7 @@ strokeArc_s tooltip : strokeArc:绘制弧 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 colour : this.subColor -default : ["0","0","100","0","90","",null,""] +default : ["0","0","100","0","90","","rgba(255,255,255,1)",""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; var code = '{"type": "strokeArc", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+', "start": '+PosString_3+', "end": '+PosString_4+ColorString_0+IntString_0+'},\n'; @@ -2771,7 +2765,7 @@ return code; drawImage_s - : '绘制图片' EvalString '翻转' Reverse_List '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline + : '绘制图片' EvalString '翻转' Reverse_List '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? '旋转度数' PosString? Newline /* drawImage_s @@ -2779,35 +2773,37 @@ tooltip : drawImage:绘制图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawImage%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9b%be%e7%89%87 previewBlock : true allImages : ['EvalString_0'] -default : ["bg.jpg","null","0","0","",""] +default : ["bg.jpg","null","0","0","","",""] colour : this.subColor if (Reverse_List_0 && Reverse_List_0 != 'null') { Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; } else Reverse_List_0 = ''; PosString_2 = PosString_2 ? (', "w": '+PosString_2) : ''; PosString_3 = PosString_3 ? (', "h": '+PosString_3) : ''; -var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+Reverse_List_0+', "x": '+PosString_0+', "y": '+PosString_1+PosString_2+PosString_3+'},\n'; +PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; +var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+Reverse_List_0+', "x": '+PosString_0+', "y": '+PosString_1+PosString_2+PosString_3+PosString_4+'},\n'; return code; */; drawImage_1_s : '绘制图片' EvalString '翻转' Reverse_List '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString BGNL? - '绘制的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline + '绘制的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '旋转度数' PosString? Newline /* drawImage_1_s tooltip : drawImage:绘制图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawImage%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9b%be%e7%89%87 -default : ["bg.jpg","0","0","32","32","0","0","32","32"] +default : ["bg.jpg","null","0","0","32","32","0","0","32","32",""] colour : this.subColor allImages : ['EvalString_0'] previewBlock : true if (Reverse_List_0 && Reverse_List_0 != 'null') { Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; } else Reverse_List_0 = ''; +PosString_8 = PosString_8 ? (', "angle": ' + PosString_8) : ''; var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+Reverse_List_0+ ', "x": '+PosString_0+', "y": '+PosString_1+', "w": '+PosString_2+', "h": '+PosString_3+ - ', "x1": '+PosString_4+', "y1": '+PosString_5+', "w1": '+PosString_6+', "h1": '+PosString_7+'},\n'; + ', "x1": '+PosString_4+', "y1": '+PosString_5+', "w1": '+PosString_6+', "h1": '+PosString_7+PosString_8+'},\n'; return code; */; @@ -2836,7 +2832,7 @@ drawBackground_s /* drawBackground_s tooltip : drawBackground:绘制背景 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawBackground%ef%bc%9a%e7%bb%98%e5%88%b6%e8%83%8c%e6%99%af%e5%9b%be -default : ["winskin.png",null,"0","0","100","100"] +default : ["winskin.png","rgba(255,255,255,1)","0","0","100","100"] colour : this.subColor previewBlock : true var colorRe = MotaActionFunctions.pattern.colorRe; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index a5779d8e..6086dd5e 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -439,7 +439,7 @@ ActionParser.prototype.parseAction = function() { case "showTextImage": // 显示图片化文本 data.loc=data.loc||['',''] this.next = MotaActionBlocks['showTextImage_s'].xmlText([ - this.EvalString(data.text),data.code,data.loc[0],data.loc[1],data.lineHeight||1.4,data.opacity,data.time||0,data.async||false,this.next]); + this.EvalString(data.text),data.code,data.loc[0],data.loc[1],data.lineHeight||1.4,data.reverse,data.opacity,data.time||0,data.async||false,this.next]); break; case "moveImage": // 移动图片 data.to=data.to||['',''] @@ -766,14 +766,9 @@ ActionParser.prototype.parseAction = function() { ]); break; case "clearMap": // 清除画布 - if (data.x != null && data.y != null && data.width != null && data.height != null) { - this.next = MotaActionBlocks['clearMap_s'].xmlText([ - data.x, data.y, data.width, data.height, this.next - ]); - } - else { - this.next = MotaActionBlocks['clearMap_1_s'].xmlText([this.next]); - } + this.next = MotaActionBlocks['clearMap_s'].xmlText([ + data.x, data.y, data.width, data.height, this.next + ]); break; case "setAttribute": // 设置画布属性 data.fillStyle=this.Colour(data.fillStyle); @@ -805,13 +800,13 @@ ActionParser.prototype.parseAction = function() { case "fillRect": // 绘制矩形 data.style = this.Colour(data.style); this.next = MotaActionBlocks['fillRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', this.next + data.x, data.y, data.width, data.height, data.radius, data.angle, data.style, 'rgba('+data.style+')', this.next ]); break; case "strokeRect": // 绘制矩形边框 data.style = this.Colour(data.style); this.next = MotaActionBlocks['strokeRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + data.x, data.y, data.width, data.height, data.radius, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next ]); break; case "drawLine": // 绘制线段 @@ -875,12 +870,12 @@ ActionParser.prototype.parseAction = function() { case "drawImage": // 绘制图片 if (data.x1 != null && data.y1 != null && data.w1 != null && data.h1 != null) { this.next = MotaActionBlocks['drawImage_1_s'].xmlText([ - data.image, data.reverse, data.x, data.y, data.w, data.h, data.x1, data.y1, data.w1, data.h1, this.next + data.image, data.reverse, data.x, data.y, data.w, data.h, data.x1, data.y1, data.w1, data.h1, data.angle, this.next ]); } else { this.next = MotaActionBlocks['drawImage_s'].xmlText([ - data.image, data.reverse, data.x, data.y, data.w, data.h, this.next + data.image, data.reverse, data.x, data.y, data.w, data.h, data.angle, this.next ]); } break; diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index ac01d954..9fec43a7 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -204,7 +204,6 @@ editor_blocklyconfig=(function(){ 'UI绘制':[ MotaActionBlocks['previewUI_s'].xmlText(), MotaActionBlocks['clearMap_s'].xmlText(), - MotaActionBlocks['clearMap_1_s'].xmlText(), MotaActionBlocks['setAttribute_s'].xmlText(), MotaActionBlocks['fillText_s'].xmlText(), MotaActionBlocks['fillBoldText_s'].xmlText(), diff --git a/_server/editor_table.js b/_server/editor_table.js index bc0410e7..2a0324f9 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -52,8 +52,10 @@ editor_table_wrapper = function (editor) { editor_table.prototype.editGrid = function (showComment, type) { var list = []; if (showComment) list.push(""); - if (type != 'select' && type != 'checkbox' && type != 'checkboxSet' && type != 'disable') + if (type != 'select' && type != 'checkbox' && type != 'checkboxSet' && type != 'popCheckboxSet' && type != 'disable') list.push(""); + if (type == 'popCheckboxSet') + list.push(""); if (type == 'disable') list.push(""); return list.join(' '); } @@ -290,7 +292,7 @@ editor_table_wrapper = function (editor) { case 'checkboxSet': return editor.table.checkboxSet(thiseval, cobj._checkboxSet.key, cobj._checkboxSet.prefix); default: - return editor.table.textarea(thiseval, cobj.indent || 0, cobj._type == 'disable' || cobj._type == 'popCheckboxSet'); + return editor.table.textarea(thiseval, cobj.indent || 0, cobj._type == 'disable'); } } diff --git a/libs/events.js b/libs/events.js index 7b2153d4..87385c7d 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1154,13 +1154,15 @@ events.prototype.__precompile_getArray = function () { "fillArc", "strokeArc", "drawIcon", "drawSelector", "drawBackground", ]; var others = { - "fillEllipse": ["a", "b"], - "strokeEllipse": ["a", "b"], + "fillEllipse": ["a", "b", "angle"], + "strokeEllipse": ["a", "b", "angle"], + "fillRect": ["radius", "angle"], + "strokeRect": ["radius", "angle"], "fillArc": ["r", "start", "end"], "strokeArc": ["r", "start", "end"], "drawLine": ["x1", "y1", "x2", "y2"], "drawArrow": ["x1", "y1", "x2", "y2"], - "drawImage": ["x", "y", "w", "h", "x1", "y1", "w1", "h1"], + "drawImage": ["x", "y", "w", "h", "x1", "y1", "w1", "h1", "angle"], "drawTextContent": ["left", "top"], }; return { @@ -1471,8 +1473,11 @@ events.prototype._action_showTextImage = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, 0, 0, prefix); if (core.isReplaying()) data.time = 0; data.text = core.replaceText(data.text, prefix); + var __tmpName = (Math.random()+"_"+Math.random()).replace(/\./g, "") + ".png"; + core.material.images.images[__tmpName] = core.ui.textImage(data.text); this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage, - data.code, core.ui.textImage(data.text), null, loc, data.opacity, data.time); + data.code, __tmpName + (data.reverse || ""), null, loc, data.opacity, data.time); + delete core.material.images.images[__tmpName]; } events.prototype._action_hideImage = function (data, x, y, prefix) { diff --git a/libs/ui.js b/libs/ui.js index 14f37612..ad2d4215 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -126,61 +126,103 @@ ui.prototype._uievent_fillBoldText = function (data) { } ////// 在某个canvas上绘制一个矩形 ////// -ui.prototype.fillRect = function (name, x, y, width, height, style) { +ui.prototype.fillRect = function (name, x, y, width, height, style, angle) { if (style) core.setFillStyle(name, style); var ctx = this.getContextByName(name); - if (ctx) ctx.fillRect(x, y, width, height); + if (ctx) { + if (angle) { + ctx.save(); + ctx.translate(x + width / 2, y + height / 2); + ctx.rotate(angle); + ctx.translate(-x - width / 2, -y - height / 2); + } + ctx.fillRect(x, y, width, height); + if (angle) { + ctx.restore(); + } + } } ui.prototype._uievent_fillRect = function (data) { this._createUIEvent(); if (data.radius) { - this.fillRoundRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), core.calValue(data.radius), data.style); + this.fillRoundRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), + core.calValue(data.radius), data.style, (core.calValue(data.angle) || 0) * Math.PI / 180); } else { - this.fillRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style); + this.fillRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), + data.style, (core.calValue(data.angle) || 0) * Math.PI / 180); } } ////// 在某个canvas上绘制一个矩形的边框 ////// -ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) { +ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth, angle) { if (style) core.setStrokeStyle(name, style); if (lineWidth) core.setLineWidth(name, lineWidth); var ctx = this.getContextByName(name); - if (ctx) ctx.strokeRect(x, y, width, height); + if (ctx) { + if (angle) { + ctx.save(); + ctx.translate(x + width / 2, y + height / 2); + ctx.rotate(angle); + ctx.translate(-x - width / 2, -y - height / 2); + } + ctx.strokeRect(x, y, width, height); + if (angle) { + ctx.restore(); + } + } } ui.prototype._uievent_strokeRect = function (data) { this._createUIEvent(); if (data.radius) { this.strokeRoundRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), - core.calValue(data.radius), data.style, data.lineWidth); + core.calValue(data.radius), data.style, data.lineWidth, (core.calValue(data.angle) || 0) * Math.PI / 180); } else { - this.strokeRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style, data.lineWidth); + this.strokeRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), + data.style, data.lineWidth, (core.calValue(data.angle) || 0) * Math.PI / 180); } } ////// 在某个canvas上绘制一个圆角矩形 ////// -ui.prototype.fillRoundRect = function (name, x, y, width, height, radius, style) { +ui.prototype.fillRoundRect = function (name, x, y, width, height, radius, style, angle) { if (style) core.setFillStyle(name, style); var ctx = this.getContextByName(name); if (ctx) { + if (angle) { + ctx.save(); + ctx.translate(x + width / 2, y + height / 2); + ctx.rotate(angle); + ctx.translate(-x - width / 2, -y - height / 2); + } this._roundRect_buildPath(ctx, x, y, width, height, radius); ctx.fill(); + if (angle) { + ctx.restore(); + } } } ////// 在某个canvas上绘制一个圆角矩形的边框 ////// -ui.prototype.strokeRoundRect = function (name, x, y, width, height, radius, style, lineWidth) { +ui.prototype.strokeRoundRect = function (name, x, y, width, height, radius, style, lineWidth, angle) { if (style) core.setStrokeStyle(name, style); if (lineWidth) core.setLineWidth(name, lineWidth); var ctx = this.getContextByName(name); if (ctx) { + if (angle) { + ctx.save(); + ctx.translate(x + width / 2, y + height / 2); + ctx.rotate(angle); + ctx.translate(-x - width / 2, -y - height / 2); + } this._roundRect_buildPath(ctx, x, y, width, height, radius); ctx.stroke(); + if (angle) { + ctx.restore(); + } } } - ui.prototype._roundRect_buildPath = function (ctx, x, y, width, height, radius) { ctx.beginPath(); ctx.moveTo(x + radius, y); @@ -504,7 +546,7 @@ ui.prototype.splitLines = function (name, text, maxWidth, font) { } ////// 绘制一张图片 ////// -ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { +ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1, angle) { // 检测文件名以 :x, :y, :o 结尾,表示左右翻转,上下翻转和中心翻转 var ctx = this.getContextByName(name); if (!ctx) return; @@ -516,7 +558,7 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { } image = core.getMappedName(image); image = core.material.images.images[image]; - if (!image || !(image instanceof Image)) return; + if (!image) return; } var scale = { @@ -533,23 +575,25 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { h = image.height; } if (x1 != null && y1 != null && w1 != null && h1 != null) { - if (reverse == null) { + if (!reverse && !angle) { ctx.drawImage(image, x, y, w, h, x1, y1, w1, h1); } else { ctx.save(); ctx.translate(x1 + w1 / 2, y1 + h1 / 2); - ctx.scale(scale[reverse][0], scale[reverse][1]); + if (reverse) ctx.scale(scale[reverse][0], scale[reverse][1]); + if (angle) ctx.rotate(angle); ctx.drawImage(image, x, y, w, h, -w1 / 2, -h1 / 2, w1, h1); ctx.restore(); } return; } - if (reverse == null) { + if (!reverse && !angle) { ctx.drawImage(image, x, y, w, h); } else { ctx.save(); ctx.translate(x + w / 2, y + h / 2); - ctx.scale(scale[reverse][0], scale[reverse][1]); + if (reverse) ctx.scale(scale[reverse][0], scale[reverse][1]); + if (angle) ctx.rotate(angle); ctx.drawImage(image, -w / 2, -h / 2, w, h); ctx.restore(); } @@ -560,7 +604,7 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { ui.prototype._uievent_drawImage = function (data) { this._createUIEvent(); this.drawImage('uievent', data.image + (data.reverse || ''), core.calValue(data.x), core.calValue(data.y), core.calValue(data.w), core.calValue(data.h), - core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.w1), core.calValue(data.h1)); + core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.w1), core.calValue(data.h1), (core.calValue(data.angle) || 0) * Math.PI / 180); } ui.prototype.drawIcon = function (name, id, x, y, w, h, frame) { diff --git a/migration.html b/migration.html index 6765c92f..df5a4697 100644 --- a/migration.html +++ b/migration.html @@ -118,7 +118,7 @@ function encode(str) { } function random_string() { - return (Math.random()+"_"+Math.random()+"_"+Math.random()).replace(".", ""); + return (Math.random()+"_"+Math.random()).replace(/\./g, ""); } // 接档全局属性 diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 18a0e758..713409f3 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -71,7 +71,7 @@ (OK) 同步存档合并;(OK) 失去焦点右键;(OK) 竖屏标题界面背景;(OK)商店录像bug (OK) 右键反复弹出;(OK) 上下楼梯绑定楼传;(OK) 属性框出现0问题;(OK) 上下楼点选点 地图编辑框无效;(OK) jumpHero和帧动画冲突;bookDetails重复计算buff;(OK) 怪物属性多选 -图片化文本翻转;绘制矩形(边框)旋转; +(OK) 图片化文本翻转;(OK) 绘制矩形(边框)旋转; -------------