[Scummvm-git-logs] scummvm master -> 6ad1b281b76106346120d149a5fcec5c4600b66b
bluegr
noreply at scummvm.org
Sun Mar 6 12:41:05 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2ed0dea723 CHEWY: Simplify the event manager code
a80e543a3c CHEWY: Start replacing minfo for cursor position
6ad1b281b7 CHEWY: Refactor the mouse code to use CursorMan and ScummVM cursors
Commit: 2ed0dea72337d175608629ab173ae4983ceb91e6
https://github.com/scummvm/scummvm/commit/2ed0dea72337d175608629ab173ae4983ceb91e6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-06T14:40:42+02:00
Commit Message:
CHEWY: Simplify the event manager code
Merge the EventsBase and EventsManager classes
Changed paths:
R engines/chewy/events_base.cpp
R engines/chewy/events_base.h
engines/chewy/dialogs/main_menu.h
engines/chewy/events.cpp
engines/chewy/events.h
engines/chewy/module.mk
diff --git a/engines/chewy/dialogs/main_menu.h b/engines/chewy/dialogs/main_menu.h
index 97489cdf4ff..bf398246e0d 100644
--- a/engines/chewy/dialogs/main_menu.h
+++ b/engines/chewy/dialogs/main_menu.h
@@ -22,7 +22,7 @@
#ifndef CHEWY_MAIN_MENU_H
#define CHEWY_MAIN_MENU_H
-#include "chewy/events_base.h"
+#include "chewy/events.h"
namespace Chewy {
namespace Dialogs {
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index 86564e53508..a3c41ad1865 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -28,7 +28,8 @@ namespace Chewy {
EventsManager *g_events;
-EventsManager::EventsManager(Graphics::Screen *screen) : EventsBase(screen) {
+EventsManager::EventsManager(Graphics::Screen *screen, uint refreshRate) : _screen(screen) {
+ addTimer(updateScreen, refreshRate);
g_events = this;
init_timer_handler();
}
@@ -37,7 +38,6 @@ EventsManager::~EventsManager() {
g_events = nullptr;
}
-
void EventsManager::init_timer_handler() {
_G(timer_int) = true;
_G(timer_count) = 0;
@@ -50,14 +50,35 @@ void EventsManager::timer_handler() {
++_G(timer_count);
}
+void EventsManager::checkTimers() {
+ uint32 currTime = g_system->getMillis();
+
+ for (TimerList::iterator it = _timers.begin(); it != _timers.end(); ++it) {
+ TimerRecord &rec = *it;
+ if (currTime >= rec._nextFrameTime) {
+ rec._proc();
+ rec._nextFrameTime = currTime + rec._interval;
+ }
+ }
+}
+
+void EventsManager::updateScreen() {
+ if (g_events->_screen)
+ g_events->_screen->update();
+ else
+ g_system->updateScreen();
+}
+
void EventsManager::handleEvent(const Common::Event &event) {
if (event.type >= Common::EVENT_MOUSEMOVE && event.type <= Common::EVENT_MBUTTONUP)
handleMouseEvent(event);
- else if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP)
+ else if (event.type == Common::EVENT_KEYUP)
handleKbdEvent(event);
}
void EventsManager::handleMouseEvent(const Common::Event &event) {
+ _pendingEvents.push(event);
+
_mousePos = event.mouse;
bool isWheelEnabled = !_G(menu_display) && !_G(flags).InventMenu &&
g_engine->canSaveAutosaveCurrently() &&
@@ -109,12 +130,14 @@ void EventsManager::handleMouseEvent(const Common::Event &event) {
// Set mouse position
if (!_cursorMoveFl) {
_cursorMoveFl = true;
- _G(minfo).x = event.mouse.x;
- _G(minfo).y = event.mouse.y;
+ g_events->_mousePos.x = event.mouse.x;
+ g_events->_mousePos.y = event.mouse.y;
}
}
void EventsManager::handleKbdEvent(const Common::Event &event) {
+ _pendingKeyEvents.push(event);
+
if (_kbInfo) {
if (event.type == Common::EVENT_KEYDOWN) {
_kbInfo->_keyCode = event.kbd.ascii;
@@ -145,6 +168,10 @@ void EventsManager::clearEvents() {
}
_G(minfo)._button = 0;
+
+ processEvents();
+ _pendingEvents.clear();
+ _pendingKeyEvents.clear();
}
KbdInfo *EventsManager::setKbdInfo(KbdInfo *kbInfo) {
@@ -153,9 +180,60 @@ KbdInfo *EventsManager::setKbdInfo(KbdInfo *kbInfo) {
return kb;
}
-void EventsManager::setMousePos(const Common::Point &pt) {
- g_system->warpMouse(pt.x, pt.y);
- _mousePos = pt;
+void EventsManager::update() {
+ // Brief pause to prevent 100% CPU usage
+ g_system->delayMillis(10);
+
+ // Check for any timers that have to be triggered
+ checkTimers();
+
+ // Process events
+ processEvents();
+}
+
+#define MOUSE_MOVE \
+ if (moveEvent.type != Common::EVENT_INVALID) { \
+ handleEvent(moveEvent); \
+ moveEvent.type = Common::EVENT_INVALID; \
+ }
+
+void EventsManager::processEvents() {
+ Common::Event e;
+ Common::Event moveEvent;
+
+ while (g_system->getEventManager()->pollEvent(e)) {
+ switch (e.type) {
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RETURN_TO_LAUNCHER:
+ return;
+
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYUP:
+ MOUSE_MOVE;
+ handleEvent(e);
+ break;
+
+ default:
+ if (e.type == Common::EVENT_MOUSEMOVE) {
+ // Mouse move events get cached so the engine isn't
+ // spammed with multiple sequential move events
+ moveEvent = e;
+ } else {
+ MOUSE_MOVE;
+ handleEvent(e);
+ return;
+ }
+ break;
+ }
+ }
+
+ MOUSE_MOVE;
+}
+
+#undef MOUSE_MOVE
+
+void EventsManager::warpMouse(const Common::Point &newPos) {
+ g_system->warpMouse(newPos.x, newPos.y);
}
void delay(size_t time) {
diff --git a/engines/chewy/events.h b/engines/chewy/events.h
index be5b3f3e955..6c67804c503 100644
--- a/engines/chewy/events.h
+++ b/engines/chewy/events.h
@@ -22,40 +22,128 @@
#ifndef CHEWY_EVENTS_H
#define CHEWY_EVENTS_H
-#include "chewy/events_base.h"
+#include "common/events.h"
+#include "common/queue.h"
+#include "graphics/screen.h"
namespace Chewy {
struct KbdInfo;
+typedef void (*TimerProc)();
+
+class EventsManager {
+ struct TimerRecord {
+ TimerProc _proc;
+ uint32 _interval;
+ uint32 _nextFrameTime;
+ TimerRecord(TimerProc proc, uint32 interval) : _proc(proc), _interval(interval), _nextFrameTime(0) {
+ }
+ };
+ typedef Common::List<TimerRecord> TimerList;
-class EventsManager : public EventsBase {
private:
void init_timer_handler();
static void timer_handler();
void handleMouseEvent(const Common::Event &event);
void handleKbdEvent(const Common::Event &event);
-protected:
- void handleEvent(const Common::Event &event) override;
+
+ TimerList _timers;
+ Common::Queue<Common::Event> _pendingEvents;
+ Common::Queue<Common::Event> _pendingKeyEvents;
+
+ /**
+ * Checks for timer expiries
+ */
+ void checkTimers();
+
+ /**
+ * Timer proc for regularly updating the screen
+ */
+ static void updateScreen();
+
+ /**
+ * Adds a new timer method
+ * @param proc Timer method to execute
+ * @param interval Interval in milliseconds between calls
+ */
+ void addTimer(TimerProc proc, uint interval) {
+ _timers.push_back(TimerRecord(proc, interval));
+ }
+
+ /**
+ * Process any pending events
+ */
+ void processEvents();
+
+ /**
+ * Handles pending event
+ */
+ void handleEvent(const Common::Event &event);
+
public:
KbdInfo *_kbInfo = nullptr;
Common::Point _mousePos;
bool _flag1 = false;
bool _flag2 = false;
- EventsManager(Graphics::Screen *screen);
+ EventsManager(Graphics::Screen *screen, uint refreshRate = 1000 / 50);
virtual ~EventsManager();
void delay(size_t time);
- void clearEvents();
-
KbdInfo *setKbdInfo(KbdInfo *kbInfo);
+ Graphics::Screen *_screen;
+
/**
- * Set the mouse position
+ * Handles doing a brief delay, checking for timer updates,
+ * and polling events
*/
- void setMousePos(const Common::Point &pt);
+ void update();
+
+ /**
+ * Returns true if any unprocessed keyboard events are pending
+ */
+ bool keyEventPending() {
+ processEvents();
+ return !_pendingKeyEvents.empty();
+ }
+
+ /**
+ * Returns true if any unprocessed event other than key events
+ * are pending
+ */
+ bool eventPending() {
+ processEvents();
+ return !_pendingEvents.empty();
+ }
+
+ /**
+ * Returns the next pending unprocessed keyboard event
+ */
+ Common::Event getPendingKeyEvent() {
+ processEvents();
+ return _pendingKeyEvents.empty() ? Common::Event() : _pendingKeyEvents.pop();
+ }
+
+ /**
+ * Returns the next event, if any
+ */
+ Common::Event getPendingEvent() {
+ processEvents();
+ return _pendingEvents.empty() ? Common::Event() : _pendingEvents.pop();
+ }
+
+ /**
+ * Sets the mouse position
+ */
+ void warpMouse(const Common::Point &newPos);
+
+ /**
+ * Clear any pending events
+ */
+ void clearEvents();
};
extern EventsManager *g_events;
diff --git a/engines/chewy/events_base.cpp b/engines/chewy/events_base.cpp
deleted file mode 100644
index 35dfff63ffb..00000000000
--- a/engines/chewy/events_base.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/system.h"
-#include "chewy/events_base.h"
-
-namespace Chewy {
-
-EventsBase *g_eventsBase;
-
-EventsBase::EventsBase(Graphics::Screen *screen, uint refreshRate) : _screen(screen) {
- g_eventsBase = this;
- addTimer(updateScreen, refreshRate);
-}
-
-EventsBase::EventsBase(uint refreshRate) : _screen(nullptr) {
- g_eventsBase = this;
- addTimer(updateScreen, refreshRate);
-}
-
-EventsBase::~EventsBase() {
- g_eventsBase = nullptr;
-}
-
-void EventsBase::checkTimers() {
- uint32 currTime = g_system->getMillis();
-
- for (TimerList::iterator it = _timers.begin(); it != _timers.end(); ++it) {
- TimerRecord &rec = *it;
- if (currTime >= rec._nextFrameTime) {
- rec._proc();
- rec._nextFrameTime = currTime + rec._interval;
- }
- }
-}
-
-void EventsBase::updateScreen() {
- if (g_eventsBase->_screen)
- g_eventsBase->_screen->update();
- else
- g_system->updateScreen();
-}
-
-void EventsBase::update() {
- // Brief pause to prevent 100% CPU usage
- g_system->delayMillis(10);
-
- // Check for any timers that have to be triggered
- checkTimers();
-
- // Process events
- processEvents();
-}
-
-#define MOUSE_MOVE \
- if (moveEvent.type != Common::EVENT_INVALID) { \
- handleEvent(moveEvent); \
- moveEvent.type = Common::EVENT_INVALID; \
- }
-
-void EventsBase::processEvents() {
- Common::Event e;
- Common::Event moveEvent;
-
- while (g_system->getEventManager()->pollEvent(e)) {
- switch (e.type) {
- case Common::EVENT_QUIT:
- case Common::EVENT_RETURN_TO_LAUNCHER:
- return;
-
- case Common::EVENT_KEYDOWN:
- case Common::EVENT_KEYUP:
- MOUSE_MOVE;
- handleEvent(e);
- break;
-
- default:
- if (e.type == Common::EVENT_MOUSEMOVE) {
- // Mouse move events get cached so the engine isn't
- // spammed with multiple sequential move events
- moveEvent = e;
- } else {
- MOUSE_MOVE;
- handleEvent(e);
- return;
- }
- break;
- }
- }
-
- MOUSE_MOVE;
-}
-
-#undef MOUSE_MOVE
-
-void EventsBase::handleEvent(const Common::Event &event) {
- if (event.type == Common::EVENT_KEYDOWN) {
- _pendingKeyEvents.push(event);
- } else {
- _pendingEvents.push(event);
- }
-}
-
-void EventsBase::warpMouse(const Common::Point &newPos) {
- g_system->warpMouse(newPos.x, newPos.y);
-}
-
-void EventsBase::clearEvents() {
- processEvents();
- _pendingEvents.clear();
- _pendingKeyEvents.clear();
-}
-
-} // namespace Chewy
diff --git a/engines/chewy/events_base.h b/engines/chewy/events_base.h
deleted file mode 100644
index c9ea0cce621..00000000000
--- a/engines/chewy/events_base.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef CHEWY_EVENTS_BASE_H
-#define CHEWY_EVENTS_BASE_H
-
-#include "common/events.h"
-#include "common/queue.h"
-#include "graphics/screen.h"
-
-namespace Chewy {
-
-typedef void (*TimerProc)();
-
-class EventsBase {
- struct TimerRecord {
- TimerProc _proc;
- uint32 _interval;
- uint32 _nextFrameTime;
- TimerRecord(TimerProc proc, uint32 interval) :
- _proc(proc), _interval(interval), _nextFrameTime(0) {
- }
- };
- typedef Common::List<TimerRecord> TimerList;
-private:
- TimerList _timers;
- Common::Queue<Common::Event> _pendingEvents;
- Common::Queue<Common::Event> _pendingKeyEvents;
-private:
- /**
- * Checks for timer expiries
- */
- void checkTimers();
-
- /**
- * Timer proc for regularly updating the screen
- */
- static void updateScreen();
-protected:
- /**
- * Adds a new timer method
- * @param proc Timer method to execute
- * @param interval Interval in milliseconds between calls
- */
- void addTimer(TimerProc proc, uint interval) {
- _timers.push_back(TimerRecord(proc, interval));
- }
-
- /**
- * Process any pending events
- */
- void processEvents();
-
- /**
- * Handles pending event
- */
- virtual void handleEvent(const Common::Event &event);
-
-public:
- Graphics::Screen *_screen;
-public:
- /**
- * Constructor
- * @param
- */
- EventsBase(Graphics::Screen *screen, uint refreshRate = 1000 / 50);
- EventsBase(uint refreshRate = 1000 / 50);
- virtual ~EventsBase();
-
- /**
- * Handles doing a brief delay, checking for timer updates,
- * and polling events
- */
- void update();
-
- /**
- * Returns true if any unprocessed keyboard events are pending
- */
- bool keyEventPending() {
- processEvents();
- return !_pendingKeyEvents.empty();
- }
-
- /**
- * Returns true if any unprocessed event other than key events
- * are pending
- */
- bool eventPending() {
- processEvents();
- return !_pendingEvents.empty();
- }
-
- /**
- * Returns the next pending unprocessed keyboard event
- */
- Common::Event getPendingKeyEvent() {
- processEvents();
- return _pendingKeyEvents.empty() ? Common::Event() : _pendingKeyEvents.pop();
- }
-
- /**
- * Returns the next event, if any
- */
- Common::Event getPendingEvent() {
- processEvents();
- return _pendingEvents.empty() ? Common::Event() : _pendingEvents.pop();
- }
-
- /**
- * Sets the mouse position
- */
- void warpMouse(const Common::Point &newPos);
-
- /**
- * Clear any pending events
- */
- void clearEvents();
-};
-
-extern EventsBase *g_eventsBase;
-
-} // namespace Chewy
-
-#endif
diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk
index e93810a2839..35c5a6a5cbe 100644
--- a/engines/chewy/module.mk
+++ b/engines/chewy/module.mk
@@ -9,7 +9,6 @@ MODULE_OBJS = \
detail.o \
effect.o \
events.o \
- events_base.o \
gedclass.o \
globals.o \
inits.o \
Commit: a80e543a3cd9f1d593ed438d93a15adbd203d43a
https://github.com/scummvm/scummvm/commit/a80e543a3cd9f1d593ed438d93a15adbd203d43a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-06T14:40:43+02:00
Commit Message:
CHEWY: Start replacing minfo for cursor position
Changed paths:
engines/chewy/dialogs/cinema.cpp
engines/chewy/dialogs/files.cpp
engines/chewy/dialogs/inventory.cpp
engines/chewy/dialogs/main_menu.cpp
engines/chewy/dialogs/options.cpp
engines/chewy/rooms/room00.cpp
engines/chewy/rooms/room04.cpp
engines/chewy/rooms/room08.cpp
engines/chewy/rooms/room37.cpp
engines/chewy/rooms/room48.cpp
engines/chewy/rooms/room51.cpp
engines/chewy/rooms/room56.cpp
engines/chewy/rooms/room80.cpp
engines/chewy/rooms/room91.cpp
engines/chewy/rooms/room97.cpp
diff --git a/engines/chewy/dialogs/cinema.cpp b/engines/chewy/dialogs/cinema.cpp
index 30e934c863e..ecbfeb4fd39 100644
--- a/engines/chewy/dialogs/cinema.cpp
+++ b/engines/chewy/dialogs/cinema.cpp
@@ -86,7 +86,7 @@ void Cinema::execute() {
if (_G(minfo)._button == 1 && !flag) {
flag = true;
- switch (_G(in)->mouseVector(_G(minfo).x, _G(minfo).y, CINEMA_TBL, 3)) {
+ switch (_G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, CINEMA_TBL, 3)) {
case 0:
_G(kbinfo).scan_code = Common::KEYCODE_UP;
if (!endLoop)
@@ -103,7 +103,7 @@ void Cinema::execute() {
case 2:
{
- int selIndex = (_G(minfo).y - 68) / 10 + topIndex;
+ int selIndex = (g_events->_mousePos.y - 68) / 10 + topIndex;
if (selIndex < (int)cutscenes.size())
selected = selIndex;
_G(kbinfo).scan_code = Common::KEYCODE_RETURN;
diff --git a/engines/chewy/dialogs/files.cpp b/engines/chewy/dialogs/files.cpp
index be24e689e6d..f28955b433e 100644
--- a/engines/chewy/dialogs/files.cpp
+++ b/engines/chewy/dialogs/files.cpp
@@ -162,7 +162,7 @@ int16 Files::execute(bool isInGame) {
}
if (!flag && _G(minfo)._button == 1) {
- int16 rect = _G(in)->mouseVector(_G(minfo).x, _G(minfo).y, FILE_ICONS, 8);
+ int16 rect = _G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, FILE_ICONS, 8);
flag = true;
key = 0;
@@ -174,7 +174,7 @@ int16 Files::execute(bool isInGame) {
key = Common::KEYCODE_DOWN;
break;
case 2: {
- int16 line = (_G(minfo).y - 68) / 10;
+ int16 line = (g_events->_mousePos.y - 68) / 10;
if (line == active_slot)
key = Common::KEYCODE_RETURN;
else
diff --git a/engines/chewy/dialogs/inventory.cpp b/engines/chewy/dialogs/inventory.cpp
index 33bc9879a7d..f6386cd5a66 100644
--- a/engines/chewy/dialogs/inventory.cpp
+++ b/engines/chewy/dialogs/inventory.cpp
@@ -60,14 +60,14 @@ void Inventory::plot_menu() {
}
int16 y;
- int16 k = _G(in)->mouseVector(_G(minfo).x, _G(minfo).y, &INVENTORY_HOTSPOTS[0][0], INVENTORY_HOTSPOTS_COUNT);
+ int16 k = _G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, &INVENTORY_HOTSPOTS[0][0], INVENTORY_HOTSPOTS_COUNT);
if (k != -1) {
if (k < 5)
_G(out)->boxFill(INVENTORY_HOTSPOTS[k][0], INVENTORY_HOTSPOTS[k][1],
INVENTORY_HOTSPOTS[k][2] + 1, INVENTORY_HOTSPOTS[k][3] + 5, 41);
else {
- int16 x = (_G(minfo).x - (WIN_INF_X)) / 54;
- y = (_G(minfo).y - (WIN_INF_Y + 4 + 30)) / 30;
+ int16 x = (g_events->_mousePos.x - (WIN_INF_X)) / 54;
+ y = (g_events->_mousePos.y - (WIN_INF_Y + 4 + 30)) / 30;
k = x + (y * 5);
k += _G(spieler).InventY * 5;
if (k < (_G(spieler).InventY + 3) * 5)
@@ -133,8 +133,8 @@ void Inventory::menu() {
_G(flags).StopAutoObj = true;
_G(menu_display) = 0;
_G(cur)->move(152, 92);
- _G(minfo).x = 152;
- _G(minfo).y = 92;
+ g_events->_mousePos.x = 152;
+ g_events->_mousePos.y = 92;
_G(invent_cur_mode) = CUR_USE;
if (_G(spieler).AkInvent != -1) {
@@ -167,7 +167,7 @@ void Inventory::menu() {
mouseFl = true;
_G(kbinfo)._keyCode = '\0';
- int16 k = _G(in)->mouseVector(_G(minfo).x, _G(minfo).y, &INVENTORY_HOTSPOTS[0][0], INVENTORY_HOTSPOTS_COUNT);
+ int16 k = _G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, &INVENTORY_HOTSPOTS[0][0], INVENTORY_HOTSPOTS_COUNT);
if (keyVal == Common::KEYCODE_F1)
k = 0;
else if (keyVal == Common::KEYCODE_F2)
@@ -211,8 +211,8 @@ void Inventory::menu() {
break;
case 5:
- inv_rand_x = (_G(minfo).x - (WIN_INF_X)) / 54;
- inv_rand_y = (_G(minfo).y - (WIN_INF_Y + 4 + 30)) / 30;
+ inv_rand_x = (g_events->_mousePos.x - (WIN_INF_X)) / 54;
+ inv_rand_y = (g_events->_mousePos.y - (WIN_INF_Y + 4 + 30)) / 30;
k = inv_rand_x + (inv_rand_y * 5);
k += _G(spieler).InventY * 5;
if (_G(invent_cur_mode) == CUR_USE) {
@@ -303,23 +303,23 @@ void Inventory::menu() {
break;
case Common::KEYCODE_RIGHT:
- if (_G(minfo).x < 320 - _G(spieler)._curWidth)
- _G(minfo).x += 3;
+ if (g_events->_mousePos.x < 320 - _G(spieler)._curWidth)
+ g_events->_mousePos.x += 3;
break;
case Common::KEYCODE_LEFT:
- if (_G(minfo).x > 2)
- _G(minfo).x -= 3;
+ if (g_events->_mousePos.x > 2)
+ g_events->_mousePos.x -= 3;
break;
case Common::KEYCODE_UP:
- if (_G(minfo).y > 2)
- _G(minfo).y -= 3;
+ if (g_events->_mousePos.y > 2)
+ g_events->_mousePos.y -= 3;
break;
case Common::KEYCODE_DOWN:
- if (_G(minfo).y < 197 - _G(spieler)._curHeight)
- _G(minfo).y += 3;
+ if (g_events->_mousePos.y < 197 - _G(spieler)._curHeight)
+ g_events->_mousePos.y += 3;
break;
case Common::KEYCODE_PAGEUP:
@@ -342,7 +342,7 @@ void Inventory::menu() {
if (_G(show_invent_menu) != 2) {
setupScreen(NO_SETUP);
- _G(cur)->move(_G(minfo).x, _G(minfo).y);
+ _G(cur)->move(g_events->_mousePos.x, g_events->_mousePos.y);
_G(cur)->show_cur();
if (menu_flag1 != MENU_HIDE) {
inv_rand_x = -1;
@@ -365,8 +365,8 @@ void Inventory::menu() {
}
_G(cur)->move(_G(maus_old_x), _G(maus_old_y));
- _G(minfo).x = _G(maus_old_x);
- _G(minfo).y = _G(maus_old_y);
+ g_events->_mousePos.x = _G(maus_old_x);
+ g_events->_mousePos.y = _G(maus_old_y);
_G(minfo)._button = 0;
while (_G(in)->getSwitchCode() == Common::KEYCODE_ESCAPE && !SHOULD_QUIT) {
@@ -422,7 +422,7 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
}
while (!endLoop) {
- int16 rect = _G(in)->mouseVector(_G(minfo).x, _G(minfo).y, (const int16 *)INVENTORY_HOTSPOTS, INVENTORY_HOTSPOTS_COUNT);
+ int16 rect = _G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, (const int16 *)INVENTORY_HOTSPOTS, INVENTORY_HOTSPOTS_COUNT);
if (_G(minfo)._button) {
if (_G(minfo)._button == 2) {
diff --git a/engines/chewy/dialogs/main_menu.cpp b/engines/chewy/dialogs/main_menu.cpp
index 3143e4836f8..7bd64c1eef8 100644
--- a/engines/chewy/dialogs/main_menu.cpp
+++ b/engines/chewy/dialogs/main_menu.cpp
@@ -53,8 +53,8 @@ void MainMenu::execute() {
show_intro();
_G(cur)->move(152, 92);
- _G(minfo).x = 152;
- _G(minfo).y = 92;
+ g_events->_mousePos.x = 152;
+ g_events->_mousePos.y = 92;
_G(spieler).inv_cur = false;
_G(menu_display) = 0;
_G(spieler).soundLoopMode = 1;
@@ -107,8 +107,8 @@ void MainMenu::execute() {
case MM_CINEMA:
cursorChoice(CUR_SAVE);
_G(cur)->move(152, 92);
- _G(minfo).x = 152;
- _G(minfo).y = 92;
+ g_events->_mousePos.x = 152;
+ g_events->_mousePos.y = 92;
Dialogs::Cinema::execute();
break;
@@ -133,7 +133,7 @@ void MainMenu::execute() {
}
void MainMenu::screenFunc() {
- int vec = _G(det)->maus_vector(_G(minfo).x + _G(spieler).scrollx, _G(minfo).y + _G(spieler).scrolly);
+ int vec = _G(det)->maus_vector(g_events->_mousePos.x + _G(spieler).scrollx, g_events->_mousePos.y + _G(spieler).scrolly);
if (_G(in)->getSwitchCode() == 28 || _G(minfo)._button == 1) {
_selection = vec;
@@ -161,7 +161,7 @@ void MainMenu::animate() {
spriteEngine();
kb_mov(1);
- calcMouseText(_G(minfo).x, _G(minfo).y, 1);
+ calcMouseText(g_events->_mousePos.x, g_events->_mousePos.y, 1);
_G(cur)->plot_cur();
_G(mouseLeftClick) = false;
_G(menu_flag) = 0;
@@ -218,8 +218,8 @@ bool MainMenu::loadGame() {
_G(fontMgr)->setFont(_G(font6));
cursorChoice(CUR_SAVE);
_G(cur)->move(152, 92);
- _G(minfo).x = 152;
- _G(minfo).y = 92;
+ g_events->_mousePos.x = 152;
+ g_events->_mousePos.y = 92;
_G(savegameFlag) = true;
int result = Dialogs::Files::execute(false);
diff --git a/engines/chewy/dialogs/options.cpp b/engines/chewy/dialogs/options.cpp
index e28275e5b33..21387fb25d3 100644
--- a/engines/chewy/dialogs/options.cpp
+++ b/engines/chewy/dialogs/options.cpp
@@ -149,7 +149,7 @@ void Options::execute(TafInfo *ti) {
if ((_G(minfo)._button == 1) || (key == Common::KEYCODE_RETURN)) {
WAIT_TASTE_LOS
- int16 rect = _G(in)->mouseVector(_G(minfo).x, _G(minfo).y, OPTION_ICONS, 9);
+ int16 rect = _G(in)->mouseVector(g_events->_mousePos.x, g_events->_mousePos.y, OPTION_ICONS, 9);
switch (rect) {
case 0:
if (_G(spieler).FramesPerSecond > 6)
@@ -194,11 +194,11 @@ void Options::execute(TafInfo *ti) {
key = Common::KEYCODE_ESCAPE;
break;
case 7:
- _G(spieler).SoundVol = (136 - _G(minfo).y) << 1;
+ _G(spieler).SoundVol = (136 - g_events->_mousePos.y) << 1;
g_engine->_sound->setSoundVolume(_G(spieler).SoundVol * Audio::Mixer::kMaxChannelVolume / 120);
break;
case 8:
- _G(spieler).MusicVol = (136 - _G(minfo).y) << 1;
+ _G(spieler).MusicVol = (136 - g_events->_mousePos.y) << 1;
g_engine->_sound->setMusicVolume(_G(spieler).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
break;
@@ -210,19 +210,19 @@ void Options::execute(TafInfo *ti) {
switch (key) {
case Common::KEYCODE_UP:
- _G(cur)->move(_G(minfo).x, --_G(minfo).y);
+ _G(cur)->move(g_events->_mousePos.x, --g_events->_mousePos.y);
break;
case Common::KEYCODE_DOWN:
- _G(cur)->move(_G(minfo).x, ++_G(minfo).y);
+ _G(cur)->move(g_events->_mousePos.x, ++g_events->_mousePos.y);
break;
case Common::KEYCODE_LEFT:
- _G(cur)->move(--_G(minfo).x, _G(minfo).y);
+ _G(cur)->move(--g_events->_mousePos.x, g_events->_mousePos.y);
break;
case Common::KEYCODE_RIGHT:
- _G(cur)->move(++_G(minfo).x, _G(minfo).y);
+ _G(cur)->move(++g_events->_mousePos.x, g_events->_mousePos.y);
break;
default:
diff --git a/engines/chewy/rooms/room00.cpp b/engines/chewy/rooms/room00.cpp
index 42cab6037ae..8ff87b3c630 100644
--- a/engines/chewy/rooms/room00.cpp
+++ b/engines/chewy/rooms/room00.cpp
@@ -307,8 +307,8 @@ void Room0::calcEyeClick(int16 aniNr) {
char *str_ = _G(atds)->ats_get_txt(172, TXT_MARK_NAME, &anz, ATS_DATA);
if (str_ != 0) {
_G(fontMgr)->setFont(_G(font8));
- int16 x = _G(minfo).x;
- int16 y = _G(minfo).y;
+ int16 x = g_events->_mousePos.x;
+ int16 y = g_events->_mousePos.y;
calcTxtXy(&x, &y, str_, anz);
for (int16 i = 0; i < anz; i++)
printShadowed(x, y + i * 10, 255, 300, 0, _G(scr_width), _G(txt)->strPos((char *)str_, i));
@@ -545,8 +545,8 @@ void Room0::calcPillowClick(int16 aniNr) {
char *str_ = _G(atds)->ats_get_txt(173, TXT_MARK_NAME, &anz, ATS_DATA);
if (str_ != nullptr) {
_G(fontMgr)->setFont(_G(font8));
- int16 x = _G(minfo).x;
- int16 y = _G(minfo).y;
+ int16 x = g_events->_mousePos.x;
+ int16 y = g_events->_mousePos.y;
calcTxtXy(&x, &y, str_, anz);
for (int16 i = 0; i < anz; i++)
printShadowed(x, y + i * 10, 255, 300, 0, _G(scr_width), _G(txt)->strPos((char *)str_, i));
diff --git a/engines/chewy/rooms/room04.cpp b/engines/chewy/rooms/room04.cpp
index cefdf1843fe..63642d824ff 100644
--- a/engines/chewy/rooms/room04.cpp
+++ b/engines/chewy/rooms/room04.cpp
@@ -61,7 +61,7 @@ int16 Room4::comp_probe() {
while (!endLoop) {
mouseAction();
if (_G(mouseLeftClick)) {
- switch (_G(in)->mouseVector(_G(minfo).x + 17, _G(minfo).y + 7, &CONSOLE[0][0], 3)) {
+ switch (_G(in)->mouseVector(g_events->_mousePos.x + 17, g_events->_mousePos.y + 7, &CONSOLE[0][0], 3)) {
case 0:
if (curX > 0)
--curX;
@@ -104,8 +104,8 @@ int16 Room4::comp_probe() {
cursorChoice(CUR_USER);
_G(spieler)._curHeight = 16;
- if (_G(minfo).y < 124)
- _G(minfo).y = 123;
+ if (g_events->_mousePos.y < 124)
+ g_events->_mousePos.y = 123;
setupScreen(DO_SETUP);
SHOULD_QUIT_RETURN0;
diff --git a/engines/chewy/rooms/room08.cpp b/engines/chewy/rooms/room08.cpp
index 17dba57f606..3fac73dc79c 100644
--- a/engines/chewy/rooms/room08.cpp
+++ b/engines/chewy/rooms/room08.cpp
@@ -95,8 +95,8 @@ void Room8::start_verbrennen() {
SHOULD_QUIT_RETURN;
if (_G(minfo)._button == 1 || _G(kbinfo)._keyCode == Common::KEYCODE_RETURN) {
- if (_G(minfo).x > 146 && _G(minfo).x < 208 &&
- _G(minfo).y > 107 && _G(minfo).y < 155)
+ if (g_events->_mousePos.x > 146 && g_events->_mousePos.x < 208 &&
+ g_events->_mousePos.y > 107 && g_events->_mousePos.y < 155)
break;
}
}
diff --git a/engines/chewy/rooms/room37.cpp b/engines/chewy/rooms/room37.cpp
index 4bbf7f5434a..59436cbb356 100644
--- a/engines/chewy/rooms/room37.cpp
+++ b/engines/chewy/rooms/room37.cpp
@@ -89,8 +89,8 @@ void Room37::gedAction(int index) {
void Room37::setup_func() {
if (_G(mouseLeftClick) && !_G(spieler).R37Kloppe &&
_G(menu_item) == CUR_WALK) {
- if ((_G(minfo).x + _G(spieler).scrollx > 380 && _G(minfo).y > 120) ||
- (_G(minfo).x + _G(spieler).scrollx > 482)) {
+ if ((g_events->_mousePos.x + _G(spieler).scrollx > 380 && g_events->_mousePos.y > 120) ||
+ (g_events->_mousePos.x + _G(spieler).scrollx > 482)) {
// Don't allow moving into chicken coop area
// until the rooster has left
autoMove(7, P_CHEWY);
diff --git a/engines/chewy/rooms/room48.cpp b/engines/chewy/rooms/room48.cpp
index a7b0c4c8872..b4af662df73 100644
--- a/engines/chewy/rooms/room48.cpp
+++ b/engines/chewy/rooms/room48.cpp
@@ -94,7 +94,7 @@ void Room48::setup_func() {
_G(menu_item) = CUR_USE;
cur_2_inventory();
cursorChoice(CUR_ZEIGE);
- const int16 idx = _G(det)->maus_vector(_G(minfo).x, _G(minfo).y);
+ const int16 idx = _G(det)->maus_vector(g_events->_mousePos.x, g_events->_mousePos.y);
if (idx != -1) {
if (_G(spieler).R48Auswahl[idx]) {
diff --git a/engines/chewy/rooms/room51.cpp b/engines/chewy/rooms/room51.cpp
index c1a27e78c5e..22878a84a9f 100644
--- a/engines/chewy/rooms/room51.cpp
+++ b/engines/chewy/rooms/room51.cpp
@@ -134,8 +134,8 @@ bool Room51::timer(int16 t_nr, int16 ani_nr) {
void Room51::setup_func() {
if (_G(spieler).flags32_10) {
- _tmpx = _G(minfo).x;
- _tmpy = _G(minfo).y;
+ _tmpx = g_events->_mousePos.x;
+ _tmpy = g_events->_mousePos.y;
if (_tmpx > 215)
_tmpx = 215;
if (_tmpy < 81)
diff --git a/engines/chewy/rooms/room56.cpp b/engines/chewy/rooms/room56.cpp
index 6af9c22fdf0..8c79a057132 100644
--- a/engines/chewy/rooms/room56.cpp
+++ b/engines/chewy/rooms/room56.cpp
@@ -433,7 +433,7 @@ void Room56::setup_func() {
return;
if (!_G(atds)->get_steuer_bit(362, ATS_AKTIV_BIT, ATS_DATA) && _G(menu_item) == CUR_WALK) {
- if (_G(minfo).x + _G(spieler).scrollx >= 157 && _G(minfo).x + _G(spieler).scrollx <= 204 && _G(minfo).y >= 28 && _G(minfo).y <= 89)
+ if (g_events->_mousePos.x + _G(spieler).scrollx >= 157 && g_events->_mousePos.x + _G(spieler).scrollx <= 204 && g_events->_mousePos.y >= 28 && g_events->_mousePos.y <= 89)
cursorChoice(CUR_EXIT_TOP);
else
cursorChoice(CUR_WALK);
diff --git a/engines/chewy/rooms/room80.cpp b/engines/chewy/rooms/room80.cpp
index 2bb2a2890f8..b147574b809 100644
--- a/engines/chewy/rooms/room80.cpp
+++ b/engines/chewy/rooms/room80.cpp
@@ -79,7 +79,7 @@ void Room80::setup_func() {
_G(menu_item) = CUR_USE;
cur_2_inventory();
cursorChoice(CUR_ZEIGE);
- int vec = _G(det)->maus_vector(_G(spieler).scrollx + _G(minfo).x, _G(minfo).y);
+ int vec = _G(det)->maus_vector(_G(spieler).scrollx + g_events->_mousePos.x, g_events->_mousePos.y);
if (vec == -1)
return;
diff --git a/engines/chewy/rooms/room91.cpp b/engines/chewy/rooms/room91.cpp
index f5fdf736d40..6067e4ba1e8 100644
--- a/engines/chewy/rooms/room91.cpp
+++ b/engines/chewy/rooms/room91.cpp
@@ -112,7 +112,7 @@ void Room91::setup_func() {
const int oldClick = _click;
_G(mouseLeftClick) = oldClick;
_click = 1;
- const int aniNr = 1 + (_G(minfo).y <= 100 ? 1 : 0);
+ const int aniNr = 1 + (g_events->_mousePos.y <= 100 ? 1 : 0);
hideCur();
_G(det)->stop_detail(0);
startSetailWait(aniNr, 1, ANI_FRONT);
diff --git a/engines/chewy/rooms/room97.cpp b/engines/chewy/rooms/room97.cpp
index 342511ba85e..175cf992d13 100644
--- a/engines/chewy/rooms/room97.cpp
+++ b/engines/chewy/rooms/room97.cpp
@@ -199,7 +199,7 @@ void Room97::setup_func() {
}
if (_G(spieler).flags37_1 && _G(menu_item) == CUR_WALK) {
- if (_G(spieler).scrollx + _G(minfo).x >= 487 && _G(spieler).scrollx + _G(minfo).x <= 522 && _G(minfo).y >= 23 && _G(minfo).y <= 59)
+ if (_G(spieler).scrollx + g_events->_mousePos.x >= 487 && _G(spieler).scrollx + g_events->_mousePos.x <= 522 && g_events->_mousePos.y >= 23 && g_events->_mousePos.y <= 59)
cursorChoice(CUR_EXIT_TOP);
else
cursorChoice(CUR_WALK);
Commit: 6ad1b281b76106346120d149a5fcec5c4600b66b
https://github.com/scummvm/scummvm/commit/6ad1b281b76106346120d149a5fcec5c4600b66b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-06T14:40:44+02:00
Commit Message:
CHEWY: Refactor the mouse code to use CursorMan and ScummVM cursors
Changed paths:
engines/chewy/cursor.cpp
engines/chewy/cursor.h
engines/chewy/dialogs/inventory.cpp
engines/chewy/events.cpp
engines/chewy/globals.h
engines/chewy/inits.cpp
engines/chewy/main.cpp
engines/chewy/menus.cpp
engines/chewy/mouse.cpp
engines/chewy/mouse.h
engines/chewy/ngstypes.h
engines/chewy/sprite.cpp
diff --git a/engines/chewy/cursor.cpp b/engines/chewy/cursor.cpp
index 0b4cc100c9e..0e933d80f35 100644
--- a/engines/chewy/cursor.cpp
+++ b/engines/chewy/cursor.cpp
@@ -19,19 +19,16 @@
*
*/
+#include "graphics/cursorman.h"
#include "chewy/cursor.h"
#include "chewy/events.h"
#include "chewy/globals.h"
namespace Chewy {
-Cursor::Cursor(McgaGraphics *iout, InputMgr *iin, CurBlk *curblkp) {
- _out = iout;
- _in = iin;
- _scrWidth = _G(scr_w);
+Cursor::Cursor(CurBlk *curblkp) {
_curblk = curblkp;
- _visible = false;
_ani = nullptr;
_curAniCountdown = 0;
_aniCount = 0;
@@ -41,21 +38,8 @@ Cursor::~Cursor() {
}
void Cursor::plot_cur() {
- if (_visible) {
- if (_cursorMoveFl) {
- _cursorMoveFl = false;
- if (!_curblk->no_back) {
-
- _out->blockcopy(_curblk->cur_back, _cur_x_old, _cur_y_old, _scrWidth);
-
- _out->sprite_save(_curblk->cur_back, (_G(minfo).x + _curblk->page_off_x),
- (_G(minfo).y + _curblk->page_off_y), _curblk->xsize,
- _curblk->ysize, _scrWidth);
- }
-
- _cur_x_old = (_G(minfo).x + _curblk->page_off_x);
- _cur_y_old = (_G(minfo).y + _curblk->page_off_y);
- }
+ if (CursorMan.isVisible()) {
+ _cursorMoveFl = false;
--_curAniCountdown;
if (_curAniCountdown <= 0 && _ani != nullptr) {
@@ -65,37 +49,20 @@ void Cursor::plot_cur() {
_aniCount = _ani->_start;
}
- _out->spriteSet(_curblk->sprite[_aniCount], _cur_x_old, _cur_y_old, _scrWidth);
+ const uint16 w = READ_LE_INT16(_curblk->sprite[_aniCount]);
+ const uint16 h = READ_LE_INT16(_curblk->sprite[_aniCount] + 2);
+ CursorMan.replaceCursor(_curblk->sprite[_aniCount] + 4, w, h, 0, 0, 0);
}
}
void Cursor::show_cur() {
- if (!_visible) {
- _visible = true;
-
- _G(minfo).x = g_events->_mousePos.x;
- _G(minfo).y = g_events->_mousePos.y;
-
- if (!_curblk->no_back) {
- _out->sprite_save(_curblk->cur_back, (_G(minfo).x + _curblk->page_off_x),
- (_G(minfo).y + _curblk->page_off_y), _curblk->xsize,
- _curblk->ysize, _scrWidth);
- }
-
- _cur_x_old = (_G(minfo).x + _curblk->page_off_x);
- _cur_y_old = (_G(minfo).y + _curblk->page_off_y);
- _cursorMoveFl = true;
- plot_cur();
- }
+ CursorMan.showMouse(true);
+ _cursorMoveFl = true;
+ plot_cur();
}
void Cursor::hide_cur() {
- if (_visible) {
- if (!_curblk->no_back) {
- _out->blockcopy(_curblk->cur_back, _cur_x_old, _cur_y_old, _scrWidth);
- }
- _visible = false;
- }
+ CursorMan.showMouse(false);
}
void Cursor::set_cur_ani(CurAni *ani1) {
@@ -105,15 +72,8 @@ void Cursor::set_cur_ani(CurAni *ani1) {
}
void Cursor::move(int16 x, int16 y) {
- _G(minfo).x = x;
- _G(minfo).y = y;
- _cur_x_old = (_G(minfo).x + _curblk->page_off_x);
- _cur_y_old = (_G(minfo).y + _curblk->page_off_y);
- _in->setMousePos(x, y);
- if (_visible)
- _cursorMoveFl = true;
- else
- _cursorMoveFl = false;
+ g_events->warpMouse(Common::Point(x, y));
+ _cursorMoveFl = CursorMan.isVisible();
}
} // namespace Chewy
diff --git a/engines/chewy/cursor.h b/engines/chewy/cursor.h
index 2bfe78ce399..715389b7e72 100644
--- a/engines/chewy/cursor.h
+++ b/engines/chewy/cursor.h
@@ -31,7 +31,7 @@ namespace Chewy {
class Cursor {
public:
Cursor();
- Cursor(McgaGraphics *out, InputMgr *in, CurBlk *curblk);
+ Cursor(CurBlk *curblk);
~Cursor();
void plot_cur();
@@ -40,16 +40,11 @@ public:
void set_cur_ani(CurAni *ani);
void move(int16 x, int16 y);
- McgaGraphics *_out = nullptr;
- InputMgr *_in = nullptr;
CurBlk *_curblk = nullptr;
CurAni *_ani = nullptr;
int _scrWidth = 0;
- int16 _cur_x_old = 0;
- int16 _cur_y_old = 0;
int16 _curAniCountdown = 0;
int16 _aniCount = 0;
- bool _visible = false;
};
} // namespace Chewy
diff --git a/engines/chewy/dialogs/inventory.cpp b/engines/chewy/dialogs/inventory.cpp
index f6386cd5a66..2140e262755 100644
--- a/engines/chewy/dialogs/inventory.cpp
+++ b/engines/chewy/dialogs/inventory.cpp
@@ -268,7 +268,7 @@ void Inventory::menu() {
ret_look = -1;
int16 abfrage = _G(in)->getSwitchCode();
- _G(cur)->hide_cur();
+ // The original hid the cursor here
if (taste_flag) {
if (abfrage != taste_flag)
@@ -342,8 +342,6 @@ void Inventory::menu() {
if (_G(show_invent_menu) != 2) {
setupScreen(NO_SETUP);
- _G(cur)->move(g_events->_mousePos.x, g_events->_mousePos.y);
- _G(cur)->show_cur();
if (menu_flag1 != MENU_HIDE) {
inv_rand_x = -1;
inv_rand_y = -1;
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index a3c41ad1865..549e31da91f 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -233,6 +233,7 @@ void EventsManager::processEvents() {
#undef MOUSE_MOVE
void EventsManager::warpMouse(const Common::Point &newPos) {
+ _mousePos = newPos;
g_system->warpMouse(newPos.x, newPos.y);
}
diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h
index 75778b6bea6..1b4677ec2d0 100644
--- a/engines/chewy/globals.h
+++ b/engines/chewy/globals.h
@@ -135,7 +135,6 @@ public:
byte **_ablage = nullptr;
byte *_workpage = nullptr;
byte *_workptr = nullptr;
- byte *_cur_back = nullptr;
byte **_ged_mem = nullptr;
byte *_spblende = nullptr;
char **_ads_item_ptr = nullptr;
@@ -150,7 +149,6 @@ public:
int16 _menu_lauflicht = 0;
int16 _menu_item = 0;
int16 _menu_item_vorwahl = 0;
- int16 _maus_menu_x = 0;
int16 _maus_old_x = 0;
int16 _maus_old_y = 0;
int16 _inventoryNr = 0;
@@ -399,8 +397,6 @@ void buildMenu(int16 x, int16 y, int16 xNr, int16 yNr, int16 col, int16 mode);
void autoMenu(int16 *x, int16 *y, int16 lineNr, int16 zeilen_hoehe,
char *txt, int16 mode);
-void mouseMovMenu();
-
void cur_2_inventory();
void inventory_2_cur(int16 nr);
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index 08e50913e04..d3da31f318c 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -54,23 +54,16 @@ void standard_init() {
_G(screen0) = (byte *)g_screen->getPixels();
_G(in)->neuer_kb_handler(&_G(kbinfo));
- _G(curblk).page_off_x = 0;
- _G(curblk).page_off_y = 0;
- _G(curblk).xsize = 16;
- _G(curblk).ysize = 16;
-
// WORKAROUND: Moved from init_load because the original
// uses _G(curtaf)->_image below before _G(curtaf) was initialized
_G(curtaf) = _G(mem)->taf_adr(CURSOR_TAF);
_G(curblk).sprite = _G(curtaf)->_image;
- _G(curblk).cur_back = _G(cur_back);
- _G(curblk).no_back = true;
_G(curani)._start = 0;
_G(curani)._end = 0;
_G(curani)._delay = 0;
- _G(cur) = new Cursor(_G(out), _G(in), &_G(curblk));
+ _G(cur) = new Cursor(&_G(curblk));
_G(cur)->set_cur_ani(&_G(curani));
_G(iog) = new IOGame(_G(out), _G(in), _G(cur));
@@ -99,7 +92,6 @@ void standard_init() {
_G(out)->cls();
_G(uhr)->setNewTimer(0, 5, SEC_10_MODE);
- _G(curblk).cur_back = _G(cur_back);
sound_init();
init_load();
}
diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index 86ff013f709..528a5560360 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -74,7 +74,6 @@ void game_main() {
void alloc_buffers() {
_G(workpage) = (byte *)MALLOC(64004l);
_G(pal) = (byte *)MALLOC(768l);
- _G(cur_back) = (byte *)MALLOC(16 * 16 + 4);
_G(Ci).TempArea = (byte *)MALLOC(64004l);
_G(det)->set_taf_ani_mem(_G(Ci).TempArea);
_G(Ci).MusicSlot = (byte *)MALLOC(MUSIC_SLOT_SIZE);
@@ -93,7 +92,6 @@ void free_buffers() {
free((char *)_G(curtaf));
free(_G(Ci).MusicSlot);
free(_G(Ci).TempArea);
- free(_G(cur_back));
free(_G(pal));
free(_G(workpage));
}
@@ -291,8 +289,8 @@ bool mainLoop(int16 mode) {
case Common::KEYCODE_F5:
case Common::KEYCODE_SPACE:
_G(tmp_menu_item) = _G(menu_item);
- _G(maus_old_x) = _G(minfo).x;
- _G(maus_old_y) = _G(minfo).y;
+ _G(maus_old_x) = g_events->_mousePos.x;
+ _G(maus_old_y) = g_events->_mousePos.y;
_G(menu_item) = CUR_USE;
menuEntry();
Dialogs::Inventory::menu();
@@ -338,12 +336,11 @@ bool mainLoop(int16 mode) {
if (_G(menu_display) == 0) {
menuEntry();
_G(tmp_menu_item) = _G(menu_item);
- _G(maus_old_x) = _G(minfo).x;
- _G(maus_old_y) = _G(minfo).y;
+ _G(maus_old_x) = g_events->_mousePos.x;
+ _G(maus_old_y) = g_events->_mousePos.y;
_G(menu_display) = MENU_DISPLAY;
- _G(maus_menu_x) = (MOUSE_MENU_MAX_X / 5) * (_G(menu_item));
_G(cur_display) = false;
- _G(cur)->move(_G(maus_menu_x), 100);
+ _G(cur)->move((MOUSE_MENU_MAX_X / 5) * (_G(menu_item)), 100);
} else {
menuExit();
_G(menu_item) = _G(tmp_menu_item);
@@ -381,8 +378,8 @@ bool mainLoop(int16 mode) {
_G(flags).SaveMenu = true;
_G(menu_display) = MENU_DISPLAY;
_G(cur)->move(152, 92);
- _G(minfo).x = 152;
- _G(minfo).y = 92;
+ g_events->_mousePos.x = 152;
+ g_events->_mousePos.y = 92;
_G(fontMgr)->setFont(_G(font6));
_G(out)->setPointer(_G(screen0));
@@ -415,8 +412,8 @@ bool mainLoop(int16 mode) {
_G(menu_display) = 0;
_G(cur_display) = true;
_G(cur)->move(_G(maus_old_x), _G(maus_old_y));
- _G(minfo).x = _G(maus_old_x);
- _G(minfo).y = _G(maus_old_y);
+ g_events->_mousePos.x = _G(maus_old_x);
+ g_events->_mousePos.y = _G(maus_old_y);
_G(spieler).inv_cur = false;
cursorChoice(_G(menu_item));
}
@@ -454,8 +451,8 @@ bool mainLoop(int16 mode) {
_G(menu_display) = 0;
_G(cur_display) = true;
_G(cur)->move(_G(maus_old_x), _G(maus_old_y));
- _G(minfo).x = _G(maus_old_x);
- _G(minfo).y = _G(maus_old_y);
+ g_events->_mousePos.x = _G(maus_old_x);
+ g_events->_mousePos.y = _G(maus_old_y);
}
}
@@ -523,7 +520,7 @@ void setupScreen(SetupScreenMode mode) {
} else {
kb_mov(1);
_G(det)->unfreeze_ani();
- check_mouse_ausgang(_G(minfo).x + _G(spieler).scrollx, _G(minfo).y + _G(spieler).scrolly);
+ check_mouse_ausgang(g_events->_mousePos.x + _G(spieler).scrollx, g_events->_mousePos.y + _G(spieler).scrolly);
if (!_G(flags).SaveMenu)
calc_ani_timer();
@@ -542,12 +539,12 @@ void setupScreen(SetupScreenMode mode) {
if (_G(mouseLeftClick)) {
if (_G(menu_item) == CUR_WALK) {
if (_G(cur_ausgang_flag)) {
- calc_ausgang(_G(minfo).x + _G(spieler).scrollx, _G(minfo).y + _G(spieler).scrolly);
+ calc_ausgang(g_events->_mousePos.x + _G(spieler).scrollx, g_events->_mousePos.y + _G(spieler).scrolly);
} else {
if (!_G(flags).ChewyDontGo) {
- _G(gpkt).Dx = _G(minfo).x - _G(spieler_mi)[P_CHEWY].HotMovX +
+ _G(gpkt).Dx = g_events->_mousePos.x - _G(spieler_mi)[P_CHEWY].HotMovX +
_G(spieler).scrollx + _G(spieler_mi)[P_CHEWY].HotX;
- _G(gpkt).Dy = _G(minfo).y - _G(spieler_mi)[P_CHEWY].HotMovY +
+ _G(gpkt).Dy = g_events->_mousePos.y - _G(spieler_mi)[P_CHEWY].HotMovY +
_G(spieler).scrolly + _G(spieler_mi)[P_CHEWY].HotY;
_G(gpkt).Sx = _G(spieler_vector)[P_CHEWY].Xypos[0] +
_G(spieler_mi)[P_CHEWY].HotX;
@@ -592,27 +589,27 @@ void setupScreen(SetupScreenMode mode) {
for (i = 0; i < _G(auto_obj) && !_G(flags).StopAutoObj; i++)
mov_objekt(&_G(auto_mov_vector)[i], &_G(auto_mov_obj)[i]);
- int16 nr = _G(obj)->is_iib_mouse(_G(minfo).x + _G(spieler).scrollx, _G(minfo).y + _G(spieler).scrolly);
+ int16 nr = _G(obj)->is_iib_mouse(g_events->_mousePos.x + _G(spieler).scrollx, g_events->_mousePos.y + _G(spieler).scrolly);
if (nr != -1) {
txt_nr = _G(obj)->iib_txt_nr(nr);
mous_obj_action(nr, mode, INVENTORY_NORMAL, txt_nr);
} else {
- int16 tmp = calcMouseText(_G(minfo).x, _G(minfo).y, mode);
+ int16 tmp = calcMouseText(g_events->_mousePos.x, g_events->_mousePos.y, mode);
if (tmp == -1 || tmp == 255) {
- nr = _G(obj)->is_sib_mouse(_G(minfo).x + _G(spieler).scrollx, _G(minfo).y + _G(spieler).scrolly);
+ nr = _G(obj)->is_sib_mouse(g_events->_mousePos.x + _G(spieler).scrollx, g_events->_mousePos.y + _G(spieler).scrolly);
if (nr != -1) {
txt_nr = _G(obj)->sib_txt_nr(nr);
mous_obj_action(nr, mode, INVENTORY_STATIC, txt_nr);
} else
- calc_mouse_person(_G(minfo).x, _G(minfo).y);
+ calc_mouse_person(g_events->_mousePos.x, g_events->_mousePos.y);
}
}
if (_G(cur_display) == true && mode == DO_SETUP) {
_G(cur)->plot_cur();
if ((_G(spieler).inv_cur) && (_G(flags).CursorStatus == true))
- _G(out)->spriteSet(_G(curtaf)->_image[_G(pfeil_ani) + 32], _G(minfo).x, _G(minfo).y,
+ _G(out)->spriteSet(_G(curtaf)->_image[_G(pfeil_ani) + 32], g_events->_mousePos.x, g_events->_mousePos.y,
_G(scr_width));
if (_G(pfeil_delay) == 0) {
_G(pfeil_delay) = _G(spieler).DelaySpeed;
@@ -698,8 +695,8 @@ void mous_obj_action(int16 nr, int16 mode, int16 txt_mode, int16 txt_nr) {
if (str_adr) {
_G(fontMgr)->setFont(_G(font8));
- int16 x = _G(minfo).x;
- int16 y = _G(minfo).y;
+ int16 x = g_events->_mousePos.x;
+ int16 y = g_events->_mousePos.y;
calcTxtXy(&x, &y, str_adr, anz);
for (int16 i = 0; i < anz; i++)
printShadowed(x, y + i * 10, 255, 300, 0, _G(scr_width), _G(txt)->strPos(str_adr, i));
@@ -754,23 +751,23 @@ void kb_mov(int16 mode) {
while (!ende) {
switch (_G(in)->getSwitchCode()) {
case Common::KEYCODE_RIGHT:
- if (_G(minfo).x < 320 - _G(spieler)._curWidth)
- _G(minfo).x += 2;
+ if (g_events->_mousePos.x < 320 - _G(spieler)._curWidth)
+ _G(cur)->move(g_events->_mousePos.x + 2, g_events->_mousePos.y);
break;
case Common::KEYCODE_LEFT:
- if (_G(minfo).x > 1)
- _G(minfo).x -= 2;
+ if (g_events->_mousePos.x > 1)
+ _G(cur)->move(g_events->_mousePos.x - 2, g_events->_mousePos.y);
break;
case Common::KEYCODE_UP:
- if (_G(minfo).y > 1)
- _G(minfo).y -= 2;
+ if (g_events->_mousePos.y > 1)
+ _G(cur)->move(g_events->_mousePos.x, g_events->_mousePos.y - 2);
break;
case Common::KEYCODE_DOWN:
- if (_G(minfo).y < 210 - _G(spieler)._curHeight)
- _G(minfo).y += 2;
+ if (g_events->_mousePos.y < 210 - _G(spieler)._curHeight)
+ _G(cur)->move(g_events->_mousePos.x, g_events->_mousePos.y + 2);
break;
default:
@@ -778,7 +775,7 @@ void kb_mov(int16 mode) {
break;
}
- _G(cur)->move(_G(minfo).x, _G(minfo).y);
+
if (mode)
ende = true;
else
@@ -795,8 +792,7 @@ void kb_cur_action(int16 key, int16 mode) {
++_G(menu_item);
else
_G(menu_item) = CUR_WALK;
- _G(maus_menu_x) = (_G(menu_item)) * (MOUSE_MENU_MAX_X / 5);
- _G(cur)->move(_G(maus_menu_x), 100);
+ _G(cur)->move((_G(menu_item)) * (MOUSE_MENU_MAX_X / 5), 100);
}
break;
@@ -806,8 +802,7 @@ void kb_cur_action(int16 key, int16 mode) {
--_G(menu_item);
else
_G(menu_item) = CUR_INVENT;
- _G(maus_menu_x) = (_G(menu_item)) * (MOUSE_MENU_MAX_X / 5);
- _G(cur)->move(_G(maus_menu_x), 100);
+ _G(cur)->move((_G(menu_item)) * (MOUSE_MENU_MAX_X / 5), 100);
}
break;
@@ -831,8 +826,8 @@ void kb_cur_action(int16 key, int16 mode) {
}
void mouseAction() {
- int16 x = _G(minfo).x;
- int16 y = _G(minfo).y;
+ int16 x = g_events->_mousePos.x;
+ int16 y = g_events->_mousePos.y;
if (x > invent_display[_G(spieler).InvDisp][0] &&
x < invent_display[_G(spieler).InvDisp][0] + 48 &&
y > invent_display[_G(spieler).InvDisp][1] &&
@@ -1631,8 +1626,8 @@ void get_user_key(int16 mode) {
case Common::KEYCODE_F5:
case Common::KEYCODE_SPACE:
case Common::KEYCODE_ESCAPE:
- _G(maus_old_x) = _G(minfo).x;
- _G(maus_old_y) = _G(minfo).y;
+ _G(maus_old_x) = g_events->_mousePos.x;
+ _G(maus_old_y) = g_events->_mousePos.y;
_G(tmp_menu_item) = _G(menu_item);
_G(menu_item) = CUR_USE;
diff --git a/engines/chewy/menus.cpp b/engines/chewy/menus.cpp
index 6934d3d2b07..8c48f874e22 100644
--- a/engines/chewy/menus.cpp
+++ b/engines/chewy/menus.cpp
@@ -38,7 +38,14 @@ void plotMainMenu() {
_G(tmp_menu) = _G(menu_item);
}
- mouseMovMenu();
+ // Don't allow the mouse to warp past the right edge, as this messes
+ // up the menu screen
+ if (g_events->_mousePos.x > 266)
+ g_events->warpMouse(Common::Point(266, g_events->_mousePos.y));
+
+ const int16 x = MAX(g_events->_mousePos.x - 32, 0);
+ _G(menu_item) = (x / (MOUSE_MENU_MAX_X / 5));
+
int16 *correction = (int16 *)_G(menutaf)->_correction;
for (int16 i = MENU_START_SPRITE; i < MAX_MENU_SPRITE; i++) {
@@ -84,16 +91,6 @@ void plotMainMenu() {
}
}
-void mouseMovMenu() {
- _G(maus_menu_x) = g_events->_mousePos.x;
- if (_G(maus_menu_x) > 200) {
- g_events->warpMouse(Common::Point(200, g_events->_mousePos.y));
- _G(maus_menu_x) = 200;
- }
-
- _G(menu_item) = (_G(maus_menu_x) / (MOUSE_MENU_MAX_X / 5));
-}
-
void calcTxtXy(int16 *x, int16 *y, char *txtAdr, int16 txtNr) {
int16 len = 0;
for (int16 i = 0; i < txtNr; i++) {
@@ -242,7 +239,7 @@ void adsMenu() {
curYStart = 190;
else
curYStart = 190 - (4 - _G(ads_item_anz)) * 10;
- int16 curY = _G(minfo).y;
+ int16 curY = g_events->_mousePos.y;
if (curY < 160 || curY > curYStart + 10)
curY = 255;
else
@@ -273,7 +270,7 @@ void adsMenu() {
if (curY < _G(ads_item_anz) && curY >= 0 && _G(ads_push) == false) {
_G(cur_display) = false;
_G(ads_push) = true;
- _G(minfo).y = 159;
+ g_events->_mousePos.y = 159;
AdsNextBlk *an_blk = _G(atds)->ads_item_choice(_G(ads_blk_nr), curY);
if (an_blk->BlkNr == -1) {
adsAction(_G(ads_dia_nr), _G(ads_blk_nr), an_blk->EndNr);
diff --git a/engines/chewy/mouse.cpp b/engines/chewy/mouse.cpp
index d26b3e77527..9fb6253a6f4 100644
--- a/engines/chewy/mouse.cpp
+++ b/engines/chewy/mouse.cpp
@@ -35,10 +35,6 @@ InputMgr::InputMgr() {
InputMgr::~InputMgr() {
}
-void InputMgr::setMousePos(int16 x, int16 y) {
- g_events->warpMouse(Common::Point(x, y));
-}
-
int16 InputMgr::mouseVector(int16 x, int16 y, const int16 *tbl, int16 anz) {
int16 i = -1;
for (int16 j = 0; (j < anz * 4) && (i == -1); j += 4) {
diff --git a/engines/chewy/mouse.h b/engines/chewy/mouse.h
index cff66978915..133b0c85ed0 100644
--- a/engines/chewy/mouse.h
+++ b/engines/chewy/mouse.h
@@ -33,8 +33,6 @@ public:
InputMgr();
~InputMgr();
- void setMousePos(int16 x, int16 y);
-
void neuer_kb_handler(KbdInfo *key);
int16 mouseVector(int16 x, int16 y, const int16 *tbl, int16 anz);
diff --git a/engines/chewy/ngstypes.h b/engines/chewy/ngstypes.h
index 94b30903685..f26fe08efd4 100644
--- a/engines/chewy/ngstypes.h
+++ b/engines/chewy/ngstypes.h
@@ -49,8 +49,6 @@ struct NewPhead {
};
struct MouseInfo {
- int16 x = 0;
- int16 y = 0;
int16 _button = 0;
};
@@ -126,13 +124,7 @@ struct GedChunkHeader {
};
struct CurBlk {
- int16 page_off_x = 0;
- int16 page_off_y = 0;
- byte *cur_back = nullptr;
- int16 xsize = 0;
- int16 ysize = 0;
byte **sprite = nullptr;
- bool no_back = false;
};
struct CurAni {
diff --git a/engines/chewy/sprite.cpp b/engines/chewy/sprite.cpp
index cab6ae43558..f99f4bd63d8 100644
--- a/engines/chewy/sprite.cpp
+++ b/engines/chewy/sprite.cpp
@@ -291,8 +291,8 @@ void calc_z_ebene() {
int16 mouse_on_prog_ani() {
int16 aniNr = -1;
for (int16 i = 0; i < MAX_PROG_ANI && aniNr == -1; i++) {
- if (_G(minfo).x >= _G(spr_info)[i]._x && _G(minfo).x <= _G(spr_info)[i].X1 &&
- _G(minfo).y >= _G(spr_info)[i]._y && _G(minfo).y <= _G(spr_info)[i].Y1) {
+ if (g_events->_mousePos.x >= _G(spr_info)[i]._x && g_events->_mousePos.x <= _G(spr_info)[i].X1 &&
+ g_events->_mousePos.y >= _G(spr_info)[i]._y && g_events->_mousePos.y <= _G(spr_info)[i].Y1) {
aniNr = i;
}
}
@@ -502,9 +502,11 @@ bool startAtsWait(int16 txtNr, int16 txtMode, int16 col, int16 mode) {
int16 vocx = _G(spieler_vector)[P_CHEWY].Xypos[0] - _G(spieler).scrollx + _G(spieler_mi)[P_CHEWY].HotX;
g_engine->_sound->setSoundChannelBalance(0, _G(atds)->getStereoPos(vocx));
- g_engine->_sound->playSpeech(VocNr,
- _G(atds)->getAtdDisplay() == DISPLAY_VOC);
- //warning("FIXME - unknown constant SMP_PLAYING");
+ if (VocNr >= 0) {
+ g_engine->_sound->playSpeech(VocNr,
+ _G(atds)->getAtdDisplay() == DISPLAY_VOC);
+ //warning("FIXME - unknown constant SMP_PLAYING");
+ }
setupScreen(DO_SETUP);
}
@@ -686,10 +688,10 @@ int16 mouse_auto_obj(int16 nr, int16 xoff, int16 yoff) {
yoff = xy ? xy[1] : 0;
yoff += _G(auto_mov_vector)[nr].Yzoom;
}
- if (_G(minfo).x >= _G(auto_mov_vector)[nr].Xypos[0] + Cxy[0] - _G(spieler).scrollx &&
- _G(minfo).x <= _G(auto_mov_vector)[nr].Xypos[0] + xoff + Cxy[0] - _G(spieler).scrollx &&
- _G(minfo).y >= _G(auto_mov_vector)[nr].Xypos[1] + Cxy[1] - _G(spieler).scrolly &&
- _G(minfo).y <= _G(auto_mov_vector)[nr].Xypos[1] + yoff + Cxy[1] - _G(spieler).scrolly)
+ if (g_events->_mousePos.x >= _G(auto_mov_vector)[nr].Xypos[0] + Cxy[0] - _G(spieler).scrollx &&
+ g_events->_mousePos.x <= _G(auto_mov_vector)[nr].Xypos[0] + xoff + Cxy[0] - _G(spieler).scrollx &&
+ g_events->_mousePos.y >= _G(auto_mov_vector)[nr].Xypos[1] + Cxy[1] - _G(spieler).scrolly &&
+ g_events->_mousePos.y <= _G(auto_mov_vector)[nr].Xypos[1] + yoff + Cxy[1] - _G(spieler).scrolly)
ret = true;
}
return ret;
More information about the Scummvm-git-logs
mailing list