Skip to content

Commit

Permalink
Fix tile search sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Aug 18, 2024
1 parent 2cad776 commit 71d2c6f
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ std::array bunny_names{
"Tutorial Bunny",
"Illegal 1",
"Origami Bunny",
"Crow Bunny",
"Spike Room Bunny",
"Ghost Bunny",
"Illegal 2",
"Fish Mural Bunny",
Expand Down Expand Up @@ -195,7 +195,7 @@ std::array bunny_names{
"Dream Bunny",
"Illegal 16",
"Floor Is Lava Bunny",
"Spike Room Bunny",
"Crow Bunny",
};

std::array portal_names{
Expand Down Expand Up @@ -1327,8 +1327,8 @@ void UI::DrawSelectedTile(SelectedTile &tile) {
void UI::DrawSelectedTileRow(SelectedTile &tile) {
DrawTileRow(*tile.tile);
ImGui::SameLine(0, 4);
ImGui::Text("%d,%d %d,%d %s", tile.room.x, tile.room.y, tile.pos.x,
tile.pos.y, (tile.layer ? "BG" : "FG"));
ImGui::Text("%02d,%02d %02d,%02d %s", tile.room.x, tile.room.y, tile.pos.x,
tile.pos.y, (tile.layer ? "B" : "F"));
ImGui::SameLine(ImGui::GetContentRegionMax().x - 24.f * uiScale, 0);
if (ImGui::Button("Go", ImVec2(24.f * uiScale, ImGui::GetFrameHeight()))) {
*Max::get().warp_map() = tile.map;
Expand Down Expand Up @@ -1505,6 +1505,18 @@ void UI::DrawLevel() {
}
}
}
std::sort(searchTiles.begin(), searchTiles.end(),
[](const auto &a, const auto &b) {
return (a.room.y < b.room.y) ||
(a.room.y == b.room.y && a.room.x < b.room.x) ||
(a.room.y == b.room.y && a.room.x == b.room.x &&
a.pos.y < b.pos.y) ||
(a.room.y == b.room.y && a.room.x == b.room.x &&
a.pos.y == b.pos.y && a.pos.x < b.pos.x) ||
(a.room.y == b.room.y && a.room.x == b.room.x &&
a.pos.y == b.pos.y && a.pos.x == b.pos.x &&
a.layer < b.layer);
});
}
int i = 0;
ImGui::PushID("TileSearchResults");
Expand Down Expand Up @@ -2076,8 +2088,13 @@ void UI::HUD() {
->AddRect(TileToScreen(ImVec2(rx, ry)),
TileToScreen(ImVec2(rx + 1, ry + 1)), 0xddffffff, 0, 0,
3.f);
std::string coord =
fmt::format("Screen: {},{}\n Tile: {},{}", x, y, rx, ry);
int wx = 320 * Max::get().player_room()->x + x;
int wy = 180 * Max::get().player_room()->y + y;
int mx = 40 * Max::get().player_room()->x + rx;
int my = 22 * Max::get().player_room()->y + ry;
std::string coord = fmt::format(
"Screen: {},{}\n Tile: {},{}\n World: {},{}\n Map: {},{}", x, y,
rx, ry, wx, wy, mx, my);
coord += fmt::format("\n Flags: 0x{:X}",
Max::get().get_room_tile_flags(rx, ry, 0xffff));
if (fg && bg)
Expand Down

0 comments on commit 71d2c6f

Please sign in to comment.