aboutsummaryrefslogtreecommitdiff
path: root/engines/cryomni3d
diff options
context:
space:
mode:
authorLe Philousophe2019-06-06 21:23:24 +0200
committerLe Philousophe2019-06-08 12:43:22 +0200
commit89922138e2f9f29b1265aabe6e250fa050411caa (patch)
tree82f9b1b341b9fa85b29d4bdb8d8550b00e8d5dc2 /engines/cryomni3d
parentd32d2167e9ef13a9fb834ed9916bfcc63870897c (diff)
downloadscummvm-rg350-89922138e2f9f29b1265aabe6e250fa050411caa.tar.gz
scummvm-rg350-89922138e2f9f29b1265aabe6e250fa050411caa.tar.bz2
scummvm-rg350-89922138e2f9f29b1265aabe6e250fa050411caa.zip
CRYOMNI3D: Use CursorMan instead of using backend directly
This avoids bugs when GMM is displayed. It uses GMM like all dialogs in ScummVM and without CursorMan our cursor get erased when GMM is closed.
Diffstat (limited to 'engines/cryomni3d')
-rw-r--r--engines/cryomni3d/cryomni3d.cpp8
-rw-r--r--engines/cryomni3d/cryomni3d.h4
-rw-r--r--engines/cryomni3d/fixed_image.cpp8
-rw-r--r--engines/cryomni3d/versailles/dialogs_manager.cpp8
-rw-r--r--engines/cryomni3d/versailles/documentation.cpp32
-rw-r--r--engines/cryomni3d/versailles/engine.cpp24
-rw-r--r--engines/cryomni3d/versailles/menus.cpp12
-rw-r--r--engines/cryomni3d/versailles/toolbar.cpp6
8 files changed, 53 insertions, 49 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp
index b7d3a9d528..f27bffb437 100644
--- a/engines/cryomni3d/cryomni3d.cpp
+++ b/engines/cryomni3d/cryomni3d.cpp
@@ -222,14 +222,14 @@ void CryOmni3DEngine::displayHLZ(const Common::String &filename) {
}
void CryOmni3DEngine::setCursor(const Graphics::Cursor &cursor) const {
- g_system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
- cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
+ CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
+ cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
}
void CryOmni3DEngine::setCursor(uint cursorId) const {
const Graphics::Cursor &cursor = _sprites.getCursor(cursorId);
- g_system->setMouseCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
- cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
+ CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
+ cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
}
bool CryOmni3DEngine::pollEvents() {
diff --git a/engines/cryomni3d/cryomni3d.h b/engines/cryomni3d/cryomni3d.h
index 003d5080b0..aba69e78f5 100644
--- a/engines/cryomni3d/cryomni3d.h
+++ b/engines/cryomni3d/cryomni3d.h
@@ -33,6 +33,8 @@
#include "engines/engine.h"
+#include "graphics/cursorman.h"
+
#include "cryomni3d/font_manager.h"
#include "cryomni3d/objects.h"
#include "cryomni3d/sprites.h"
@@ -106,8 +108,10 @@ public:
Image::ImageDecoder *loadHLZ(const Common::String &filename);
void fillSurface(byte color);
+ /* We use CursorMan because it avoids problems with cursors in GMM */
void setCursor(const Graphics::Cursor &cursor) const;
void setCursor(uint cursorId) const;
+ bool showMouse(bool visible) { return CursorMan.showMouse(visible); }
typedef void (CryOmni3DEngine::*HNMCallback)(uint frameNum);
void playHNM(const Common::String &filename,
Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType,
diff --git a/engines/cryomni3d/fixed_image.cpp b/engines/cryomni3d/fixed_image.cpp
index f00b309e11..3e8428ab44 100644
--- a/engines/cryomni3d/fixed_image.cpp
+++ b/engines/cryomni3d/fixed_image.cpp
@@ -48,12 +48,12 @@ void ZonFixedImage::run(const CallbackFunctor *callback) {
_callback = callback;
- g_system->showMouse(true);
+ _engine.showMouse(true);
while (!_exit) {
(*_callback)(this);
}
_engine.waitMouseRelease();
- g_system->showMouse(false);
+ _engine.showMouse(false);
// Deselect object
_inventory.setSelectedObject(nullptr);
@@ -97,10 +97,10 @@ void ZonFixedImage::load(const Common::String &image, const char *zone) {
// WORKAROUND: Wait for release after displaying the fixed image to avoid handling events due to mouse being pressed
// There is this bug in game
// Don't display cursor to prevent displaying an invalid cursor
- g_system->showMouse(false);
+ _engine.showMouse(false);
g_system->updateScreen();
_engine.waitMouseRelease();
- g_system->showMouse(true);
+ _engine.showMouse(true);
}
void ZonFixedImage::display() const {
diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp
index 2b9d38e3a1..d49984a327 100644
--- a/engines/cryomni3d/versailles/dialogs_manager.cpp
+++ b/engines/cryomni3d/versailles/dialogs_manager.cpp
@@ -42,12 +42,12 @@ bool Versailles_DialogsManager::play(const Common::String &sequence) {
_engine->setCursor(181);
// No need to adjust hide cursor counter, there isn't any in ScummVM
- bool cursorWasVisible = g_system->showMouse(true);
+ bool cursorWasVisible = _engine->showMouse(true);
bool slowStop = false;
bool didSth = DialogsManager::play(sequence, slowStop);
- g_system->showMouse(cursorWasVisible);
+ _engine->showMouse(cursorWasVisible);
if (didSth && slowStop) {
if (_engine->showSubtitles()) {
@@ -123,7 +123,7 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
return;
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
uint16 width = videoDecoder->getWidth();
uint16 height = videoDecoder->getHeight();
@@ -235,7 +235,7 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
// It's intentional that _lastImage is set with the first video image
delete videoDecoder;
- g_system->showMouse(true);
+ _engine->showMouse(true);
}
void Versailles_DialogsManager::displayMessage(const Common::String &text) {
diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp
index b830b0c70d..3846651dd2 100644
--- a/engines/cryomni3d/versailles/documentation.cpp
+++ b/engines/cryomni3d/versailles/documentation.cpp
@@ -146,7 +146,7 @@ void Versailles_Documentation::init(const Sprites *sprites, FontManager *fontMan
}
void Versailles_Documentation::handleDocArea() {
- g_system->showMouse(false);
+ _engine->showMouse(false);
// Load all links lazily and free them at the end to not waste memory
// Maybe it's not really useful
@@ -173,7 +173,7 @@ void Versailles_Documentation::handleDocArea() {
_allLinks.clear();
- g_system->showMouse(true);
+ _engine->showMouse(true);
}
void Versailles_Documentation::handleDocInGame(const Common::String &record) {
@@ -184,7 +184,7 @@ void Versailles_Documentation::handleDocInGame(const Common::String &record) {
Common::String nextRecord;
MouseBoxes boxes(3);
- g_system->showMouse(false);
+ _engine->showMouse(false);
bool end = false;
while (!end) {
inGamePrepareRecord(docSurface, boxes);
@@ -212,7 +212,7 @@ void Versailles_Documentation::handleDocInGame(const Common::String &record) {
error("Invalid case %d when displaying doc record", action);
}
}
- g_system->showMouse(true);
+ _engine->showMouse(true);
}
Common::String Versailles_Documentation::docAreaHandleSummary() {
@@ -327,7 +327,7 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
imageDecoder->getPaletteColorCount());
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
bool redraw = true;
uint hoveredBox = -1;
@@ -409,7 +409,7 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
delete imageDecoder;
@@ -456,7 +456,7 @@ Common::String Versailles_Documentation::docAreaHandleTimeline() {
479 - _sprites->getCursor(105).getHeight(), 640, 480);
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
bool redraw = true;
uint hoveredBox = -1;
@@ -515,7 +515,7 @@ Common::String Versailles_Documentation::docAreaHandleTimeline() {
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
delete imageDecoder;
@@ -693,7 +693,7 @@ uint Versailles_Documentation::docAreaHandleRecord(Graphics::ManagedSurface &sur
MouseBoxes &boxes, Common::String &nextRecord) {
// Hovering is only handled for timeline entries
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
bool first = true;
bool redraw = true;
@@ -856,7 +856,7 @@ uint Versailles_Documentation::docAreaHandleRecord(Graphics::ManagedSurface &sur
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
_engine->setCursor(181);
return action;
}
@@ -954,7 +954,7 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
imageDecoder->getPaletteColorCount());
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
bool redraw = true;
uint hoveredBox = -1;
@@ -1050,7 +1050,7 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
delete imageDecoder;
@@ -1172,7 +1172,7 @@ Common::String Versailles_Documentation::docAreaHandleCastleMap() {
imageDecoder->getPaletteColorCount());
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
bool redraw = true;
uint hoveredBox = -1;
@@ -1294,7 +1294,7 @@ Common::String Versailles_Documentation::docAreaHandleCastleMap() {
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
delete imageDecoder;
@@ -1340,7 +1340,7 @@ void Versailles_Documentation::inGamePrepareRecord(Graphics::ManagedSurface &sur
uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surface,
MouseBoxes &boxes, Common::String &nextRecord) {
_engine->setCursor(181);
- g_system->showMouse(true);
+ _engine->showMouse(true);
uint action = -1;
@@ -1383,7 +1383,7 @@ uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surf
}
}
- g_system->showMouse(false);
+ _engine->showMouse(false);
_engine->setCursor(181);
return action;
}
diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp
index 6417a9bc58..321b71c758 100644
--- a/engines/cryomni3d/versailles/engine.cpp
+++ b/engines/cryomni3d/versailles/engine.cpp
@@ -600,7 +600,7 @@ void CryOmni3DEngine_Versailles::playTransitionEndLevel(int level) {
fillSurface(0);
// In original game the HNM player just doesn't render the cursor
- bool cursorWasVisible = g_system->showMouse(false);
+ bool cursorWasVisible = showMouse(false);
// Videos are like music because if you mute music in game it will mute videos soundtracks
playHNM(video, Audio::Mixer::kMusicSoundType);
@@ -618,7 +618,7 @@ void CryOmni3DEngine_Versailles::playTransitionEndLevel(int level) {
}
// Display back cursor there once the palette has been zeroed
- g_system->showMouse(cursorWasVisible);
+ showMouse(cursorWasVisible);
fillSurface(0);
@@ -1115,7 +1115,7 @@ int CryOmni3DEngine_Versailles::handleWarp() {
bool firstDraw = true;
bool moving = true;
uint actionId;
- g_system->showMouse(true);
+ showMouse(true);
while (!leftButtonPressed && !exit) {
int xDelta = 0, yDelta = 0;
uint movingCursor = -1;
@@ -1200,7 +1200,7 @@ int CryOmni3DEngine_Versailles::handleWarp() {
// Slow down loop but after updating screen
g_system->delayMillis(10);
}
- g_system->showMouse(false);
+ showMouse(false);
return actionId;
}
@@ -1395,7 +1395,7 @@ void CryOmni3DEngine_Versailles::animateCursor(const Object *obj) {
return;
}
- bool cursorWasVisible = g_system->showMouse(true);
+ bool cursorWasVisible = showMouse(true);
for (uint i = 4; i > 0; i--) {
// Wait 100ms
@@ -1416,7 +1416,7 @@ void CryOmni3DEngine_Versailles::animateCursor(const Object *obj) {
g_system->updateScreen();
}
- g_system->showMouse(cursorWasVisible);
+ showMouse(cursorWasVisible);
}
void CryOmni3DEngine_Versailles::collectObject(Object *obj, const ZonFixedImage *fimg,
@@ -1468,7 +1468,7 @@ void CryOmni3DEngine_Versailles::displayObject(const Common::String &imgName,
setMousePos(Common::Point(320, 240)); // Center of screen
setCursor(181);
- bool cursorWasVisible = g_system->showMouse(true);
+ bool cursorWasVisible = showMouse(true);
bool exitImg = false;
while (!g_engine->shouldQuit() && !exitImg) {
@@ -1483,7 +1483,7 @@ void CryOmni3DEngine_Versailles::displayObject(const Common::String &imgName,
waitMouseRelease();
clearKeys();
- g_system->showMouse(cursorWasVisible);
+ showMouse(cursorWasVisible);
setMousePos(Common::Point(320, 240)); // Center of screen
}
@@ -1506,12 +1506,12 @@ void CryOmni3DEngine_Versailles::executeSeeAction(uint actionId) {
void CryOmni3DEngine_Versailles::executeSpeakAction(uint actionId) {
PlaceActionKey key(_currentPlaceId, actionId);
Common::HashMap<PlaceActionKey, Common::String>::iterator it = _whoSpeaksWhere.find(key);
- g_system->showMouse(true);
+ showMouse(true);
bool doneSth = false;
if (it != _whoSpeaksWhere.end()) {
doneSth = _dialogsMan.play(it->_value);
}
- g_system->showMouse(false);
+ showMouse(false);
_forcePaletteUpdate = true;
if (doneSth) {
setMousePos(Common::Point(320, 240)); // Center of screen
@@ -1570,7 +1570,7 @@ void CryOmni3DEngine_Versailles::playInGameVideo(const Common::String &filename,
if (restoreCursorPalette) {
// WORKAROUND: Don't mess with mouse when not restoring cursors palette
- g_system->showMouse(false);
+ showMouse(false);
}
lockPalette(0, 241);
// Videos are like music because if you mute music in game it will mute videos soundtracks
@@ -1582,7 +1582,7 @@ void CryOmni3DEngine_Versailles::playInGameVideo(const Common::String &filename,
// Restore cursors colors as 2 first ones may have been erased by the video
setPalette(&_cursorPalette[3 * 240], 240, 248);
// WORKAROUND: Don't mess with mouse when not restoring cursors palette
- g_system->showMouse(true);
+ showMouse(true);
}
}
diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp
index 031739d44a..98d433a3ba 100644
--- a/engines/cryomni3d/versailles/menus.cpp
+++ b/engines/cryomni3d/versailles/menus.cpp
@@ -96,7 +96,7 @@ uint CryOmni3DEngine_Versailles::displayOptions() {
optionsSurface.create(bgFrame->w, bgFrame->h, bgFrame->format);
setCursor(181);
- g_system->showMouse(true);
+ showMouse(true);
uint hoveredBox = -1;
uint selectedBox;
@@ -452,7 +452,7 @@ uint CryOmni3DEngine_Versailles::displayOptions() {
}
}
- g_system->showMouse(false);
+ showMouse(false);
if (selectedMsg == 42) {
_abortCommand = kAbortLoadGame;
@@ -570,7 +570,7 @@ uint CryOmni3DEngine_Versailles::displayFilePicker(const Graphics::Surface *bgFr
_fontManager.displayStr(164, 214, _messages[subtitleId]);
// Draw an empty screen before we list saves
- g_system->showMouse(false);
+ showMouse(false);
g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, surface.w, surface.h);
g_system->updateScreen();
@@ -578,7 +578,7 @@ uint CryOmni3DEngine_Versailles::displayFilePicker(const Graphics::Surface *bgFr
getSavesList(_isVisiting, savesList);
Common::String saveNameBackup;
- g_system->showMouse(true);
+ showMouse(true);
MouseBoxes boxes(10); // 6 files + Yes/No/Up/Down buttons
@@ -962,7 +962,7 @@ void CryOmni3DEngine_Versailles::displayCredits() {
return;
}
- g_system->showMouse(false);
+ showMouse(false);
char line[256];
bool end = false;
@@ -1068,7 +1068,7 @@ void CryOmni3DEngine_Versailles::displayCredits() {
currentY += lineHeight;
}
}
- g_system->showMouse(true);
+ showMouse(true);
}
} // End of namespace Versailles
diff --git a/engines/cryomni3d/versailles/toolbar.cpp b/engines/cryomni3d/versailles/toolbar.cpp
index 23b94b8c81..a0d4d3091a 100644
--- a/engines/cryomni3d/versailles/toolbar.cpp
+++ b/engines/cryomni3d/versailles/toolbar.cpp
@@ -263,9 +263,9 @@ uint Toolbar::callbackViewObject(uint dragStatus) {
return 1;
case kDragStatus_Finished:
// Just clicked
- g_system->showMouse(false);
+ _engine->showMouse(false);
(*selectedObject->viewCallback())();
- g_system->showMouse(true);
+ _engine->showMouse(true);
_parentMustRedraw = true;
_shortExit = true;
return 1;
@@ -293,7 +293,7 @@ uint Toolbar::callbackOptions(uint dragStatus) {
_shortExit = true;
_engine->setMousePos(Common::Point(320, 240)); // Center of screen
// Displaying options hides the mouse
- g_system->showMouse(true);
+ _engine->showMouse(true);
return 0;
default:
return 0;