124 const int tile_display_size =
130 ImGui::SetCursorPos(ImVec2(0, 0));
131 ImGui::Dummy(content_size);
132 ImGui::SetCursorPos(ImVec2(0, 0));
140 const ImVec2 window_size = ImGui::GetWindowSize();
142 target.x - (window_size.x / 2.0f) + (tile_display_size / 2.0f);
144 target.y - (window_size.y / 2.0f) + (tile_display_size / 2.0f);
145 scroll_x = std::max(0.0f, scroll_x);
146 scroll_y = std::max(0.0f, scroll_y);
147 ImGui::SetScrollX(scroll_x);
148 ImGui::SetScrollY(scroll_y);
168 ImGui::BeginTooltip();
169 ImGui::Text(
"Tile %d (0x%03X)", hovered_tile, hovered_tile);
178 auto* texture_id = atlas.
texture();
179 if (texture_id !=
nullptr) {
180 float atlas_w =
static_cast<float>(atlas.
width());
181 float atlas_h =
static_cast<float>(atlas.
height());
182 if (atlas_w > 0 && atlas_h > 0) {
183 ImVec2 uv0(src_x / atlas_w, src_y / atlas_h);
187 ImGui::Image((ImTextureID)(intptr_t)texture_id,
188 ImVec2(preview_size, preview_size), uv0, uv1);
332 const float available_width = std::max(ImGui::GetContentRegionAvail().x, 1.0f);
333 const bool compact_layout = available_width < 420.0f;
334 const float jump_input_width =
335 compact_layout ? std::clamp(available_width * 0.28f, 56.0f, 88.0f)
337 const float range_input_width =
338 compact_layout ? std::clamp((available_width - 110.0f) * 0.5f, 56.0f, 88.0f)
341 constexpr ImGuiInputTextFlags kHexFlags =
342 ImGuiInputTextFlags_CharsHexadecimal |
343 ImGuiInputTextFlags_EnterReturnsTrue |
344 ImGuiInputTextFlags_AutoSelectAll;
349 ImGui::AlignTextToFramePadding();
350 ImGui::TextUnformatted(
"Go:");
353 ImGui::SetNextItemWidth(jump_input_width);
365 if (ImGui::IsItemHovered()) {
367 "Enter tile ID and press Enter:\n"
373 ImGui::TextDisabled(
"/ 0x%03X", max_tile_id);
375 if (compact_layout) {
379 ImGui::SameLine(0, 8.0f);
380 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"Invalid hex ID");
382 ImGui::SameLine(0, 8.0f);
383 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
384 "Out of range (max: 0x%03X)", max_tile_id);
389 if (!compact_layout) {
390 ImGui::SameLine(0, 12.0f);
392 ImGui::TextUnformatted(
"Range:");
395 bool range_changed =
false;
396 ImGui::SetNextItemWidth(range_input_width);
399 range_changed =
true;
401 if (ImGui::IsItemHovered()) {
403 "Min tile ID. Press Enter to apply.\n"
408 ImGui::TextUnformatted(
"-");
410 ImGui::SetNextItemWidth(range_input_width);
413 range_changed =
true;
415 if (ImGui::IsItemHovered()) {
417 "Max tile ID. Press Enter to apply.\n"
421 if (!compact_layout) {
423 ImGui::TextDisabled(
"(hex, d:dec)");
426 ImGui::TextDisabled(
"hex or d:dec");
435 if (has_min && has_max && parsed_min <= parsed_max) {
445 }
else if (!has_min && !has_max) {
449 }
else if (has_min && has_max && parsed_min > parsed_max) {
458 if (!compact_layout) {
461 if (ImGui::SmallButton(
"X##ClearRange")) {
467 if (ImGui::IsItemHovered()) {
468 ImGui::SetTooltip(
"Clear range filter");
474 if (!compact_layout) {
475 ImGui::SameLine(0, 8.0f);
477 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"Min must be <= Max");
479 if (!compact_layout) {
480 ImGui::SameLine(0, 8.0f);
482 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
486 if (range_count <= 0) {
487 if (!compact_layout) {
488 ImGui::SameLine(0, 8.0f);
490 ImGui::TextDisabled(
"(no tiles in range)");