[Scummvm-git-logs] scummvm master -> f7e7bfaa4a6d0d5d0e871e094dc80cee65366bed
OMGPizzaGuy
noreply at scummvm.org
Sat Jun 10 14:36:00 UTC 2023
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:
f7e7bfaa4a ULTIMA8: Use system configurable double-click time
Commit: f7e7bfaa4a6d0d5d0e871e094dc80cee65366bed
https://github.com/scummvm/scummvm/commit/f7e7bfaa4a6d0d5d0e871e094dc80cee65366bed
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-06-10T09:35:27-05:00
Commit Message:
ULTIMA8: Use system configurable double-click time
Changed paths:
engines/ultima/ultima8/kernel/mouse.cpp
engines/ultima/ultima8/kernel/mouse.h
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 609afe44fb7..c61ac1c403b 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -55,6 +55,8 @@ bool Mouse::buttonDown(MouseButton button) {
assert(button != MOUSE_LAST);
bool handled = false;
uint32 now = g_system->getMillis();
+ uint32 timeout = g_system->getDoubleClickTime();
+ timeout = timeout > 0 ? timeout : DOUBLE_CLICK_TIMEOUT;
MButton &mbutton = _mouseButton[button];
@@ -72,7 +74,7 @@ bool Mouse::buttonDown(MouseButton button) {
mbutton.setState(MBS_DOWN);
mbutton.clearState(MBS_HANDLED);
- if (mbutton.isUnhandledDoubleClick()) {
+ if (mbutton.isUnhandledDoubleClick(timeout)) {
if (_dragging == Mouse::DRAG_NOT) {
Gump *gump = getGump(mbutton._downGump);
if (gump) {
@@ -515,9 +517,13 @@ void Mouse::stopDragging(int mx, int my) {
}
void Mouse::handleDelayedEvents() {
+ uint32 now = g_system->getMillis();
+ uint32 timeout = g_system->getDoubleClickTime();
+ timeout = timeout > 0 ? timeout : DOUBLE_CLICK_TIMEOUT;
+
for (int button = 0; button < MOUSE_LAST; ++button) {
if (!(_mouseButton[button]._state & (MBS_HANDLED | MBS_DOWN)) &&
- !_mouseButton[button].lastWithinDblClkTimeout()) {
+ !_mouseButton[button].lastWithinDblClkTimeout(now, timeout)) {
Gump *gump = getGump(_mouseButton[button]._downGump);
if (gump) {
int32 mx = _mouseButton[button]._downPoint.x;
diff --git a/engines/ultima/ultima8/kernel/mouse.h b/engines/ultima/ultima8/kernel/mouse.h
index 3e700756cce..f97a5855aae 100644
--- a/engines/ultima/ultima8/kernel/mouse.h
+++ b/engines/ultima/ultima8/kernel/mouse.h
@@ -30,7 +30,7 @@
namespace Ultima {
namespace Ultima8 {
-const unsigned int DOUBLE_CLICK_TIMEOUT = 200;
+const unsigned int DOUBLE_CLICK_TIMEOUT = 300;
enum MouseButtonState {
MBS_DOWN = 0x1,
@@ -58,20 +58,18 @@ struct MButton {
_state &= ~state;
}
- bool curWithinDblClkTimeout() {
- uint32 now = g_system->getMillis();
- return now - _curDown <= DOUBLE_CLICK_TIMEOUT;
+ bool curWithinDblClkTimeout(uint32 now, uint32 timeout) {
+ return now - _curDown <= timeout;
}
- bool lastWithinDblClkTimeout() {
- uint32 now = g_system->getMillis();
- return now - _lastDown <= DOUBLE_CLICK_TIMEOUT;
+ bool lastWithinDblClkTimeout(uint32 now, uint32 timeout) {
+ return now - _lastDown <= timeout;
}
//! A convenience function - true if the current state is down, unhandled, and within the double click timeout.
- bool isUnhandledDoubleClick() {
+ bool isUnhandledDoubleClick(uint32 timeout) {
return isState(MBS_DOWN) && !isState(MBS_HANDLED) &&
- (_curDown - _lastDown) <= DOUBLE_CLICK_TIMEOUT;
+ (_curDown - _lastDown) <= timeout;
}
};
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 14f700d1771..0e61a68c0e7 100644
--- a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
@@ -52,15 +52,19 @@ void U8AvatarMoverProcess::handleHangingMode() {
if (stasis)
return;
+ uint32 now = g_system->getMillis();
+ uint32 timeout = g_system->getDoubleClickTime();
+ timeout = timeout > 0 ? timeout : DOUBLE_CLICK_TIMEOUT;
+
bool m0clicked = false;
//bool m1clicked = false;
if (!_mouseButton[0].isState(MBS_HANDLED) &&
- !_mouseButton[0].curWithinDblClkTimeout()) {
+ !_mouseButton[0].curWithinDblClkTimeout(now, timeout)) {
m0clicked = true;
_mouseButton[0].setState(MBS_HANDLED);
}
if (!_mouseButton[1].isState(MBS_HANDLED) &&
- !_mouseButton[1].curWithinDblClkTimeout()) {
+ !_mouseButton[1].curWithinDblClkTimeout(now, timeout)) {
//m1clicked = true;
_mouseButton[1].setState(MBS_HANDLED);
}
@@ -116,17 +120,21 @@ void U8AvatarMoverProcess::handleCombatMode() {
if (stasis)
return;
+ uint32 now = g_system->getMillis();
+ uint32 timeout = g_system->getDoubleClickTime();
+ timeout = timeout > 0 ? timeout : DOUBLE_CLICK_TIMEOUT;
+
bool m0clicked = false;
bool m1clicked = false;
if (!_mouseButton[0].isState(MBS_HANDLED) &&
- !_mouseButton[0].curWithinDblClkTimeout()) {
+ !_mouseButton[0].curWithinDblClkTimeout(now, timeout)) {
m0clicked = true;
_mouseButton[0].setState(MBS_HANDLED);
}
if (!_mouseButton[1].isState(MBS_HANDLED) &&
- !_mouseButton[1].curWithinDblClkTimeout()) {
+ !_mouseButton[1].curWithinDblClkTimeout(now, timeout)) {
m1clicked = true;
_mouseButton[1].setState(MBS_HANDLED);
}
@@ -152,7 +160,7 @@ void U8AvatarMoverProcess::handleCombatMode() {
Common::RandomSource &rs = Ultima8Engine::get_instance()->getRandomSource();
- if (_mouseButton[0].isUnhandledDoubleClick()) {
+ if (_mouseButton[0].isUnhandledDoubleClick(timeout)) {
_mouseButton[0].setState(MBS_HANDLED);
_mouseButton[0]._lastDown = 0;
@@ -174,7 +182,7 @@ void U8AvatarMoverProcess::handleCombatMode() {
return;
}
- if (_mouseButton[1].isUnhandledDoubleClick()) {
+ if (_mouseButton[1].isUnhandledDoubleClick(timeout)) {
_mouseButton[1].setState(MBS_HANDLED);
_mouseButton[1]._lastDown = 0;
@@ -356,18 +364,22 @@ void U8AvatarMoverProcess::handleNormalMode() {
return;
}
+ uint32 now = g_system->getMillis();
+ uint32 timeout = g_system->getDoubleClickTime();
+ timeout = timeout > 0 ? timeout : DOUBLE_CLICK_TIMEOUT;
+
bool m0clicked = false;
bool m1clicked = false;
// check mouse state to see what needs to be done
if (!_mouseButton[0].isState(MBS_HANDLED) &&
- !_mouseButton[0].curWithinDblClkTimeout()) {
+ !_mouseButton[0].curWithinDblClkTimeout(now, timeout)) {
m0clicked = true;
_mouseButton[0].setState(MBS_HANDLED);
}
if (!_mouseButton[1].isState(MBS_HANDLED) &&
- !_mouseButton[1].curWithinDblClkTimeout()) {
+ !_mouseButton[1].curWithinDblClkTimeout(now, timeout)) {
m1clicked = true;
_mouseButton[1].setState(MBS_HANDLED);
}
@@ -431,7 +443,7 @@ void U8AvatarMoverProcess::handleNormalMode() {
down = _mouseButton[0]._curDown - down;
}
- if (down < DOUBLE_CLICK_TIMEOUT) {
+ if (down < timeout) {
// Both buttons pressed within the timeout
_mouseButton[0].setState(MBS_HANDLED);
_mouseButton[1].setState(MBS_HANDLED);
@@ -446,7 +458,7 @@ void U8AvatarMoverProcess::handleNormalMode() {
setMovementFlag(MOVE_JUMP);
}
- if (_mouseButton[1].isUnhandledDoubleClick()) {
+ if (_mouseButton[1].isUnhandledDoubleClick(timeout)) {
Gump *desktopgump = Ultima8Engine::get_instance()->getDesktopGump();
int32 mx, my;
mouse->getMouseCoords(mx, my);
More information about the Scummvm-git-logs
mailing list