From a02d14bb5fcfdd0c25a9add6edd49109d5ff8755 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 10 Sep 2023 12:29:31 -0700 Subject: [PATCH] alternate drawing designation and priority --- plugins/pathable.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/plugins/pathable.cpp b/plugins/pathable.cpp index e63947caf..1ba88631e 100644 --- a/plugins/pathable.cpp +++ b/plugins/pathable.cpp @@ -11,6 +11,7 @@ #include "df/init.h" #include "df/map_block.h" #include "df/tile_designation.h" +#include "df/block_square_event_designation_priorityst.h" #include @@ -276,12 +277,35 @@ static bool blink(int delay) { return (Core::getInstance().p->getTickCount()/delay) % 2 == 0; } +static char get_tile_char(const df::coord &pos, char desig_char, bool draw_priority) { + if (!draw_priority) + return desig_char; + + std::vector priorities; + Maps::SortBlockEvents(Maps::getTileBlock(pos), NULL, NULL, NULL, NULL, NULL, NULL, NULL, &priorities); + if (priorities.empty()) + return '4'; + switch (priorities[0]->priority[pos.x % 16][pos.y % 16] / 1000) { + case 1: return '1'; + case 2: return '2'; + case 3: return '3'; + case 4: return '4'; + case 5: return '5'; + case 6: return '6'; + case 7: return '7'; + default: + return '0'; + } +} + static void paintScreenCarve() { DEBUG(log).print("entering paintScreenCarve\n"); if (Screen::inGraphicsMode() || blink(500)) return; + bool draw_priority = blink(1000); + auto dims = Gui::getDwarfmodeViewDims().map(); for (int y = dims.first.y; y <= dims.second.y; ++y) { for (int x = dims.first.x; x <= dims.second.x; ++x) { @@ -303,15 +327,15 @@ static void paintScreenCarve() { if (is_designated_for_smoothing(map_pos)) { if (is_smooth_wall(map_pos)) - cur_tile.ch = (char)206; // hash, indicating a fortification designation + cur_tile.ch = get_tile_char(map_pos, 206, draw_priority); // hash, indicating a fortification designation else - cur_tile.ch = (char)219; // solid block, indicating a smoothing designation + cur_tile.ch = get_tile_char(map_pos, 219, draw_priority); // solid block, indicating a smoothing designation } else if (is_designated_for_engraving(map_pos)) { - cur_tile.ch = (char)10; // solid block with a circle on it + cur_tile.ch = get_tile_char(map_pos, 10, draw_priority); // solid block with a circle on it } else if (is_designated_for_track_carving(map_pos)) { - cur_tile.ch = get_track_char(map_pos); // directional track + cur_tile.ch = get_tile_char(map_pos, get_track_char(map_pos), draw_priority); // directional track } else { TRACE(log).print("skipping tile with no carving designation\n");