107 const int tile_display_size =
113 const ImVec2 content_size(
119 ImGui::SetCursorPos(ImVec2(0, 0));
120 ImGui::Dummy(content_size);
121 ImGui::SetCursorPos(ImVec2(0, 0));
129 const ImVec2 window_size = ImGui::GetWindowSize();
131 target.x - (window_size.x / 2.0f) + (tile_display_size / 2.0f);
133 target.y - (window_size.y / 2.0f) + (tile_display_size / 2.0f);
134 scroll_x = std::max(0.0f, scroll_x);
135 scroll_y = std::max(0.0f, scroll_y);
136 ImGui::SetScrollX(scroll_x);
137 ImGui::SetScrollY(scroll_y);
157 ImGui::BeginTooltip();
158 ImGui::Text(
"Tile %d (0x%03X)", hovered_tile, hovered_tile);
167 auto* texture_id = atlas.
texture();
168 if (texture_id !=
nullptr) {
169 float atlas_w =
static_cast<float>(atlas.
width());
170 float atlas_h =
static_cast<float>(atlas.
height());
171 if (atlas_w > 0 && atlas_h > 0) {
172 ImVec2 uv0(src_x / atlas_w, src_y / atlas_h);
176 ImGui::Image((ImTextureID)(intptr_t)texture_id,
177 ImVec2(preview_size, preview_size), uv0, uv1);
322 constexpr ImGuiInputTextFlags kHexFlags =
323 ImGuiInputTextFlags_CharsHexadecimal |
324 ImGuiInputTextFlags_EnterReturnsTrue |
325 ImGuiInputTextFlags_AutoSelectAll;
330 ImGui::PushItemWidth(64);
331 ImGui::AlignTextToFramePadding();
332 ImGui::TextUnformatted(
"Go:");
346 if (ImGui::IsItemHovered()) {
348 "Enter tile ID and press Enter:\n"
354 ImGui::TextDisabled(
"/ 0x%03X", max_tile_id);
356 ImGui::SameLine(0, 8.0f);
357 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"Invalid hex ID");
359 ImGui::SameLine(0, 8.0f);
360 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
361 "Out of range (max: 0x%03X)", max_tile_id);
365 ImGui::SameLine(0, 12.0f);
366 ImGui::TextUnformatted(
"Range:");
369 bool range_changed =
false;
372 range_changed =
true;
374 if (ImGui::IsItemHovered()) {
376 "Min tile ID. Press Enter to apply.\n"
381 ImGui::TextUnformatted(
"-");
385 range_changed =
true;
387 if (ImGui::IsItemHovered()) {
389 "Max tile ID. Press Enter to apply.\n"
394 ImGui::TextDisabled(
"(hex, d:dec)");
402 if (has_min && has_max && parsed_min <= parsed_max) {
412 }
else if (!has_min && !has_max) {
416 }
else if (has_min && has_max && parsed_min > parsed_max) {
426 if (ImGui::SmallButton(
"X##ClearRange")) {
432 if (ImGui::IsItemHovered()) {
433 ImGui::SetTooltip(
"Clear range filter");
439 ImGui::SameLine(0, 8.0f);
440 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"Min must be <= Max");
442 ImGui::SameLine(0, 8.0f);
443 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
447 if (range_count <= 0) {
448 ImGui::SameLine(0, 8.0f);
449 ImGui::TextDisabled(
"(no tiles in range)");
453 ImGui::PopItemWidth();