added ItemListTab and fix lang

This commit is contained in:
MaksSlyzar 2026-03-29 08:41:19 +03:00
parent e2fd660f8b
commit 627cdc8b40
5 changed files with 377 additions and 16 deletions

View File

@ -9,7 +9,7 @@ class GameDataManager {
this.enemies = new Map();
this.translations = {};
this.manifest = {};
this.currentLang = "en_us";
this.currentLang = "en_US";
this.isLoaded = false;
}

View File

@ -4,7 +4,6 @@ import GameHeader from "./components/GameHeader";
import Navigation from "./components/Navigation";
import Console from "../../components/Console/Console.jsx";
// Вкладки
import DashboardTab from "./tabs/DashboardTab";
import InventoryTab from "./tabs/InventoryTab";
import DungeonsTab from "./tabs/DungeonsTab";
@ -14,9 +13,9 @@ import QuestsTab from "./tabs/QuestsTab";
import ShopTab from "./tabs/ShopTab";
import CraftingTab from "./tabs/CraftingTab";
// Бойовий екран (Екран данжу)
import DungeonScreen from "./components/DungeonScreen";
import { useSocket } from "../../hooks/useSocket.js";
import ItemListTab from "./tabs/ItemListTab.jsx";
const GameInterface = ({ onExit }) => {
const [activeTab, setActiveTab] = useState("dashboard");
@ -24,24 +23,19 @@ const GameInterface = ({ onExit }) => {
const [onlinePlayers, setOnlinePlayers] = useState([]);
const { socket } = useSocket();
// --- SOCKET LOGIC ---
useEffect(() => {
if (!socket) return;
// Слухаємо старт данжу від сервера
socket.on("dungeon:started", (sessionData) => {
console.log("Deployment initiated:", sessionData);
setActiveDungeonSession(sessionData);
});
// Слухаємо повне завершення данжу
socket.on("dungeon:completed", (results) => {
console.log("Mission accomplished:", results);
// Можна додати затримку або вікно результатів перед виходом
setActiveDungeonSession(null);
});
// Обробка помилок (наприклад, не вистачило енергії)
socket.on("error", (err) => {
alert(`SYSTEM_ERROR: ${err.message}`);
});
@ -53,9 +47,7 @@ const GameInterface = ({ onExit }) => {
};
}, [socket]);
// --- HANDLERS ---
const handleStartDungeon = (dungeonId) => {
// Відправляємо сигнал на сервер про початок місії
socket.emit("dungeon:start", { dungeonId });
};
@ -66,13 +58,9 @@ const GameInterface = ({ onExit }) => {
)
) {
setActiveDungeonSession(null);
// Можна додати socket.emit("dungeon:abort");
}
};
// --- RENDER LOGIC ---
// 1. Якщо гравець у данжі - рендеримо тільки DungeonScreen
if (activeDungeonSession) {
return (
<DungeonScreen
@ -83,7 +71,6 @@ const GameInterface = ({ onExit }) => {
);
}
// 2. Якщо гравець в хабі/орбіті - рендеримо стандартний інтерфейс з вкладками
const tabs = {
dashboard: <DashboardTab />,
dungeons: <DungeonsTab startDungeon={handleStartDungeon} />,
@ -93,6 +80,7 @@ const GameInterface = ({ onExit }) => {
inventory: <InventoryTab />,
shop: <ShopTab />,
crafting: <CraftingTab />,
itemlist: <ItemListTab />,
};
return (

View File

@ -9,6 +9,7 @@ const Navigation = ({ activeTab, onTabChange }) => {
{ id: "inventory", icon: "fa-archive", label: "Inventory" },
{ id: "shop", icon: "fa-store", label: "Shop" },
{ id: "crafting", icon: "fa-hammer", label: "Crafting" },
{ id: "itemlist", iocon: "fa-store", label: "Item List" },
];
return (
@ -24,7 +25,6 @@ const Navigation = ({ activeTab, onTabChange }) => {
<i className={`fas ${tab.icon}`}></i>
<span className="nav-label">{tab.label}</span>
</div>
{/* Декоративна лінія для активного стану */}
<div className="nav-active-indicator"></div>
</button>
))}

View File

@ -0,0 +1,170 @@
import React, { useState, useEffect } from "react";
import GameDataManager from "../../../services/GameDataManager.js";
import "./styles/ItemListTab.css";
const ItemListTab = () => {
const [allItems, setAllItems] = useState([]);
const [filteredItems, setFilteredItems] = useState([]);
const [searchQuery, setSearchQuery] = useState("");
const [selectedCategory, setSelectedCategory] = useState("all");
const [selectedItem, setSelectedItem] = useState(null);
const ASSET_BASE_URL = "http://localhost:5003/static/";
useEffect(() => {
const itemsArray = Array.from(GameDataManager.items.keys()).map((id) =>
GameDataManager.getItem(id),
);
setAllItems(itemsArray);
setFilteredItems(itemsArray);
}, []);
useEffect(() => {
let result = allItems;
if (selectedCategory !== "all") {
result = result.filter(
(item) => item.meta?.category === selectedCategory,
);
}
if (searchQuery) {
const q = searchQuery.toLowerCase();
result = result.filter(
(item) =>
item.displayName.toLowerCase().includes(q) ||
item.id.toLowerCase().includes(q),
);
}
setFilteredItems(result);
}, [searchQuery, selectedCategory, allItems]);
const getFullTextureUrl = (path) => {
if (!path) return "/assets/no-image.png";
return path.startsWith("http") ? path : `${ASSET_BASE_URL}${path}`;
};
const categories = [
"all",
...new Set(allItems.map((i) => i.meta?.category).filter(Boolean)),
];
return (
<div className="item-list-container">
<div className="item-list-sidebar">
<div className="search-box">
<i className="fas fa-search"></i>
<input
type="text"
placeholder="FILTER_BY_DATABASE_ID..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
</div>
<div className="category-filters">
{categories.map((cat) => (
<button
key={cat}
className={`filter-btn ${selectedCategory === cat ? "active" : ""}`}
onClick={() => setSelectedCategory(cat)}
>
{cat.toUpperCase()}
</button>
))}
</div>
<div className="items-list-scroll">
{filteredItems.map((item) => (
<div
key={item.id}
className={`item-row ${selectedItem?.id === item.id ? "selected" : ""} ${item.meta?.rarity}`}
onClick={() => setSelectedItem(item)}
>
<div className="item-row-icon">
<img src={getFullTextureUrl(item.texture)} alt="" />
</div>
<div className="item-row-content">
<div className="item-row-title">{item.displayName}</div>
<div className="item-row-subtitle">{item.id}</div>
</div>
<div className="item-row-rarity-indicator"></div>
</div>
))}
{filteredItems.length === 0 && (
<div className="no-results">NO_RECORDS_FOUND</div>
)}
</div>
</div>
<div className="item-inspector">
{selectedItem ? (
<div className="inspector-content">
<div className={`inspector-header ${selectedItem.meta?.rarity}`}>
<div className="header-visual">
<img src={getFullTextureUrl(selectedItem.texture)} alt="" />
</div>
<div className="header-info">
<div className="id-tag">{selectedItem.id}</div>
<h1>{selectedItem.displayName}</h1>
<div className="rarity-label">
{selectedItem.meta?.rarity?.toUpperCase()}
</div>
</div>
</div>
<div className="inspector-grid">
<div className="inspector-section main-desc">
<div className="section-title">DATA_DESCRIPTION</div>
<p>{selectedItem.description}</p>
</div>
{selectedItem.stats &&
Object.keys(selectedItem.stats).length > 0 && (
<div className="inspector-section stats">
<div className="section-title">PARAMETER_READOUT</div>
<div className="stat-pills">
{Object.entries(selectedItem.stats).map(([k, v]) => (
<div key={k} className="stat-pill">
<span className="p-label">
{GameDataManager.getStatName(k)}
</span>
<span className="p-value">+{v}</span>
</div>
))}
</div>
</div>
)}
<div className="inspector-section meta">
<div className="section-title">OBJECT_METADATA</div>
<div className="meta-list">
<div className="meta-item">
<span>CATEGORY</span>
<span>{selectedItem.meta?.category || "general"}</span>
</div>
<div className="meta-item">
<span>EQUIP_SLOT</span>
<span>{selectedItem.meta?.equipmentSlot || "none"}</span>
</div>
<div className="meta-item">
<span>STACK_LIMIT</span>
<span>{selectedItem.meta?.stackable ? "64" : "1"}</span>
</div>
</div>
</div>
</div>
</div>
) : (
<div className="inspector-placeholder">
<div className="scanner-line"></div>
<p>AWAITING_OBJECT_SELECTION...</p>
</div>
)}
</div>
</div>
);
};
export default ItemListTab;

View File

@ -0,0 +1,203 @@
.item-list-container {
display: flex;
height: calc(100vh - 120px);
background: rgba(10, 15, 25, 0.95);
color: #e0e6ed;
font-family: "Rajdhani", "Segoe UI", sans-serif;
border-top: 1px solid rgba(0, 255, 255, 0.1);
overflow: hidden;
}
/* SIDEBAR & SEARCH */
.item-list-sidebar {
width: 380px;
border-right: 1px solid rgba(0, 255, 255, 0.1);
display: flex;
flex-direction: column;
background: rgba(5, 10, 20, 0.5);
}
.search-box {
padding: 20px;
position: relative;
}
.search-box input {
width: 100%;
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(0, 255, 255, 0.2);
padding: 12px 15px;
color: #00ffff;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 14px;
transition: all 0.3s;
}
.search-box input:focus {
outline: none;
border-color: #00ffff;
box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}
/* CATEGORY FILTERS */
.category-filters {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 0 20px 15px;
}
.filter-btn {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
color: #aaa;
padding: 4px 10px;
font-size: 11px;
cursor: pointer;
transition: 0.2s;
}
.filter-btn.active,
.filter-btn:hover {
background: rgba(0, 255, 255, 0.1);
color: #00ffff;
border-color: #00ffff;
}
/* ITEM LIST ROWS */
.items-list-scroll {
flex: 1;
overflow-y: auto;
padding: 10px 20px;
}
.item-row {
display: flex;
align-items: center;
padding: 10px;
margin-bottom: 8px;
background: rgba(255, 255, 255, 0.02);
border-left: 3px solid transparent;
cursor: pointer;
transition: all 0.2s;
position: relative;
}
.item-row:hover {
background: rgba(255, 255, 255, 0.05);
transform: translateX(5px);
}
.item-row.selected {
background: rgba(0, 255, 255, 0.08);
border-left-color: #00ffff;
}
.item-row-icon {
width: 44px;
height: 44px;
background: rgba(0, 0, 0, 0.5);
border: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: center;
margin-right: 15px;
}
.item-row-icon img {
width: 32px;
height: 32px;
object-fit: contain;
image-rendering: pixelated; /* Щоб іконки були чіткими */
}
.item-row-content {
flex: 1;
display: flex;
flex-direction: column;
}
.item-row-title {
font-size: 15px;
font-weight: 600;
color: #fff;
text-transform: uppercase;
}
.item-row-subtitle {
font-size: 11px;
color: #666;
font-family: "Courier New", monospace;
}
/* RARITY COLORS */
.item-row.legendary {
border-left-color: #ff8000;
}
.item-row.epic {
border-left-color: #a335ee;
}
.item-row.rare {
border-left-color: #0070dd;
}
.item-row.common {
border-left-color: #9d9d9d;
}
/* INSPECTOR PANEL */
.item-inspector {
flex: 1;
padding: 40px;
background: radial-gradient(
circle at top right,
rgba(0, 255, 255, 0.03),
transparent
);
overflow-y: auto;
}
.inspector-header {
display: flex;
gap: 30px;
margin-bottom: 40px;
align-items: center;
}
.header-visual {
width: 120px;
height: 120px;
background: rgba(0, 0, 0, 0.3);
border: 2px solid rgba(0, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
.header-visual img {
width: 80px;
height: 80px;
}
.header-info h1 {
font-size: 32px;
margin: 5px 0;
text-transform: uppercase;
letter-spacing: 2px;
}
.id-tag {
font-family: monospace;
color: #00ffff;
opacity: 0.6;
font-size: 14px;
}
/* SCROLLBAR CUSTOMIZATION */
.items-list-scroll::-webkit-scrollbar {
width: 4px;
}
.items-list-scroll::-webkit-scrollbar-thumb {
background: rgba(0, 255, 255, 0.2);
}