From bf9a4163a3d65374a360da6e7c27f8deb0b01c35 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit <116128211+DrPerkyLegit@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:59:29 -0400 Subject: [PATCH] enable color for items, in inventory and on hud --- Minecraft.Client/Common/UI/UIScene_HUD.cpp | 32 ++++++++++++++++++++-- Minecraft.World/ItemInstance.cpp | 32 +++++++++++----------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIScene_HUD.cpp b/Minecraft.Client/Common/UI/UIScene_HUD.cpp index ac159fc1..ddf35350 100644 --- a/Minecraft.Client/Common/UI/UIScene_HUD.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HUD.cpp @@ -21,6 +21,17 @@ UIScene_HUD::UIScene_HUD(int iPad, void *initData, UILayer *parentLayer) : UISce SetDragonLabel( app.GetString( IDS_BOSS_ENDERDRAGON_HEALTH ) ); SetSelectedLabel(L""); + //enable colors for selected item text + { + IggyValuePath classPath; + IggyValuePathMakeNameRef(&classPath, m_rootPath, "SelectedLabel"); + + IggyValuePath labelPath; + IggyValuePathMakeNameRef(&labelPath, &classPath, "Label"); + + IggyValueSetBooleanRS(&labelPath, 0, "m_bUseHtmlText", true); + } + for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i) { m_labelChatText[i].init(L""); @@ -263,6 +274,17 @@ void UIScene_HUD::handleReload() SetDragonLabel(BossMobGuiInfo::name[idx]); SetSelectedLabel(L""); + //enable colors for selected item text + { + IggyValuePath classPath; + IggyValuePathMakeNameRef(&classPath, m_rootPath, "SelectedLabel"); + + IggyValuePath labelPath; + IggyValuePathMakeNameRef(&labelPath, &classPath, "Label"); + + IggyValueSetBooleanRS(&labelPath, 0, "m_bUseHtmlText", true); + } + for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i) { m_labelChatText[i].init(L""); @@ -599,11 +621,17 @@ void UIScene_HUD::SetSelectedLabel(const wstring &label) // 4J Stu - Timing here is kept the same as on Xbox360, even though we do it differently now and do the fade out in Flash rather than directly setting opacity if(!label.empty()) m_uiSelectedItemOpacityCountDown = SharedConstants::TICKS_PER_SECOND * 3; + wstring itemName = L""; + if (!label.empty()) { + itemName = app.EscapeHTMLString(label); + itemName = app.FormatColoredString(itemName); + } + IggyDataValue result; IggyDataValue value[1]; IggyStringUTF16 stringVal; - stringVal.string = (IggyUTF16*)label.c_str(); - stringVal.length = label.length(); + stringVal.string = (IggyUTF16*)itemName.c_str(); + stringVal.length = itemName.length(); value[0].type = IGGY_DATATYPE_string_UTF16; value[0].string16 = stringVal; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetSelectedLabel , 1 , value ); diff --git a/Minecraft.World/ItemInstance.cpp b/Minecraft.World/ItemInstance.cpp index dcc2200f..6581ea6c 100644 --- a/Minecraft.World/ItemInstance.cpp +++ b/Minecraft.World/ItemInstance.cpp @@ -560,9 +560,13 @@ vector *ItemInstance::getHoverText(shared_ptr player, bool a { vector *lines = new vector(); Item *item = Item::items[id]; - HtmlString title = HtmlString(getHoverName()); - if (hasCustomHoverName()) + wstring hoverName = getHoverName(); + HtmlString title = HtmlString(L""); + title.text = app.EscapeHTMLString(hoverName); + title.text = app.FormatColoredString(title.text); + + if (hasCustomHoverName() && !(hoverName[0] == L'\u00A7' && hoverName[1] == L'r')) { title.italics = true; } @@ -615,19 +619,12 @@ vector *ItemInstance::getHoverText(shared_ptr player, bool a { CompoundTag *display = tag->getCompound(L"display"); - //if (display->contains(L"color")) - //{ - // if (advanced) - // { - // wchar_t text [256]; - // swprintf(text, 256, L"Color: LOCALISE #%08X", display->getInt(L"color")); - // lines->push_back(HtmlString(text)); - // } - // else - // { - // lines->push_back(HtmlString(L"Dyed LOCALISE", eMinecraftColour_NOT_SET, true)); - // } - //} + if (display->contains(L"color") && advanced) + { + wchar_t text[256]; + swprintf(text, 256, L"Color: LOCALISE #%08X", display->getInt(L"color")); + lines->push_back(HtmlString(text)); + } if (display->contains(L"Lore")) { @@ -637,7 +634,10 @@ vector *ItemInstance::getHoverText(shared_ptr player, bool a for (int i = 0; i < lore->size(); i++) { //lines->push_back(ChatFormatting::DARK_PURPLE + "" + ChatFormatting::ITALIC + lore->get(i)->data); - lines->push_back(lore->get(i)->data); + HtmlString loreString = HtmlString(L""); + loreString.text = app.EscapeHTMLString(lore->get(i)->data); + loreString.text = app.EscapeHTMLString(loreString.text); + lines->push_back(loreString); } } }