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);
167 ImGui::BeginTooltip();
168 ImGui::Text(tr(
"Tile %d (0x%03X)"), hovered_tile, hovered_tile);
177 auto* texture_id = atlas.
texture();
178 if (texture_id !=
nullptr) {
179 float atlas_w =
static_cast<float>(atlas.
width());
180 float atlas_h =
static_cast<float>(atlas.
height());
181 if (atlas_w > 0 && atlas_h > 0) {
182 ImVec2 uv0(src_x / atlas_w, src_y / atlas_h);
186 ImGui::Image((ImTextureID)(intptr_t)texture_id,
187 ImVec2(preview_size, preview_size), uv0, uv1);
334 const float available_width =
335 std::max(ImGui::GetContentRegionAvail().x, 1.0f);
336 const bool compact_layout = available_width < 420.0f;
337 const float jump_input_width =
338 compact_layout ? std::clamp(available_width * 0.28f, 56.0f, 88.0f)
340 const float range_input_width =
342 ? std::clamp((available_width - 110.0f) * 0.5f, 56.0f, 88.0f)
345 constexpr ImGuiInputTextFlags kHexFlags =
346 ImGuiInputTextFlags_CharsHexadecimal |
347 ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll;
352 ImGui::AlignTextToFramePadding();
353 ImGui::TextUnformatted(tr(
"Go:"));
356 ImGui::SetNextItemWidth(jump_input_width);
368 if (ImGui::IsItemHovered()) {
370 tr(
"Enter tile ID and press Enter:\n"
376 ImGui::TextDisabled(tr(
"/ 0x%03X"), max_tile_id);
378 if (compact_layout) {
382 ImGui::SameLine(0, 8.0f);
383 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), tr(
"Invalid hex ID"));
385 ImGui::SameLine(0, 8.0f);
386 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
387 tr(
"Out of range (max: 0x%03X)"), max_tile_id);
392 if (!compact_layout) {
393 ImGui::SameLine(0, 12.0f);
395 ImGui::TextUnformatted(tr(
"Range:"));
398 bool range_changed =
false;
399 ImGui::SetNextItemWidth(range_input_width);
402 range_changed =
true;
404 if (ImGui::IsItemHovered()) {
406 tr(
"Min tile ID. Press Enter to apply.\n"
411 ImGui::TextUnformatted(
"-");
413 ImGui::SetNextItemWidth(range_input_width);
416 range_changed =
true;
418 if (ImGui::IsItemHovered()) {
420 tr(
"Max tile ID. Press Enter to apply.\n"
424 if (!compact_layout) {
426 ImGui::TextDisabled(tr(
"(hex, d:dec)"));
429 ImGui::TextDisabled(tr(
"hex or d:dec"));
438 if (has_min && has_max && parsed_min <= parsed_max) {
448 }
else if (!has_min && !has_max) {
452 }
else if (has_min && has_max && parsed_min > parsed_max) {
461 if (!compact_layout) {
464 if (ImGui::SmallButton(tr(
"X##ClearRange"))) {
470 if (ImGui::IsItemHovered()) {
471 ImGui::SetTooltip(tr(
"Clear range filter"));
477 if (!compact_layout) {
478 ImGui::SameLine(0, 8.0f);
480 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
481 tr(
"Min must be <= Max"));
483 if (!compact_layout) {
484 ImGui::SameLine(0, 8.0f);
486 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
490 if (range_count <= 0) {
491 if (!compact_layout) {
492 ImGui::SameLine(0, 8.0f);
494 ImGui::TextDisabled(tr(
"(no tiles in range)"));