自绘标题界面居中插件
This commit is contained in:
parent
ea9d47df63
commit
bc7df1fe9b
@ -80,6 +80,12 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
||||||
"_data": "勇士四帧行走动画"
|
"_data": "勇士四帧行走动画"
|
||||||
|
},
|
||||||
|
"startCanvas": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "textarea",
|
||||||
|
"_range": "typeof(thiseval)=='string' || thiseval==null",
|
||||||
|
"_data": "自绘标题界面居中"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj[key]) return obj[key];
|
if (obj[key]) return obj[key];
|
||||||
|
|||||||
@ -452,9 +452,8 @@ actions.prototype._sys_keyUp = function (keyCode, altKey) {
|
|||||||
|
|
||||||
////// 点击(触摸)事件按下时 //////
|
////// 点击(触摸)事件按下时 //////
|
||||||
actions.prototype.ondown = function (loc) {
|
actions.prototype.ondown = function (loc) {
|
||||||
var lx = Math.max(loc.x, 0), ly = Math.max(loc.y, 0);
|
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
|
||||||
var x = parseInt(lx / loc.size), y = parseInt(ly / loc.size);
|
var px = parseInt(loc.x / core.domStyle.scale), py = parseInt(loc.y / core.domStyle.scale);
|
||||||
var px = parseInt(lx / core.domStyle.scale), py = parseInt(ly / core.domStyle.scale);
|
|
||||||
this.doRegisteredAction('ondown', x, y, px, py);
|
this.doRegisteredAction('ondown', x, y, px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +627,7 @@ actions.prototype._getClickLoc = function (x, y) {
|
|||||||
|
|
||||||
var left = core.dom.gameGroup.offsetLeft + statusBar.x;
|
var left = core.dom.gameGroup.offsetLeft + statusBar.x;
|
||||||
var top = core.dom.gameGroup.offsetTop + statusBar.y;
|
var top = core.dom.gameGroup.offsetTop + statusBar.y;
|
||||||
var loc = {'x': x - left, 'y': y - top, 'size': size};
|
var loc = {'x': Math.max(x - left), 'y': Math.max(y - top, 0), 'size': size};
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,7 +880,7 @@ actions.prototype.onStatusBarClick = function (e) {
|
|||||||
var left = core.dom.gameGroup.offsetLeft + 3;
|
var left = core.dom.gameGroup.offsetLeft + 3;
|
||||||
var top = core.dom.gameGroup.offsetTop + 3;
|
var top = core.dom.gameGroup.offsetTop + 3;
|
||||||
var px = parseInt((e.clientX - left) / core.domStyle.scale), py = parseInt((e.clientY - top) / core.domStyle.scale);
|
var px = parseInt((e.clientX - left) / core.domStyle.scale), py = parseInt((e.clientY - top) / core.domStyle.scale);
|
||||||
return this.doRegisteredAction('onStatusBarClick', px, py);
|
return this.doRegisteredAction('onStatusBarClick', Math.max(px, 0), Math.max(py, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.prototype._sys_onStatusBarClick = function (px, py, vertical) {
|
actions.prototype._sys_onStatusBarClick = function (px, py, vertical) {
|
||||||
|
|||||||
346
project/data.js
346
project/data.js
@ -146,86 +146,258 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
|||||||
"text": "也可以直接切换到其他楼层(比如某个开始剧情楼层)进行操作。"
|
"text": "也可以直接切换到其他楼层(比如某个开始剧情楼层)进行操作。"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "showImage",
|
"type": "previewUI",
|
||||||
"code": 1,
|
"action": [
|
||||||
"image": "bg.jpg",
|
{
|
||||||
"loc": [
|
"type": "fillRect",
|
||||||
0,
|
"x": 0,
|
||||||
0
|
"y": 0,
|
||||||
],
|
"width": "core.__PIXELS__",
|
||||||
"opacity": 1,
|
"height": "core.__PIXELS__",
|
||||||
"time": 0
|
"style": [
|
||||||
|
82,
|
||||||
|
82,
|
||||||
|
82,
|
||||||
|
1
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "setAttribute",
|
||||||
|
"align": "center"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fillBoldText",
|
||||||
|
"x": "core.__PIXELS__ / 2",
|
||||||
|
"y": 80,
|
||||||
|
"style": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"strokeStyle": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"font": "bold 40px Verdana",
|
||||||
|
"text": "${core.firstData.title}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "setValue",
|
||||||
|
"name": "flag:selection",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "在右下方自绘一个对话框进行显示选择项"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "previewUI",
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "fillRect",
|
||||||
|
"x": 230,
|
||||||
|
"y": 250,
|
||||||
|
"width": 150,
|
||||||
|
"height": 142,
|
||||||
|
"radius": 10,
|
||||||
|
"style": [
|
||||||
|
50,
|
||||||
|
54,
|
||||||
|
159,
|
||||||
|
0.85
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "strokeRect",
|
||||||
|
"x": 230,
|
||||||
|
"y": 250,
|
||||||
|
"width": 150,
|
||||||
|
"height": 142,
|
||||||
|
"radius": 10,
|
||||||
|
"style": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"lineWidth": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fillBoldText",
|
||||||
|
"x": 305,
|
||||||
|
"y": 290,
|
||||||
|
"style": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"font": "bold 25px Verdana",
|
||||||
|
"text": "开始游戏"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fillBoldText",
|
||||||
|
"x": 305,
|
||||||
|
"y": 330,
|
||||||
|
"font": "bold 25px Verdana",
|
||||||
|
"text": "读取存档"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fillBoldText",
|
||||||
|
"x": 305,
|
||||||
|
"y": 370,
|
||||||
|
"font": "bold 25px Verdana",
|
||||||
|
"text": "回放录像"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "while",
|
"type": "while",
|
||||||
"condition": "1",
|
"condition": "1",
|
||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "drawSelector",
|
||||||
"text": "给用户提供选择项,这里简单的使用了choices事件"
|
"image": "winskin.png",
|
||||||
|
"code": 1,
|
||||||
|
"x": 245,
|
||||||
|
"y": "261 + 40*flag:selection",
|
||||||
|
"width": 120,
|
||||||
|
"height": 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "wait",
|
||||||
"text": "也可以贴按钮图然后使用等待操作来完成"
|
"data": [
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "choices",
|
|
||||||
"choices": [
|
|
||||||
{
|
{
|
||||||
"text": "开始游戏",
|
"case": "keyboard",
|
||||||
|
"keycode": "13,32",
|
||||||
|
"break": true,
|
||||||
"action": [
|
"action": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "switch",
|
||||||
"text": "检查bgm状态,下同"
|
"condition": "flag:selection",
|
||||||
},
|
"caseList": [
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"function": "function(){\ncore.control.checkBgm()\n}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "if",
|
|
||||||
"condition": "main.levelChoose.length == 0",
|
|
||||||
"true": [
|
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"case": "0",
|
||||||
"text": "直接开始游戏"
|
"action": [
|
||||||
}
|
{
|
||||||
],
|
"type": "comment",
|
||||||
"false": [
|
"text": "在“开始游戏”确定"
|
||||||
{
|
},
|
||||||
"type": "comment",
|
{
|
||||||
"text": "动态生成难度选择项"
|
"type": "break",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "function",
|
"case": "1",
|
||||||
"function": "function(){\nvar choices = [];\nmain.levelChoose.forEach(function (one) {\n\tchoices.push({\n\t\t\"text\": one.title || '',\n\t\t\"action\": [\n\t\t\t{ \"type\": \"function\", \"function\": \"function() { core.status.hard = '\" + (one.name || '') + \"'; }\" }\n\t\t]\n\t});\n})\ncore.insertAction({ \"type\": \"choices\", \"choices\": choices });\n}"
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "在“读取存档”确定"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "callLoad"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": "2",
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "在“回放录像”确定"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "if",
|
||||||
|
"condition": "(!core.isReplaying())",
|
||||||
|
"true": [
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": "function(){\ncore.chooseReplayFile()\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hideImage",
|
|
||||||
"code": 1,
|
|
||||||
"time": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "comment",
|
|
||||||
"text": "成功选择难度"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "break"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "读取存档",
|
"case": "keyboard",
|
||||||
|
"keycode": "38",
|
||||||
|
"break": true,
|
||||||
"action": [
|
"action": [
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "comment",
|
||||||
"function": "function(){\ncore.control.checkBgm()\n}"
|
"text": "光标上键"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "setValue",
|
||||||
|
"name": "flag:selection",
|
||||||
|
"value": "(flag:selection + 2) % 3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": "keyboard",
|
||||||
|
"keycode": "40",
|
||||||
|
"break": true,
|
||||||
|
"action": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"text": "简单的使用“呼出读档界面”来处理"
|
"text": "光标下键"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "setValue",
|
||||||
|
"name": "flag:selection",
|
||||||
|
"value": "(flag:selection + 1) % 3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": "mouse",
|
||||||
|
"px": [
|
||||||
|
245,
|
||||||
|
365
|
||||||
|
],
|
||||||
|
"py": [
|
||||||
|
261,
|
||||||
|
300
|
||||||
|
],
|
||||||
|
"break": true,
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "点击“开始游戏”"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "break",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": "mouse",
|
||||||
|
"px": [
|
||||||
|
245,
|
||||||
|
365
|
||||||
|
],
|
||||||
|
"py": [
|
||||||
|
301,
|
||||||
|
340
|
||||||
|
],
|
||||||
|
"break": true,
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "点击“读取存档”"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "callLoad"
|
"type": "callLoad"
|
||||||
@ -233,15 +405,20 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "回放录像",
|
"case": "mouse",
|
||||||
|
"px": [
|
||||||
|
245,
|
||||||
|
365
|
||||||
|
],
|
||||||
|
"py": [
|
||||||
|
341,
|
||||||
|
380
|
||||||
|
],
|
||||||
|
"break": true,
|
||||||
"action": [
|
"action": [
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"function": "function(){\ncore.control.checkBgm()\n}"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"text": "这段代码会弹框选择录像文件"
|
"text": "点击“播放录像”"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "if",
|
"type": "if",
|
||||||
@ -259,9 +436,56 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "setValue",
|
||||||
|
"name": "flag:selection",
|
||||||
|
"value": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "drawSelector",
|
||||||
|
"code": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "clearMap"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": "function(){\ncore.control.checkBgm()\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "if",
|
||||||
|
"condition": "(main.levelChoose.length == 0)",
|
||||||
|
"true": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "没有难度选择:直接开始游戏"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"false": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "难度选择:作为样例,这里只提供了一个显示选择项。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": "function(){\nvar choices = [];\nmain.levelChoose.forEach(function (one) {\n\tchoices.push({\n\t\t\"text\": one.title || '',\n\t\t\"action\": [\n\t\t\t{ \"type\": \"function\", \"function\": \"function() { core.status.hard = '\" + (one.name || '') + \"'; }\" }\n\t\t]\n\t});\n})\ncore.insertAction({ \"type\": \"choices\", \"choices\": choices });\n}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "你也可以仿照上面的样例进行自己创建等待用户操作来处理不同的难度分歧。\n如需自己处理,请设置 core.status.hard \n(例如,自定义js脚本:core.status.hard = 'Easy' )"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "clearMap"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"text": "接下来会执行startText中的事件"
|
"text": "接下来会执行startText中的事件"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "状态栏默认处于隐藏状态;可以使用“显示状态栏”事件进行显示。"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"startText": [
|
"startText": [
|
||||||
|
|||||||
@ -1310,5 +1310,92 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"startCanvas": function () {
|
||||||
|
// 使用本插件可以将自绘的标题界面居中。仅在【标题开启事件化】后才有效。
|
||||||
|
// 由于一些技术性的原因,标题界面事件化无法应用到覆盖状态栏的整个界面。
|
||||||
|
// 这是一个较为妥协的插件,会在自绘标题界面时隐藏状态栏、工具栏和边框,并将画布进行居中。
|
||||||
|
// 本插件仅在全塔属性的 "startCanvas" 生效;进入 "startText" 时将会离开居中状态,回归正常界面。
|
||||||
|
|
||||||
|
// 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
|
||||||
|
var __enable = true;
|
||||||
|
if (!__enable) return;
|
||||||
|
|
||||||
|
// 检查【标题开启事件化】是否开启
|
||||||
|
if (!core.flags.startUsingCanvas || main.mode != 'play') return;
|
||||||
|
|
||||||
|
|
||||||
|
var _isTitleCanvasEnabled = false;
|
||||||
|
var _getClickLoc = core.actions._getClickLoc;
|
||||||
|
this._setTitleCanvas = function () {
|
||||||
|
if (_isTitleCanvasEnabled) return;
|
||||||
|
_isTitleCanvasEnabled = true;
|
||||||
|
|
||||||
|
// 禁用窗口resize
|
||||||
|
window.onresize = function () {};
|
||||||
|
core.resize = function () {}
|
||||||
|
|
||||||
|
// 隐藏状态栏
|
||||||
|
core.dom.statusBar.style.display = 'none';
|
||||||
|
core.dom.statusCanvas.style.display = 'none';
|
||||||
|
core.dom.toolBar.style.display = 'none';
|
||||||
|
// 居中画布
|
||||||
|
if (core.domStyle.isVertical) {
|
||||||
|
core.dom.gameDraw.style.top =
|
||||||
|
(parseInt(core.dom.gameGroup.style.height) - parseInt(core.dom.gameDraw.style.height)) / 2 + "px";
|
||||||
|
} else {
|
||||||
|
core.dom.gameDraw.style.right =
|
||||||
|
(parseInt(core.dom.gameGroup.style.width) - parseInt(core.dom.gameDraw.style.width)) / 2 + "px";
|
||||||
|
}
|
||||||
|
core.dom.gameDraw.style.border = '3px transparent solid';
|
||||||
|
core.actions._getClickLoc = function (x, y) {
|
||||||
|
var left = core.dom.gameGroup.offsetLeft + core.dom.gameDraw.offsetLeft + 3;
|
||||||
|
var top = core.dom.gameGroup.offsetTop + core.dom.gameDraw.offsetTop + 3;
|
||||||
|
var loc = { 'x': Math.max(x - left, 0), 'y': Math.max(y - top, 0), 'size': 32 * core.domStyle.scale };
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._resetTitleCanvas = function () {
|
||||||
|
if (!_isTitleCanvasEnabled) return;
|
||||||
|
_isTitleCanvasEnabled = false;
|
||||||
|
window.onresize = function () { try { main.core.resize(); } catch (e) { main.log(e); } }
|
||||||
|
core.resize = function () { return core.control.resize(); }
|
||||||
|
core.resize();
|
||||||
|
core.actions._getClickLoc = _getClickLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复写“开始游戏”
|
||||||
|
core.events._startGame_start = function (hard, seed, route, callback) {
|
||||||
|
console.log('开始游戏');
|
||||||
|
core.resetGame(core.firstData.hero, hard, null, core.cloneArray(core.initStatus.maps));
|
||||||
|
core.setHeroLoc('x', -1);
|
||||||
|
core.setHeroLoc('y', -1);
|
||||||
|
|
||||||
|
if (seed != null) {
|
||||||
|
core.setFlag('__seed__', seed);
|
||||||
|
core.setFlag('__rand__', seed);
|
||||||
|
} else core.utils.__init_seed();
|
||||||
|
|
||||||
|
core.clearStatusBar();
|
||||||
|
core.plugin._setTitleCanvas();
|
||||||
|
|
||||||
|
var todo = [];
|
||||||
|
core.hideStatusBar();
|
||||||
|
core.push(todo, core.firstData.startCanvas);
|
||||||
|
core.push(todo, { "type": "function", "function": "function() { core.plugin._resetTitleCanvas(); core.events._startGame_setHard(); }" })
|
||||||
|
core.push(todo, core.firstData.startText);
|
||||||
|
this.insertAction(todo, null, null, function () {
|
||||||
|
core.events._startGame_afterStart(callback);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (route != null) core.startReplay(route);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _loadData = core.control.loadData;
|
||||||
|
core.control.loadData = function (data, callback) {
|
||||||
|
core.plugin._resetTitleCanvas();
|
||||||
|
_loadData.call(core.control, data, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user