diff --git a/extern/aurora b/extern/aurora index d950468064..702583583d 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit d9504680642bae0f862b8928f1ee42be3c9b274a +Subproject commit 702583583dba50107261eab7d6f59572101cd549 diff --git a/src/dusk/ui/button.cpp b/src/dusk/ui/button.cpp index 80925faf7f..de390893df 100644 --- a/src/dusk/ui/button.cpp +++ b/src/dusk/ui/button.cpp @@ -15,7 +15,7 @@ Rml::Element* createRoot(Rml::Element* parent, const Rml::String& tagName) { } // namespace -Button::Button(Rml::Element* parent, ButtonProps props, const Rml::String& tagName) +Button::Button(Rml::Element* parent, Props props, const Rml::String& tagName) : Component(createRoot(parent, tagName)) { update_props(std::move(props)); } @@ -55,4 +55,11 @@ void Button::update_props(Props props) { mProps = std::move(props); } +void ControlledButton::update() { + if (mIsSelected) { + set_selected(mIsSelected()); + } + Button::update(); +} + } // namespace dusk::ui \ No newline at end of file diff --git a/src/dusk/ui/button.hpp b/src/dusk/ui/button.hpp index 6066064257..d8dcd38acd 100644 --- a/src/dusk/ui/button.hpp +++ b/src/dusk/ui/button.hpp @@ -6,14 +6,12 @@ namespace dusk::ui { using ButtonCallback = std::function; -struct ButtonProps { - Rml::String text; - bool selected = false; -}; - class Button : public Component { public: - using Props = ButtonProps; + struct Props { + Rml::String text; + bool selected = false; + }; Button(Rml::Element* parent, Props props, const Rml::String& tagName = "button"); Button(Rml::Element* parent, Rml::String text, const Rml::String& tagName = "button") @@ -31,4 +29,21 @@ private: Props mProps; }; +class ControlledButton : public Button { +public: + struct Props { + Rml::String text; + std::function isSelected; + }; + + ControlledButton(Rml::Element* parent, Props props, const Rml::String& tagName = "button") + : Button(parent, Button::Props{std::move(props.text)}, tagName), + mIsSelected(std::move(props.isSelected)) {} + + void update() override; + +private: + std::function mIsSelected; +}; + } // namespace dusk::ui \ No newline at end of file diff --git a/src/dusk/ui/editor.cpp b/src/dusk/ui/editor.cpp index 22d729e8a2..6f974608f1 100644 --- a/src/dusk/ui/editor.cpp +++ b/src/dusk/ui/editor.cpp @@ -4,6 +4,8 @@ #include #include "button.hpp" +#include "d/actor/d_a_player.h" +#include "d/d_meter2_info.h" #include "number_button.hpp" #include "pane.hpp" #include "select_button.hpp" @@ -395,14 +397,23 @@ EditorWindow::EditorWindow() { leftPane .add_select_button({ .key = label, - .value = item_label_for_slot(selectItemData), + .getValue = [&selectItemData] { return item_label_for_slot(selectItemData); }, }) .on_hover([&rightPane, &selectItemData](Rml::Event&) { rightPane.clear(); - rightPane.add_button("None", [&selectItemData] { selectItemData = 0xFF; }); + rightPane.add_button( + { + .text = "None", + .isSelected = [&selectItemData] { return selectItemData == 0xFF; }, + }, + [&selectItemData] { selectItemData = 0xFF; }); for (int i = 0; i < 24; i++) { rightPane.add_button( - item_label_for_slot(i), [i, &selectItemData] { selectItemData = i; }); + { + .text = item_label_for_slot(i), + .isSelected = [i, &selectItemData] { return selectItemData == i; }, + }, + [i, &selectItemData] { selectItemData = i; }); } }); }; @@ -410,6 +421,34 @@ EditorWindow::EditorWindow() { genSelectItemComboBox("Equip Y", get_player_status()->mSelectItem[1]); genSelectItemComboBox("Combo Equip X", get_player_status()->mMixItem[0]); genSelectItemComboBox("Combo Equip Y", get_player_status()->mMixItem[1]); + + leftPane + .add_select_button({ + .key = "Clothes", + .getValue = + [] { + return itemMap.find(get_player_status()->mSelectEquip[0])->second.m_name; + }, + }) + .on_hover([&rightPane](Rml::Event&) { + rightPane.clear(); + const auto addOption = [&rightPane](const Rml::String& name, u8 id) { + rightPane.add_button( + { + .text = name, + .isSelected = + [id] { return get_player_status()->mSelectEquip[0] == id; }, + }, + [id] { + dMeter2Info_setCloth(id, false); + 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); + }); }); add_tab("Location", [this](Rml::Element* content) { diff --git a/src/dusk/ui/pane.hpp b/src/dusk/ui/pane.hpp index cf92a04967..b20611b8a6 100644 --- a/src/dusk/ui/pane.hpp +++ b/src/dusk/ui/pane.hpp @@ -19,14 +19,15 @@ public: void update() override; Rml::Element* add_section(const Rml::String& text); - Button& add_button(Button::Props props, ButtonCallback callback) { - return add_child