inventori

This commit is contained in:
2025-12-13 03:07:45 +01:00
parent f0cd2ae056
commit 725cd98e7c
9 changed files with 1067 additions and 67 deletions

View File

@@ -9,6 +9,9 @@ class UIScene extends Phaser.Scene {
// Pridobi reference na GameScene podatke (ko bodo na voljo)
this.gameScene = this.scene.get('GameScene');
// Track selected inventory slot (for tools)
this.selectedSlot = 0;
// Setup UI Container
// Shared Overlay (DayNight + Weather)
// Rendered here to be screen-space (HUD) and ignore zoom
@@ -22,7 +25,12 @@ class UIScene extends Phaser.Scene {
this.createVirtualJoystick();
this.createClock();
this.createMinimap(); // NEW: Mini mapa
// this.createDebugInfo();
// this.createDebugInfo(); // REMOVED - Using UnifiedStatsPanel
// Hide old debug panel if it exists
if (this.debugText) this.debugText.setVisible(false);
if (this.debugBg) this.debugBg.setVisible(false);
this.createSettingsButton();
// ESC Pause Menu
@@ -343,7 +351,7 @@ class UIScene extends Phaser.Scene {
this.createTimeControlPanel();
this.createInventoryBar();
this.createInventoryBar();
this.createDebugInfo();
// this.createDebugInfo(); // REMOVED - Using UnifiedStatsPanel
this.createSettingsButton();
// Refresh data
@@ -739,28 +747,7 @@ class UIScene extends Phaser.Scene {
this.goldText.setText(`GOLD: ${amount}`);
}
createDebugInfo() {
if (this.debugText) this.debugText.destroy();
if (this.debugBg) this.debugBg.destroy();
const x = this.scale.width - 170;
const y = 120; // Below Gold and Clock area
// Background
this.debugBg = this.add.graphics();
this.debugBg.fillStyle(0x000000, 0.7);
this.debugBg.fillRect(x, y, 160, 70);
this.debugBg.setDepth(2999);
this.debugText = this.add.text(x + 10, y + 10, 'Waiting for stats...', {
fontSize: '12px',
fontFamily: 'monospace',
fill: '#ffffff',
stroke: '#000000',
strokeThickness: 2
});
this.debugText.setDepth(3000);
}
// DEBUG INFO REMOVED - Now using UnifiedStatsPanel (TAB/F3)
update() {
if (!this.gameScene) return;
@@ -814,6 +801,9 @@ class UIScene extends Phaser.Scene {
this.updateResourceDisplay('iron', inv.getItemCount('iron'));
}
// Update Equipment Preview
this.updateEquipmentPreview();
// Update Minimap
this.updateMinimap();
}
@@ -2489,8 +2479,9 @@ class UIScene extends Phaser.Scene {
// Equipment Preview
createEquipmentPreview() {
const previewX = 20;
const previewY = 400; // MOVED LOWER (was 150)
// Position next to inventory bar (bottom right)
const previewX = this.scale.width - 80; // Right side
const previewY = this.scale.height - 80; // Bottom
// Background - SMALLER
this.equipmentBg = this.add.graphics();
@@ -2500,6 +2491,7 @@ class UIScene extends Phaser.Scene {
this.equipmentBg.strokeRoundedRect(previewX, previewY, 60, 60, 8);
this.equipmentBg.setScrollFactor(0);
this.equipmentBg.setDepth(1000);
this.equipmentBg.setVisible(true); // VISIBLE
// Label - SMALLER
this.equipmentLabel = this.add.text(
@@ -2514,17 +2506,19 @@ class UIScene extends Phaser.Scene {
this.equipmentLabel.setOrigin(0.5, 1);
this.equipmentLabel.setScrollFactor(0);
this.equipmentLabel.setDepth(1001);
this.equipmentLabel.setVisible(true); // VISIBLE
// Icon sprite placeholder - SMALLER
this.equipmentIcon = this.add.rectangle(previewX + 30, previewY + 30, 24, 24, 0x888888);
this.equipmentIcon.setScrollFactor(0);
this.equipmentIcon.setDepth(1001);
this.equipmentIcon.setVisible(true); // VISIBLE
// Tool name - HIDDEN (too much text)
// Tool name
this.equipmentName = this.add.text(
previewX + 30,
previewY + 50,
'',
'None',
{
font: 'bold 8px Arial',
fill: '#ffffff'
@@ -2533,28 +2527,57 @@ class UIScene extends Phaser.Scene {
this.equipmentName.setOrigin(0.5, 0);
this.equipmentName.setScrollFactor(0);
this.equipmentName.setDepth(1001);
this.equipmentName.setVisible(false); // HIDDEN
this.equipmentName.setVisible(true); // VISIBLE
console.log('🎮 Equipment preview created!');
console.log('🎮 Equipment preview created and VISIBLE!');
}
updateEquipmentPreview() {
if (!this.gameScene || !this.gameScene.inventorySystem) return;
if (!this.equipmentName) return;
if (!this.equipmentIcon) return;
const inv = this.gameScene.inventorySystem;
const selectedItem = inv.items[inv.selectedSlot];
if (selectedItem) {
// Update name
this.equipmentName.setText(selectedItem.name || selectedItem.id);
this.equipmentIcon.setVisible(true);
this.equipmentName.setVisible(true);
} else {
// Hide if no item
this.equipmentName.setText('None');
this.equipmentIcon.setVisible(false);
// Since inv.selectedSlot is undefined, use slot 0 for now
const slotIndex = 0;
if (this.equipmentLabel) {
this.equipmentLabel.setText(`SLOT ${slotIndex + 1}`);
}
const selectedSlot = inv.slots ? inv.slots[slotIndex] : null;
if (selectedSlot && selectedSlot.item) {
// Has item - show color
if (selectedSlot.item.id === 'axe') {
this.equipmentIcon.setFillStyle(0x8B4513);
} else if (selectedSlot.item.id === 'hoe') {
this.equipmentIcon.setFillStyle(0x654321);
} else {
this.equipmentIcon.setFillStyle(0x00ff00);
}
if (this.equipmentName) {
this.equipmentName.setText(selectedSlot.item.id);
this.equipmentName.setVisible(true);
}
} else {
this.equipmentIcon.setFillStyle(0x444444);
if (this.equipmentName) {
this.equipmentName.setText('Empty');
this.equipmentName.setVisible(true);
}
}
this.equipmentIcon.setVisible(true);
}
// Select inventory slot (called from GameScene keyboard input)
selectSlot(slotIndex) {
this.selectedSlot = slotIndex;
// Update equipment preview immediately
this.updateEquipmentPreview();
}
/**