diff --git a/API列表.txt b/API列表.txt index 4a12de10..6140cf9e 100644 --- a/API列表.txt +++ b/API列表.txt @@ -685,10 +685,6 @@ core.updateHeroIcon() 更新状态栏上的勇士图标。 -core.updateGlobalAttribute() -更新全局属性,例如状态栏的背景图等。 - - core.setToolbarButton(useButtom) 设置工具栏是否是拓展键盘。 diff --git a/_docs/api.md b/_docs/api.md index 0519a600..badadd59 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -684,10 +684,6 @@ core.updateHeroIcon() 更新状态栏上的勇士图标。 -core.updateGlobalAttribute() -更新全局属性,例如状态栏的背景图等。 - - core.setToolbarButton(useButtom) 设置工具栏是否是拓展键盘。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index b71b85c4..7497c0c3 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -557,6 +557,35 @@ return '{' + [ */; +mainStyle_m + : '主要样式设置:' '标题界面背景图(全路径):' EvalString BGNL? Newline + '标题样式;可写 display: none 隐藏标题' EvalString BGNL? Newline + '标题按钮样式:' EvalString BGNL? Newline + '横屏状态栏背景;url(...) 0 0/100% 100% no-repeat 可将图片拉伸自适配' BGNL? Newline EvalString BGNL? Newline + '竖屏状态栏背景:' EvalString BGNL? Newline + '竖屏工具栏背景:' EvalString BGNL? Newline + '楼层切换样式:' EvalString BGNL? Newline + '状态栏颜色' ColorString Colour '边框颜色' ColorString Colour '全局字体' EvalString BEND + +/* mainStyle_m +tooltip : 主要样式设置 +default : ["project/images/bg.jpg", "color: black", "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;", "url(project/materials/ground.png) repeat", "url(project/materials/ground.png) repeat", "url(project/materials/ground.png) repeat", "background-color: black; color: white", "255,255,255,1", "rgba(255,255,255,1)", "204,204,204,1", "rgba(204,204,204,1)", "Verdana"] +helpUrl : https://h5mota.com/games/template/_docs/#/event +var code = { + startBackground: EvalString_0, + startLogoStyle: EvalString_1, + startButtonsStyle: EvalString_2, + statusLeftBackground: EvalString_3, + statusTopBackground: EvalString_4, + toolsBackground: EvalString_5, + floorChangingStyle: EvalString_6, + statusBarColor: JSON.parse('['+ColorString_0+']'), + borderColor: JSON.parse('['+ColorString_1+']'), + font: EvalString_7 +}; +return JSON.stringify(code); +*/; + //为了避免关键字冲突,全部加了_s //动作 action @@ -818,6 +847,7 @@ tip_s /* tip_s tooltip : tip:显示一段提示文字 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=tip%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%8F%90%E7%A4%BA%E6%96%87%E5%AD%97 +allIds : ['IdString_0'] default : ["这段话将在左上角以气泡形式显示",""] IdString_0 = IdString_0 && (', "icon": "' + IdString_0 + '"'); var code = '{"type": "tip", "text": "'+EvalString_0+'"'+IdString_0+'},\n'; @@ -857,17 +887,17 @@ return code; setFloor_s - : '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '值' EvalString Newline + : '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '值' JsonEvalString Newline /* setFloor_s tooltip : setFloor:设置楼层属性;该楼层属性和编辑器中的楼层属性一一对应 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7 -default : ["title","","'字符串类型的值要加引号,其他类型则不用'"] +default : ["title","","\"新楼层名\""] allFloorIds : ['IdString_0'] colour : this.dataColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setFloor", "name": "'+Floor_Meta_List_0+'"'+IdString_0+', "value": "'+EvalString_0+'"},\n'; +var code = '{"type": "setFloor", "name": "'+Floor_Meta_List_0+'"'+IdString_0+', "value": '+JsonEvalString_0+'},\n'; return code; */; @@ -1481,6 +1511,7 @@ tooltip : changeFloor: 楼层切换,动画时间可不填 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changefloor%EF%BC%9A%E6%A5%BC%E5%B1%82%E5%88%87%E6%8D%A2 default : [null,"",null,"","",null,"",null] selectPoint : ["PosString_0", "PosString_1", "IdString_0", true] +allFloorIds : ['IdString_0'] colour : this.dataColor var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; @@ -3166,8 +3197,8 @@ Floor_Meta_List /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/; Global_Attribute_List - : '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'楼层转换背景'|'楼层转换文字色'|'装备列表' - /*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'floorChangingBackground', 'floorChangingTextColor', 'equipName']*/; + : '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'楼层转换样式'|'装备列表' + /*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'floorChangingStyle', 'equipName']*/; Global_Value_List : '血网伤害'|'中毒伤害'|'衰弱效果'|'红宝石效果'|'蓝宝石效果'|'绿宝石效果'|'红血瓶效果'|'蓝血瓶效果'|'黄血瓶效果'|'绿血瓶效果'|'破甲比例'|'反击比例'|'净化比例'|'仇恨增加值'|'动画时间' diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index ec20ffa0..6acd654f 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -104,6 +104,14 @@ ActionParser.prototype.parse = function (obj,type) { if(!obj) obj={}; return MotaActionBlocks['faceIds_m'].xmlText([obj.up||"", obj.down||"", obj.left||"", obj.right||""]); + case 'mainStyle': + if(!obj) obj={}; + return MotaActionBlocks['mainStyle_m'].xmlText([ + obj.startBackground, obj.startLogoStyle, obj.startButtonsStyle, obj.statusLeftBackground, obj.statusTopBackground, + obj.toolsBackground, obj.floorChangingStyle, + obj.statusBarColor, 'rgba('+obj.statusBarColor+')', obj.borderColor, 'rgba('+obj.borderColor+')', obj.font + ]); + case 'shop': var buildsub = function(obj,parser,next){ var text_choices = null; @@ -568,7 +576,7 @@ ActionParser.prototype.parseAction = function() { break; case "setFloor": this.next = MotaActionBlocks['setFloor_s'].xmlText([ - data.name, data.floorId||null, data.value, this.next]); + data.name, data.floorId||null, JSON.stringify(data.value), this.next]); break; case "setGlobalAttribute": this.next = MotaActionBlocks['setGlobalAttribute_s'].xmlText([ @@ -1222,7 +1230,7 @@ MotaActionFunctions.pattern=MotaActionFunctions.pattern||{}; MotaActionFunctions.pattern.id=/^(flag|global):([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; MotaActionFunctions.pattern.id2=/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+),flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; MotaActionFunctions.pattern.idWithoutFlag=/^[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; -MotaActionFunctions.pattern.colorRe=/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/; +MotaActionFunctions.pattern.colorRe=/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/; MotaActionFunctions.pattern.fontRe=/^(italic )?(bold )?(\d+)px ([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index db354d67..c7789296 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -595,7 +595,7 @@ Blockly.FieldColour.prototype.createWidget_ = function() { var getValue=function(){ // return self.getValue() // css颜色 var f = pb.getFieldValue(targetf); - if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(f)) { + if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(f)) { return f; } return ""; @@ -656,7 +656,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { // 给inputDom绑事件 inputDom.oninput=function(){ var value=inputDom.value - if(/[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?/.test(value)){ + if(/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)){ setValue('rgba('+value+')') } } diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 37933f01..ac01d954 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -82,6 +82,7 @@ editor_blocklyconfig=(function(){ "time": 160, "openSound": "door.mp3", "closeSound": "door.mp3", "keys": {"yellowKey": 1, "orangeKey": 1} }, 'doorInfo'), MotaActionBlocks['faceIds_m'].xmlText(), + MotaActionBlocks['mainStyle_m'].xmlText(), ], '显示文字':[ MotaActionBlocks['text_0_s'].xmlText(), diff --git a/_server/editor_table.js b/_server/editor_table.js index 0da79ddf..6d44a3c4 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -451,7 +451,7 @@ editor_table_wrapper = function (editor) { editor_table.prototype.selectColor = function (input) { if (input.value != null) { var str = input.value.toString().replace(/[^\d.,]/g, ''); - if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(str)) { + if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(str)) { document.getElementById('colorPicker').value = str; } } diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 54b45d53..0cadf638 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -109,27 +109,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "文件映射", "_data": "文件名映射,目前仅对images, animates, bgms, sounds有效。\n例如定义 {\"精灵石.mp3\":\"jinglingshi.mp3\"} 就可以使用\ncore.playBgm(\"精灵石.mp3\") 或对应的事件来播放该bgm。" }, - "startBackground": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "标题背景", - "_data": "标题界面的背景,建议使用jpg格式以压缩背景图空间" - }, - "startLogoStyle": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "标题样式", - "_data": "标题样式:可以改变颜色,也可以写\"display: none\"来隐藏标题" - }, - "startButtonsStyle": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "标题按钮样式", - "_data": "标题界面按钮的样式;caret-color指的是当前选中项的边框颜色" - }, "levelChoose": { "_leaf": true, "_type": "event", @@ -153,61 +132,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "标题音乐", "_data": "在标题界面应该播放的bgm内容" }, - "statusLeftBackground": { + "styles": { "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "横状态栏", - "_data": "横屏时左侧状态栏的背景样式,可以定义背景图、平铺方式等。\n具体请网上搜索\"css background\"了解写法。\n如果弄一张图片作为背景图,推荐写法:\n\"url(project/images/XXX.png) 0 0/100% 100% no-repeat\"\n图片最好进行一些压缩等操作节省流量。" - }, - "statusTopBackground": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "竖状态栏", - "_data": "竖屏时上方状态栏的背景样式,可以定义背景图、平铺方式等。\n具体请网上搜索\"css background\"了解写法。\n如果弄一张图片作为背景图,推荐写法:\n\"url(project/images/XXX.png) 0 0/100% 100% no-repeat\"\n图片最好进行一些压缩等操作节省流量。" - }, - "toolsBackground": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "竖工具栏", - "_data": "竖屏时下方工具栏的背景样式,可以定义背景图、平铺方式等。\n具体请网上搜索\"css background\"了解写法。\n如果弄一张图片作为背景图,推荐写法:\n\"url(project/images/XXX.png) 0 0/100% 100% no-repeat\"\n图片最好进行一些压缩等操作节省流量。" - }, - "borderColor": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "边框色", - "_data": "边框颜色,包括游戏边界的边框和对话框边框等。" - }, - "statusBarColor": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "状态栏文字色", - "_data": "状态栏的文字颜色,默认是白色" - }, - "floorChangingBackground": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "转场背景", - "_data": "楼层转换界面的背景样式;可以使用纯色(默认值black),也可以使用图片(参见状态栏的图片写法)" - }, - "floorChangingTextColor": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "转场文字", - "_data": "楼层转换界面的文字颜色,默认是白色" - }, - "font": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "全局字体", - "_data": "游戏中使用的字体,默认是Verdana" + "_type": "event", + "_event": "mainStyle", + "_docs": "主样式", + "_data": "主要样式设置,包括标题、按钮、状态栏等的背景色等" } } }, diff --git a/libs/control.js b/libs/control.js index 46aa0a08..34150505 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2063,12 +2063,17 @@ control.prototype.getRealStatusOrDefault = function (status, name) { ////// 设置某个属性的增幅值 ////// control.prototype.setBuff = function (name, value) { + // 仅保留三位有效buff值 + value = parseFloat(value.toFixed(3)); this.setFlag('__'+name+'_buff__', value); } ////// 加减某个属性的增幅值 ////// control.prototype.addBuff = function (name, value) { - this.setFlag('__'+name+'_buff__', this.getBuff(name) + value); + var buff = this.getBuff(name) + value; + // 仅保留三位有效buff值 + buff = parseFloat(buff.toFixed(3)); + this.setFlag('__'+name+'_buff__', buff); } ////// 获得某个属性的增幅值 ////// @@ -2530,61 +2535,6 @@ control.prototype.updateHeroIcon = function (name) { core.statusBar.image.name.src = canvas.toDataURL("image/png"); } -control.prototype.updateGlobalAttribute = function (name) { - if (name == null) name = Object.keys(core.status.globalAttribute); - if (name instanceof Array) { - name.forEach(function (t) { - core.control.updateGlobalAttribute(t); - }); - return; - } - var attribute = core.status.globalAttribute || core.initStatus.globalAttribute; - if (attribute == null) return; - switch (name) { - case 'statusLeftBackground': - if (!core.domStyle.isVertical) { - core.dom.statusBar.style.background = attribute[name]; - } - break; - case 'statusTopBackground': - if (core.domStyle.isVertical) { - core.dom.statusBar.style.background = attribute[name]; - } - break; - case 'toolsBackground': - if (core.domStyle.isVertical) { - core.dom.toolBar.style.background = attribute[name]; - } - break; - case 'borderColor': - { - var border = '3px ' + attribute[name] + ' solid'; - core.dom.statusBar.style.borderTop = border; - core.dom.statusBar.style.borderLeft = border; - core.dom.statusBar.style.borderRight = core.domStyle.isVertical?border:''; - core.dom.statusBar.style.borderBottom = core.domStyle.isVertical?'':border; - core.dom.gameDraw.style.border = border; - core.dom.toolBar.style.borderLeft = border; - core.dom.toolBar.style.borderRight = core.domStyle.isVertical?border:''; - core.dom.toolBar.style.borderBottom = core.domStyle.isVertical?border:''; - break; - } - case 'statusBarColor': - { - var texts = core.dom.statusTexts; - for (var i=0;i 1e24 || x < -1e24) return x; var c = x < 0 ? "-" : ""; x = Math.abs(x); @@ -436,12 +437,14 @@ utils.prototype.formatBigNumber = function (x, onMap) { ////// 数组转RGB ////// utils.prototype.arrayToRGB = function (color) { + if (!(color instanceof Array)) return color; var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), nowB = this.clamp(parseInt(color[2]), 0, 255); return "#" + ((1 << 24) + (nowR << 16) + (nowG << 8) + nowB).toString(16).slice(1); } utils.prototype.arrayToRGBA = function (color) { + if (!(color instanceof Array)) return color; if (color[3] == null) color[3] = 1; var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), nowB = this.clamp(parseInt(color[2]), 0, 255), nowA = this.clamp(parseFloat(color[3]), 0, 1); diff --git a/main.js b/main.js index 3f51a8c7..7f502e20 100644 --- a/main.js +++ b/main.js @@ -200,9 +200,9 @@ main.prototype.init = function (mode, callback) { var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main; for(var ii in mainData)main[ii]=mainData[ii]; - main.dom.startBackground.src = main.startBackground; - main.dom.startLogo.style=main.startLogoStyle; - main.dom.startButtonGroup.style = main.startButtonsStyle; + main.dom.startBackground.src = main.styles.startBackground; + main.dom.startLogo.style=main.styles.startLogoStyle; + main.dom.startButtonGroup.style = main.styles.startButtonsStyle; main.levelChoose = main.levelChoose || []; main.levelChoose.forEach(function (value) { var span = document.createElement('span'); diff --git a/project/data.js b/project/data.js index 52d53fa0..40c16e7d 100644 --- a/project/data.js +++ b/project/data.js @@ -41,8 +41,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "背景图.jpg": "bg.jpg", "背景音乐.mp3": "bgm.mp3" }, - "startBackground": "project/images/bg.jpg", - "startLogoStyle": "color: black", "levelChoose": [ { "title": "简单", @@ -73,15 +71,18 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "盾牌" ], "startBgm": null, - "statusLeftBackground": "url(project/materials/ground.png) repeat", - "statusTopBackground": "url(project/materials/ground.png) repeat", - "toolsBackground": "url(project/materials/ground.png) repeat", - "borderColor": "#CCCCCC", - "statusBarColor": "white", - "floorChangingBackground": "black", - "floorChangingTextColor": "white", - "font": "Verdana", - "startButtonsStyle": "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;" + "styles": { + "startBackground": "project/images/bg.jpg", + "startLogoStyle": "color: black", + "startButtonsStyle": "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;", + "statusLeftBackground": "url(project/materials/ground.png) repeat", + "statusTopBackground": "url(project/materials/ground.png) repeat", + "toolsBackground": "url(project/materials/ground.png) repeat", + "borderColor": [204,204,204,1], + "statusBarColor": [255,255,255,1], + "floorChangingStyle": "background-color: black; color: white", + "font": "Verdana" + } }, "firstData": { "title": "魔塔样板", diff --git a/project/functions.js b/project/functions.js index db296e5a..7defe6ba 100644 --- a/project/functions.js +++ b/project/functions.js @@ -41,7 +41,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core._init_sys_flags(); // 初始化界面,状态栏等 core.resize(); - core.updateGlobalAttribute(); // 状态栏是否显示 if (core.hasFlag('hideStatusBar')) core.hideStatusBar(core.hasFlag('showToolbox')); @@ -939,7 +938,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var toAttribute = core.getFlag('globalAttribute', core.status.globalAttribute); if (!core.same(toAttribute, core.status.globalAttribute)) { core.status.globalAttribute = toAttribute; - core.updateGlobalAttribute(); + core.resize(); } // 重置音量 core.events.setVolume(core.getFlag("__volume__", 1), 0); diff --git a/runtime.d.ts b/runtime.d.ts index 7bcfad48..f6cb996f 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -221,8 +221,7 @@ type gameStatus = { toolsBackground: string borderColor: string statusBarColor: string - floorChangingBackground: string - floorChangingTextColor: string + floorChangingStyle: string font: string } curtainColor: null