feat:新版道具栏 批量使用功能

This commit is contained in:
ShakeFlower 2025-02-14 10:50:18 +08:00
parent 6f9bfbbb27
commit 425f3d74c9
4 changed files with 46 additions and 29 deletions

View File

@ -107,13 +107,13 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_docs": "能否使用或装备",
"_data": "当前能否使用或装备该道具仅对cls不为items有效。null表示始终不可使用但可装备"
},
"noBatchUse": {
"canBatchUse": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_lint": true,
"_docs": "可批量使用",
"_data": "该道具是否允许批量使用true表示可批量使用"
"_docs": "可批量使用",
"_data": "该道具是否允许批量使用,仅对cls为tools或constants有效true表示可批量使用。建议同时勾选[回放不绘制道具栏]"
}
}
},

View File

@ -25,7 +25,18 @@ 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]
],
"firstArrive": [],
"firstArrive": [
{
"type": "setValue",
"name": "item:wand",
"value": "99"
},
{
"type": "setValue",
"name": "item:silverCoin",
"value": "99"
}
],
"parallelDo": "",
"events": {
"6,8": [

View File

@ -357,8 +357,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"text": "可以查看当前楼层各怪物属性",
"hideInToolbox": true,
"useItemEffect": "core.ui.drawBook(0);",
"canUseItemEffect": "true",
"noBatchUse": "true"
"canUseItemEffect": "true"
},
"fly": {
"cls": "constants",
@ -367,8 +366,7 @@ 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})();",
"noBatchUse": "true"
"canUseItemEffect": "(function () {\n\tif (core.flags.flyNearStair && !core.nearStair()) return false;\n\treturn core.status.maps[core.status.floorId].canFlyFrom;\n})();"
},
"coin": {
"cls": "constants",
@ -442,8 +440,7 @@ 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})();",
"noBatchUse": "true"
"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})();"
},
"upFly": {
"cls": "tools",
@ -507,8 +504,12 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"canUseItemEffect": "(function () {\n\tvar nx = core.nextX(2),\n\t\tny = core.nextY(2);\n\treturn nx >= 0 && nx < core.bigmap.width && ny >= 0 && ny < core.bigmap.height && core.getBlockId(nx, ny) == null;\n})();"
},
"wand": {
"cls": "items",
"name": "新物品"
"cls": "tools",
"name": "生命魔杖",
"canBatchUse": "true",
"text": "使用后回复100体力。",
"canUseItemEffect": "true",
"useItemEffect": "core.addStatus('hp', 100);"
},
"pack": {
"cls": "items",
@ -533,7 +534,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"operator": "+=",
"value": "1"
}
]
],
"canBatchUse": "true"
},
"orb": {
"cls": "items",
@ -550,8 +552,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"name": "设置",
"canUseItemEffect": "true",
"text": "可以调节设置开关。",
"useItemEffect": "core.plugin.openSetting();",
"noBatchUse": "true"
"useItemEffect": "core.plugin.openSetting();"
},
"redWand": {
"cls": "items",

View File

@ -2971,10 +2971,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
function batchUse(item, count) {
try {
const itemCount = core.itemCount(item);
if (eval(core.material.items[item].noBatchUse)) {
core.drawFailTip('该道具不能被批量使用!');
return;
}
if (count > itemCount) count = itemCount;
core.closePanel();
for (let i = 0; i < count; i++) {
@ -2982,12 +2978,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
else return;
}
} catch (e) {
console.log(e);
console.error(e);
core.drawFailTip('批量使用时出现未知错误!');
}
}
function drawToolbox_setBatchUseBtn(ctx, x, y, r, h, style, lineWidth) {
try {
const selectedItem = getSelectedItem();
let canBatchUse = eval(core.material.items[selectedItem]?.canBatchUse);
if (!canBatchUse) return;
}
catch (error) {
console.error(error);
return;
}
core.setTextAlign(ctx, "left");
core.setTextBaseline(ctx, "top");
var fontSize = h - 4;
@ -2999,10 +3004,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.fillText(ctx, text, x + r, y + lineWidth / 2 + 2, style, font);
var todo = function () {
core.utils.myprompt('输入要使用该物品的次数(0~99)。 请勿对不适合重复使用的物品这么做。', null, (value) => {
core.utils.myprompt('输入要使用该物品的次数(0~99)。', null, (value) => {
value = parseInt(value);
var id = getSelectedItem();
const id = getSelectedItem();
if (Number.isNaN(value) || value < 0 || value > 99) {
core.drawFailTip('输入不合法!');
@ -3138,7 +3143,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
info.select = {};
info.select.id = id;
core.setIndexAndSelect('index');
core.refreshBox();
refreshBox();
}
this.clickOneEquipbox = function (id, type) {
@ -3150,7 +3155,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
type: type,
action: "unload"
}
return core.refreshBox();
return refreshBox();
}
this.useSelectItemInBox = function () {
@ -3221,7 +3226,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
info.index = 1;
setPageItems(info.page);
core.setIndexAndSelect("select");
core.refreshBox();
refreshBox();
}
this.addItemListboxIndex = function (num) {
@ -3233,7 +3238,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (info.index <= 0) info.index = 1;
if (info.index > maxItem) info.index = maxItem;
core.setIndexAndSelect("select");
core.refreshBox();
refreshBox();
}
this.addEquipboxType = function (num) {
@ -3250,7 +3255,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var m = Math.abs(info.select.type);
if (info.select.type < 0) info.select.type = max - m;
core.setIndexAndSelect("select")
core.refreshBox();
refreshBox();
return;
}
}
@ -3310,7 +3315,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (info.index == 1) {
info.select.type = core.status.globalAttribute.equipName.length - 1;
core.setIndexAndSelect();
return core.refreshBox();
return refreshBox();
}
if (info.index) return core.addItemListboxIndex(-1);
return core.addEquipboxType(-1 * info.equips);
@ -3387,7 +3392,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.status.thisEventClickArea = [];
}
this.refreshBox = function () {
function refreshBox() {
if (!core.status.event.id) return;
if (core.status.event.id == "toolbox") core.drawToolbox();
else core.drawEquipbox();