From 0d973a497b98ec0a9190bdc76fa75288241aabd2 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 1 May 2026 00:40:57 -0600 Subject: [PATCH] Editor: Add get_item_name --- src/dusk/ui/editor.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dusk/ui/editor.cpp b/src/dusk/ui/editor.cpp index 6f974608f1..7973638e6a 100644 --- a/src/dusk/ui/editor.cpp +++ b/src/dusk/ui/editor.cpp @@ -316,13 +316,16 @@ std::map itemMap = { {dItemNo_NONE_e, {"None"}}, }; +Rml::String get_item_name(u8 id) { + return itemMap.find(id)->second.m_name; +} + Rml::String item_label_for_slot(u8 slot) { if (slot == 0xFF) { return "None"; } - auto& item = dComIfGs_getSaveData()->getPlayer().getItem(); - auto itemNo = item.mItems[slot]; - return fmt::format("Slot {0} ({1})", slot, itemMap.find(itemNo)->second.m_name); + const auto id = dComIfGs_getSaveData()->getPlayer().getItem().mItems[slot]; + return fmt::format("Slot {0} ({1})", slot, get_item_name(id)); } } // namespace @@ -425,17 +428,14 @@ EditorWindow::EditorWindow() { leftPane .add_select_button({ .key = "Clothes", - .getValue = - [] { - return itemMap.find(get_player_status()->mSelectEquip[0])->second.m_name; - }, + .getValue = [] { return get_item_name(get_player_status()->mSelectEquip[0]); }, }) .on_hover([&rightPane](Rml::Event&) { rightPane.clear(); - const auto addOption = [&rightPane](const Rml::String& name, u8 id) { + const auto addOption = [&rightPane](u8 id) { rightPane.add_button( { - .text = name, + .text = get_item_name(id), .isSelected = [id] { return get_player_status()->mSelectEquip[0] == id; }, }, @@ -444,10 +444,10 @@ EditorWindow::EditorWindow() { daPy_getPlayerActorClass()->setClothesChange(0); }); }; - addOption("Ordon Clothes", dItemNo_WEAR_CASUAL_e); - addOption("Hero's Clothes", dItemNo_WEAR_KOKIRI_e); - addOption("Zora Armor", dItemNo_WEAR_ZORA_e); - addOption("Magic Armor", dItemNo_ARMOR_e); + addOption(dItemNo_WEAR_CASUAL_e); + addOption(dItemNo_WEAR_KOKIRI_e); + addOption(dItemNo_WEAR_ZORA_e); + addOption(dItemNo_ARMOR_e); }); });