mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge ed7d0594ff into dacebf94bc
This commit is contained in:
commit
3c9a8e28f4
2 changed files with 22 additions and 24 deletions
|
|
@ -113,30 +113,25 @@ SlotView::SlotView(GUI& gui, SlotLayout layout)
|
|||
setColor(glm::vec4(0, 0, 0, 0.2f));
|
||||
setTooltipDelay(0.0f);
|
||||
}
|
||||
// TODO: Refactor
|
||||
static std::wstring get_caption_string(
|
||||
const ItemStack& stack, const ItemDef& item
|
||||
) {
|
||||
dv::value* caption = stack.getField("caption");
|
||||
if (caption != nullptr) {
|
||||
return util::pascal_case(
|
||||
langs::get(util::str2wstr_utf8(caption->asString()))
|
||||
);
|
||||
} else {
|
||||
return util::pascal_case(langs::get(util::str2wstr_utf8(item.caption)));
|
||||
}
|
||||
}
|
||||
// TODO: Refactor
|
||||
static std::wstring get_description_string(
|
||||
const ItemStack& stack, const ItemDef& item
|
||||
) {
|
||||
dv::value* description = stack.getField("description");
|
||||
|
||||
if (description != nullptr) {
|
||||
return langs::get(util::str2wstr_utf8(description->asString()));
|
||||
} else {
|
||||
return langs::get(util::str2wstr_utf8(item.description));
|
||||
}
|
||||
// May not work correctly, requires review
|
||||
static std::wstring get_item_field_string(
|
||||
const ItemStack& stack,
|
||||
const std::string& field_name,
|
||||
const std::string& fallback_value
|
||||
) {
|
||||
dv::value* field = stack.getField(field_name);
|
||||
const std::string& target_str = (field != nullptr) ? field->asString() : fallback_value;
|
||||
|
||||
return langs::get(util::str2wstr_utf8(target_str));
|
||||
}
|
||||
|
||||
static std::wstring get_caption_string(const ItemStack& stack, const ItemDef& item) {
|
||||
return util::pascal_case(get_item_field_string(stack, "caption", item.caption));
|
||||
}
|
||||
// pascal_case is omitted for descriptions to preserve standard text formatting and readability
|
||||
static std::wstring get_description_string(const ItemStack& stack, const ItemDef& item) {
|
||||
return get_item_field_string(stack, "description", item.description);
|
||||
}
|
||||
|
||||
static bool is_same_tooltip(const ItemStack& stack, const ItemStack& cache) {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ static Align align_from_string(std::string_view str, Align def) {
|
|||
return def;
|
||||
}
|
||||
|
||||
static constexpr glm::vec4 INVENTORY_VIEW_BACKGROUND_COLOR = glm::vec4(0.122f, 0.122f, 0.122f, 0.878f);
|
||||
|
||||
static Gravity gravity_from_string(const std::string& str) {
|
||||
static const std::unordered_map<std::string, Gravity> gravity_names {
|
||||
{"top-left", Gravity::TOP_LEFT},
|
||||
|
|
@ -860,7 +862,8 @@ static std::shared_ptr<UINode> read_inventory(
|
|||
UiXmlReader& reader, const xml::xmlelement& element
|
||||
) {
|
||||
auto view = std::make_shared<InventoryView>(reader.getGUI());
|
||||
view->setColor(glm::vec4(0.122f, 0.122f, 0.122f, 0.878f)); // TODO: fixme
|
||||
// view->setColor(glm::vec4(0.122f, 0.122f, 0.122f, 0.878f));
|
||||
view->setColor(INVENTORY_VIEW_BACKGROUND_COLOR); // fixed variant (magic color -> constant)
|
||||
reader.addIgnore("slot");
|
||||
reader.addIgnore("slots-grid");
|
||||
reader.readUINode(reader, element, *view);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue