feat:新版道具栏隐藏道具
This commit is contained in:
parent
cdb26566c8
commit
7828113a5a
@ -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表示不可批量使用"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
27
libs/ui.js
27
libs/ui.js
@ -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'整体的列表
|
||||
}
|
||||
return Object.keys(core.status.hero.items[cls] || {})
|
||||
.filter(function (id) { return !core.material.items[id].hideInToolbox; })
|
||||
.sort();
|
||||
if (!showHide) list = list.filter(function (id) {
|
||||
return !core.material.items[id].hideInToolbox;
|
||||
})
|
||||
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) {
|
||||
|
||||
46
mynote.md
46
mynote.md
@ -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);
|
||||
|
||||
```
|
||||
@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -1683,16 +1683,20 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"getToolboxItems": function (cls) {
|
||||
"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 }*/);
|
||||
},
|
||||
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化
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
2577
project/plugins.js
2577
project/plugins.js
File diff suppressed because it is too large
Load Diff
7
runtime.d.ts
vendored
7
runtime.d.ts
vendored
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user