mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +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));
|
setColor(glm::vec4(0, 0, 0, 0.2f));
|
||||||
setTooltipDelay(0.0f);
|
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) {
|
// May not work correctly, requires review
|
||||||
return langs::get(util::str2wstr_utf8(description->asString()));
|
static std::wstring get_item_field_string(
|
||||||
} else {
|
const ItemStack& stack,
|
||||||
return langs::get(util::str2wstr_utf8(item.description));
|
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) {
|
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;
|
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 Gravity gravity_from_string(const std::string& str) {
|
||||||
static const std::unordered_map<std::string, Gravity> gravity_names {
|
static const std::unordered_map<std::string, Gravity> gravity_names {
|
||||||
{"top-left", Gravity::TOP_LEFT},
|
{"top-left", Gravity::TOP_LEFT},
|
||||||
|
|
@ -860,7 +862,8 @@ static std::shared_ptr<UINode> read_inventory(
|
||||||
UiXmlReader& reader, const xml::xmlelement& element
|
UiXmlReader& reader, const xml::xmlelement& element
|
||||||
) {
|
) {
|
||||||
auto view = std::make_shared<InventoryView>(reader.getGUI());
|
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("slot");
|
||||||
reader.addIgnore("slots-grid");
|
reader.addIgnore("slots-grid");
|
||||||
reader.readUINode(reader, element, *view);
|
reader.readUINode(reader, element, *view);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue