From 2450cbe42b1f36bd2b85abfc08ae25f6663b6a16 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sun, 20 Apr 2008 14:20:40 +0000 Subject: Fixing minimap issue where the markers could get confused if there were multiple squares with the player colour. Markers no longer depend on the contents of the map. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4409 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/guic-win.cc | 31 +++++++++++++++---------------- crawl-ref/source/guic-x11.cc | 41 ++++++++++++++++++++++++++--------------- crawl-ref/source/guic.cc | 1 + crawl-ref/source/guic.h | 11 +++++++---- crawl-ref/source/libgui.cc | 16 ++++++++++++++-- 5 files changed, 63 insertions(+), 37 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/guic-win.cc b/crawl-ref/source/guic-win.cc index 432f14d8c8..ba7208128b 100644 --- a/crawl-ref/source/guic-win.cc +++ b/crawl-ref/source/guic-win.cc @@ -574,11 +574,9 @@ void MapRegionClass::redraw(int x1, int y1, int x2, int y2) ReleaseDC(win->hWnd, hdc); } -void MapRegionClass::draw_data(unsigned char *buf) +void MapRegionClass::draw_data(unsigned char *buf, bool show_mark, + int mark_x, int mark_y) { - static int px = 0; - static int py = 0; - if (!flag) return; @@ -603,10 +601,10 @@ void MapRegionClass::draw_data(unsigned char *buf) // erase old markers for (int j = 0; j < dy * marker_length; j++) - *(pDibBit0 + BUF_IDX(px, 0, dx/2 + x_margin, j)) = MAP_BLACK; + *(pDibBit0 + BUF_IDX(old_mark_x, 0, dx/2 + x_margin, j)) = MAP_BLACK; for (int j = 0; j < dx * marker_length; j++) - *(pDibBit0 + BUF_IDX(0, py, j, dy/2 + y_margin)) = MAP_BLACK; + *(pDibBit0 + BUF_IDX(0, old_mark_y, j, dy/2 + y_margin)) = MAP_BLACK; force_redraw = true; @@ -618,11 +616,6 @@ void MapRegionClass::draw_data(unsigned char *buf) { int col = (j >= my2 - y_margin || i >= mx2 - x_margin) ? MAP_BLACK : ptr[i]; - if (col == Options.tile_player_col) - { - px = i; - py = j; - } if ( col != get_col(i,j) || force_redraw || i < marker_length || j < marker_length) { @@ -643,12 +636,18 @@ void MapRegionClass::draw_data(unsigned char *buf) ppix += inc_y; } - // draw new markers - for (int j = 0; j < dy * marker_length; j++) - *(pDibBit0 + BUF_IDX(px, 0, dx/2 + x_margin, j)) = MAP_WHITE; + old_mark_x = mark_x; + old_mark_y = mark_y; - for (int j = 0; j < dx * marker_length; j++) - *(pDibBit0 + BUF_IDX(0, py, j, dy/2 + y_margin)) = MAP_WHITE; + if (show_mark) + { + // draw new markers + for (int j = 0; j < dy * marker_length; j++) + *(pDibBit0 + BUF_IDX(mark_x, 0, dx/2 + x_margin, j)) = MAP_WHITE; + + for (int j = 0; j < dx * marker_length; j++) + *(pDibBit0 + BUF_IDX(0, mark_y, j, dy/2 + y_margin)) = MAP_WHITE; + } redraw(); force_redraw = false; diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index 402b8680d8..18052dab2a 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -318,19 +318,23 @@ void MapRegionClass::redraw(int x1, int y1, int x2, int y2) (x2-x1+1)*dx, (y2-y1+1)*dy); } -void MapRegionClass::draw_data(unsigned char *buf) +void MapRegionClass::draw_data(unsigned char *buf, bool show_mark, + int mark_x, int mark_y) { - static int px = 0; - static int py = 0; - if (!flag) return; for (int yy = 0; yy < dy * marker_length; yy++) - XPutPixel(backbuf, px*dx+dx/2 + x_margin, yy, map_pix[MAP_BLACK]); + { + XPutPixel(backbuf, old_mark_x*dx+dx/2 + x_margin, yy, + map_pix[MAP_BLACK]); + } for (int xx = 0; xx < dx * marker_length; xx++) - XPutPixel(backbuf, xx, py*dy+dy/2 + y_margin, map_pix[MAP_BLACK]); + { + XPutPixel(backbuf, xx, old_mark_y*dy+dy/2 + y_margin, + map_pix[MAP_BLACK]); + } for (int y = 0; y < my - y_margin; y++) { @@ -338,11 +342,6 @@ void MapRegionClass::draw_data(unsigned char *buf) for (int x = 0; x < mx - x_margin; x++) { int col = ptr[x]; - if (col == Options.tile_player_col) - { - px = x; - py = y; - } if (col != get_col(x, y) || force_redraw || x < marker_length || y < marker_length) { @@ -358,11 +357,23 @@ void MapRegionClass::draw_data(unsigned char *buf) } } - for (int yy = 0; yy < dy * marker_length; yy++) - XPutPixel(backbuf, px*dx+dx/2 + x_margin, yy, map_pix[MAP_WHITE]); + old_mark_x = mark_x; + old_mark_y = mark_y; - for (int xx = 0; xx < dx * marker_length; xx++) - XPutPixel(backbuf, xx, py*dy+dy/2 + y_margin, map_pix[MAP_WHITE]); + if (show_mark) + { + for (int yy = 0; yy < dy * marker_length; yy++) + { + XPutPixel(backbuf, old_mark_x*dx+dx/2 + x_margin, yy, + map_pix[MAP_WHITE]); + } + + for (int xx = 0; xx < dx * marker_length; xx++) + { + XPutPixel(backbuf, xx, old_mark_y*dy+dy/2 + y_margin, + map_pix[MAP_WHITE]); + } + } redraw(); XFlush(display); diff --git a/crawl-ref/source/guic.cc b/crawl-ref/source/guic.cc index daa9266150..eb823b0dc6 100644 --- a/crawl-ref/source/guic.cc +++ b/crawl-ref/source/guic.cc @@ -316,6 +316,7 @@ MapRegionClass::MapRegionClass(int x, int y, int o_x, int o_y, int marker_len) x_margin = o_x; y_margin = o_y; marker_length = marker_len; + old_mark_x = old_mark_y = 0; force_redraw = false; SysInit(x, y, o_x, o_y); diff --git a/crawl-ref/source/guic.h b/crawl-ref/source/guic.h index b49c2b4d5f..68b5190972 100644 --- a/crawl-ref/source/guic.h +++ b/crawl-ref/source/guic.h @@ -352,9 +352,9 @@ class TileRegionClass :public RegionClass ~TileRegionClass(); }; -class MapRegionClass :public RegionClass +class MapRegionClass : public RegionClass { - public: +public: int mx2; int my2; int x_margin; @@ -363,7 +363,7 @@ class MapRegionClass :public RegionClass unsigned char *mbuf; bool force_redraw; bool mouse_pos(int mouse_x, int mouse_y, int *cx, int *cy); - void draw_data(unsigned char *buf); + void draw_data(unsigned char *buf, bool show_mark, int mark_x, int mark_y); void redraw(int x1, int y1, int x2, int y2); void redraw(); void clear(); @@ -377,11 +377,14 @@ class MapRegionClass :public RegionClass int get_col(int x, int y); MapRegionClass(int x, int y, int o_x, int o_y, int marker_length); + ~MapRegionClass(); void SysInit(int x, int y, int o_x, int o_y); void SysDeinit(); - ~MapRegionClass(); +protected: + int old_mark_x; + int old_mark_y; }; #define PLACE_RIGHT 0 diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index a63497d717..6ccf2ae5a7 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -341,6 +341,9 @@ int tile_idx_unseen_terrain(int x, int y, int what) void GmapUpdate(int x, int y, int what, bool upd_tile) { + if ((you.level_type == LEVEL_LABYRINTH) || (you.level_type == LEVEL_ABYSS)) + return; + int c; if (x == you.x_pos && y == you.y_pos) @@ -467,16 +470,25 @@ void GmapDisplay(int linex, int liney) count += GXM - (gmap_max_x - gmap_min_x + 1); } - if ( (you.level_type != LEVEL_LABYRINTH)&&(you.level_type != LEVEL_ABYSS) ) + bool show_mark = false; + int mark_x = 0; + int mark_y = 0; + if ((you.level_type != LEVEL_LABYRINTH) && (you.level_type != LEVEL_ABYSS)) { ox += linex - gmap_min_x; oy += liney - gmap_min_y; + + mark_x = ox; + mark_y = oy; + show_mark = true; + // highlight centre of the map + // [enne] Maybe we need another colour for the highlight? buf2[ox + oy * GXM] = Options.tile_player_col; } region_map->flag = true; - region_map->draw_data(buf2); + region_map->draw_data(buf2, show_mark, mark_x, mark_y); } /* initialize routines */ -- cgit v1.2.3-54-g00ecf