feat:新版道具栏隐藏道具

This commit is contained in:
lizhuoyuan 2025-02-11 17:29:24 +08:00
parent cdb26566c8
commit 7828113a5a
8 changed files with 2258 additions and 1637 deletions

View File

@ -106,6 +106,14 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true,
"_docs": "能否使用或装备",
"_data": "当前能否使用或装备该道具仅对cls不为items有效。null表示始终不可使用但可装备"
},
"noBatchUse": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_lint": true,
"_docs": "不可批量使用",
"_data": "该道具是否不允许批量使用true表示不可批量使用"
}
}
},

View File

@ -2699,13 +2699,28 @@ ui.prototype._drawToolbox = function (index) {
}
////// 获得所有应该在道具栏显示的某个类型道具 //////
ui.prototype.getToolboxItems = function (cls) {
if (this.uidata.getToolboxItems) {
return this.uidata.getToolboxItems(cls);
ui.prototype.getToolboxItems = function (cls, showHide) {
let list = Object.keys(core.status.hero.items[cls] || {});;
if (cls === 'all') {
for (let name in core.status.hero.items) {
if (name == "equips") continue;
list = list.concat(Object.keys(core.status.hero.items[name])); // 获取'constants'和'tools'整体的列表
}
if (!showHide) list = list.filter(function (id) {
return !core.material.items[id].hideInToolbox;
})
list = list.sort();
return list;
}
return Object.keys(core.status.hero.items[cls] || {})
.filter(function (id) { return !core.material.items[id].hideInToolbox; })
.sort();
if (this.uidata.getToolboxItems) {
return this.uidata.getToolboxItems(cls, showHide);
}
if (!showHide) list = list.filter(function (id) {
return !core.material.items[id].hideInToolbox;
})
list = list.sort();
return list;
}
ui.prototype._drawToolbox_getInfo = function (index) {

View File

@ -18,3 +18,49 @@ extractBlocks->_mapIntoBlocks->initBlock
cannotOut和cannotIn的关键
箭头还在getBlockByNumber中
首先抽象一下 思考一下顶层设计
ItemBox类
需要的属性当前持有的Item和数量 当前的页数
使用道具时情况会改变所以每次重绘时都需要获取一遍core.status.hero.items然后依据此获取一个列表itemList。根据当前页数(currPage)获取该绘制的内容。
整个道具栏做成一个大按钮还需要属性selectedItem 每次根据selectedItem重绘右侧的物品详细说明
按钮可往前不往后,以防一页的道具全用光会不去
点击时:点左侧 根据位置和itemList和currPage推导处在哪里更新selectedItem更新右侧 左侧是一个大按钮
点下方 左右 currPage
右侧按键:
使用 尝试使用selectedItem
批量使用 新功能
隐藏/显示 修改道具的隐藏属性
显示隐藏 页面级属性 showHidedItem
最高级 MenuPage 名为boxPage
拥有背景和背景中的两个箭头和道具栏|装备栏的字样
按键切换两栏 监听tab等
右下角的×
toolBox 拥有底部两按钮,右侧的一切,中间的大按钮
equipBox 拥有
```js
const itemClsName = {
"constants": "永久道具",
"tools": "消耗道具",
}
const itemNum = 12;
core.initThisEventInfo();
let info = core.status.thisUIEventInfo
info.index = 1;
core.setIndexAndSelect('select');
let ctx =core.canvas.ui;
core.status.thisEventClickArea = [];
let info1 = core.drawBoxBackground(ctx);
info1.itemNum = itemNum;
core.drawItemListbox(ctx, info1.obj);
core.drawToolboxRightbar(ctx, info1);
```

View File

@ -7,7 +7,7 @@ main.floors.MT0=
"canFlyFrom": true,
"canUseQuickShop": true,
"cannotViewMap": false,
"defaultGround": "ground",
"defaultGround": "X10036",
"images": [],
"ratio": 2,
"map": [
@ -16,9 +16,9 @@ main.floors.MT0=
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0,121,121, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@ -28,18 +28,25 @@ main.floors.MT0=
"firstArrive": [],
"parallelDo": "",
"events": {
"6,5": [
"欢迎使用事件编辑器(双击方块可直接预览)"
],
"5,5": [
"欢迎使用事件编辑器(双击方块可直接预览)",
"6,8": [
{
"type": "jumpHero",
"loc": [
0,
0
],
"time": 500
"type": "setValue",
"name": "item:poisonWine",
"value": "2"
},
{
"type": "setValue",
"name": "item:yellowKey",
"value": "99"
},
{
"type": "setValue",
"name": "item:silverCoin",
"value": "999"
},
{
"type": "comment",
"text": "unlockControl"
}
]
},

View File

@ -1,8 +1,8 @@
/// <reference path="../runtime.d.ts" />
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
{
"events": {
"resetGame": function (hero, hard, floorId, maps, values) {
"events": {
"resetGame": function (hero, hard, floorId, maps, values) {
// 重置整个游戏;此函数将在游戏开始时,或者每次读档时最先被调用
// hero勇士信息hard难度floorId当前楼层IDmaps地图信息values全局数值信息
@ -53,7 +53,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 隐藏右下角的音乐按钮
core.dom.musicBtn.style.display = 'none';
},
"win": function (reason, norank, noexit) {
"win": function (reason, norank, noexit) {
// 游戏获胜事件
// 请注意成绩统计时是按照hp进行上传并排名
// 可以先在这里对最终分数进行计算比如将2倍攻击和5倍黄钥匙数量加到分数上
@ -82,7 +82,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
})
});
},
"lose": function (reason) {
"lose": function (reason) {
// 游戏失败事件
core.ui.closePanel();
var replaying = core.isReplaying();
@ -95,7 +95,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
});
})
},
"changingFloor": function (floorId, heroLoc) {
"changingFloor": function (floorId, heroLoc) {
// 正在切换楼层过程中执行的操作;此函数的执行时间是“屏幕完全变黑“的那一刻
// floorId为要切换到的楼层IDheroLoc表示勇士切换到的位置
@ -165,7 +165,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等
},
"afterChangeFloor": function (floorId) {
"afterChangeFloor": function (floorId) {
// 转换楼层结束的事件;此函数会在整个楼层切换完全结束后再执行
// floorId是切换到的楼层
@ -184,7 +184,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
}
},
"flyTo": function (toId, callback) {
"flyTo": function (toId, callback) {
// 楼层传送器的使用从当前楼层飞往toId
// 如果不能飞行请返回false
@ -227,7 +227,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
return true;
},
"beforeBattle": function (enemyId, x, y) {
"beforeBattle": function (enemyId, x, y) {
// 战斗前触发的事件,可以加上一些战前特效(详见下面支援的例子)
// 此函数在“检测能否战斗和自动存档”【之后】执行。如果需要更早的战前事件,请在插件中覆重写 core.events.doSystemEvent 函数。
// 返回true则将继续战斗返回false将不再战斗。
@ -258,7 +258,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
return true;
},
"afterBattle": function (enemyId, x, y) {
"afterBattle": function (enemyId, x, y) {
// 战斗结束后触发的事件
var enemy = core.material.enemys[enemyId];
@ -472,7 +472,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.clearContinueAutomaticRoute();
},
"afterOpenDoor": function (doorId, x, y) {
"afterOpenDoor": function (doorId, x, y) {
// 开一个门后触发的事件
var todo = [];
@ -493,7 +493,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
else
core.clearContinueAutomaticRoute();
},
"afterGetItem": function (itemId, x, y, isGentleClick) {
"afterGetItem": function (itemId, x, y, isGentleClick) {
// 获得一个道具后触发的事件
// itemId获得的道具IDx和y是该道具所在的坐标
// isGentleClick是否是轻按触发的
@ -515,7 +515,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (todo.length > 0) core.insertAction(todo, x, y);
},
"afterPushBox": function () {
"afterPushBox": function () {
// 推箱子后的事件
if (core.searchBlock('box').length == 0) {
// 可以通过if语句来进行开门操作
@ -528,9 +528,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
*/
}
}
},
"enemys": {
"getSpecials": function () {
},
"enemys": {
"getSpecials": function () {
// 获得怪物的特殊属性,每一行定义一个特殊属性。
// 分为五项,第一项为该特殊属性的数字,第二项为特殊属性的名字,第三项为特殊属性的描述
// 第四项为该特殊属性的颜色,可以写十六进制 #RRGGBB 或者 [r,g,b,a] 四元数组
@ -569,7 +569,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
[30, "吸噬", function (enemy) { return ""; }, "#c0ddbb"],
];
},
"getEnemyInfo": function (enemy, hero, x, y, floorId) {
"getEnemyInfo": function (enemy, hero, x, y, floorId) {
// 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用
// 例如:坚固、模仿、仿攻等等
//
@ -692,7 +692,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"guards": guards, // 返回支援情况
};
},
"getDamageInfo": function (enemy, hero, x, y, floorId) {
"getDamageInfo": function (enemy, hero, x, y, floorId) {
// 获得战斗伤害信息(实际伤害计算函数)
//
// 参数说明:
@ -850,9 +850,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"damage": Math.floor(damage)
};
}
},
"actions": {
"onKeyUp": function (keyCode, altKey) {
},
"actions": {
"onKeyUp": function (keyCode, altKey) {
// 键盘按键处理,可以在这里自定义快捷键列表
// keyCode当前按键的keyCode每个键的keyCode自行百度
// altKeyAlt键是否被按下为true代表同时按下了Alt键
@ -1029,7 +1029,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
},
"onStatusBarClick": function (px, py, vertical) {
"onStatusBarClick": function (px, py, vertical) {
// 点击状态栏时触发的事件,仅在自绘状态栏开启时生效
// px和py为点击的像素坐标
// vertical为录像播放过程中的横竖屏信息
@ -1097,9 +1097,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
*/
}
},
"control": {
"saveData": function () {
},
"control": {
"saveData": function () {
// 存档操作,此函数应该返回“具体要存档的内容”
// 差异化存储values
@ -1124,7 +1124,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
return data;
},
"loadData": function (data, callback) {
"loadData": function (data, callback) {
// 读档操作;从存储中读取了内容后的行为
// 重置游戏和路线
@ -1163,7 +1163,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (callback) callback();
});
},
"getStatusLabel": function (name) {
"getStatusLabel": function (name) {
// 返回某个状态英文名的对应中文标签如atk -> 攻击def -> 防御等。
// 请注意此项仅影响 libs/ 下的内容(如绘制怪物手册、数据统计等)
// 自行定义的(比如获得道具效果)中用到的“攻击+3”等需要自己去对应地方修改
@ -1184,7 +1184,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
steps: "步数",
}[name] || name;
},
"triggerDebuff": function (action, type) {
"triggerDebuff": function (action, type) {
// 毒衰咒效果的获得与解除
// action获得还是解除'get'表示获得,'remove'表示解除
// type一个数组表示获得了哪些毒衰咒效果poison, weakcurse
@ -1241,7 +1241,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (success) core.playSound('回血');
}
},
"updateStatusBar": function () {
"updateStatusBar": function () {
// 更新状态栏
// 检查等级
@ -1323,7 +1323,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// updateDamage只能在此处执行更新全地图显伤
core.updateDamage();
},
"getCheckBlock": function (floorId) {
"getCheckBlock": function (floorId) {
// 领域、夹击、阻击等的伤害值计算
floorId = floorId || core.status.floorId;
if (!floorId || !core.status.maps) return;
@ -1563,7 +1563,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
cache: {} // clear cache
};
},
"moveOneStep": function (callback) {
"moveOneStep": function (callback) {
// 勇士每走一步后执行的操作。callback为行走完毕后的回调
// 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。
// 请注意:瞬间移动不会执行该函数。如果要控制能否瞬间移动有三种方法:
@ -1626,7 +1626,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如需强行终止行走可以在这里条件判定:
// core.stopAutomaticRoute();
},
"moveDirectly": function (x, y, ignoreSteps) {
"moveDirectly": function (x, y, ignoreSteps) {
// 瞬间移动x,y为要瞬间移动的点ignoreSteps为减少的步数可能之前已经被计算过
// 返回true代表成功瞬移false代表没有成功瞬移
@ -1664,7 +1664,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
return false;
},
"parallelDo": function (timestamp) {
"parallelDo": function (timestamp) {
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
// 该函数将被系统反复执行每次执行间隔视浏览器或设备性能而定一般约为16.6ms一次
// 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差以毫秒为单位
@ -1681,19 +1681,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
}
}
},
"ui": {
"getToolboxItems": function (cls) {
// 获得道具栏中当前某类型道具的显示项和显示顺序
// cls为道具类型只可能是 tools, constants 和 equips
// 返回一个数组,代表当前某类型道具的显示内容和顺序
// 默认按id升序排列您可以取消下面的注释改为按名称排列
},
"ui": {
"getToolboxItems": function (cls, showHide) {
// 获得道具栏中当前某类型道具的显示项和显示顺序
// cls为道具类型只可能是 tools, constants 和 equips
// 返回一个数组,代表当前某类型道具的显示内容和顺序
// 默认按id升序排列您可以取消下面的注释改为按名称排列
// showHide 是否显示隐藏的道具
return Object.keys(core.status.hero.items[cls] || {})
.filter(function (id) { return !core.material.items[id].hideInToolbox; })
.sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/);
},
"drawStatusBar": function () {
let list = Object.keys(core.status.hero.items[cls] || {});
if (!showHide) list = list.filter(function (id) {
return !core.material.items[id].hideInToolbox;
})
list = list.sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/ );
return list;
},
"drawStatusBar": function () {
// 自定义绘制状态栏需要开启状态栏canvas化
// 如果是非状态栏canvas化直接返回
@ -1796,7 +1800,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
_fillBoldTextWithFontCheck(core.setTwoDigits(core.itemCount('redKey')), 212, 90, '#FF8888');
}
},
"drawStatistics": function () {
"drawStatistics": function () {
// 浏览地图时参与的统计项目
return [
@ -1812,7 +1816,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 在这里可以增加新的ID来进行统计个数只能增加道具ID
];
},
"drawAbout": function () {
"drawAbout": function () {
// 绘制“关于”界面
core.ui.closePanel();
core.lockControl();
@ -1840,5 +1844,5 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// TODO: 写自己的“关于”页面每次增加32像素即可
core.playSound('打开界面');
}
}
}
}

View File

@ -357,7 +357,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"text": "可以查看当前楼层各怪物属性",
"hideInToolbox": true,
"useItemEffect": "core.ui.drawBook(0);",
"canUseItemEffect": "true"
"canUseItemEffect": "true",
"noBatchUse": "true"
},
"fly": {
"cls": "constants",
@ -366,7 +367,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"hideInReplay": true,
"hideInToolbox": true,
"useItemEffect": "core.ui.drawFly(core.floorIds.indexOf(core.status.floorId));",
"canUseItemEffect": "(function () {\n\tif (core.flags.flyNearStair && !core.nearStair()) return false;\n\treturn core.status.maps[core.status.floorId].canFlyFrom;\n})();"
"canUseItemEffect": "(function () {\n\tif (core.flags.flyNearStair && !core.nearStair()) return false;\n\treturn core.status.maps[core.status.floorId].canFlyFrom;\n})();",
"noBatchUse": "true"
},
"coin": {
"cls": "constants",
@ -440,7 +442,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"name": "中心对称飞行器",
"text": "可以飞向当前楼层中心对称的位置",
"useItemEffect": "core.playSound('centerFly.mp3');\ncore.clearMap('hero');\ncore.setHeroLoc('x', core.bigmap.width - 1 - core.getHeroLoc('x'));\ncore.setHeroLoc('y', core.bigmap.height - 1 - core.getHeroLoc('y'));\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
"canUseItemEffect": "(function () {\n\tvar toX = core.bigmap.width - 1 - core.getHeroLoc('x'),\n\t\ttoY = core.bigmap.height - 1 - core.getHeroLoc('y');\n\tvar id = core.getBlockId(toX, toY);\n\treturn id == null;\n})();"
"canUseItemEffect": "(function () {\n\tvar toX = core.bigmap.width - 1 - core.getHeroLoc('x'),\n\t\ttoY = core.bigmap.height - 1 - core.getHeroLoc('y');\n\tvar id = core.getBlockId(toX, toY);\n\treturn id == null;\n})();",
"noBatchUse": "true"
},
"upFly": {
"cls": "tools",
@ -519,9 +522,18 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"canUseItemEffect": "true"
},
"silverCoin": {
"cls": "items",
"cls": "tools",
"name": "新物品",
"canUseItemEffect": "true"
"canUseItemEffect": "true",
"useItemEffect": "core.status.hero.hp += 1;",
"useItemEvent": [
{
"type": "setValue",
"name": "status:hp",
"operator": "+=",
"value": "1"
}
]
},
"orb": {
"cls": "items",
@ -538,7 +550,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"name": "设置",
"canUseItemEffect": "true",
"text": "可以调节设置开关。",
"useItemEffect": "core.plugin.openSetting();"
"useItemEffect": "core.plugin.openSetting();",
"noBatchUse": "true"
},
"redWand": {
"cls": "items",

File diff suppressed because it is too large Load Diff

7
runtime.d.ts vendored
View File

@ -2453,8 +2453,11 @@ interface ui {
/** 绘制楼层传送器 */
drawFly(page?: any): void
/** 获得所有应该在道具栏显示的某个类型道具 */
getToolboxItems(cls: string): string[]
/**
* @param cls
* @param cls
*/
getToolboxItems(cls: 'tools' | 'constants' | 'all', showHide: boolean): string[]
/** 绘制状态栏 */
drawStatusBar(): void