92 auto& chests = room.GetChests();
95 int chest_count =
static_cast<int>(chests.size());
97 chest_count > 6 ? theme.text_error_red : theme.text_primary;
101 if (chest_count > 6) {
104 if (ImGui::IsItemHovered()) {
106 tr(
"Room exceeds chest limit (6 max)!\n"
107 "This may cause game crashes."));
115 zelda3::chest_data new_chest;
117 new_chest.size =
false;
118 chests.push_back(new_chest);
119 room.MarkChestsDirty();
125 if (ImGui::IsItemHovered()) {
126 ImGui::SetTooltip(tr(
"Add new chest to room"));
130 if (chests.empty()) {
131 ImGui::TextColored(theme.text_secondary_gray,
138 std::min(200.0f, ImGui::GetContentRegionAvail().y * 0.5f);
139 ImGui::BeginChild(
"##ChestList", ImVec2(0, list_height),
true);
141 for (
size_t i = 0; i < chests.size(); ++i) {
142 const auto&
chest = chests[i];
145 ImGui::PushID(
static_cast<int>(i));
148 const char* size_icon =
150 const char* size_label =
chest.size ?
"Big" :
"Small";
153 std::string item_name =
154 (
chest.id < item_names.size())
155 ? item_names[
chest.id]
156 : absl::StrFormat(
"Unknown (0x%02X)",
chest.id);
159 std::string label = absl::StrFormat(
"%s [%zu] %s: %s", size_icon, i + 1,
160 size_label, item_name.c_str());
162 if (ImGui::Selectable(label.c_str(), is_selected)) {
168 ImVec2 min = ImGui::GetItemRectMin();
169 ImVec2 max = ImGui::GetItemRectMax();
171 ImGui::ColorConvertFloat4ToU32(theme.dungeon_selection_primary);
172 ImGui::GetWindowDrawList()->AddRect(min, max, sel_color, 0.0f, 0, 2.0f);
184 auto& chests = room.GetChests();
188 ImGui::TextColored(theme.text_secondary_gray,
199 ImGui::Text(tr(
"Type:"));
201 bool is_big =
chest.size;
202 if (ImGui::RadioButton(tr(
"Small"), !is_big)) {
204 room.MarkChestsDirty();
210 if (ImGui::RadioButton(tr(
"Big"), is_big)) {
212 room.MarkChestsDirty();
219 ImGui::Text(tr(
"Item:"));
222 std::string current_item =
223 (
chest.id < item_names.size())
224 ? absl::StrFormat(
"[%02X] %s",
chest.id,
225 item_names[
chest.id].c_str())
226 : absl::StrFormat(
"[%02X] Unknown",
chest.id);
228 ImGui::SetNextItemWidth(-1);
229 if (ImGui::BeginCombo(
"##ItemSelect", current_item.c_str())) {
231 static char search_buf[64] =
"";
232 ImGui::InputTextWithHint(
"##Search",
"Search items...", search_buf,
236 for (
size_t i = 0; i < item_names.size(); ++i) {
238 if (search_buf[0] !=
'\0') {
239 std::string name_lower = item_names[i];
240 std::string filter_lower = search_buf;
241 for (
auto& c : name_lower) {
242 c =
static_cast<char>(tolower(
static_cast<unsigned char>(c)));
244 for (
auto& c : filter_lower) {
245 c =
static_cast<char>(tolower(
static_cast<unsigned char>(c)));
247 if (name_lower.find(filter_lower) == std::string::npos) {
252 std::string item_label = absl::StrFormat(
253 "[%02X] %s",
static_cast<int>(i), item_names[i].c_str());
254 bool is_selected = (
chest.id ==
static_cast<uint8_t
>(i));
256 if (ImGui::Selectable(item_label.c_str(), is_selected)) {
257 chest.id =
static_cast<uint8_t
>(i);
258 room.MarkChestsDirty();
265 ImGui::SetItemDefaultFocus();
278 room.MarkChestsDirty();