[Scummvm-git-logs] scummvm master -> 12cf2edad22307572dc26c6d594a129cd6133242

OMGPizzaGuy noreply at scummvm.org
Fri Dec 23 04:00:34 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:
12cf2edad2 ULTIMA8: Add hightlight to minimap border when mouse over resize positions


Commit: 12cf2edad22307572dc26c6d594a129cd6133242
    https://github.com/scummvm/scummvm/commit/12cf2edad22307572dc26c6d594a129cd6133242
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-22T21:59:58-06:00

Commit Message:
ULTIMA8: Add hightlight to minimap border when mouse over resize positions

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


diff --git a/engines/ultima/ultima8/gumps/minimap_gump.cpp b/engines/ultima/ultima8/gumps/minimap_gump.cpp
index f9c0db16f6e..a90e88c2a40 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.cpp
+++ b/engines/ultima/ultima8/gumps/minimap_gump.cpp
@@ -33,6 +33,9 @@ namespace Ultima8 {
 
 DEFINE_RUNTIME_CLASSTYPE_CODE(MiniMapGump)
 
+static const uint32 NORMAL_COLOR = 0xFFFFAF00;
+static const uint32 HIGHLIGHT_COLOR = 0xFFFFCF00;
+
 MiniMapGump::MiniMapGump(int x, int y) : ResizableGump(x, y, 120, 120), _minimaps(), _ax(0), _ay(0) {
 	setMinSize(60, 60);
 }
@@ -106,11 +109,15 @@ void MiniMapGump::clear() {
 }
 
 void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
-	// Draw the yellow border
-	surf->Fill32(0xFFFFAF00, 0, 0, _dims.width(), 1);
-	surf->Fill32(0xFFFFAF00, 0, 1, 1, _dims.height());
-	surf->Fill32(0xFFFFAF00, 1, _dims.bottom - 1, _dims.width(), 1);
-	surf->Fill32(0xFFFFAF00, _dims.right - 1, 1, 1, _dims.height());
+	uint32 color = NORMAL_COLOR;
+	if (_dragPosition != Gump::CENTER || _mousePosition != Gump::CENTER)
+		color = HIGHLIGHT_COLOR;
+
+	// Draw the border
+	surf->Fill32(color, 0, 0, _dims.width(), 1);
+	surf->Fill32(color, 0, 1, 1, _dims.height());
+	surf->Fill32(color, 1, _dims.bottom - 1, _dims.width(), 1);
+	surf->Fill32(color, _dims.right - 1, 1, 1, _dims.height());
 
 	// Dimensions minus border
 	Common::Rect dims(_dims.left, _dims.top, _dims.right, _dims.bottom);
@@ -162,10 +169,10 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
 	int32 ay = _ay - sy;
 
 	// Paint the avatar position marker
-	surf->Fill32(0xFFFFFF00, 1 + ax - 2, 1 + ay + 0, 2, 1);
-	surf->Fill32(0xFFFFFF00, 1 + ax + 0, 1 + ay - 2, 1, 2);
-	surf->Fill32(0xFFFFFF00, 1 + ax + 1, 1 + ay + 0, 2, 1);
-	surf->Fill32(0xFFFFFF00, 1 + ax + 0, 1 + ay + 1, 1, 2);
+	surf->Fill32(color, 1 + ax - 2, 1 + ay + 0, 2, 1);
+	surf->Fill32(color, 1 + ax + 0, 1 + ay - 2, 1, 2);
+	surf->Fill32(color, 1 + ax + 1, 1 + ay + 0, 2, 1);
+	surf->Fill32(color, 1 + ax + 0, 1 + ay + 1, 1, 2);
 }
 
 Gump *MiniMapGump::onMouseDown(int button, int32 mx, int32 my) {
diff --git a/engines/ultima/ultima8/gumps/resizable_gump.cpp b/engines/ultima/ultima8/gumps/resizable_gump.cpp
index 4b4b870b0d7..370b3383748 100644
--- a/engines/ultima/ultima8/gumps/resizable_gump.cpp
+++ b/engines/ultima/ultima8/gumps/resizable_gump.cpp
@@ -28,42 +28,39 @@ namespace Ultima8 {
 #define RESIZE_BORDER 5
 
 ResizableGump::ResizableGump(int x, int y, int width, int height)
-	: Gump(x, y, width, height, 0, FLAG_DRAGGABLE, LAYER_NORMAL), _dragPosition(Gump::CENTER), _minWidth(20), _minHeight(20) {
+	: Gump(x, y, width, height, 0, FLAG_DRAGGABLE, LAYER_NORMAL),
+	_dragPosition(Gump::CENTER), _mousePosition(Gump::CENTER), _minWidth(20), _minHeight(20) {
 }
 
-ResizableGump::ResizableGump() : Gump(), _dragPosition(Gump::CENTER), _minWidth(20), _minHeight(20) {
+ResizableGump::ResizableGump() : Gump(),
+	_dragPosition(Gump::CENTER), _mousePosition(Gump::CENTER), _minWidth(20), _minHeight(20) {
 }
 
 ResizableGump::~ResizableGump() {
 }
 
+
+Gump *ResizableGump::onMouseMotion(int32 mx, int32 my) {
+	_mousePosition = getPosition(mx, my);
+	return Gump::onMouseMotion(mx, my);
+}
+
+void ResizableGump::onMouseLeft() {
+	_mousePosition = Gump::CENTER;
+}
+
 bool ResizableGump::onDragStart(int32 mx, int32 my) {
 	if (Gump::onDragStart(mx, my)) {
-		ParentToGump(mx, my);
-		if (mx < _dims.left + RESIZE_BORDER && my < _dims.top + RESIZE_BORDER) {
-			_dragPosition = Gump::TOP_LEFT;
-		} else if (mx >= _dims.right - RESIZE_BORDER && my < _dims.top + RESIZE_BORDER) {
-			_dragPosition = Gump::TOP_RIGHT;
-		} else if (mx < _dims.left + RESIZE_BORDER && my >= _dims.bottom - RESIZE_BORDER) {
-			_dragPosition = Gump::BOTTOM_LEFT;
-		} else if (mx >= _dims.right - RESIZE_BORDER && my >= _dims.bottom - RESIZE_BORDER) {
-			_dragPosition = Gump::BOTTOM_RIGHT;
-		} else if (my < _dims.top + RESIZE_BORDER) {
-			_dragPosition = Gump::TOP_CENTER;
-		} else if (my >= _dims.bottom - RESIZE_BORDER) {
-			_dragPosition = Gump::BOTTOM_CENTER;
-		} else if (mx < _dims.left + RESIZE_BORDER) {
-			_dragPosition = Gump::LEFT_CENTER;
-		} else if (mx >= _dims.right - RESIZE_BORDER) {
-			_dragPosition = Gump::RIGHT_CENTER;
-		} else {
-			_dragPosition = Gump::CENTER;
-		}
+		_dragPosition = getPosition(mx, my);
 		return true;
 	}
 	return false;
 }
 
+void ResizableGump::onDragStop(int32 mx, int32 my) {
+	_dragPosition = Gump::CENTER;
+}
+
 void ResizableGump::onDrag(int32 mx, int32 my) {
 	int32 x = _x;
 	int32 y = _y;
@@ -130,5 +127,28 @@ void ResizableGump::onDrag(int32 mx, int32 my) {
 	}
 }
 
+Gump::Position ResizableGump::getPosition(int32 mx, int32 my) {
+	Gump::Position position = Gump::CENTER;
+	ParentToGump(mx, my);
+	if (mx < _dims.left + RESIZE_BORDER && my < _dims.top + RESIZE_BORDER) {
+		position = Gump::TOP_LEFT;
+	} else if (mx >= _dims.right - RESIZE_BORDER && my < _dims.top + RESIZE_BORDER) {
+		position = Gump::TOP_RIGHT;
+	} else if (mx < _dims.left + RESIZE_BORDER && my >= _dims.bottom - RESIZE_BORDER) {
+		position = Gump::BOTTOM_LEFT;
+	} else if (mx >= _dims.right - RESIZE_BORDER && my >= _dims.bottom - RESIZE_BORDER) {
+		position = Gump::BOTTOM_RIGHT;
+	} else if (my < _dims.top + RESIZE_BORDER) {
+		position = Gump::TOP_CENTER;
+	} else if (my >= _dims.bottom - RESIZE_BORDER) {
+		position = Gump::BOTTOM_CENTER;
+	} else if (mx < _dims.left + RESIZE_BORDER) {
+		position = Gump::LEFT_CENTER;
+	} else if (mx >= _dims.right - RESIZE_BORDER) {
+		position = Gump::RIGHT_CENTER;
+	}
+	return position;
+}
+
 } // End of namespace Ultima8
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gumps/resizable_gump.h b/engines/ultima/ultima8/gumps/resizable_gump.h
index c13999d2e6f..3ea0ca9553a 100644
--- a/engines/ultima/ultima8/gumps/resizable_gump.h
+++ b/engines/ultima/ultima8/gumps/resizable_gump.h
@@ -32,8 +32,8 @@ namespace Ultima8 {
  * An example of such would be the Console and the GameMap gumps
  */
 class ResizableGump : public Gump {
-private:
-	Gump::Position _dragPosition;
+protected:
+	Gump::Position _dragPosition, _mousePosition;
 	int32 _minWidth;
 	int32 _minHeight;
 
@@ -47,8 +47,15 @@ public:
 		_minHeight = minHeight;
 	}
 
+	Gump *onMouseMotion(int32 mx, int32 my) override;
+	void onMouseLeft() override;
+
 	bool onDragStart(int32 mx, int32 my) override;
+	void onDragStop(int32 mx, int32 my) override;
 	void onDrag(int32 mx, int32 my) override;
+
+private:
+	Gump::Position getPosition(int32 mx, int32 my);
 };
 
 } // End of namespace Ultima8




More information about the Scummvm-git-logs mailing list