refactor(localization): switch block translations to item naming

Remove the `name_key` field from block definitions and use item-based
localization keys (`item.*.name`) for inventory display. Item data now
stores the localized name at load time.
This commit is contained in:
2026-08-05 15:42:53 +08:00
parent 277aab1b81
commit 322fb2fea0
19 changed files with 44 additions and 58 deletions

View File

@@ -42,7 +42,6 @@ struct LookBlock {
struct BlockData {
std::string name;
std::string name_key;
BlockType id = 0;
bool is_liquid = false;
@@ -56,17 +55,14 @@ struct BlockData {
bool is_blend = false;
bool is_transitional = false;
float roughness = 1.0f;
BlockData(std::string_view b_name, std::string_view name_k, BlockType b_id,
bool liquid, bool passable, bool cross_plane, bool transparent,
bool gas, bool discard, bool blend, bool transitional, float r)
: name(b_name), name_key(name_k), id(b_id), is_liquid(liquid),
is_gas(gas), is_passable(passable), is_cross_plane(cross_plane),
BlockData(std::string_view b_name, BlockType b_id, bool liquid,
bool passable, bool cross_plane, bool transparent, bool gas,
bool discard, bool blend, bool transitional, float r)
: name(b_name), id(b_id), is_liquid(liquid), is_gas(gas),
is_passable(passable), is_cross_plane(cross_plane),
is_transparent(transparent), is_discard(discard), is_blend(blend),
is_transitional(transitional), roughness(r) {}
BlockData() {
name = "";
name_key = "";
}
BlockData() { name = ""; }
};
} // namespace Cubed

View File

@@ -11,7 +11,6 @@ public:
static unsigned sums();
static unsigned cross_plane_sum();
static const std::string& name_form_id(BlockType id);
static std::string local_name(BlockType id);
static bool is_gas(BlockType id);
static bool is_liquid(BlockType id);

View File

@@ -19,6 +19,7 @@ using ItemProperty = std::variant<BlockType, std::string>;
struct ItemData {
ItemID id = 0;
std::string name;
std::string local_name;
std::string description;
std::string path;
ItemKind kind = ItemKind::NONE;