194 ImGui::TextColored(theme.text_secondary_gray,
195 tr(
"Select a door style, then click a wall in the room "
196 "canvas to place it."));
208 constexpr float kDoorCardHeight = 48.0f;
209 constexpr float kDoorCardSpacing = 6.0f;
210 constexpr float kMinDoorCardWidth = 92.0f;
211 const float panel_width = ImGui::GetContentRegionAvail().x;
212 const int items_per_row =
213 std::max(2,
static_cast<int>((panel_width + kDoorCardSpacing) /
214 (kMinDoorCardWidth + kDoorCardSpacing)));
215 const float card_width = std::max(
217 (panel_width - (items_per_row - 1) * kDoorCardSpacing) / items_per_row);
219 ImGui::BeginChild(
"##DoorTypeGrid", ImVec2(0, 150),
true,
220 ImGuiWindowFlags_AlwaysVerticalScrollbar);
223 for (
size_t i = 0; i < kDoorTypes.size(); ++i) {
224 const auto door_type = kDoorTypes[i];
226 const int type_val =
static_cast<int>(door_type);
227 ImGui::PushID(
static_cast<int>(i));
229 ImVec4 button_color = DoorTypeAccent(theme, door_type);
231 button_color.x = std::min(1.0f, button_color.x + 0.2f);
232 button_color.y = std::min(1.0f, button_color.y + 0.2f);
233 button_color.z = std::min(1.0f, button_color.z + 0.2f);
237 {ImGuiCol_Button, button_color},
238 {ImGuiCol_ButtonHovered,
239 ImVec4(button_color.x + 0.1f, button_color.y + 0.1f,
240 button_color.z + 0.1f, 1.0f)},
241 {ImGuiCol_ButtonActive,
242 ImVec4(button_color.x + 0.2f, button_color.y + 0.2f,
243 button_color.z + 0.2f, 1.0f)},
246 const std::string label =
247 absl::StrFormat(
"%s %02X\n%s", DoorTypeIcon(door_type), type_val,
248 ShortDoorTypeLabel(door_type).c_str());
249 if (ImGui::Button(label.c_str(), ImVec2(card_width, kDoorCardHeight))) {
258 if (ImGui::IsItemHovered()) {
259 ImGui::SetTooltip(tr(
"%s (0x%02X)\nClick to select for placement"),
265 ImVec2 min = ImGui::GetItemRectMin();
266 ImVec2 max = ImGui::GetItemRectMax();
267 ImGui::GetWindowDrawList()->AddRect(min, max, IM_COL32(255, 255, 0, 255),
273 if (col < items_per_row && i < kDoorTypes.size() - 1) {
282 if (!
rooms_ || current_room_id_ < 0 || current_room_id_ >= 296) {
287 const auto& doors = room.GetDoors();
292 ImGui::TextColored(theme.text_secondary_gray,
297 int selected_door_index = -1;
300 const auto selected_entity =
303 selected_door_index =
static_cast<int>(selected_entity.index);
307 if (selected_door_index >= 0 &&
308 selected_door_index <
static_cast<int>(doors.size())) {
309 uint8_t raw_type =
static_cast<uint8_t
>(doors[selected_door_index].type);
310 ImGui::AlignTextToFramePadding();
311 ImGui::TextUnformatted(tr(
"Selected raw type"));
313 ImGui::SetNextItemWidth(72.0f);
315 "##SelectedDoorRawType", ImGuiDataType_U8, &raw_type,
"%02X",
316 ImGuiInputTextFlags_CharsHexadecimal,
317 {
reinterpret_cast<uintptr_t
>(
rooms_),
319 static_cast<uint64_t
>(selected_door_index)});
321 "Selected door raw type byte");
331 ImGui::BeginChild(
"##DoorList", ImVec2(0, 0),
true);
332 for (
size_t i = 0; i < doors.size(); ++i) {
333 const auto& door = doors[i];
334 const auto [tile_x, tile_y] = door.GetTileCoords();
338 ImGui::PushID(
static_cast<int>(i));
339 const std::string row_label = absl::StrFormat(
"[%zu] %s", i, type_name);
340 const bool row_selected = ImGui::Selectable(
341 row_label.c_str(), selected_door_index ==
static_cast<int>(i));
343 "Select a door in the current dungeon room");
350 ImGui::TextColored(theme.text_secondary_gray,
"(%s @ %d,%d)",
351 dir_name.c_str(), tile_x, tile_y);
DungeonCanvasViewer * canvas_viewer_
zelda3::DoorType selected_door_type_
DungeonCanvasViewer * ResolveCanvasViewer()
std::function< DungeonCanvasViewer *()> canvas_viewer_provider_
void OnClose() override
Called when panel is hidden.
void Draw(bool *p_open) override
Draw the panel content.
std::function< void()> open_selection_inspector_callback_
std::string ShortDoorTypeLabel(zelda3::DoorType type)
ImVec4 DoorTypeAccent(const AgentUITheme &theme, zelda3::DoorType type)
const char * DoorTypeIcon(zelda3::DoorType type)