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, "_lint": true,
"_docs": "能否使用或装备", "_docs": "能否使用或装备",
"_data": "当前能否使用或装备该道具仅对cls不为items有效。null表示始终不可使用但可装备" "_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) { ui.prototype.getToolboxItems = function (cls, showHide) {
if (this.uidata.getToolboxItems) { let list = Object.keys(core.status.hero.items[cls] || {});;
return this.uidata.getToolboxItems(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'整体的列表
} }
return Object.keys(core.status.hero.items[cls] || {}) if (!showHide) list = list.filter(function (id) {
.filter(function (id) { return !core.material.items[id].hideInToolbox; }) return !core.material.items[id].hideInToolbox;
.sort(); })
list = list.sort();
return list;
}
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) { ui.prototype._drawToolbox_getInfo = function (index) {

View File

@ -18,3 +18,49 @@ extractBlocks->_mapIntoBlocks->initBlock
cannotOut和cannotIn的关键 cannotOut和cannotIn的关键
箭头还在getBlockByNumber中 箭头还在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, "canFlyFrom": true,
"canUseQuickShop": true, "canUseQuickShop": true,
"cannotViewMap": false, "cannotViewMap": false,
"defaultGround": "ground", "defaultGround": "X10036",
"images": [], "images": [],
"ratio": 2, "ratio": 2,
"map": [ "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, 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, 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], [ 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": [], "firstArrive": [],
"parallelDo": "", "parallelDo": "",
"events": { "events": {
"6,5": [ "6,8": [
"欢迎使用事件编辑器(双击方块可直接预览)"
],
"5,5": [
"欢迎使用事件编辑器(双击方块可直接预览)",
{ {
"type": "jumpHero", "type": "setValue",
"loc": [ "name": "item:poisonWine",
0, "value": "2"
0 },
], {
"time": 500 "type": "setValue",
"name": "item:yellowKey",
"value": "99"
},
{
"type": "setValue",
"name": "item:silverCoin",
"value": "999"
},
{
"type": "comment",
"text": "unlockControl"
} }
] ]
}, },

View File

@ -1683,15 +1683,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
} }
}, },
"ui": { "ui": {
"getToolboxItems": function (cls) { "getToolboxItems": function (cls, showHide) {
// 获得道具栏中当前某类型道具的显示项和显示顺序 // 获得道具栏中当前某类型道具的显示项和显示顺序
// cls为道具类型只可能是 tools, constants 和 equips // cls为道具类型只可能是 tools, constants 和 equips
// 返回一个数组,代表当前某类型道具的显示内容和顺序 // 返回一个数组,代表当前某类型道具的显示内容和顺序
// 默认按id升序排列您可以取消下面的注释改为按名称排列 // 默认按id升序排列您可以取消下面的注释改为按名称排列
// showHide 是否显示隐藏的道具
return Object.keys(core.status.hero.items[cls] || {}) let list = Object.keys(core.status.hero.items[cls] || {});
.filter(function (id) { return !core.material.items[id].hideInToolbox; }) if (!showHide) list = list.filter(function (id) {
.sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/); 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 () { "drawStatusBar": function () {
// 自定义绘制状态栏需要开启状态栏canvas化 // 自定义绘制状态栏需要开启状态栏canvas化

View File

@ -357,7 +357,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"text": "可以查看当前楼层各怪物属性", "text": "可以查看当前楼层各怪物属性",
"hideInToolbox": true, "hideInToolbox": true,
"useItemEffect": "core.ui.drawBook(0);", "useItemEffect": "core.ui.drawBook(0);",
"canUseItemEffect": "true" "canUseItemEffect": "true",
"noBatchUse": "true"
}, },
"fly": { "fly": {
"cls": "constants", "cls": "constants",
@ -366,7 +367,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"hideInReplay": true, "hideInReplay": true,
"hideInToolbox": true, "hideInToolbox": true,
"useItemEffect": "core.ui.drawFly(core.floorIds.indexOf(core.status.floorId));", "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": { "coin": {
"cls": "constants", "cls": "constants",
@ -440,7 +442,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"name": "中心对称飞行器", "name": "中心对称飞行器",
"text": "可以飞向当前楼层中心对称的位置", "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 + '使用成功');", "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": { "upFly": {
"cls": "tools", "cls": "tools",
@ -519,9 +522,18 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"silverCoin": { "silverCoin": {
"cls": "items", "cls": "tools",
"name": "新物品", "name": "新物品",
"canUseItemEffect": "true" "canUseItemEffect": "true",
"useItemEffect": "core.status.hero.hp += 1;",
"useItemEvent": [
{
"type": "setValue",
"name": "status:hp",
"operator": "+=",
"value": "1"
}
]
}, },
"orb": { "orb": {
"cls": "items", "cls": "items",
@ -538,7 +550,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"name": "设置", "name": "设置",
"canUseItemEffect": "true", "canUseItemEffect": "true",
"text": "可以调节设置开关。", "text": "可以调节设置开关。",
"useItemEffect": "core.plugin.openSetting();" "useItemEffect": "core.plugin.openSetting();",
"noBatchUse": "true"
}, },
"redWand": { "redWand": {
"cls": "items", "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 drawFly(page?: any): void
/** 获得所有应该在道具栏显示的某个类型道具 */ /**
getToolboxItems(cls: string): string[] * @param cls
* @param cls
*/
getToolboxItems(cls: 'tools' | 'constants' | 'all', showHide: boolean): string[]
/** 绘制状态栏 */ /** 绘制状态栏 */
drawStatusBar(): void drawStatusBar(): void