122 const int tile_display_size =
128 ImGui::SetCursorPos(ImVec2(0, 0));
129 ImGui::Dummy(content_size);
130 ImGui::SetCursorPos(ImVec2(0, 0));
138 const ImVec2 window_size = ImGui::GetWindowSize();
140 target.x - (window_size.x / 2.0f) + (tile_display_size / 2.0f);
142 target.y - (window_size.y / 2.0f) + (tile_display_size / 2.0f);
143 scroll_x = std::max(0.0f, scroll_x);
144 scroll_y = std::max(0.0f, scroll_y);
145 ImGui::SetScrollX(scroll_x);
146 ImGui::SetScrollY(scroll_y);
165 ImGui::BeginTooltip();
166 ImGui::Text(tr(
"Tile %d (0x%03X)"), hovered_tile, hovered_tile);
175 auto* texture_id = atlas.
texture();
176 if (texture_id !=
nullptr) {
177 float atlas_w =
static_cast<float>(atlas.
width());
178 float atlas_h =
static_cast<float>(atlas.
height());
179 if (atlas_w > 0 && atlas_h > 0) {
180 ImVec2 uv0(src_x / atlas_w, src_y / atlas_h);
184 ImGui::Image((ImTextureID)(intptr_t)texture_id,
185 ImVec2(preview_size, preview_size), uv0, uv1);
332 const float available_width =
333 std::max(ImGui::GetContentRegionAvail().x, 1.0f);
334 const bool compact_layout = available_width < 420.0f;
335 const float jump_input_width =
336 compact_layout ? std::clamp(available_width * 0.28f, 56.0f, 88.0f)
338 const float range_input_width =
340 ? std::clamp((available_width - 110.0f) * 0.5f, 56.0f, 88.0f)
343 constexpr ImGuiInputTextFlags kHexFlags =
344 ImGuiInputTextFlags_CharsHexadecimal |
345 ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll;
350 ImGui::AlignTextToFramePadding();
351 ImGui::TextUnformatted(tr(
"Go:"));
354 ImGui::SetNextItemWidth(jump_input_width);
366 if (ImGui::IsItemHovered()) {
368 tr(
"Enter tile ID and press Enter:\n"
374 ImGui::TextDisabled(tr(
"/ 0x%03X"), max_tile_id);
376 if (compact_layout) {
380 ImGui::SameLine(0, 8.0f);
381 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), tr(
"Invalid hex ID"));
383 ImGui::SameLine(0, 8.0f);
384 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
385 tr(
"Out of range (max: 0x%03X)"), max_tile_id);
390 if (!compact_layout) {
391 ImGui::SameLine(0, 12.0f);
393 ImGui::TextUnformatted(tr(
"Range:"));
396 bool range_changed =
false;
397 ImGui::SetNextItemWidth(range_input_width);
400 range_changed =
true;
402 if (ImGui::IsItemHovered()) {
404 tr(
"Min tile ID. Press Enter to apply.\n"
409 ImGui::TextUnformatted(
"-");
411 ImGui::SetNextItemWidth(range_input_width);
414 range_changed =
true;
416 if (ImGui::IsItemHovered()) {
418 tr(
"Max tile ID. Press Enter to apply.\n"
422 if (!compact_layout) {
424 ImGui::TextDisabled(tr(
"(hex, d:dec)"));
427 ImGui::TextDisabled(tr(
"hex or d:dec"));
436 if (has_min && has_max && parsed_min <= parsed_max) {
446 }
else if (!has_min && !has_max) {
450 }
else if (has_min && has_max && parsed_min > parsed_max) {
459 if (!compact_layout) {
462 if (ImGui::SmallButton(tr(
"X##ClearRange"))) {
468 if (ImGui::IsItemHovered()) {
469 ImGui::SetTooltip(tr(
"Clear range filter"));
475 if (!compact_layout) {
476 ImGui::SameLine(0, 8.0f);
478 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
479 tr(
"Min must be <= Max"));
481 if (!compact_layout) {
482 ImGui::SameLine(0, 8.0f);
484 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
488 if (range_count <= 0) {
489 if (!compact_layout) {
490 ImGui::SameLine(0, 8.0f);
492 ImGui::TextDisabled(tr(
"(no tiles in range)"));