[Scummvm-git-logs] scummvm master -> 58e0fa5bb31fe06377c3f88fe7ae6577953c9c6c

OMGPizzaGuy noreply at scummvm.org
Fri Nov 4 21:59:38 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
58e0fa5bb3 ULTIMA8: Update mini-map on run instead of paint and do not close on toggle.


Commit: 58e0fa5bb31fe06377c3f88fe7ae6577953c9c6c
    https://github.com/scummvm/scummvm/commit/58e0fa5bb31fe06377c3f88fe7ae6577953c9c6c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-11-04T16:59:13-05:00

Commit Message:
ULTIMA8: Update mini-map on run instead of paint and do not close on toggle.

We now hide the mini map gump instead of closing to keep surface it draws infrom being discarded. The surface will be drawn on run instead of paint so it can continue updating even while the gump is hidden. This does not yet persist the mini map when saving or on map change.

Changed paths:
    engines/ultima/ultima8/gumps/minimap_gump.cpp
    engines/ultima/ultima8/gumps/minimap_gump.h
    engines/ultima/ultima8/misc/debugger.cpp


diff --git a/engines/ultima/ultima8/gumps/minimap_gump.cpp b/engines/ultima/ultima8/gumps/minimap_gump.cpp
index 9181103ce23..ea95684ede4 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.cpp
+++ b/engines/ultima/ultima8/gumps/minimap_gump.cpp
@@ -49,27 +49,9 @@ MiniMapGump::MiniMapGump() : Gump() , _lastMapNum(0){
 MiniMapGump::~MiniMapGump(void) {
 }
 
-void MiniMapGump::setPixelAt(int x, int y, uint32 pixel) {
-	if (_minimap.format.bytesPerPixel == 2) {
-		uint16 *buf = (uint16 *)_minimap.getBasePtr(x, y);
-		*buf = pixel;
-	} else {
-		uint32 *buf = (uint32 *)_minimap.getBasePtr(x, y);
-		*buf = pixel;
-	}
-}
-
-uint32 MiniMapGump::getPixelAt(int x, int y) const {
-	if (_minimap.format.bytesPerPixel == 2) {
-		const uint16 *buf = (const uint16 *)_minimap.getBasePtr(x, y);
-		return *buf;
-	} else {
-		const uint32 *buf = (const uint32 *)_minimap.getBasePtr(x, y);
-		return *buf;
-	}
-}
+void MiniMapGump::run() {
+	Gump::run();
 
-void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
 	World *world = World::get_instance();
 	CurrentMap *currentmap = world->getCurrentMap();
 	int mapChunkSize = currentmap->getChunkSize();
@@ -79,29 +61,35 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
 		_lastMapNum = currentmap->getNum();
 	}
 
-	// Draw the yellow border
-	surf->Fill32(0xFFFFAF00, 0, 0, MAP_NUM_CHUNKS * 2 + 3, 1);
-	surf->Fill32(0xFFFFAF00, 0, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
-	surf->Fill32(0xFFFFAF00, 1, MAP_NUM_CHUNKS * 2 + 1, MAP_NUM_CHUNKS * 2 + 1, 1);
-	surf->Fill32(0xFFFFAF00, MAP_NUM_CHUNKS * 2 + 1, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
-
 	// Draw into the map surface
 	for (int yv = 0; yv < MAP_NUM_CHUNKS; yv++) {
 		for (int xv = 0; xv < MAP_NUM_CHUNKS; xv++) {
 			if (currentmap->isChunkFast(xv, yv)) {
 				for (int j = 0; j < MINMAPGUMP_SCALE; j++) for (int i = 0; i < MINMAPGUMP_SCALE; i++) {
-					uint32 val = getPixelAt(xv * MINMAPGUMP_SCALE + i, yv * MINMAPGUMP_SCALE + j);
+					uint32 val = _minimap.getPixel(xv * MINMAPGUMP_SCALE + i, yv * MINMAPGUMP_SCALE + j);
 					if (val == 0) {
 						val = sampleAtPoint(
 							xv * mapChunkSize + mapChunkSize / (MINMAPGUMP_SCALE * 2) + (mapChunkSize * i) / MINMAPGUMP_SCALE,
 							yv * mapChunkSize + mapChunkSize / (MINMAPGUMP_SCALE * 2) + (mapChunkSize * j) / MINMAPGUMP_SCALE,
 							currentmap);
-						setPixelAt(xv * MINMAPGUMP_SCALE + i, yv * MINMAPGUMP_SCALE + j, val);
+						_minimap.setPixel(xv * MINMAPGUMP_SCALE + i, yv * MINMAPGUMP_SCALE + j, val);
 					}
 				}
 			}
 		}
 	}
+}
+
+void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
+	World *world = World::get_instance();
+	CurrentMap *currentmap = world->getCurrentMap();
+	int mapChunkSize = currentmap->getChunkSize();
+
+	// Draw the yellow border
+	surf->Fill32(0xFFFFAF00, 0, 0, MAP_NUM_CHUNKS * 2 + 3, 1);
+	surf->Fill32(0xFFFFAF00, 0, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
+	surf->Fill32(0xFFFFAF00, 1, MAP_NUM_CHUNKS * 2 + 1, MAP_NUM_CHUNKS * 2 + 1, 1);
+	surf->Fill32(0xFFFFAF00, MAP_NUM_CHUNKS * 2 + 1, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
 
 	// Center on avatar
 	int sx = 0, sy = 0, ox = 0, oy = 0, lx = 0, ly = 0;
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.h b/engines/ultima/ultima8/gumps/minimap_gump.h
index e7754b6863d..63f41524f55 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.h
+++ b/engines/ultima/ultima8/gumps/minimap_gump.h
@@ -35,8 +35,6 @@ private:
 	Graphics::ManagedSurface _minimap;
 	unsigned int        _lastMapNum;
 
-	uint32 getPixelAt(int x, int y) const;
-	void setPixelAt(int x, int y, uint32 pixel);
 	uint32 sampleAtPoint(int x, int y, CurrentMap *map);
 public:
 	ENABLE_RUNTIME_CLASSTYPE()
@@ -45,6 +43,8 @@ public:
 	MiniMapGump(int x, int y);
 	~MiniMapGump() override;
 
+	void run() override;
+
 	void        PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) override;
 	uint16      TraceObjId(int32 mx, int32 my) override;
 
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 57aa9b8a50d..2deae975ced 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -1797,8 +1797,10 @@ bool Debugger::cmdToggleMinimap(int argc, const char **argv) {
 		mmg = new MiniMapGump(4, 4);
 		mmg->InitGump(0);
 		mmg->setRelativePosition(Gump::TOP_LEFT, 4, 4);
+	} else if (mmg->IsHidden()) {
+		mmg->UnhideGump();
 	} else {
-		mmg->Close();
+		mmg->HideGump();
 	}
 
 	return false;




More information about the Scummvm-git-logs mailing list