89 auto& chests = room.GetChests();
92 int chest_count =
static_cast<int>(chests.size());
94 chest_count > 6 ? theme.text_error_red : theme.text_primary;
98 if (chest_count > 6) {
101 if (ImGui::IsItemHovered()) {
103 tr(
"Room exceeds chest limit (6 max)!\n"
104 "This may cause game crashes."));
112 zelda3::chest_data new_chest;
114 new_chest.size =
false;
115 chests.push_back(new_chest);
116 room.MarkChestsDirty();
122 if (ImGui::IsItemHovered()) {
123 ImGui::SetTooltip(tr(
"Add new chest to room"));
127 if (chests.empty()) {
128 ImGui::TextColored(theme.text_secondary_gray,
135 std::min(200.0f, ImGui::GetContentRegionAvail().y * 0.5f);
136 ImGui::BeginChild(
"##ChestList", ImVec2(0, list_height),
true);
138 for (
size_t i = 0; i < chests.size(); ++i) {
139 const auto&
chest = chests[i];
142 ImGui::PushID(
static_cast<int>(i));
145 const char* size_icon =
147 const char* size_label =
chest.size ?
"Big" :
"Small";
150 std::string item_name =
151 (
chest.id < item_names.size())
152 ? item_names[
chest.id]
153 : absl::StrFormat(
"Unknown (0x%02X)",
chest.id);
156 std::string label = absl::StrFormat(
"%s [%zu] %s: %s", size_icon, i + 1,
157 size_label, item_name.c_str());
159 if (ImGui::Selectable(label.c_str(), is_selected)) {
165 ImVec2 min = ImGui::GetItemRectMin();
166 ImVec2 max = ImGui::GetItemRectMax();
168 ImGui::ColorConvertFloat4ToU32(theme.dungeon_selection_primary);
169 ImGui::GetWindowDrawList()->AddRect(min, max, sel_color, 0.0f, 0, 2.0f);
181 auto& chests = room.GetChests();
185 ImGui::TextColored(theme.text_secondary_gray,
196 ImGui::Text(tr(
"Type:"));
198 bool is_big =
chest.size;
199 if (ImGui::RadioButton(tr(
"Small"), !is_big)) {
201 room.MarkChestsDirty();
207 if (ImGui::RadioButton(tr(
"Big"), is_big)) {
209 room.MarkChestsDirty();
216 ImGui::Text(tr(
"Item:"));
219 std::string current_item =
220 (
chest.id < item_names.size())
221 ? absl::StrFormat(
"[%02X] %s",
chest.id,
222 item_names[
chest.id].c_str())
223 : absl::StrFormat(
"[%02X] Unknown",
chest.id);
225 ImGui::SetNextItemWidth(-1);
226 if (ImGui::BeginCombo(
"##ItemSelect", current_item.c_str())) {
228 static char search_buf[64] =
"";
229 ImGui::InputTextWithHint(
"##Search",
"Search items...", search_buf,
233 for (
size_t i = 0; i < item_names.size(); ++i) {
235 if (search_buf[0] !=
'\0') {
236 std::string name_lower = item_names[i];
237 std::string filter_lower = search_buf;
238 for (
auto& c : name_lower) {
239 c =
static_cast<char>(tolower(
static_cast<unsigned char>(c)));
241 for (
auto& c : filter_lower) {
242 c =
static_cast<char>(tolower(
static_cast<unsigned char>(c)));
244 if (name_lower.find(filter_lower) == std::string::npos) {
249 std::string item_label = absl::StrFormat(
250 "[%02X] %s",
static_cast<int>(i), item_names[i].c_str());
251 bool is_selected = (
chest.id ==
static_cast<uint8_t
>(i));
253 if (ImGui::Selectable(item_label.c_str(), is_selected)) {
254 chest.id =
static_cast<uint8_t
>(i);
255 room.MarkChestsDirty();
262 ImGui::SetItemDefaultFocus();
275 room.MarkChestsDirty();