fix:新版道具栏手机选装备的bug,以及飞行器不能使用时的特判
This commit is contained in:
parent
b257e6d0fa
commit
ab2cb171b7
@ -2621,6 +2621,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addBtnList(key, button) {
|
||||||
|
this.btnList.set(key, button);
|
||||||
|
button.menu = this;
|
||||||
|
button.ctx = this.name;
|
||||||
|
button.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
// 返回换算后的画布上的相对坐标
|
// 返回换算后的画布上的相对坐标
|
||||||
convertCoordinate(px, py) {
|
convertCoordinate(px, py) {
|
||||||
return [px - this.x, py - this.y];
|
return [px - this.x, py - this.y];
|
||||||
@ -3030,7 +3037,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
const [x, y, w, h] = [this.x, this.y, this.w, this.h];
|
const [x, y, w, h] = [this.x, this.y, this.w, this.h];
|
||||||
const space = 2, lineWidth = 2, squareSize = w;
|
const space = 2, lineWidth = 2, squareSize = w;
|
||||||
const equipId = core.getEquip(this.key);
|
const equipId = core.getEquip(this.menu.getTotalIndex(this.key));
|
||||||
if (equipId) core.drawIcon(ctx, equipId, x + 4, y + 4, squareSize - 8, squareSize - 8);
|
if (equipId) core.drawIcon(ctx, equipId, x + 4, y + 4, squareSize - 8, squareSize - 8);
|
||||||
const color = (globalUI.selectType === 'equipBox' && this.menu.index === this.key) ? 'gold' : 'white';
|
const color = (globalUI.selectType === 'equipBox' && this.menu.index === this.key) ? 'gold' : 'white';
|
||||||
core.strokeRect(ctx, x, y, squareSize, squareSize, color, lineWidth);
|
core.strokeRect(ctx, x, y, squareSize, squareSize, color, lineWidth);
|
||||||
@ -3234,11 +3241,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
/** 聚焦于指定序号的按钮,并重绘画面 */
|
/** 聚焦于指定序号的按钮,并重绘画面 */
|
||||||
focus(index) {
|
focus(index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
if (this instanceof EquipChangeBoard) {
|
||||||
|
this.itemId = core.status.hero.equipment[this.getTotalIndex()];
|
||||||
|
globalUI.selectType = 'equipBox';
|
||||||
|
globalUI.equipInv.index = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.itemId = this.currItemList[this.index];
|
this.itemId = this.currItemList[this.index];
|
||||||
|
globalUI.selectType = 'toolBox';
|
||||||
|
if (this instanceof EquipInventory) globalUI.equipChangeBoard.index = -1;
|
||||||
|
}
|
||||||
this.btnList.forEach(btn => {
|
this.btnList.forEach(btn => {
|
||||||
btn.status = (btn.key === this.index) ? 'selected' : 'none'
|
btn.status = (btn.key === this.index) ? 'selected' : 'none'
|
||||||
});
|
});
|
||||||
globalUI.selectType = (this instanceof EquipChangeBoard) ? 'equipBox' : 'toolBox';
|
|
||||||
globalUI.itemId = this.itemId;
|
globalUI.itemId = this.itemId;
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
@ -3291,19 +3306,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
const spaceX = (this.w - columnCount * boxWidth) / (1 + columnCount),
|
const spaceX = (this.w - columnCount * boxWidth) / (1 + columnCount),
|
||||||
spaceY = (this.h - rowCount * boxHeight) / (1 + rowCount);
|
spaceY = (this.h - rowCount * boxHeight) / (1 + rowCount);
|
||||||
let [x, y] = [spaceX, spaceY];
|
let [x, y] = [spaceX, spaceY];
|
||||||
/** @type {[number, EquipBox][]} */
|
|
||||||
const btnArr = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < this.currItemList.length; i++) {
|
for (let i = 0; i < this.pageCap; i++) {
|
||||||
|
if (!this.btnList.has(i)) {
|
||||||
const btn = new EquipBox(x, y, boxWidth, boxHeight);
|
const btn = new EquipBox(x, y, boxWidth, boxHeight);
|
||||||
btnArr.push([i, btn]);
|
this.addBtnList(i, btn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const btn = this.btnList.get(i);
|
||||||
|
if (btn) btn.disable = (i >= this.currItemList.length);
|
||||||
|
}
|
||||||
if ((i + 1) % this.columnMax === 0) {
|
if ((i + 1) % this.columnMax === 0) {
|
||||||
x = spaceX;
|
x = spaceX;
|
||||||
y += spaceY + boxHeight;
|
y += spaceY + boxHeight;
|
||||||
}
|
}
|
||||||
else x += spaceX + boxWidth;
|
else x += spaceX + boxWidth;
|
||||||
}
|
}
|
||||||
this.initBtnList(btnArr);
|
if (this.allItemList.length < this.pageCap) {
|
||||||
|
const pgDown = this.btnList.get('pgDown');
|
||||||
|
const pgUp = this.btnList.get('pgUp');
|
||||||
|
if (pgDown) pgDown.disable = true;
|
||||||
|
if (pgUp) pgUp.disable = true;
|
||||||
|
}
|
||||||
super.drawContent();
|
super.drawContent();
|
||||||
}
|
}
|
||||||
/** 注意,对于装备切换面板来说,它的装备列表不是装备本身,而是角色的装备孔 */
|
/** 注意,对于装备切换面板来说,它的装备列表不是装备本身,而是角色的装备孔 */
|
||||||
@ -3311,8 +3335,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
return core.status.globalAttribute.equipName;
|
return core.status.globalAttribute.equipName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTotalIndex(index) {
|
||||||
|
if (index == null) index = this.index;
|
||||||
|
return this.page * this.pageCap + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
changePageByTotalIndex(index) {
|
||||||
|
const newPage = Math.floor(index / this.pageCap);
|
||||||
|
this.page = newPage;
|
||||||
|
this.updateItemList();
|
||||||
|
}
|
||||||
|
|
||||||
triggerItem() {
|
triggerItem() {
|
||||||
const index = this.index;
|
const index = this.getTotalIndex();
|
||||||
if (core.status.hero.equipment[index]) {
|
if (core.status.hero.equipment[index]) {
|
||||||
core.unloadEquip(index);
|
core.unloadEquip(index);
|
||||||
core.status.route.push("unEquip:" + index);
|
core.status.route.push("unEquip:" + index);
|
||||||
@ -3379,7 +3414,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
|
|
||||||
triggerItem() {
|
triggerItem() {
|
||||||
const itemId = this.itemId;
|
const itemId = this.itemId;
|
||||||
if (!core.canUseItem(itemId)) {
|
if (!core.canUseItem(itemId) && itemId !== 'centerFly') {
|
||||||
core.drawFailTip("当前无法使用" + core.material.items[itemId].name, itemId);
|
core.drawFailTip("当前无法使用" + core.material.items[itemId].name, itemId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3403,6 +3438,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
triggerItem() {
|
triggerItem() {
|
||||||
const equip = this.itemId;
|
const equip = this.itemId;
|
||||||
if (!core.canEquip(equip, true)) return;
|
if (!core.canEquip(equip, true)) return;
|
||||||
|
const equipPos = core.getEquipTypeById(equip);
|
||||||
|
globalUI.equipChangeBoard.changePageByTotalIndex(equipPos);
|
||||||
core.loadEquip(equip);
|
core.loadEquip(equip);
|
||||||
core.status.route.push("equip:" + equip); // 注意focus会导致itemId改变
|
core.status.route.push("equip:" + equip); // 注意focus会导致itemId改变
|
||||||
this.updateItemList(); // 穿上装备会导致道具数量变化,并且需要重新锁定当前选中的道具
|
this.updateItemList(); // 穿上装备会导致道具数量变化,并且需要重新锁定当前选中的道具
|
||||||
@ -3775,8 +3812,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
this._equipChangeBoard = new EquipChangeBoard(7, 10, 240, 125, 137);
|
this._equipChangeBoard = new EquipChangeBoard(7, 10, 240, 125, 137);
|
||||||
const config = { marginLeft: 4, marginTop: 3, marginRight: 2 };
|
const config = { marginLeft: 4, marginTop: 3, marginRight: 2 };
|
||||||
const [pgDown, pgUp] = [new ArrowBtn(0, 56, 14, 14, 'left', config), new ArrowBtn(222, 56, 14, 14, 'right', config)];
|
const [pgDown, pgUp] = [new ArrowBtn(0, 56, 14, 14, 'left', config), new ArrowBtn(222, 56, 14, 14, 'right', config)];
|
||||||
pgDown.event = () => { globalUI.equipChangeBoard.pageDown(); redraw(); };
|
pgDown.event = () => {
|
||||||
pgUp.event = () => { globalUI.equipChangeBoard.pageUp(); redraw(); };
|
globalUI.equipChangeBoard.pageDown();
|
||||||
|
redraw();
|
||||||
|
};
|
||||||
|
pgUp.event = () => {
|
||||||
|
globalUI.equipChangeBoard.pageUp();
|
||||||
|
redraw();
|
||||||
|
};
|
||||||
|
this._equipChangeBoard.addBtnList('pgDown', pgDown);
|
||||||
|
this._equipChangeBoard.addBtnList('pgUp', pgUp);
|
||||||
}
|
}
|
||||||
return this._equipChangeBoard;
|
return this._equipChangeBoard;
|
||||||
}
|
}
|
||||||
|
|||||||
2
runtime.d.ts
vendored
2
runtime.d.ts
vendored
@ -3244,6 +3244,8 @@ declare class MenuBaseClass {
|
|||||||
createCanvas(): CanvasRenderingContext2D
|
createCanvas(): CanvasRenderingContext2D
|
||||||
/** 初始化该菜单的按钮列表 */
|
/** 初始化该菜单的按钮列表 */
|
||||||
initBtnList(arr: [any, ButtonBaseClass][]): void
|
initBtnList(arr: [any, ButtonBaseClass][]): void
|
||||||
|
/** 为该菜单添加一个按钮 */
|
||||||
|
addBtnList(key, button): void
|
||||||
/** 绘制该菜单上的按钮 */
|
/** 绘制该菜单上的按钮 */
|
||||||
drawButtonContent(): void
|
drawButtonContent(): void
|
||||||
/** 绘制该菜单上的按钮(需要派生类自行绘制画布和填充内容) */
|
/** 绘制该菜单上的按钮(需要派生类自行绘制画布和填充内容) */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user