Update look of quickslots
This commit is contained in:
@@ -14,32 +14,39 @@ export class QuickSlotComponent {
|
|||||||
|
|
||||||
create() {
|
create() {
|
||||||
const { width, height } = this.scene.scale;
|
const { width, height } = this.scene.scale;
|
||||||
// Position bottom center-ish
|
const slotSize = 48;
|
||||||
this.container = this.scene.add.container(width / 2 - 100, height - 50);
|
const slotSpacing = 4;
|
||||||
|
const totalWidth = (slotSize + slotSpacing) * 4 - slotSpacing;
|
||||||
|
|
||||||
|
// Position bottom center
|
||||||
|
this.container = this.scene.add.container(width / 2 - totalWidth / 2, height - slotSize - 20);
|
||||||
this.container.setScrollFactor(0).setDepth(1500);
|
this.container.setScrollFactor(0).setDepth(1500);
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
const x = i * 50;
|
const x = i * (slotSize + slotSpacing);
|
||||||
const g = this.scene.add.graphics();
|
const g = this.scene.add.graphics();
|
||||||
|
|
||||||
// Slot bg
|
// Draw slot background (dark purple/brown)
|
||||||
g.fillStyle(0x1a1a1a, 0.8);
|
g.fillStyle(0x2a1f3d, 0.95);
|
||||||
g.fillRect(0, 0, 40, 40);
|
g.fillRect(0, 0, slotSize, slotSize);
|
||||||
g.lineStyle(1, 0x555555);
|
|
||||||
g.strokeRect(0, 0, 40, 40);
|
// Draw gold border (default state)
|
||||||
|
g.lineStyle(2, 0xD4AF37, 1);
|
||||||
|
g.strokeRect(0, 0, slotSize, slotSize);
|
||||||
|
|
||||||
// Hotkey label
|
// Hotkey label (bottom-left, gold color)
|
||||||
const key = this.scene.add.text(2, 2, `${i + 1}`, {
|
const key = this.scene.add.text(3, slotSize - 3, `${i + 1}`, {
|
||||||
fontSize: "10px",
|
fontSize: "12px",
|
||||||
color: "#aaaaaa"
|
color: "#D4AF37",
|
||||||
});
|
fontStyle: "bold"
|
||||||
|
}).setOrigin(0, 1);
|
||||||
|
|
||||||
const slotContainer = this.scene.add.container(x, 0, [g, key]);
|
const slotContainer = this.scene.add.container(x, 0, [g, key]);
|
||||||
this.slots.push(slotContainer);
|
this.slots.push(slotContainer);
|
||||||
this.container.add(slotContainer);
|
this.container.add(slotContainer);
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
const hitArea = new Phaser.Geom.Rectangle(0, 0, 40, 40);
|
const hitArea = new Phaser.Geom.Rectangle(0, 0, slotSize, slotSize);
|
||||||
slotContainer.setInteractive(hitArea, Phaser.Geom.Rectangle.Contains);
|
slotContainer.setInteractive(hitArea, Phaser.Geom.Rectangle.Contains);
|
||||||
slotContainer.on("pointerdown", () => {
|
slotContainer.on("pointerdown", () => {
|
||||||
this.activateSlot(i);
|
this.activateSlot(i);
|
||||||
@@ -56,6 +63,8 @@ export class QuickSlotComponent {
|
|||||||
update(player: CombatantActor, activeItemId?: string | null) {
|
update(player: CombatantActor, activeItemId?: string | null) {
|
||||||
if (!player.inventory) return;
|
if (!player.inventory) return;
|
||||||
|
|
||||||
|
const slotSize = 48;
|
||||||
|
|
||||||
// Update slots based on inventory availability
|
// Update slots based on inventory availability
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
const desiredId = this.assignedIds[i];
|
const desiredId = this.assignedIds[i];
|
||||||
@@ -75,39 +84,45 @@ export class QuickSlotComponent {
|
|||||||
|
|
||||||
// Redraw background based on active state
|
// Redraw background based on active state
|
||||||
bgGraphics.clear();
|
bgGraphics.clear();
|
||||||
bgGraphics.fillStyle(0x1a1a1a, 0.8);
|
|
||||||
bgGraphics.fillRect(0, 0, 40, 40);
|
|
||||||
|
|
||||||
|
// Dark background
|
||||||
|
bgGraphics.fillStyle(0x2a1f3d, 0.95);
|
||||||
|
bgGraphics.fillRect(0, 0, slotSize, slotSize);
|
||||||
|
|
||||||
|
// Border - subtle cyan for active, gold for normal
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
bgGraphics.lineStyle(2, 0xffff00); // Gold highlight
|
bgGraphics.lineStyle(2, 0x00E5FF, 1); // Cyan highlight
|
||||||
} else {
|
} else {
|
||||||
bgGraphics.lineStyle(1, 0x555555); // Default gray
|
bgGraphics.lineStyle(2, 0xD4AF37, 1); // Gold border
|
||||||
}
|
}
|
||||||
bgGraphics.strokeRect(0, 0, 40, 40);
|
bgGraphics.strokeRect(0, 0, slotSize, slotSize);
|
||||||
|
|
||||||
if (foundItem) {
|
if (foundItem) {
|
||||||
const texture = foundItem.textureKey ?? "items";
|
const texture = foundItem.textureKey ?? "items";
|
||||||
const sprite = this.scene.add.sprite(20, 20, texture, foundItem.spriteIndex);
|
const sprite = this.scene.add.sprite(slotSize / 2, slotSize / 2, texture, foundItem.spriteIndex);
|
||||||
// PD items are 16x16, slot is 40x40. Scale it up?
|
// PD items are 16x16, slot is 48x48. Scale up slightly
|
||||||
sprite.setScale(2);
|
sprite.setScale(2.5);
|
||||||
slot.add(sprite);
|
slot.add(sprite);
|
||||||
|
|
||||||
// Add count if stackable (future)
|
// Add count in bottom-right corner (white with x prefix)
|
||||||
const count = player.inventory.items.filter(it => it.id === desiredId).length;
|
const count = player.inventory.items.filter(it => it.id === desiredId).length;
|
||||||
const countText = this.scene.add.text(38, 38, `${count}`, {
|
if (count > 1) {
|
||||||
fontSize: "10px",
|
const countText = this.scene.add.text(slotSize - 3, slotSize - 3, `x${count}`, {
|
||||||
color: "#ffffff"
|
fontSize: "11px",
|
||||||
}).setOrigin(1, 1);
|
color: "#ffffff",
|
||||||
slot.add(countText);
|
fontStyle: "bold"
|
||||||
|
}).setOrigin(1, 1);
|
||||||
|
slot.add(countText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.itemMap[i] = null;
|
this.itemMap[i] = null;
|
||||||
// Reset bg
|
// Reset bg
|
||||||
bgGraphics.clear();
|
bgGraphics.clear();
|
||||||
bgGraphics.fillStyle(0x1a1a1a, 0.8);
|
bgGraphics.fillStyle(0x2a1f3d, 0.95);
|
||||||
bgGraphics.fillRect(0, 0, 40, 40);
|
bgGraphics.fillRect(0, 0, slotSize, slotSize);
|
||||||
bgGraphics.lineStyle(1, 0x555555);
|
bgGraphics.lineStyle(2, 0xD4AF37, 1);
|
||||||
bgGraphics.strokeRect(0, 0, 40, 40);
|
bgGraphics.strokeRect(0, 0, slotSize, slotSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user