commit
5bda31e965
@ -271,16 +271,19 @@ return code;
|
||||
|
||||
//changeFloor 事件编辑器入口之一
|
||||
changeFloor_m
|
||||
: '楼梯, 传送门' BGNL? Newline Floor_List IdString? Stair_List 'x' Number ',' 'y' Number '朝向' DirectionEx_List '动画时间' IntString? '穿透性' IgnoreChangeFloor_List BEND
|
||||
: '楼梯, 传送门' BGNL? Newline Floor_List IdString? Stair_List 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' IntString? '穿透性' IgnoreChangeFloor_List BEND
|
||||
|
||||
|
||||
/* changeFloor_m
|
||||
tooltip : 楼梯, 传送门, 如果目标楼层有多个楼梯, 写upFloor或downFloor可能会导致到达的楼梯不确定, 这时候请使用loc方式来指定具体的点位置
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/element?id=%e8%b7%af%e9%9a%9c%ef%bc%8c%e6%a5%bc%e6%a2%af%ef%bc%8c%e4%bc%a0%e9%80%81%e9%97%a8
|
||||
default : [null,"MTx",null,0,0,null,"",null]
|
||||
default : [null,"MTx",null,"","",null,"",null]
|
||||
var toFloorId = IdString_0;
|
||||
if (Floor_List_0!='floorId') toFloorId = Floor_List_0;
|
||||
var loc = ', "loc": ['+Number_0+', '+Number_1+']';
|
||||
var loc = '';
|
||||
if (PosString_0 && PosString_1) {
|
||||
loc = ', "loc": ['+PosString_0+', '+PosString_1+']';
|
||||
}
|
||||
if (Stair_List_0===':now') loc = '';
|
||||
else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"';
|
||||
if (DirectionEx_List_0 == 'null') DirectionEx_List_0 = '';
|
||||
@ -430,8 +433,10 @@ action
|
||||
| drawArrow_s
|
||||
| fillPolygon_s
|
||||
| strokePolygon_s
|
||||
| fillCircle_s
|
||||
| strokeCircle_s
|
||||
| fillEllipse_s
|
||||
| strokeEllipse_s
|
||||
| fillArc_s
|
||||
| strokeArc_s
|
||||
| drawImage_s
|
||||
| drawImage_1_s
|
||||
| drawIcon_s
|
||||
@ -1187,7 +1192,7 @@ return code;
|
||||
*/;
|
||||
|
||||
changeFloor_s
|
||||
: '楼层切换' Floor_List IdString? Stair_List 'x' Number ',' 'y' Number '朝向' DirectionEx_List '动画时间' IntString? Newline
|
||||
: '楼层切换' Floor_List IdString? Stair_List 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' IntString? Newline
|
||||
|
||||
|
||||
/* changeFloor_s
|
||||
@ -1197,8 +1202,11 @@ default : [null,"",null,"","",null,"",null]
|
||||
colour : this.dataColor
|
||||
var toFloorId = IdString_0;
|
||||
if (Floor_List_0!='floorId') toFloorId = Floor_List_0;
|
||||
toFloorId = toFloorId ? (', "floorId": ' + toFloorId) : '';
|
||||
var loc = ', "loc": ['+Number_0+', '+Number_1+']';
|
||||
toFloorId = toFloorId ? (', "floorId": "' + toFloorId +'"') : '';
|
||||
var loc = '';
|
||||
if (PosString_0 && PosString_1) {
|
||||
loc = ', "loc": ['+PosString_0+', '+PosString_1+']';
|
||||
}
|
||||
if (Stair_List_0===':now') loc = '';
|
||||
else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"';
|
||||
if (DirectionEx_List_0 == 'null') DirectionEx_List_0 = '';
|
||||
@ -2242,29 +2250,31 @@ return code;
|
||||
*/;
|
||||
|
||||
fillRect_s
|
||||
: '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' ColorString? Colour Newline
|
||||
: '绘制矩形' '起点像素' 'x' PosString 'y' 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
|
||||
default : ["0","0","flag:x","300","",null]
|
||||
default : ["0","0","flag:x","300","","",null]
|
||||
ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : '';
|
||||
var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+ColorString_0+'},\n';
|
||||
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';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
strokeRect_s
|
||||
: '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' ColorString? Colour '线宽' IntString? Newline
|
||||
: '绘制矩形边框' '起点像素' 'x' PosString 'y' 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
|
||||
default : ["0","0","flag:x","300","",null,""]
|
||||
default : ["0","0","flag:x","300","","",null,""]
|
||||
ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : '';
|
||||
IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : '';
|
||||
var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+ColorString_0+IntString_0+'},\n';
|
||||
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';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2337,33 +2347,64 @@ var code = '{"type": "strokePolygon", "nodes": ['+EvalString_0+']'+ColorString_0
|
||||
return code;
|
||||
*/;
|
||||
|
||||
fillCircle_s
|
||||
: '绘制圆' '圆心' 'x' PosString 'y' PosString '半径' PosString '颜色' ColorString? Colour Newline
|
||||
fillEllipse_s
|
||||
: '绘制椭圆' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour Newline
|
||||
|
||||
/* fillCircle_s
|
||||
tooltip : fillCircle:绘制圆
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillCircle%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86
|
||||
/* 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
|
||||
default : ["0","0","100","",null]
|
||||
default : ["0","0","100","100","0","",null]
|
||||
ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : '';
|
||||
var code = '{"type": "fillCircle", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+ColorString_0+'},\n';
|
||||
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';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
strokeCircle_s
|
||||
: '绘制圆边框' '圆心' 'x' PosString 'y' PosString '半径' PosString '颜色' ColorString? Colour '线宽' IntString? Newline
|
||||
strokeEllipse_s
|
||||
: '绘制椭圆边框' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline
|
||||
|
||||
/* strokeCircle_s
|
||||
tooltip : strokeCircle:绘制圆边框
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeCircle%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86%e8%be%b9%e6%a1%86
|
||||
/* 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
|
||||
default : ["0","0","100","",null,""]
|
||||
default : ["0","0","100","100","0","",null,""]
|
||||
ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : '';
|
||||
IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : '';
|
||||
var code = '{"type": "strokeCircle", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+ColorString_0+IntString_0+'},\n';
|
||||
PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : '';
|
||||
var code = '{"type": "strokeEllipse", "x": '+PosString_0+', "y": '+PosString_1+', "a": '+PosString_2+', "b": '+PosString_3+PosString_4+ColorString_0+IntString_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
fillArc_s
|
||||
: '绘制扇形' '中心' 'x' PosString 'y' PosString '半径' PosString '起点角度' PosString '终点角度' PosString '颜色' ColorString? Colour Newline
|
||||
|
||||
/* 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,""]
|
||||
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;
|
||||
*/;
|
||||
|
||||
|
||||
strokeArc_s
|
||||
: '绘制弧' '中心' 'x' PosString 'y' PosString '半径' PosString '起点角度' PosString '终点角度' PosString '颜色' ColorString? Colour '线宽' IntString? Newline
|
||||
|
||||
/* 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,""]
|
||||
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';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
|
||||
drawImage_s
|
||||
: '绘制图片' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline
|
||||
@ -2507,9 +2548,15 @@ expression
|
||||
: expression Arithmetic_List expression
|
||||
| negate_e
|
||||
| bool_e
|
||||
| idFixedList_e
|
||||
| idFlag_e
|
||||
| idTemp_e
|
||||
| idIdList_e
|
||||
| idString_e
|
||||
| evFlag_e
|
||||
| evTemp_e
|
||||
| enemyattr_e
|
||||
| blockId_e
|
||||
| blockCls_e
|
||||
| equip_e
|
||||
| evalString_e
|
||||
|
||||
|
||||
@ -2571,90 +2618,77 @@ var code = IdString_0;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_1_e
|
||||
idIdList_e
|
||||
: Id_List ':' IdText
|
||||
|
||||
|
||||
/* idString_1_e
|
||||
/* idIdList_e
|
||||
colour : this.idstring_eColor
|
||||
default : [null,"自定义flag"]
|
||||
//todo 将其output改成'idString_e'
|
||||
var code = MotaActionFunctions.replaceFromName(MotaActionFunctions.replaceToName(Id_List_0+':'+IdText_0));
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_2_e
|
||||
idFixedList_e
|
||||
: FixedId_List
|
||||
|
||||
|
||||
/* idString_2_e
|
||||
/* idFixedList_e
|
||||
colour : this.idstring_eColor
|
||||
//todo 将其output改成'idString_e'
|
||||
var code = FixedId_List_0;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_3_e
|
||||
enemyattr_e
|
||||
: '怪物' IdString '的' EnemyId_List
|
||||
|
||||
|
||||
/* idString_3_e
|
||||
colour : this.idstring_eColor
|
||||
/* enemyattr_e
|
||||
default : ['greenSlime',"攻击"]
|
||||
//todo 将其output改成'idString_e'
|
||||
var code = 'enemy:'+IdString_0+':'+EnemyId_List_0;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_4_e
|
||||
blockId_e
|
||||
: '图块ID:' Int ',' Int
|
||||
|
||||
|
||||
/* idString_4_e
|
||||
colour : this.idstring_eColor
|
||||
/* blockId_e
|
||||
default : [0,0]
|
||||
var code = 'blockId:'+Int_0+','+Int_1;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_5_e
|
||||
blockCls_e
|
||||
: '图块类别:' Int ',' Int
|
||||
|
||||
|
||||
/* idString_5_e
|
||||
colour : this.idstring_eColor
|
||||
/* blockCls_e
|
||||
default : [0,0]
|
||||
var code = 'blockCls:'+Int_0+','+Int_1;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
//这一条不会被antlr识别,总是会被归到idString_e
|
||||
idString_6_e
|
||||
equip_e
|
||||
: '装备孔:' Int
|
||||
|
||||
|
||||
/* idString_6_e
|
||||
colour : this.idstring_eColor
|
||||
/* equip_e
|
||||
default : [0]
|
||||
var code = 'equip:'+Int_0;
|
||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
evFlag_e
|
||||
idFlag_e
|
||||
: '独立开关' Letter_List
|
||||
|
||||
|
||||
/* evFlag_e
|
||||
/* idFlag_e
|
||||
colour : this.idstring_eColor
|
||||
default : ["A"]
|
||||
var code = "switch:"+Letter_List_0;
|
||||
@ -2662,11 +2696,11 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||
*/;
|
||||
|
||||
|
||||
evTemp_e
|
||||
idTemp_e
|
||||
: '临时变量' Letter_List
|
||||
|
||||
|
||||
/* evTemp_e
|
||||
/* idTemp_e
|
||||
colour : this.idstring_eColor
|
||||
default : ["A"]
|
||||
var code = "temp:"+Letter_List_0;
|
||||
@ -2899,14 +2933,10 @@ this.evisitor.mapColor=175;
|
||||
|
||||
/* Function_1
|
||||
delete(this.block('negate_e').inputsInline);
|
||||
this.block('idString_1_e').output='idString_e';
|
||||
this.block('idString_2_e').output='idString_e';
|
||||
this.block('idString_3_e').output='idString_e';
|
||||
this.block('idString_4_e').output='idString_e';
|
||||
this.block('idString_5_e').output='idString_e';
|
||||
this.block('idString_6_e').output='idString_e';
|
||||
this.block('evFlag_e').output='idString_e';
|
||||
this.block('evTemp_e').output='idString_e';
|
||||
this.block('idIdList_e').output='idString_e';
|
||||
this.block('idFixedList_e').output='idString_e';
|
||||
this.block('idFlag_e').output='idString_e';
|
||||
this.block('idTemp_e').output='idString_e';
|
||||
*/
|
||||
|
||||
/* Functions
|
||||
@ -2932,9 +2962,9 @@ ActionParser.prototype.parse = function (obj,type) {
|
||||
|
||||
case 'changeFloor':
|
||||
if(!obj)obj={};
|
||||
if(!this.isset(obj.loc)) {
|
||||
obj.loc=[0,0];
|
||||
if (!this.isset(obj.stair)) obj.stair=':now';
|
||||
if (!obj.loc) {
|
||||
obj.loc = obj.loc || ['',''];
|
||||
obj.stair = obj.stair || ':now';
|
||||
}
|
||||
if (obj.floorId==':before'||obj.floorId==':next'||obj.floorId==':now') {
|
||||
obj.floorType=obj.floorId;
|
||||
@ -2957,7 +2987,7 @@ ActionParser.prototype.parse = function (obj,type) {
|
||||
var text_choices = null;
|
||||
for(var ii=obj.length-1,choice;choice=obj[ii];ii--) {
|
||||
text_choices=MotaActionBlocks['levelCase'].xmlText([
|
||||
MotaActionBlocks['evalString_e'].xmlText([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]);
|
||||
this.expandEvalBlock([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]);
|
||||
}
|
||||
return MotaActionBlocks['level_m'].xmlText([text_choices]);
|
||||
|
||||
@ -3235,8 +3265,8 @@ ActionParser.prototype.parseAction = function() {
|
||||
data.floorType=data.floorId;
|
||||
delete data.floorId;
|
||||
}
|
||||
return MotaActionBlocks['changeFloor_s'].xmlText([
|
||||
data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],obj.direction,
|
||||
this.next = MotaActionBlocks['changeFloor_s'].xmlText([
|
||||
data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],data.direction,
|
||||
data.time, this.next]);
|
||||
break;
|
||||
case "changePos": // 直接更换勇士位置, 不切换楼层
|
||||
@ -3414,14 +3444,14 @@ ActionParser.prototype.parseAction = function() {
|
||||
break
|
||||
case "setValue":
|
||||
this.next = MotaActionBlocks['setValue_s'].xmlText([
|
||||
this.tryToUseEvFlag_e('idString_e', [data.name]), data["operator"]||'=',
|
||||
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
||||
this.expandIdBlock([data.name]), data["operator"]||'=',
|
||||
this.expandEvalBlock([data.value]),
|
||||
data.norefresh || false,
|
||||
this.next]);
|
||||
break;
|
||||
case "setEnemy":
|
||||
this.next = MotaActionBlocks['setEnemy_s'].xmlText([
|
||||
data.id, data.name, MotaActionBlocks['evalString_e'].xmlText([data.value]), this.next]);
|
||||
data.id, data.name, this.expandEvalBlock([data.value]), this.next]);
|
||||
break;
|
||||
case "setFloor":
|
||||
this.next = MotaActionBlocks['setFloor_s'].xmlText([
|
||||
@ -3450,14 +3480,14 @@ ActionParser.prototype.parseAction = function() {
|
||||
case "if": // 条件判断
|
||||
if (data["false"]) {
|
||||
this.next = MotaActionBlocks['if_s'].xmlText([
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data["true"]),
|
||||
this.insertActionList(data["false"]),
|
||||
this.next]);
|
||||
}
|
||||
else {
|
||||
this.next = MotaActionBlocks['if_1_s'].xmlText([
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data["true"]),
|
||||
this.next]);
|
||||
}
|
||||
@ -3473,11 +3503,10 @@ ActionParser.prototype.parseAction = function() {
|
||||
var case_caseList = null;
|
||||
for(var ii=data.caseList.length-1,caseNow;caseNow=data.caseList[ii];ii--) {
|
||||
case_caseList=MotaActionBlocks['switchCase'].xmlText([
|
||||
this.isset(caseNow.case)?MotaActionBlocks['evalString_e'].xmlText([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]);
|
||||
this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]);
|
||||
}
|
||||
this.next = MotaActionBlocks['switch_s'].xmlText([
|
||||
// MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
case_caseList,this.next]);
|
||||
break;
|
||||
case "choices": // 提供选项
|
||||
@ -3494,30 +3523,28 @@ ActionParser.prototype.parseAction = function() {
|
||||
break;
|
||||
case "for": // 循环遍历
|
||||
this.next = MotaActionBlocks['for_s'].xmlText([
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.name]),
|
||||
this.expandEvalBlock([data.name]),
|
||||
data.from || 0, data.to || 0, data.step || 0,
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
break;
|
||||
case "forEach": // 循环遍历列表
|
||||
this.next = MotaActionBlocks['forEach_s'].xmlText([
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.name]),
|
||||
this.expandEvalBlock([data.name]),
|
||||
JSON.stringify(data.list),
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
break;
|
||||
case "while": // 前置条件循环处理
|
||||
this.next = MotaActionBlocks['while_s'].xmlText([
|
||||
// MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
break;
|
||||
case "dowhile": // 后置条件循环处理
|
||||
this.next = MotaActionBlocks['dowhile_s'].xmlText([
|
||||
this.insertActionList(data.data),
|
||||
// MotaActionBlocks['evalString_e'].xmlText([data.condition]),
|
||||
this.tryToUseEvFlag_e('evalString_e', [data.condition]),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.next]);
|
||||
break;
|
||||
case "break": // 跳出循环
|
||||
@ -3657,13 +3684,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.style, 'rgba('+data.style+')', this.next
|
||||
data.x, data.y, data.width, data.height, data.radius, 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.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
]);
|
||||
break;
|
||||
case "drawLine": // 绘制线段
|
||||
@ -3700,16 +3727,28 @@ ActionParser.prototype.parseAction = function() {
|
||||
x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
]);
|
||||
break;
|
||||
case "fillCircle": // 绘制圆
|
||||
case "fillEllipse": // 绘制椭圆
|
||||
data.style = this.Colour(data.style);
|
||||
this.next = MotaActionBlocks['fillCircle_s'].xmlText([
|
||||
data.x, data.y, data.r, data.style, 'rgba('+data.style+')', this.next
|
||||
this.next = MotaActionBlocks['fillEllipse_s'].xmlText([
|
||||
data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', this.next
|
||||
]);
|
||||
break;
|
||||
case "strokeCircle": // 绘制圆边框
|
||||
case "strokeEllipse": // 绘制椭圆边框
|
||||
data.style = this.Colour(data.style);
|
||||
this.next = MotaActionBlocks['strokeCircle_s'].xmlText([
|
||||
data.x, data.y, data.r, data.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
this.next = MotaActionBlocks['strokeEllipse_s'].xmlText([
|
||||
data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
]);
|
||||
break;
|
||||
case "fillArc": // 绘制弧
|
||||
data.style = this.Colour(data.style);
|
||||
this.next = MotaActionBlocks['fillArc_s'].xmlText([
|
||||
data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', this.next
|
||||
]);
|
||||
break;
|
||||
case "strokeArc": // 绘制弧
|
||||
data.style = this.Colour(data.style);
|
||||
this.next = MotaActionBlocks['strokeArc_s'].xmlText([
|
||||
data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', data.lineWidth, this.next
|
||||
]);
|
||||
break;
|
||||
case "drawImage": // 绘制图片
|
||||
@ -3826,18 +3865,53 @@ ActionParser.prototype.Colour = function(color) {
|
||||
return color?JSON.stringify(color).slice(1,-1):null;
|
||||
}
|
||||
|
||||
ActionParser.prototype.tryToUseEvFlag_e = function(defaultType, args, isShadow, comment) {
|
||||
var match=/^switch:([A-Z])$/.exec(args[0])
|
||||
ActionParser.prototype.matchId = function(args, isShadow, comment) {
|
||||
var rt=function(xml){
|
||||
return {xml:xml,ret:true}
|
||||
}
|
||||
var match = /nothing/.exec('nothing')
|
||||
// 固定列表
|
||||
var FixedId_List=MotaActionBlocks.idFixedList_e.json.args0[0].options; // [["生命", "status:hp"], ...]
|
||||
match=new RegExp('^('+FixedId_List.map(function(v){return v[1]}).join('|')+')$').exec(args[0])
|
||||
if(match){
|
||||
return rt(MotaActionBlocks['idFixedList_e'].xmlText(args, isShadow, comment));
|
||||
}
|
||||
// 独立开关
|
||||
match=/^switch:([A-Z])$/.exec(args[0])
|
||||
if(match){
|
||||
args[0]=match[1]
|
||||
return MotaActionBlocks['evFlag_e'].xmlText(args, isShadow, comment);
|
||||
return rt(MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment));
|
||||
}
|
||||
// 临时变量
|
||||
match=/^temp:([A-Z])$/.exec(args[0])
|
||||
if(match){
|
||||
args[0]=match[1]
|
||||
return MotaActionBlocks['evTemp_e'].xmlText(args, isShadow, comment);
|
||||
return rt(MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment));
|
||||
}
|
||||
return MotaActionBlocks[defaultType||'evalString_e'].xmlText(args, isShadow, comment);
|
||||
// id列表
|
||||
var Id_List = MotaActionBlocks.idIdList_e.json.args0[0].options; // [["变量", "flag"], ...]
|
||||
match=new RegExp('^('+Id_List.map(function(v){return v[1]}).join('|')+'):([a-zA-Z0-9_\\u4E00-\\u9FCC]+)$').exec(args[0])
|
||||
if(match){
|
||||
args=[match[1],match[2]].concat(args.slice(1))
|
||||
return rt(MotaActionBlocks['idIdList_e'].xmlText(args, isShadow, comment));
|
||||
}
|
||||
return {xml:'',ret:false}
|
||||
}
|
||||
|
||||
ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) {
|
||||
var ret=this.matchId(args, isShadow, comment)
|
||||
if (ret.ret) return ret.xml;
|
||||
return MotaActionBlocks['idString_e'].xmlText(args, isShadow, comment);
|
||||
}
|
||||
|
||||
ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) {
|
||||
var ret=this.matchId(args, isShadow, comment)
|
||||
if (ret.ret) return ret.xml;
|
||||
// todo
|
||||
// 1. 将「数值设置」的名称尽可能替换掉;如果是 FixedId_List 那就用它;否则如果是 独立开关/临时变量 那就用对应的;否则用 A:B 的那个框
|
||||
// 2. 将「值块」尽可能替换掉,主要是「独立开关」,「临时变量」,「非 - 独立开关」,「非-临时变量」;以及true/false替换成勾选框;对于其他变量/属性等之类也尽可能进行替换
|
||||
|
||||
return MotaActionBlocks['evalString_e'].xmlText(args, isShadow, comment);
|
||||
}
|
||||
|
||||
MotaActionFunctions.actionParser = new ActionParser();
|
||||
|
||||
@ -55,6 +55,7 @@ function editor() {
|
||||
editModeSelect :document.getElementById('editModeSelect'),
|
||||
mid2 : document.getElementById('mid2'),
|
||||
clearLastUsedBtn: document.getElementById('clearLastUsedBtn'),
|
||||
lastUsedTitle: document.getElementById('lastUsedTitle'),
|
||||
lastUsedDiv: document.getElementById('lastUsedDiv'),
|
||||
lastUsed: document.getElementById('lastUsed'),
|
||||
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
||||
@ -105,6 +106,7 @@ function editor() {
|
||||
lockMode: false,
|
||||
|
||||
// 最近使用的图块
|
||||
lastUsedType: null,
|
||||
lastUsed: [],
|
||||
};
|
||||
|
||||
@ -406,16 +408,35 @@ editor.prototype.updateMap = function () {
|
||||
this.updateLastUsedMap();
|
||||
}
|
||||
|
||||
editor.prototype.setLastUsedType = function (type) {
|
||||
if (type == editor.uivalues.lastUsedType) return;
|
||||
editor.uivalues.lastUsedType = type;
|
||||
var _buildHtml = function (type, text) {
|
||||
if (type == null) return "<b>" + text + "</b>";
|
||||
else return `<a href="javascript:editor.setLastUsedType('${type}')">${text}</a>`;
|
||||
}
|
||||
editor.dom.lastUsedTitle.innerHTML
|
||||
= type == 'frequent' ? (_buildHtml('recent', '最近使用') + " | " + _buildHtml(null, '最常使用'))
|
||||
: (_buildHtml(null, '最近使用') + " | " + _buildHtml('frequent', '最常使用'));
|
||||
this.updateLastUsedMap();
|
||||
}
|
||||
|
||||
editor.prototype.updateLastUsedMap = function () {
|
||||
var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) {
|
||||
if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0);
|
||||
return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0);
|
||||
});
|
||||
|
||||
// 绘制最近使用事件
|
||||
var ctx = editor.dom.lastUsedCtx;
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
|
||||
ctx.fillStyle = 'rgba(255,0,0,0.85)';
|
||||
ctx.lineWidth = 4;
|
||||
for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) {
|
||||
for (var i = 0; i < lastUsed.length; ++i) {
|
||||
try {
|
||||
var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
|
||||
var info = editor.uivalues.lastUsed[i];
|
||||
var info = lastUsed[i];
|
||||
if (!info || !info.images) continue;
|
||||
if (info.isTile && core.material.images.tilesets[info.images]) {
|
||||
ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
|
||||
@ -425,6 +446,9 @@ editor.prototype.updateLastUsedMap = function () {
|
||||
var per_height = info.images.endsWith('48') ? 48 : 32;
|
||||
ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32);
|
||||
}
|
||||
if (info.istop) {
|
||||
ctx.fillRect(32 * x, 32 * y + 24, 8, 8);
|
||||
}
|
||||
if (selectBox.isSelected() && editor.info.id == info.id) {
|
||||
ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28);
|
||||
}
|
||||
@ -458,6 +482,7 @@ editor.prototype.drawInitData = function (icons) {
|
||||
// editor.uivalues.folded = true;
|
||||
editor.uivalues.foldPerCol = editor.config.get('foldPerCol', 50);
|
||||
// var imgNames = Object.keys(images); //还是固定顺序吧;
|
||||
editor.setLastUsedType(editor.config.get('lastUsedType', 'recent'));
|
||||
editor.uivalues.lastUsed = editor.config.get("lastUsed", []);
|
||||
var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"];
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ editor_blockly = function () {
|
||||
],
|
||||
'数据相关':[
|
||||
MotaActionBlocks['setValue_s'].xmlText([
|
||||
MotaActionBlocks['idString_1_e'].xmlText(['status','生命']), '=', '', false
|
||||
MotaActionBlocks['idIdList_e'].xmlText(['status','生命']), '=', '', false
|
||||
]),
|
||||
MotaActionBlocks['setEnemy_s'].xmlText(),
|
||||
MotaActionBlocks['setFloor_s'].xmlText(),
|
||||
@ -202,8 +202,10 @@ editor_blockly = function () {
|
||||
MotaActionBlocks['drawArrow_s'].xmlText(),
|
||||
MotaActionBlocks['fillPolygon_s'].xmlText(),
|
||||
MotaActionBlocks['strokePolygon_s'].xmlText(),
|
||||
MotaActionBlocks['fillCircle_s'].xmlText(),
|
||||
MotaActionBlocks['strokeCircle_s'].xmlText(),
|
||||
MotaActionBlocks['fillEllipse_s'].xmlText(),
|
||||
MotaActionBlocks['strokeEllipse_s'].xmlText(),
|
||||
MotaActionBlocks['fillArc_s'].xmlText(),
|
||||
MotaActionBlocks['strokeArc_s'].xmlText(),
|
||||
MotaActionBlocks['drawImage_s'].xmlText(),
|
||||
MotaActionBlocks['drawImage_1_s'].xmlText(),
|
||||
MotaActionBlocks['drawIcon_s'].xmlText(),
|
||||
@ -217,20 +219,20 @@ editor_blockly = function () {
|
||||
],
|
||||
'值块':[
|
||||
MotaActionBlocks['setValue_s'].xmlText([
|
||||
MotaActionBlocks['idString_1_e'].xmlText(['status','生命']), '=', '', false
|
||||
MotaActionBlocks['idIdList_e'].xmlText(['status','生命']), '=', '', false
|
||||
]),
|
||||
MotaActionBlocks['expression_arithmetic_0'].xmlText(),
|
||||
MotaActionBlocks['evFlag_e'].xmlText(),
|
||||
MotaActionBlocks['evTemp_e'].xmlText(),
|
||||
MotaActionBlocks['idFlag_e'].xmlText(),
|
||||
MotaActionBlocks['idTemp_e'].xmlText(),
|
||||
MotaActionBlocks['negate_e'].xmlText(),
|
||||
MotaActionBlocks['bool_e'].xmlText(),
|
||||
MotaActionBlocks['idString_e'].xmlText(),
|
||||
MotaActionBlocks['idString_1_e'].xmlText(),
|
||||
MotaActionBlocks['idString_2_e'].xmlText(),
|
||||
MotaActionBlocks['idString_3_e'].xmlText(),
|
||||
MotaActionBlocks['idString_4_e'].xmlText(),
|
||||
MotaActionBlocks['idString_5_e'].xmlText(),
|
||||
MotaActionBlocks['idString_6_e'].xmlText(),
|
||||
MotaActionBlocks['idIdList_e'].xmlText(),
|
||||
MotaActionBlocks['idFixedList_e'].xmlText(),
|
||||
MotaActionBlocks['enemyattr_e'].xmlText(),
|
||||
MotaActionBlocks['blockId_e'].xmlText(),
|
||||
MotaActionBlocks['blockCls_e'].xmlText(),
|
||||
MotaActionBlocks['equip_e'].xmlText(),
|
||||
MotaActionBlocks['evalString_e'].xmlText(),
|
||||
],
|
||||
'常见事件模板':[
|
||||
@ -398,22 +400,22 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
}
|
||||
if(editor_blockly.workspace.topBlocks_.length>=2){
|
||||
codeAreaHL.setValue('入口方块只能有一个');
|
||||
editor_blockly.setValue('入口方块只能有一个');
|
||||
return;
|
||||
}
|
||||
var eventType = document.getElementById('entryType').value;
|
||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||
if(blockType!==eventType+'_m'){
|
||||
codeAreaHL.setValue('入口方块类型错误');
|
||||
editor_blockly.setValue('入口方块类型错误');
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\(i|c|d|e|z)/g, '\\\\\\\\$1');
|
||||
codeAreaHL.setValue(code);
|
||||
editor_blockly.setValue(code);
|
||||
} catch (error) {
|
||||
codeAreaHL.setValue(String(error));
|
||||
editor_blockly.setValue(String(error));
|
||||
if (error instanceof OmitedError){
|
||||
var blockName = error.blockName;
|
||||
var varName = error.varName;
|
||||
@ -529,13 +531,19 @@ function omitedcheckUpdateFunction(event) {
|
||||
xhr.open('GET', '_server/MotaAction.g4', true);
|
||||
xhr.send(null);
|
||||
|
||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||
var codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
lineWrapping: true,
|
||||
continueComments: "Enter",
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||
});
|
||||
codeAreaHL.on('changes', function () {
|
||||
editor_blockly.highlightParse(!changeFromBlockly);
|
||||
changeFromBlockly = false;
|
||||
});
|
||||
var changeFromBlockly = false;
|
||||
var shouldNotifyParse = false;
|
||||
|
||||
editor_blockly.showXML = function () {
|
||||
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
||||
@ -561,6 +569,11 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
}
|
||||
|
||||
editor_blockly.setValue = function (value) {
|
||||
changeFromBlockly = true;
|
||||
codeAreaHL.setValue(value);
|
||||
}
|
||||
|
||||
editor_blockly.parse = function () {
|
||||
MotaActionFunctions.parse(
|
||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
||||
@ -580,7 +593,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
var type = args.type;
|
||||
if (!type) return false;
|
||||
editor_blockly.id = id_;
|
||||
codeAreaHL.setValue(input.value);
|
||||
editor_blockly.setValue(input.value);
|
||||
document.getElementById('entryType').value = type;
|
||||
editor_blockly.parse();
|
||||
editor_blockly.show();
|
||||
@ -604,6 +617,13 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
}
|
||||
|
||||
var blocklyParseBtn = document.getElementById('blocklyParse');
|
||||
editor_blockly.highlightParse = function (shouldHighLight) {
|
||||
if (shouldNotifyParse == shouldHighLight) return;
|
||||
shouldNotifyParse = shouldHighLight;
|
||||
blocklyParseBtn.style.background = shouldNotifyParse ? '#FFCCAA' : 'unset';
|
||||
}
|
||||
|
||||
editor_blockly.cancel = function () {
|
||||
editor_blockly.id = '';
|
||||
editor_blockly.hide();
|
||||
@ -614,15 +634,19 @@ function omitedcheckUpdateFunction(event) {
|
||||
editor_blockly.id = '';
|
||||
return;
|
||||
}
|
||||
if (shouldNotifyParse) {
|
||||
alert('你尚未解析修改后的内容,请进行解析或放弃操作');
|
||||
return;
|
||||
}
|
||||
if(editor_blockly.workspace.topBlocks_.length>=2){
|
||||
codeAreaHL.setValue('入口方块只能有一个');
|
||||
editor_blockly.setValue('入口方块只能有一个');
|
||||
return;
|
||||
}
|
||||
var eventType = document.getElementById('entryType').value;
|
||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||
if(blockType!==eventType+'_m'){
|
||||
codeAreaHL.setValue('入口方块类型错误');
|
||||
editor_blockly.setValue('入口方块类型错误');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -684,7 +708,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
var types = [
|
||||
"previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s",
|
||||
"fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s",
|
||||
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s",
|
||||
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillEllipse_s", "strokeEllipse_s", "fillArc_s", "strokeArc_s",
|
||||
"drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s",
|
||||
"waitContext_2"
|
||||
];
|
||||
@ -826,9 +850,9 @@ function omitedcheckUpdateFunction(event) {
|
||||
|
||||
// id: [x, y, floorId, forceFloor]
|
||||
var selectPointBlocks = {
|
||||
"changeFloor_m": ["Number_0", "Number_1", "IdString_0", true],
|
||||
"changeFloor_m": ["PosString_0", "PosString_1", "IdString_0", true],
|
||||
"jumpHero_s": ["PosString_0", "PosString_1"],
|
||||
"changeFloor_s": ["Number_0", "Number_1", "IdString_0", true],
|
||||
"changeFloor_s": ["PosString_0", "PosString_1", "IdString_0", true],
|
||||
"changePos_s": ["PosString_0", "PosString_1"],
|
||||
"battle_1_s": ["PosString_0", "PosString_1"],
|
||||
"openDoor_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
@ -1011,7 +1035,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
|
||||
// 对怪物ID提供补全
|
||||
if ((type == 'idString_3_e' || type == 'battle_s' || type == 'setEnemy_s') && name == 'IdString_0') {
|
||||
if ((type == 'enemyattr_e' || type == 'battle_s' || type == 'setEnemy_s') && name == 'IdString_0') {
|
||||
return filter(allEnemys, content);
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ editor_listen_wrapper = function (editor) {
|
||||
editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click
|
||||
|
||||
editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click;
|
||||
editor.dom.lastUsed.oncontextmenu = function (e) { e.preventDefault(); }
|
||||
editor.dom.clearLastUsedBtn.onclick = editor.uifunctions.clearLastUsedBtn_click;
|
||||
editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange;
|
||||
|
||||
|
||||
@ -257,7 +257,17 @@ 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}));
|
||||
var found = false;
|
||||
editor.uivalues.lastUsed.forEach(function (one) {
|
||||
if (one.id == editor.info.id) {
|
||||
found = true;
|
||||
one.recent = new Date().getTime();
|
||||
one.frequent = (one.frequent || 0) + 1;
|
||||
}
|
||||
})
|
||||
if (!found) {
|
||||
editor.uivalues.lastUsed.push(Object.assign({}, editor.info, {recent: new Date().getTime(), frequent: 1}));
|
||||
}
|
||||
editor.config.set("lastUsed", editor.uivalues.lastUsed);
|
||||
}
|
||||
editor.updateMap();
|
||||
@ -781,16 +791,34 @@ editor_mappanel_wrapper = function (editor) {
|
||||
var x = parseInt(px / 32), y = parseInt(py / 32);
|
||||
var index = x + core.__SIZE__ * y;
|
||||
if (index >= editor.uivalues.lastUsed.length) return;
|
||||
editor.setSelectBoxFromInfo(editor.uivalues.lastUsed[index]);
|
||||
return;
|
||||
var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) {
|
||||
if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0);
|
||||
return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0);
|
||||
});
|
||||
|
||||
if (e.button == 2) {
|
||||
lastUsed[index].istop = lastUsed[index].istop ? 0 : 1;
|
||||
printf("已"+(lastUsed[index].istop ? '置顶' : '取消置顶')+"该图块");
|
||||
editor.config.set('lastUsed', editor.uivalues.lastUsed);
|
||||
editor.updateLastUsedMap();
|
||||
return false;
|
||||
}
|
||||
var one = Object.assign({}, lastUsed[index]);
|
||||
delete one['recent'];
|
||||
delete one['frequent'];
|
||||
delete one['istop'];
|
||||
editor.setSelectBoxFromInfo(one);
|
||||
return false;
|
||||
}
|
||||
|
||||
editor.uifunctions.clearLastUsedBtn_click = function () {
|
||||
if (editor.isMobile) return;
|
||||
|
||||
editor.uivalues.lastUsed = [];
|
||||
editor.config.set('lastUsed', []);
|
||||
editor.updateLastUsedMap();
|
||||
|
||||
if (confirm("你确定要清理全部最近使用图块么?\n所有最近使用和最常使用图块(含置顶图块)都将被清除;此过程不可逆!")) {
|
||||
editor.uivalues.lastUsed = [];
|
||||
editor.config.set('lastUsed', []);
|
||||
editor.updateLastUsedMap();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -97,14 +97,12 @@ editor_mode = function (editor) {
|
||||
}
|
||||
|
||||
editor_mode.prototype.onmode = function (mode, callback) {
|
||||
//setTimeout(function(){
|
||||
if (editor_mode.mode != mode) {
|
||||
if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback);
|
||||
if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode);
|
||||
if (mode !== 'save') editor_mode.mode = mode;
|
||||
editor_mode.actionList = [];
|
||||
}
|
||||
//})
|
||||
if (editor_mode.mode != mode) {
|
||||
if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback);
|
||||
if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode);
|
||||
if (mode !== 'save') editor_mode.mode = mode;
|
||||
editor_mode.actionList = [];
|
||||
}
|
||||
}
|
||||
|
||||
editor_mode.prototype.showMode = function (mode) {
|
||||
|
||||
@ -27,7 +27,8 @@ editor_table_wrapper = function (editor) {
|
||||
return /* html */`<textarea spellcheck='false'>${JSON.stringify(value, null, indent || 0)}</textarea>\n`
|
||||
}
|
||||
editor_table.prototype.checkboxSet = function (value, keys, prefixStrings) {
|
||||
if (!(value instanceof Array)) value = [];
|
||||
if (value == null) value = [];
|
||||
if (!(value instanceof Array)) value = [value];
|
||||
keys=Array.from(keys)
|
||||
prefixStrings=Array.from(prefixStrings)
|
||||
for (var index = 0; index < value.length; index++) {
|
||||
@ -224,8 +225,10 @@ editor_table_wrapper = function (editor) {
|
||||
|
||||
var listen = function (guids) {
|
||||
// 每个叶节点的事件绑定
|
||||
var tableid = editor.util.guid();
|
||||
editor.mode.currentTable=tableid;
|
||||
guids.forEach(function (guid) {
|
||||
editor.table.guidListen(guid, obj, commentObj)
|
||||
editor.table.guidListen(guid, tableid, obj, commentObj)
|
||||
});
|
||||
}
|
||||
return { "HTML": outstr.join(''), "guids": guids, "listen": listen };
|
||||
@ -309,7 +312,7 @@ editor_table_wrapper = function (editor) {
|
||||
* 监听一个guid对应的表格项
|
||||
* @param {String} guid
|
||||
*/
|
||||
editor_table.prototype.guidListen = function (guid, obj, commentObj) {
|
||||
editor_table.prototype.guidListen = function (guid, tableid, obj, commentObj) {
|
||||
// tr>td[title=field]
|
||||
// >td[title=comment,cobj=cobj:json]
|
||||
// >td>div>input[value=thiseval]
|
||||
@ -318,6 +321,7 @@ editor_table_wrapper = function (editor) {
|
||||
var field = thisTr.children[0].getAttribute('title');
|
||||
var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj'));
|
||||
var modeNode = thisTr.parentNode;
|
||||
thisTr.setAttribute('tableid',tableid)
|
||||
while (!editor_mode._ids.hasOwnProperty(modeNode.getAttribute('id'))) {
|
||||
modeNode = modeNode.parentNode;
|
||||
}
|
||||
@ -341,6 +345,7 @@ editor_table_wrapper = function (editor) {
|
||||
*/
|
||||
editor_table.prototype.onchange = function (guid, obj, commentObj, thisTr, input, field, cobj, modeNode) {
|
||||
editor_mode.onmode(editor_mode._ids[modeNode.getAttribute('id')]);
|
||||
if (editor.mode.currentTable!=thisTr.getAttribute('tableid')) return;
|
||||
var thiseval = null;
|
||||
if (input.checked != null) input.value = input.checked;
|
||||
try {
|
||||
|
||||
@ -792,8 +792,10 @@ editor_ui_wrapper = function (editor) {
|
||||
}
|
||||
// 试听音频
|
||||
if (one.endsWith('.mp3') || one.endsWith('.wmv') || one.endsWith('.ogg') || one.endsWith('.wav')) {
|
||||
html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>试听</button>";
|
||||
html += '<br style="display:none"/><audio controls preload="none" src="'+directory+one+'" style="display:none; max-width: 100%"></audio>';
|
||||
html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>";
|
||||
html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/>
|
||||
<audio preload="none" src="${directory+one}" ontimeupdate="editor.uievent._previewMaterialAudio_onTimeUpdate(this)"></audio>
|
||||
<progress value="0" max="1" style="display:none; width:100%" onclick="editor.uievent._previewMaterialAudio_seek(this, event)"></progress>`;
|
||||
}
|
||||
html += '<br/>';
|
||||
});
|
||||
@ -824,19 +826,41 @@ editor_ui_wrapper = function (editor) {
|
||||
}
|
||||
|
||||
uievent._previewMaterialAudio = function (button) {
|
||||
var br = button.nextElementSibling;
|
||||
var span = button.nextElementSibling;
|
||||
var br = span.nextElementSibling;
|
||||
var audio = br.nextElementSibling;
|
||||
var progress = audio.nextElementSibling;
|
||||
if (br.style.display == 'none') {
|
||||
button.innerText = '折叠';
|
||||
button.innerText = '暂停';
|
||||
br.style.display = 'block';
|
||||
audio.style.display = 'block';
|
||||
progress.style.display = 'block';
|
||||
span.style.display = 'inline';
|
||||
audio.play();
|
||||
} else {
|
||||
button.innerText = '试听';
|
||||
button.innerText = '播放';
|
||||
br.style.display = 'none';
|
||||
audio.style.display = 'none';
|
||||
progress.style.display='none';
|
||||
span.style.display = 'none';
|
||||
audio.pause();
|
||||
}
|
||||
}
|
||||
|
||||
uievent._previewMaterialAudio_onTimeUpdate = function (audio) {
|
||||
var _format = function (time) { return parseInt(time/60) + ":" + core.setTwoDigits(parseInt(time) % 60); }
|
||||
if (audio.duration > 0) {
|
||||
audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration);
|
||||
audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration);
|
||||
}
|
||||
}
|
||||
|
||||
uievent._previewMaterialAudio_seek = function (element, event) {
|
||||
var audio = element.previousElementSibling;
|
||||
var value = event.offsetX * element.max / element.offsetWidth;
|
||||
element.setAttribute("value", value);
|
||||
audio.currentTime = audio.duration * value;
|
||||
if (audio.paused) audio.play();
|
||||
}
|
||||
|
||||
editor.constructor.prototype.uievent=uievent;
|
||||
|
||||
}
|
||||
@ -91,6 +91,18 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_docs": "本塔使用音效",
|
||||
"_data": "在此存放所有的SE,和文件名一致 \n音频名不能使用中文,不能带空格或特殊字符;可以直接改名拼音就好"
|
||||
},
|
||||
"fonts": {
|
||||
"_leaf": true,
|
||||
"_type": "material",
|
||||
"_range": "editor.mode.checkUnique(thiseval)",
|
||||
"_directory": "./project/fonts/",
|
||||
"_transform": (function (one) {
|
||||
if (one.endsWith(".ttf")) return one.substring(0, one.lastIndexOf('.'));
|
||||
return null;
|
||||
}).toString(),
|
||||
"_docs": "本塔使用字体",
|
||||
"_data": "在此存放所有可能使用的字体 \n 字体名不能使用中文,不能带空格或特殊字符"
|
||||
},
|
||||
"nameMap": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
|
||||
@ -219,7 +219,7 @@
|
||||
<option value="item">item</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
<!-- 手机端放不下,因此不显示搜索框 -->
|
||||
<div style="display: none">
|
||||
@ -320,7 +320,7 @@
|
||||
|
||||
</div>
|
||||
<div id="mid2" style="display: none">
|
||||
<p style="margin: 10px">最近使用的图块列表: <button id='clearLastUsedBtn'>清除</button></p>
|
||||
<p style="margin: 10px"><span id='lastUsedTitle'></span> <button id='clearLastUsedBtn'>清除</button></p>
|
||||
<div class="map" style="height: 160px; margin-top: 25px" id="lastUsedDiv">
|
||||
<canvas class='gameCanvas' id='lastUsed' width='416' height='160'></canvas>
|
||||
</div>
|
||||
|
||||
@ -215,7 +215,7 @@
|
||||
<option value="item">item</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
<div style="position: relative; display: inline-block; margin-left: 10px">
|
||||
<div class="searchLogo"></div>
|
||||
@ -366,7 +366,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="mid2">
|
||||
<p style="margin: 10px">最近使用的图块列表(Ctrl+滚轮放缩) <button id='clearLastUsedBtn'>清除</button></p>
|
||||
<p style="margin: 10px"><span id='lastUsedTitle'></span><small>(Ctrl+滚轮放缩,右键置顶)</small> <button id='clearLastUsedBtn'>清除</button></p>
|
||||
<div class="map" id="lastUsedDiv">
|
||||
<canvas id='lastUsed' width='416' height='416' style="overflow: hidden"></canvas>
|
||||
</div>
|
||||
|
||||
@ -937,13 +937,6 @@ events.prototype._popEvents = function (current, prefix) {
|
||||
events.prototype.insertAction = function (action, x, y, callback, addToLast) {
|
||||
if (core.hasFlag("__statistics__")) return;
|
||||
if (core.status.gameOver) return;
|
||||
|
||||
// ------ 判定commonEvent
|
||||
var commonEvent = this.getCommonEvent(action);
|
||||
if (commonEvent instanceof Array) {
|
||||
// 将公共事件视为一个do-while事件插入执行,可被break跳出
|
||||
action = [{"type": "dowhile", "condition": "false", "data": commonEvent}];
|
||||
}
|
||||
if (!action) return;
|
||||
|
||||
action = this.precompile(action);
|
||||
@ -960,6 +953,16 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) {
|
||||
}
|
||||
}
|
||||
|
||||
////// 往当前事件列表之前或之后添加一个公共事件 //////
|
||||
events.prototype.insertCommonEvent = function (name, x, y, callback, addToLast) {
|
||||
var commonEvent = this.getCommonEvent(name);
|
||||
if (!commonEvent) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
this.insertAction(commonEvent, x, y, callback, addToLast);
|
||||
}
|
||||
|
||||
////// 获得一个公共事件 //////
|
||||
events.prototype.getCommonEvent = function (name) {
|
||||
if (!name || typeof name !== 'string') return null;
|
||||
@ -1119,11 +1122,14 @@ events.prototype.__precompile_getArray = function () {
|
||||
"setValue", "setEnemy", "setFloor", "setGlobalValue",
|
||||
];
|
||||
var uievents = [
|
||||
"clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "strokeCircle",
|
||||
"drawIcon", "drawSelector", "drawBackground",
|
||||
"clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "fillEllipse", "strokeEllipse",
|
||||
"fillArc", "strokeArc", "drawIcon", "drawSelector", "drawBackground",
|
||||
];
|
||||
var others = {
|
||||
"strokeCircle": ["r"],
|
||||
"fillEllipse": ["a", "b"],
|
||||
"strokeEllipse": ["a", "b"],
|
||||
"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"],
|
||||
@ -1562,7 +1568,7 @@ events.prototype._action_insert = function (data, x, y, prefix) {
|
||||
}
|
||||
if (data.name) { // 公共事件
|
||||
core.setFlag('arg0', data.name);
|
||||
core.insertAction(data.name);
|
||||
core.insertCommonEvent(data.name);
|
||||
}
|
||||
else {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
@ -1632,6 +1638,11 @@ events.prototype._action_setValue = function (data, x, y, prefix) {
|
||||
core.doAction();
|
||||
}
|
||||
|
||||
events.prototype._action_addValue = function (data, x, y, prefix) {
|
||||
data.operator = '+=';
|
||||
this._action_setValue(data, x, y, prefix);
|
||||
}
|
||||
|
||||
events.prototype._action_setEnemy = function (data, x, y, prefix) {
|
||||
this.setEnemy(data.id, data.name, data.value, prefix);
|
||||
core.doAction();
|
||||
@ -2205,11 +2216,19 @@ events.prototype._precompile_strokePolygon = function (data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
events.prototype._action_fillCircle = function (data, x, y, prefix) {
|
||||
events.prototype._action_fillEllipse = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
events.prototype._action_strokeCircle = function (data, x, y, prefix) {
|
||||
events.prototype._action_strokeEllipse = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
events.prototype._action_fillArc = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
events.prototype._action_strokeArc = function (data, x, y, prefix) {
|
||||
this.__action_doUIEvent(data);
|
||||
}
|
||||
|
||||
|
||||
407
libs/loader.js
407
libs/loader.js
@ -25,115 +25,199 @@ loader.prototype._setStartLoadTipText = function (text) {
|
||||
}
|
||||
|
||||
loader.prototype._load = function (callback) {
|
||||
this._loadIcons();
|
||||
this._loadAnimates();
|
||||
this._loadMusic();
|
||||
if (main.useCompress) {
|
||||
this._load_async(callback);
|
||||
} else {
|
||||
this._load_sync(callback);
|
||||
}
|
||||
}
|
||||
|
||||
core.loader._loadMaterialImages(function () {
|
||||
core.loader._loadExtraImages(function () {
|
||||
core.loader._loadAutotiles(function () {
|
||||
core.loader._loadTilesets(callback);
|
||||
loader.prototype._load_sync = function (callback) {
|
||||
this._loadAnimates_sync();
|
||||
this._loadMusic_sync();
|
||||
core.loader._loadMaterials_sync(function () {
|
||||
core.loader._loadExtraImages_sync(function () {
|
||||
core.loader._loadAutotiles_sync(function () {
|
||||
core.loader._loadTilesets_sync(callback);
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadIcons = function () {
|
||||
this.loadImage("materials", "icons.png", function (id, image) {
|
||||
var images = core.splitImage(image);
|
||||
for (var key in core.statusBar.icons) {
|
||||
if (typeof core.statusBar.icons[key] == 'number') {
|
||||
core.statusBar.icons[key] = images[core.statusBar.icons[key]];
|
||||
if (core.statusBar.image[key] != null)
|
||||
core.statusBar.image[key].src = core.statusBar.icons[key].src;
|
||||
loader.prototype._load_async = function (callback) {
|
||||
core.loader._setStartLoadTipText('正在加载资源文件...');
|
||||
var all = {};
|
||||
|
||||
var _makeOnProgress = function (name) {
|
||||
if (!all[name]) all[name] = {loaded: 0, total: 0, finished: false};
|
||||
return function (loaded, total) {
|
||||
all[name].loaded = loaded;
|
||||
all[name].total = total;
|
||||
var allLoaded = 0, allTotal = 0;
|
||||
for (var one in all) {
|
||||
allLoaded += all[one].loaded;
|
||||
allTotal += all[one].total;
|
||||
}
|
||||
if (allTotal > 0) {
|
||||
if (allLoaded == allTotal) {
|
||||
core.loader._setStartLoadTipText("正在处理资源文件... 请稍后...");
|
||||
} else {
|
||||
core.loader._setStartLoadTipText('正在加载资源文件... ' +
|
||||
core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) +
|
||||
" (" + (allLoaded / allTotal * 100).toFixed(2) + "%)");
|
||||
}
|
||||
core.loader._setStartProgressVal(allLoaded / allTotal * 100);
|
||||
}
|
||||
};
|
||||
}
|
||||
var _makeOnFinished = function (name) {
|
||||
return function () {
|
||||
setTimeout(function () {
|
||||
all[name].finished = true;
|
||||
for (var one in all) {
|
||||
if (!all[one].finished) return;
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this._loadAnimates_async(_makeOnProgress('animates'), _makeOnFinished('animates'));
|
||||
this._loadMusic_async(_makeOnProgress('sounds'), _makeOnFinished('sounds'));
|
||||
this._loadMaterials_async(_makeOnProgress('materials'), _makeOnFinished('materials'));
|
||||
this._loadExtraImages_async(_makeOnProgress('images'), _makeOnFinished('images'));
|
||||
this._loadAutotiles_async(_makeOnProgress('autotiles'), _makeOnFinished('autotiles'));
|
||||
this._loadTilesets_async(_makeOnProgress('tilesets'), _makeOnFinished('tilesets'));
|
||||
}
|
||||
|
||||
// ----- 加载资源文件 ------ //
|
||||
|
||||
loader.prototype._loadMaterials_sync = function (callback) {
|
||||
this._setStartLoadTipText("正在加载资源文件...");
|
||||
this.loadImages("materials", core.materials, core.material.images, function () {
|
||||
core.loader._loadMaterials_afterLoad();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadMaterialImages = function (callback) {
|
||||
this._setStartLoadTipText("正在加载资源文件...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, callback);
|
||||
} else {
|
||||
this.loadImages("materials", core.materials, core.material.images, callback);
|
||||
loader.prototype._loadMaterials_async = function (onprogress, onfinished) {
|
||||
this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, onprogress, function () {
|
||||
core.loader._loadMaterials_afterLoad();
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadMaterials_afterLoad = function () {
|
||||
var images = core.splitImage(core.material.images['icons']);
|
||||
for (var key in core.statusBar.icons) {
|
||||
if (typeof core.statusBar.icons[key] == 'number') {
|
||||
core.statusBar.icons[key] = images[core.statusBar.icons[key]];
|
||||
if (core.statusBar.image[key] != null)
|
||||
core.statusBar.image[key].src = core.statusBar.icons[key].src;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loader.prototype._loadExtraImages = function (callback) {
|
||||
// ------ 加载使用的图片 ------ //
|
||||
|
||||
loader.prototype._loadExtraImages_sync = function (callback) {
|
||||
core.material.images.images = {};
|
||||
|
||||
var images = core.clone(core.images);
|
||||
|
||||
this._setStartLoadTipText("正在加载图片文件...");
|
||||
if (main.useCompress) {
|
||||
// Check .gif
|
||||
var gifs = images.filter(function (name) {
|
||||
return name.toLowerCase().endsWith('.gif');
|
||||
});
|
||||
images = images.filter(function (name) {
|
||||
return !name.toLowerCase().endsWith('.gif');
|
||||
});
|
||||
|
||||
this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, callback);
|
||||
gifs.forEach(function (gif) {
|
||||
this.loadImage("images", gif, function (id, image) {
|
||||
if (image != null) {
|
||||
core.material.images.images[gif] = image;
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
} else {
|
||||
this.loadImages("images", images, core.material.images.images, callback);
|
||||
}
|
||||
core.loadImages("images", core.images, core.material.images.images, callback);
|
||||
}
|
||||
|
||||
loader.prototype._loadAutotiles = function (callback) {
|
||||
loader.prototype._loadExtraImages_async = function (onprogress, onfinished) {
|
||||
core.material.images.images = {};
|
||||
var images = core.images;
|
||||
|
||||
// Check .gif
|
||||
var gifs = images.filter(function (name) {
|
||||
return name.toLowerCase().endsWith('.gif');
|
||||
});
|
||||
images = images.filter(function (name) {
|
||||
return !name.toLowerCase().endsWith('.gif');
|
||||
});
|
||||
|
||||
this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, onprogress, onfinished);
|
||||
// gif没有被压缩在zip中,延迟加载...
|
||||
gifs.forEach(function (gif) {
|
||||
this.loadImage("images", gif, function (id, image) {
|
||||
if (image != null) {
|
||||
core.material.images.images[gif] = image;
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
// ------ 加载自动元件 ------ //
|
||||
|
||||
loader.prototype._loadAutotiles_sync = function (callback) {
|
||||
core.material.images.autotile = {};
|
||||
var keys = Object.keys(core.material.icons.autotile);
|
||||
var autotiles = {};
|
||||
var _callback = function () {
|
||||
keys.forEach(function (v) {
|
||||
core.material.images.autotile[v] = autotiles[v];
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
core.maps._makeAutotileEdges();
|
||||
});
|
||||
|
||||
callback();
|
||||
}
|
||||
this._setStartLoadTipText("正在加载自动元件...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, _callback);
|
||||
} else {
|
||||
this.loadImages("autotiles", keys, autotiles, _callback);
|
||||
this.loadImages("autotiles", keys, autotiles, function () {
|
||||
core.loader._loadAutotiles_afterLoad(keys, autotiles);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadAutotiles_async = function (onprogress, onfinished) {
|
||||
core.material.images.autotile = {};
|
||||
var keys = Object.keys(core.material.icons.autotile);
|
||||
var autotiles = {};
|
||||
|
||||
this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, onprogress, function () {
|
||||
core.loader._loadAutotiles_afterLoad(keys, autotiles);
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) {
|
||||
// autotile需要保证顺序
|
||||
keys.forEach(function (v) {
|
||||
core.material.images.autotile[v] = autotiles[v];
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
core.maps._makeAutotileEdges();
|
||||
});
|
||||
}
|
||||
|
||||
// ------ 加载额外素材 ------ //
|
||||
|
||||
loader.prototype._loadTilesets_sync = function (callback) {
|
||||
core.material.images.tilesets = {};
|
||||
this._setStartLoadTipText("正在加载额外素材...");
|
||||
this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, function () {
|
||||
core.loader._loadTilesets_afterLoad();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadTilesets_async = function (onprogress, onfinished) {
|
||||
core.material.images.tilesets = {};
|
||||
this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, onprogress, function () {
|
||||
core.loader._loadTilesets_afterLoad();
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadTilesets_afterLoad = function () {
|
||||
// 检查宽高是32倍数,如果出错在控制台报错
|
||||
for (var imgName in core.material.images.tilesets) {
|
||||
var img = core.material.images.tilesets[imgName];
|
||||
if (img.width % 32 != 0 || img.height % 32 != 0) {
|
||||
console.warn("警告!" + imgName + "的宽或高不是32的倍数!");
|
||||
}
|
||||
if (img.width * img.height > 32 * 32 * 3000) {
|
||||
console.warn("警告!" + imgName + "上的图块素材个数大于3000!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loader.prototype._loadTilesets = function (callback) {
|
||||
core.material.images.tilesets = {};
|
||||
core.tilesets = core.tilesets || [];
|
||||
var _callback = function () {
|
||||
// 检查宽高是32倍数,如果出错在控制台报错
|
||||
for (var imgName in core.material.images.tilesets) {
|
||||
var img = core.material.images.tilesets[imgName];
|
||||
if (img.width % 32 != 0 || img.height % 32 != 0) {
|
||||
console.warn("警告!" + imgName + "的宽或高不是32的倍数!");
|
||||
}
|
||||
if (img.width * img.height > 32 * 32 * 3000) {
|
||||
console.warn("警告!" + imgName + "上的图块素材个数大于3000!");
|
||||
}
|
||||
}
|
||||
callback();
|
||||
}
|
||||
this._setStartLoadTipText("正在加载额外素材...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, _callback);
|
||||
} else {
|
||||
this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, _callback);
|
||||
}
|
||||
}
|
||||
// ------ 实际加载一系列图片 ------ //
|
||||
|
||||
loader.prototype.loadImages = function (dir, names, toSave, callback) {
|
||||
if (!names || names.length == 0) {
|
||||
@ -159,37 +243,6 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
loader.prototype.loadImagesFromZip = function (url, names, toSave, callback) {
|
||||
if (!names || names.length == 0) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
|
||||
core.unzip(url + "?v=" + main.version, function (data) {
|
||||
var cnt = 1;
|
||||
names.forEach(function (name) {
|
||||
var imgName = name;
|
||||
if (imgName.indexOf('.') < 0) imgName += '.png';
|
||||
if (imgName in data) {
|
||||
var img = new Image();
|
||||
var url = URL.createObjectURL(data[imgName]);
|
||||
cnt++;
|
||||
img.onload = function () {
|
||||
cnt--;
|
||||
URL.revokeObjectURL(url);
|
||||
if (cnt == 0 && callback) callback();
|
||||
}
|
||||
img.src = url;
|
||||
toSave[name] = img;
|
||||
}
|
||||
});
|
||||
cnt--;
|
||||
if (cnt == 0 && callback) callback();
|
||||
}, null, false, function (percentage) {
|
||||
core.loader._setStartProgressVal(percentage * 100);
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype.loadImage = function (dir, imgName, callback) {
|
||||
try {
|
||||
var name = imgName;
|
||||
@ -211,28 +264,63 @@ loader.prototype.loadImage = function (dir, imgName, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
loader.prototype._loadAnimates = function () {
|
||||
this._setStartLoadTipText("正在加载动画文件...");
|
||||
if (main.useCompress) {
|
||||
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);
|
||||
if (core.animates.indexOf(t) >= 0)
|
||||
core.loader._loadAnimate(t, animates[name]);
|
||||
}
|
||||
}
|
||||
}, null, true);
|
||||
} else {
|
||||
core.animates.forEach(function (t) {
|
||||
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
||||
core.loader._loadAnimate(t, content);
|
||||
}, function (e) {
|
||||
main.log(e);
|
||||
core.material.animates[t] = null;
|
||||
}, "text/plain; charset=x-user-defined")
|
||||
})
|
||||
// ------ 从zip中加载一系列图片 ------ //
|
||||
|
||||
loader.prototype.loadImagesFromZip = function (url, names, toSave, onprogress, onfinished) {
|
||||
if (!names || names.length == 0) {
|
||||
if (onfinished) onfinished();
|
||||
return;
|
||||
}
|
||||
|
||||
core.unzip(url + "?v=" + main.version, function (data) {
|
||||
var cnt = 1;
|
||||
names.forEach(function (name) {
|
||||
var imgName = name;
|
||||
if (imgName.indexOf('.') < 0) imgName += '.png';
|
||||
if (imgName in data) {
|
||||
var img = new Image();
|
||||
var url = URL.createObjectURL(data[imgName]);
|
||||
cnt++;
|
||||
img.onload = function () {
|
||||
cnt--;
|
||||
URL.revokeObjectURL(url);
|
||||
if (cnt == 0 && onfinished) onfinished();
|
||||
}
|
||||
img.src = url;
|
||||
toSave[name] = img;
|
||||
}
|
||||
});
|
||||
cnt--;
|
||||
if (cnt == 0 && onfinished) onfinished();
|
||||
}, null, false, onprogress);
|
||||
}
|
||||
|
||||
// ------ 加载动画文件 ------ //
|
||||
|
||||
loader.prototype._loadAnimates_sync = function () {
|
||||
this._setStartLoadTipText("正在加载动画文件...");
|
||||
|
||||
core.animates.forEach(function (t) {
|
||||
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
||||
core.loader._loadAnimate(t, content);
|
||||
}, function (e) {
|
||||
main.log(e);
|
||||
core.material.animates[t] = null;
|
||||
}, "text/plain; charset=x-user-defined")
|
||||
});
|
||||
}
|
||||
|
||||
loader.prototype._loadAnimates_async = function (onprogress, onfinished) {
|
||||
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);
|
||||
if (core.animates.indexOf(t) >= 0)
|
||||
core.loader._loadAnimate(t, animates[name]);
|
||||
}
|
||||
}
|
||||
onfinished();
|
||||
}, null, true, onprogress);
|
||||
}
|
||||
|
||||
loader.prototype._loadAnimate = function (name, content) {
|
||||
@ -283,26 +371,36 @@ loader.prototype._loadAnimate = function (name, content) {
|
||||
}
|
||||
}
|
||||
|
||||
////// 加载音频 //////
|
||||
loader.prototype._loadMusic = function () {
|
||||
// ------ 加载音乐和音效 ------ //
|
||||
|
||||
loader.prototype._loadMusic_sync = function () {
|
||||
this._setStartLoadTipText("正在加载音效文件...");
|
||||
core.bgms.forEach(function (t) {
|
||||
core.loader.loadOneMusic(t);
|
||||
});
|
||||
core.sounds.forEach(function (t) {
|
||||
core.loader.loadOneSound(t);
|
||||
});
|
||||
// 直接开始播放
|
||||
core.playBgm(main.startBgm);
|
||||
}
|
||||
|
||||
this._setStartLoadTipText("正在加载音效文件...");
|
||||
if (main.useCompress && core.musicStatus.audioContext) {
|
||||
core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) {
|
||||
loader.prototype._loadMusic_async = function (onprogress, onfinished) {
|
||||
core.bgms.forEach(function (t) {
|
||||
core.loader.loadOneMusic(t);
|
||||
});
|
||||
core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) {
|
||||
// 延迟解析
|
||||
setTimeout(function () {
|
||||
for (var name in data) {
|
||||
if (core.sounds.indexOf(name) >= 0) {
|
||||
core.loader._loadOneSound_decodeData(name, data[name]);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
core.sounds.forEach(function (t) {
|
||||
core.loader.loadOneSound(t);
|
||||
});
|
||||
}
|
||||
onfinished();
|
||||
}, null, false, onprogress);
|
||||
|
||||
// 直接开始播放
|
||||
core.playBgm(main.startBgm);
|
||||
}
|
||||
@ -317,19 +415,12 @@ loader.prototype.loadOneMusic = function (name) {
|
||||
}
|
||||
|
||||
loader.prototype.loadOneSound = function (name) {
|
||||
if (core.musicStatus.audioContext != null) {
|
||||
core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) {
|
||||
core.loader._loadOneSound_decodeData(name, data);
|
||||
}, function (e) {
|
||||
main.log(e);
|
||||
core.material.sounds[name] = null;
|
||||
}, null, 'arraybuffer');
|
||||
}
|
||||
else {
|
||||
var music = new Audio();
|
||||
music.src = 'project/sounds/' + name;
|
||||
core.material.sounds[name] = music;
|
||||
}
|
||||
core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) {
|
||||
core.loader._loadOneSound_decodeData(name, data);
|
||||
}, function (e) {
|
||||
main.log(e);
|
||||
core.material.sounds[name] = null;
|
||||
}, null, 'arraybuffer');
|
||||
}
|
||||
|
||||
loader.prototype._loadOneSound_decodeData = function (name, data) {
|
||||
|
||||
148
libs/ui.js
148
libs/ui.js
@ -134,7 +134,65 @@ ui.prototype.fillRect = function (name, x, y, width, height, style) {
|
||||
|
||||
ui.prototype._uievent_fillRect = function (data) {
|
||||
this._createUIEvent();
|
||||
this.fillRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style);
|
||||
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);
|
||||
} else {
|
||||
this.fillRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style);
|
||||
}
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个矩形的边框 //////
|
||||
ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
this.strokeRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style, data.lineWidth);
|
||||
}
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个圆角矩形 //////
|
||||
ui.prototype.fillRoundRect = function (name, x, y, width, height, radius, style) {
|
||||
if (style) core.setFillStyle(name, style);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) {
|
||||
this._roundRect_buildPath(ctx, x, y, width, height, radius);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个圆角矩形的边框 //////
|
||||
ui.prototype.strokeRoundRect = function (name, x, y, width, height, radius, style, lineWidth) {
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (ctx) {
|
||||
this._roundRect_buildPath(ctx, x, y, width, height, radius);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ui.prototype._roundRect_buildPath = function (ctx, x, y, width, height, radius) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + radius, y);
|
||||
ctx.lineTo(x + width - radius, y);
|
||||
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
|
||||
ctx.lineTo(x + width, y + height - radius);
|
||||
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
|
||||
ctx.lineTo(x + radius, y + height);
|
||||
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
|
||||
ctx.lineTo(x, y + radius);
|
||||
ctx.quadraticCurveTo(x, y, x + radius, y);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个多边形 //////
|
||||
@ -158,19 +216,6 @@ ui.prototype._uievent_fillPolygon = function (data) {
|
||||
this.fillPolygon('uievent', data.nodes, data.style);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个矩形的边框 //////
|
||||
ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) {
|
||||
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);
|
||||
}
|
||||
|
||||
ui.prototype._uievent_strokeRect = function (data) {
|
||||
this._createUIEvent();
|
||||
this.strokeRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style, data.lineWidth);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个多边形的边框 //////
|
||||
ui.prototype.strokePolygon = function (name, nodes, style, lineWidth) {
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
@ -193,35 +238,78 @@ ui.prototype._uievent_strokePolygon = function (data) {
|
||||
this.strokePolygon('uievent', data.nodes, data.style, data.lineWidth);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个圆 //////
|
||||
ui.prototype.fillCircle = function (name, x, y, r, style) {
|
||||
////// 在某个canvas上绘制一个椭圆 //////
|
||||
ui.prototype.fillEllipse = function (name, x, y, a, b, angle, style) {
|
||||
if (style) core.setFillStyle(name, style);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, 2*Math.PI);
|
||||
ctx.ellipse(x, y, a, b, angle, 0, 2*Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
ui.prototype._uievent_fillCircle = function (data) {
|
||||
ui.prototype.fillCircle = function (name, x, y, r, style) {
|
||||
return this.fillEllipse(name, x, y, r, r, 0, style);
|
||||
}
|
||||
|
||||
ui.prototype._uievent_fillEllipse = function (data) {
|
||||
this._createUIEvent();
|
||||
this.fillCircle('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), data.style);
|
||||
this.fillEllipse('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.a),
|
||||
core.calValue(data.b), (core.calValue(data.angle) || 0) * Math.PI / 180, data.style);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一个圆的边框 //////
|
||||
ui.prototype.strokeCircle = function (name, x, y, r, style, lineWidth) {
|
||||
ui.prototype.strokeEllipse = function (name, x, y, a, b, angle, style, lineWidth) {
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, 2*Math.PI);
|
||||
ctx.ellipse(x, y, a, b, angle, 0, 2*Math.PI);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ui.prototype._uievent_strokeCircle = function (data) {
|
||||
ui.prototype.strokeCircle = function (name, x, y, r, style, lineWidth) {
|
||||
return this.strokeEllipse(name, x, y, r, r, 0, style, lineWidth);
|
||||
}
|
||||
|
||||
ui.prototype._uievent_strokeEllipse = function (data) {
|
||||
this._createUIEvent();
|
||||
this.strokeCircle('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), data.style, data.lineWidth);
|
||||
this.strokeEllipse('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.a),
|
||||
core.calValue(data.b), (core.calValue(data.angle) || 0) * Math.PI / 180, data.style, data.lineWidth);
|
||||
}
|
||||
|
||||
ui.prototype.fillArc = function (name, x, y, r, start, end, style) {
|
||||
if (style) core.setFillStyle(name, style);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y);
|
||||
ctx.arc(x, y, r, start, end);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
ui.prototype._uievent_fillArc = function (data) {
|
||||
this._createUIEvent();
|
||||
this.fillArc('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r),
|
||||
(core.calValue(data.start) || 0) * Math.PI / 180, (core.calValue(data.end) || 0) * Math.PI / 180, data.style);
|
||||
}
|
||||
|
||||
ui.prototype.strokeArc = function (name, x, y, r, start, end, style, lineWidth) {
|
||||
if (style) core.setStrokeStyle(name, style);
|
||||
if (lineWidth) core.setLineWidth(name, lineWidth);
|
||||
var ctx = this.getContextByName(name);
|
||||
if (!ctx) return;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, start, end);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ui.prototype._uievent_strokeArc = function (data) {
|
||||
this._createUIEvent();
|
||||
this.strokeArc('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r),
|
||||
(core.calValue(data.start) || 0) * Math.PI / 180, (core.calValue(data.end) || 0) * Math.PI / 180, data.style, data.lineWidth);
|
||||
}
|
||||
|
||||
////// 在某个canvas上绘制一条线 //////
|
||||
@ -1496,8 +1584,8 @@ ui.prototype._drawChoices_drawChoices = function (choices, isWindowSkin, hPos, v
|
||||
this.drawWindowSelector(core.status.textAttribute.background,
|
||||
this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20, len + 10, 28);
|
||||
else
|
||||
core.strokeRect('ui', this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20,
|
||||
len+10, 28, "#FFD700", 2);
|
||||
core.strokeRoundRect('ui', this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20,
|
||||
len+10, 28, 6, "#FFD700", 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1536,7 +1624,7 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
|
||||
if (isWindowSkin)
|
||||
this.drawWindowSelector(core.status.textAttribute.background, strokeLeft, rect.bottom-35-20, len+10, 28);
|
||||
else
|
||||
core.strokeRect('ui', strokeLeft, rect.bottom-35-20, len+10, 28, "#FFD700", 2);
|
||||
core.strokeRoundRect('ui', strokeLeft, rect.bottom-35-20, len+10, 28, 6, "#FFD700", 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1750,7 +1838,7 @@ ui.prototype._drawBook_drawOne = function (floorId, index, enemy, pageinfo, sele
|
||||
this._drawBook_drawName(index, enemy, top, left, name_width);
|
||||
this._drawBook_drawContent(index, enemy, top, left + name_width);
|
||||
if (selected)
|
||||
core.strokeRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, '#FFD700');
|
||||
core.strokeRoundRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, 10, '#FFD700');
|
||||
}
|
||||
|
||||
ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) {
|
||||
@ -2273,7 +2361,7 @@ ui.prototype._drawToolbox_drawContent = function (info, line, items, page, drawC
|
||||
if (drawCount)
|
||||
core.fillText('ui', core.itemCount(item), 64 * (i % this.HSIZE) + 56, yoffset + 33, '#FFFFFF', this._buildFont(14, true));
|
||||
if (info.selectId == item)
|
||||
core.strokeRect('ui', 64 * (i % this.HSIZE) + 17, yoffset - 4, 40, 40, '#FFD700');
|
||||
core.strokeRoundRect('ui', 64 * (i % this.HSIZE) + 17, yoffset - 4, 40, 40, 6, '#FFD700');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2448,7 +2536,7 @@ ui.prototype._drawEquipbox_drawEquiped = function (info, line) {
|
||||
core.drawImage('ui', core.material.images.items, 0, 32 * icon, 32, 32, offset_image, y, 32, 32);
|
||||
}
|
||||
core.fillText('ui', info.allEquips[i] || "未知", offset_text, y + 27, '#FFFFFF', this._buildFont(16, true))
|
||||
core.strokeRect('ui', offset_image - 4, y - 4, 40, 40, info.index==i?'#FFD700':"#FFFFFF");
|
||||
core.strokeRoundRect('ui', offset_image - 4, y - 4, 40, 40, 6, info.index==i?'#FFD700':"#FFFFFF");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2631,7 +2719,7 @@ ui.prototype.drawKeyBoard = function () {
|
||||
if (isWindowSkin)
|
||||
this.drawWindowSelector(core.status.textAttribute.background, this.HPIXEL + 92, offset - 22, 72, 27);
|
||||
else
|
||||
core.strokeRect('ui', this.HPIXEL + 92, offset - 22, 72, 27, "#FFD700", 2);
|
||||
core.strokeRoundRect('ui', this.HPIXEL + 92, offset - 22, 72, 27, 6, "#FFD700", 2);
|
||||
}
|
||||
|
||||
////// 绘制状态栏 /////
|
||||
|
||||
@ -392,6 +392,12 @@ utils.prototype.setTwoDigits = function (x) {
|
||||
return parseInt(x) < 10 ? "0" + x : x;
|
||||
}
|
||||
|
||||
utils.prototype.formatSize = function (size) {
|
||||
if (size < 1024) return size + 'B';
|
||||
else if (size < 1024 * 1024) return (size/1024).toFixed(2) + "KB";
|
||||
else return (size/1024/1024).toFixed(2) + "MB";
|
||||
}
|
||||
|
||||
utils.prototype.formatBigNumber = function (x, onMap) {
|
||||
x = Math.floor(parseFloat(x));
|
||||
if (!core.isset(x)) return '???';
|
||||
@ -1227,7 +1233,7 @@ utils.prototype.http = function (type, url, formData, success, error, mimeType,
|
||||
};
|
||||
xhr.onprogress = function (e) {
|
||||
if (e.lengthComputable) {
|
||||
if (onprogress) onprogress(e.loaded / e.total);
|
||||
if (onprogress) onprogress(e.loaded, e.total);
|
||||
}
|
||||
}
|
||||
xhr.onabort = function () {
|
||||
|
||||
16
main.js
16
main.js
@ -85,7 +85,7 @@ function main() {
|
||||
'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events', 'plugins'
|
||||
];
|
||||
this.materials = [
|
||||
'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48'
|
||||
'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48', 'icons'
|
||||
];
|
||||
|
||||
this.statusBar = {
|
||||
@ -215,6 +215,7 @@ main.prototype.init = function (mode, callback) {
|
||||
main.dom.levelChooseButtons.appendChild(span);
|
||||
});
|
||||
main.createOnChoiceAnimation();
|
||||
main.importFonts(main.fonts);
|
||||
|
||||
main.loadJs('libs', main.loadList, function () {
|
||||
main.core = core;
|
||||
@ -371,6 +372,19 @@ main.prototype.selectButton = function (index) {
|
||||
}
|
||||
}
|
||||
|
||||
////// 创建字体 //////
|
||||
main.prototype.importFonts = function (fonts) {
|
||||
if (!(fonts instanceof Array) || fonts.length == 0) return;
|
||||
var style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
var html = '';
|
||||
fonts.forEach(function (font) {
|
||||
html += '@font-face { font-family: "'+font+'"; src: url("project/fonts/'+font+'.ttf") format("truetype")';
|
||||
});
|
||||
style.innerHTML = html;
|
||||
document.body.appendChild(style);
|
||||
}
|
||||
|
||||
main.prototype.listen = function () {
|
||||
|
||||
////// 窗口大小变化时 //////
|
||||
|
||||
@ -36,6 +36,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"bomb.mp3",
|
||||
"centerFly.mp3"
|
||||
],
|
||||
"fonts": [],
|
||||
"nameMap": {
|
||||
"背景图.jpg": "bg.jpg",
|
||||
"背景音乐.mp3": "bgm.mp3"
|
||||
|
||||
@ -67,7 +67,10 @@ def static_file(path):
|
||||
if not os.path.isfile(path):
|
||||
abort(404)
|
||||
return None
|
||||
return Response(get_file(path), mimetype = get_mimetype(path))
|
||||
mimetype = get_mimetype(path)
|
||||
response = Response(get_file(path), mimetype = mimetype)
|
||||
if mimetype.startswith('audio/'): response.headers["Accept-Ranges"] = "bytes"
|
||||
return response
|
||||
|
||||
def process_request():
|
||||
data = request.get_data() # str in py2 and bytes in py3
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
(已完成!) 动画/音乐/音效自动补全
|
||||
(已完成!) 重构全局商店!
|
||||
(已完成!) 读档时色调数据丢失
|
||||
圆角边框
|
||||
(已完成!) 圆角边框
|
||||
像素高分辨率问题
|
||||
(已完成!) 道具效果优化,删除部分道具相关的开关
|
||||
(已完成!) 素材列表选择
|
||||
@ -51,6 +51,12 @@
|
||||
地图拉框选择复制剪切删除
|
||||
(已完成!) 素材替换
|
||||
大屏幕下放大游戏界面
|
||||
(已完成!) 最近使用/最常使用的图块
|
||||
(已完成!) loader并行加载
|
||||
合并items.js
|
||||
(已完成!) 增加fonts目录,全塔属性增加fonts引用
|
||||
(已完成!) 右边框输入完后解析按钮高亮
|
||||
32x48的门
|
||||
|
||||
-------------
|
||||
|
||||
@ -129,7 +135,7 @@
|
||||
70. “显隐勇士”事件指令希望加个淡入淡出时间参数
|
||||
(不处理,请用等待事件) 1. 希望给core.drawTip()和core.playSound()出个同步版本,目前只有异步版本,后者如果要模拟同步就得绑在一个透明动画上
|
||||
(已完成!) 72. “绘制描边文本”事件希望加一个“描边颜色”参数,目前只能描黑边
|
||||
73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度
|
||||
(已完成!) 73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度
|
||||
(已完成!) 74. “设置画布属性”的基准线建议增加'hanging'和'ideographic'这两种模式
|
||||
(已完成!) 75. 建议修复“绘制多行文本”时行距比字号大不太多会导致各行下缘丢失的bug(加大行距又会导致第一行的纵坐标难以估计),此bug在道具商店和1.3倍行距英文看的很明显
|
||||
(已完成!) 76. (来自群友)建议给第一代全局商店像“显示选择项”一样提供图标、颜色和出现条件
|
||||
|
||||
91
v266-v2.7接档说明
Normal file
91
v266-v2.7接档说明
Normal file
@ -0,0 +1,91 @@
|
||||
V2.6.6 -> V2.7 接档说明:
|
||||
|
||||
此版本仅可接档【地图】,【事件】和【怪物数据】。脚本编辑等不可进行接档。
|
||||
|
||||
请严格按照此说明进行每一步操作以避免可能的bug。接档前请做好备份。
|
||||
|
||||
接档准备:
|
||||
- Visual Studio Code
|
||||
- 需要进行接档的V266的样板
|
||||
- 两个全新的V2.7的样板(一个用于接档结果,一个用于抄部分修改后的内容)
|
||||
|
||||
接档步骤:
|
||||
1. 将V266的样板中,【project】目录下的如下文件和文件夹,直接复制并覆盖到V2.7的样板中的project目录下:
|
||||
- animates/
|
||||
- floors/
|
||||
- enemys.js
|
||||
- events.js
|
||||
- icons.js
|
||||
- items.js
|
||||
- maps.js
|
||||
|
||||
2. 将V266样板中,【project/images】目录下的图片,拆分后放入V2.7的对应图片目录下:
|
||||
- 系统默认图片放入materials中
|
||||
- 自动元件放入autotiles中
|
||||
- 额外素材放入tilesets中
|
||||
- 使用到的其他图片放入images中
|
||||
【请注意】hero.png在V2.7请放入images目录(而不是materials目录)
|
||||
|
||||
3. 将V266样板中,【project/sounds】目录下的音乐和音效,分别放入V2.7的bgms和sounds目录。
|
||||
|
||||
4. 使用VSCode直接分别打开V266和V2.7的【project/data.js】,并执行以下操作:
|
||||
- 将【main】一项的全部内容从V2.6.6直接复制到V2.7
|
||||
- 将【firstData】一项中的,【title】,【name】,【floorId】,【hero】直接复制到
|
||||
- 在注册的图片中,请手动补上【hero.png】项
|
||||
- 在【hero】中【name】上方增加 "image": "hero.png"
|
||||
- 在【hero】中【steps】上方新增一项 "followers": []
|
||||
- 将【hero】中的【experience】改成【exp】
|
||||
- 删除【hero】中【items】中的【keys】项
|
||||
请勿覆盖或复制其他内容(例如全塔数值或全局开关),否则可能导致编辑器无法打开。
|
||||
|
||||
5. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/items.js】,并执行以下操作:
|
||||
- 将三色钥匙的cls从"keys"改成"tools",并新增 "hideInToolbox": true
|
||||
- 如下道具的【useItemEffect】和【canUseItemEffect】有所改变,请直接从纯净的V2.7覆盖到你要接档的V2.7:
|
||||
- earthquake, pickaxe, icePickaxe, snow, bigKey, bomb, upFly, downFly
|
||||
- 如果确认你的塔不会使用该道具,可忽略
|
||||
- 黄宝石和生命魔杖增加了【useItemEvent】;如需使用请进行复制
|
||||
|
||||
6. 使用VSCode打开接档后的V2.7的【project/icons.js】,并执行如下操作:
|
||||
- 找到【terrains】中的三色墙和六色门,删除对应的这几行
|
||||
- yellowWall, blueWall, whiteWall, yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor
|
||||
- (在V2.7中,terrains不再保留门的引用,门效果仅由animates决定)
|
||||
- 将【terrains】中的 blueShop-left, blueShop-right, pinkShop-left, pinkShop-right 分别重命名为
|
||||
blueShopLeft, blueShopRight, pinkShopLeft, pinkShopRight
|
||||
|
||||
7. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/maps.js】,并执行以下操作:
|
||||
- 将纯净的V2.7中如下ID的行,直接替换掉要接档的V2.7:
|
||||
- yellowWall, whiteWall, blueWall, blueShopLeft, blueShopRight, pinkShopLeft, pinkShopRight,
|
||||
lavaNet, poisonNet, weakNet, curseNet, yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor,
|
||||
arrowUp, arrowDown, arrowLeft, arrowRight, light
|
||||
- 将所有的 "noPass":false 改成 "canPass":true 原来是 "noPass":true 的请直接删除
|
||||
- V2.7中,不再在图块属性使用noPass,而是全部改成了canPass;请检查此文件的全部noPass是否被替换或删除
|
||||
|
||||
8. 到这一步后已经可以打开编辑器了。
|
||||
- 如果打开编辑器白屏或报错,请检查一下上面是否每个步骤都完成了
|
||||
- 如果还有问题请联系小艾
|
||||
|
||||
9. 在编辑器中,切换到「全塔属性」标签,并进行修改:
|
||||
- V2.7中,全局商店的结构完全重写了,请重新实现一遍
|
||||
- 全塔开关中,是否在状态栏显示XXX改成在同一个方框中
|
||||
- 删除了部分全局数值和全塔开关
|
||||
|
||||
10. 在编辑器中,切换到「脚本编辑」标签,并进行修改:
|
||||
- setInitData已经被删除;移动到了开场剧情的startText中
|
||||
- 删除了afterChangeLight和afterPassNet脚本
|
||||
- 很多函数的实现有所改变,改变较为严重的有:
|
||||
- resetGame, changingFloor, afterBattle, getDamageInfo, saveData, loadData,
|
||||
updateStatusBar, updateCheckBlock, moveOneStep
|
||||
- 修改脚本编辑(例如getDamageInfo)时,请勿直接拿原来的脚本进行覆盖,而是重新对函数进行修改!
|
||||
|
||||
11. 在编辑器中,切换到「插件编写」标签,并重新增加新增的插件插件
|
||||
- 请勿随意修改已有的默认插件
|
||||
|
||||
12. 逐楼层检查firstArrive以及每个点的事件列表;主要事件API变化如下:
|
||||
- 所有的「数值增减」事件已被删除,被数值设置+运算符替代
|
||||
- 编辑器将无法再解析「数值增减」事件(会被解析成自定义事件),但是游戏中仍然可以正确执行
|
||||
- 「隐藏事件」将不再默认删除该点(而只是纯粹的隐藏);请给有需要的「隐藏事件」勾选「同时删除」选项
|
||||
- 「重启当前事件」已经被删除并且无法在游戏中使用。请替换成等价的循环处理或者插入事件
|
||||
- 在V2.7中,所有的experience全部改名exp;请检查所有对经验值进行操作的地方
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user