[Scummvm-git-logs] scummvm master -> e678ed2bb8f537751409ad14b7065106815a573e

OMGPizzaGuy noreply at scummvm.org
Tue Apr 30 12:30:23 UTC 2024


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

Summary:
f73b9b0c48 ULTIMA8: Add config settings for walk and run thresholds
e678ed2bb8 ULTIMA8: Override mouse length with step & run key binds


Commit: f73b9b0c48a3f6eea6a7a75967f4579db3c61a48
    https://github.com/scummvm/scummvm/commit/f73b9b0c48a3f6eea6a7a75967f4579db3c61a48
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-04-30T07:16:55-05:00

Commit Message:
ULTIMA8: Add config settings for walk and run thresholds

Changed paths:
    engines/ultima/ultima8/kernel/mouse.cpp
    engines/ultima/ultima8/kernel/mouse.h


diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index 15b0bcf2773..6581e481ae7 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "graphics/cursorman.h"
 #include "ultima/ultima.h"
 #include "ultima/ultima8/kernel/mouse.h"
@@ -45,6 +46,22 @@ Mouse::Mouse() : _lastMouseFrame(-1), _flashingCursorTime(0), _mouseOverGump(0),
 
 	_cursors.push(MOUSE_NONE);
 	CursorMan.showMouse(false);
+
+	// The original game switches cursors from small -> medium -> large on
+	// rectangles - in x, ~30px and ~130px away from the avatar (center) on
+	// the 320px screen, and approximately the same proportions in y.
+	//
+	// These cursors correspond to the player movement of step -> walk -> run.
+	// 
+	// Modern players may be in a window so give them a little bit more
+	// space to make the large cursor without having to hit the edge.
+
+	// Walk & run threshold range of 0-255
+	ConfMan.registerDefault("walk_threshold", 24);
+	ConfMan.registerDefault("run_threshold", 80);
+
+	_walkThreshold = CLIP<int>(ConfMan.getInt("walk_threshold"), 0, 255);
+	_runThreshold = CLIP<int>(ConfMan.getInt("run_threshold"), 0, 255);
 }
 
 Mouse::~Mouse() {
@@ -134,28 +151,19 @@ int Mouse::getMouseLength(int mx, int my) const {
 	RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
 	screen->GetSurfaceDims(dims);
 
-	//
-	// The original game switches cursors from small -> medium -> large on
-	// rectangles - in x, ~30px and ~130px away from the avatar (center) on
-	// the 320px screen, and approximately the same proportions in y.
-	//
-	// Modern players may be in a window so give them a little bit more
-	// space to make the large cursor without having to hit the edge.
-	//
-
 	// Reference point is the center of the screen
 	int dx = abs(mx - dims.width() / 2);
 	int dy = abs((dims.height() / 2) - my);
-	int xmed = dims.width() * 100 / 320;
-	int ymed = dims.height() * 100 / 320;
+	int xmed = dims.width() * _runThreshold / 255;
+	int ymed = dims.height() * _runThreshold / 255;
 
 	if (dx > xmed || dy > ymed)
 		return 2;
 
 	// For short cursor, reference point is near the avatar's feet
 	dy = abs((dims.height() / 2 + 14) - my); //! constant
-	int xshort = dims.width() * 30 / 320;
-	int yshort = dims.height() * 30 / 320;
+	int xshort = dims.width() * _walkThreshold / 255;
+	int yshort = dims.height() * _walkThreshold / 255;
 
 	if (dx > xshort || dy > yshort)
 		return 1;
diff --git a/engines/ultima/ultima8/kernel/mouse.h b/engines/ultima/ultima8/kernel/mouse.h
index 6e2244b8584..3d49e989def 100644
--- a/engines/ultima/ultima8/kernel/mouse.h
+++ b/engines/ultima/ultima8/kernel/mouse.h
@@ -118,6 +118,9 @@ private:
 	ObjId _dragging_objId;
 	uint16 _draggingItem_startGump;
 	uint16 _draggingItem_lastGump;
+
+	int _walkThreshold;
+	int _runThreshold;
 private:
 	void startDragging(int mx, int my);
 	void moveDragging(int mx, int my);


Commit: e678ed2bb8f537751409ad14b7065106815a573e
    https://github.com/scummvm/scummvm/commit/e678ed2bb8f537751409ad14b7065106815a573e
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-04-30T07:16:55-05:00

Commit Message:
ULTIMA8: Override mouse length with step & run key binds
This with a low walk threshold provides a solution for feature request #15105

Changed paths:
    engines/ultima/ultima8/kernel/mouse.cpp
    engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp


diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index 6581e481ae7..c0fa5a2dc48 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -29,6 +29,7 @@
 #include "ultima/ultima8/kernel/kernel.h"
 #include "ultima/ultima8/misc/direction_util.h"
 #include "ultima/ultima8/world/get_object.h"
+#include "ultima/ultima8/world/actors/avatar_mover_process.h"
 #include "ultima/ultima8/world/actors/main_actor.h"
 #include "ultima/ultima8/graphics/shape.h"
 #include "ultima/ultima8/graphics/shape_frame.h"
@@ -147,8 +148,17 @@ bool Mouse::isMouseDownEvent(MouseButton button) const {
 }
 
 int Mouse::getMouseLength(int mx, int my) const {
+	Ultima8Engine *engine = Ultima8Engine::get_instance();
+	AvatarMoverProcess *proc = engine->getAvatarMoverProcess();
+	if (proc) {
+		if (proc->hasMovementFlags(AvatarMoverProcess::MOVE_STEP))
+			return 0;
+		if (proc->hasMovementFlags(AvatarMoverProcess::MOVE_RUN))
+			return 2;
+	}
+
 	Rect dims;
-	RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
+	RenderSurface *screen = engine->getRenderScreen();
 	screen->GetSurfaceDims(dims);
 
 	// Reference point is the center of the screen
diff --git a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
index c2a1a63ba0f..584abc420e3 100644
--- a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
@@ -230,7 +230,7 @@ void U8AvatarMoverProcess::handleCombatMode() {
 			nextanim = Animation::advance;
 		}
 
-		if (mouselength == 2) {
+		if (mouselength == 2 || hasMovementFlags(MOVE_RUN)) {
 			// Take a step before running
 			nextanim = Animation::walk;
 			avatar->setActorFlag(Actor::ACT_COMBATRUN);
@@ -508,9 +508,9 @@ void U8AvatarMoverProcess::handleNormalMode() {
 		if (checkTurn(mousedir, false))
 			return;
 
-		Animation::Sequence nextanim = Animation::jumpUp;
-		if (mouselength > 0) {
-			nextanim = Animation::jump;
+		Animation::Sequence nextanim = Animation::jump;
+		if (mouselength == 0 || hasMovementFlags(MOVE_STEP)) {
+			nextanim = Animation::jumpUp;
 		}
 
 		// check if there's something we can climb up onto here
@@ -539,11 +539,11 @@ void U8AvatarMoverProcess::handleNormalMode() {
 	}
 
 	if (hasMovementFlags(MOVE_MOUSE_DIRECTION)) {
-		Animation::Sequence nextanim = Animation::step;
+		Animation::Sequence nextanim = Animation::walk;
 
-		if (mouselength == 1) {
-			nextanim = Animation::walk;
-		} else if (mouselength == 2) {
+		if (mouselength == 0 || hasMovementFlags(MOVE_STEP)) {
+			nextanim = Animation::step;
+		} else if (mouselength == 2 || hasMovementFlags(MOVE_RUN)) {
 			if (lastanim == Animation::run
 			        || lastanim == Animation::runningJump
 			        || lastanim == Animation::walk)




More information about the Scummvm-git-logs mailing list