aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-13 10:28:45 -0400
committerPaul Gilbert2016-03-13 10:28:45 -0400
commitf0d992d8548ee8bacae72ecc15e69f9de4187549 (patch)
treec4206efd80ea37699992ad850e8206df29dce374
parentc6b07dcdd7d2ec629d0287922f47e48de90dfc97 (diff)
downloadscummvm-rg350-f0d992d8548ee8bacae72ecc15e69f9de4187549.tar.gz
scummvm-rg350-f0d992d8548ee8bacae72ecc15e69f9de4187549.tar.bz2
scummvm-rg350-f0d992d8548ee8bacae72ecc15e69f9de4187549.zip
TITANIC: Implemented setMode method for game state
-rw-r--r--engines/titanic/game_manager.h10
-rw-r--r--engines/titanic/game_state.cpp25
-rw-r--r--engines/titanic/game_state.h7
-rw-r--r--engines/titanic/input_handler.cpp12
-rw-r--r--engines/titanic/input_handler.h16
-rw-r--r--engines/titanic/screen_manager.h7
6 files changed, 70 insertions, 7 deletions
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 1d2a88e626..d53a611a72 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -87,6 +87,16 @@ public:
void postLoad(CProjectItem *project);
int fn2() { return _gameState._sub.fn2(); }
+
+ /**
+ * Lock the input handler
+ */
+ void lockInputHandler() { _inputHandler.incLockCount(); }
+
+ /**
+ * Unlock the input handler
+ */
+ void unlockInputHandler() { _inputHandler.decLockCount(); }
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index 59e4b7b837..41c4388f64 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -21,12 +21,14 @@
*/
#include "titanic/game_state.h"
+#include "titanic/game_manager.h"
+#include "titanic/screen_manager.h"
namespace Titanic {
CGameState::CGameState(CGameManager *gameManager) :
_gameManager(gameManager), _sub(this),
- _field8(0), _fieldC(0), _field10(10), _field14(0), _field18(0),
+ _field8(0), _fieldC(0), _mode(10), _field14(0), _field18(0),
_field1C(0), _field20(0), _field24(0), _field28(0), _field2C(0),
_field30(0), _field34(0), _field38(0) {
}
@@ -55,4 +57,25 @@ void CGameState::load(SimpleFile *file) {
_field28 = _field2C = 0;
}
+void CGameState::setMode(int newMode) {
+ CScreenManager *sm = CScreenManager::_screenManagerPtr;
+
+ if (newMode == 2 && newMode != _mode) {
+ if (_gameManager)
+ _gameManager->lockInputHandler();
+
+ if (sm && sm->_mouseCursor)
+ sm->_mouseCursor->hide();
+
+ } else if (newMode != 2 && newMode != _mode) {
+ if (sm && sm->_mouseCursor)
+ sm->_mouseCursor->show();
+
+ if (_gameManager)
+ _gameManager->unlockInputHandler();
+ }
+
+ _mode = newMode;
+}
+
} // End of namespace Titanic z
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index e6275dee01..1f93f693c8 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -46,7 +46,7 @@ public:
CGameStateList _list;
int _field8;
int _fieldC;
- int _field10;
+ int _mode;
int _field14;
int _field18;
int _field1C;
@@ -69,6 +69,11 @@ public:
* Load the data for the class from file
*/
void load(SimpleFile *file);
+
+ /**
+ * Sets a new mode
+ */
+ void setMode(int newMode);
};
} // End of namespace Titanic
diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp
index 0c09429bd4..d5825c0c32 100644
--- a/engines/titanic/input_handler.cpp
+++ b/engines/titanic/input_handler.cpp
@@ -28,7 +28,7 @@ namespace Titanic {
CInputHandler::CInputHandler(CGameManager *owner) :
_gameManager(owner), _inputTranslator(nullptr),
_field4(0), _field8(0), _fieldC(0), _field10(0), _field14(0),
- _field18(0), _field1C(0), _field20(0), _field24(0) {
+ _lockCount(0), _field24(0) {
CScreenManager::_screenManagerPtr->_inputHandler = this;
}
@@ -36,4 +36,14 @@ void CInputHandler::setTranslator(CInputTranslator *translator) {
_inputTranslator = translator;
}
+void CInputHandler::incLockCount() {
+ ++_lockCount;
+}
+
+void CInputHandler::decLockCount() {
+ if (--_lockCount == 0 && _inputTranslator) {
+ warning("TODO");
+ }
+}
+
} // End of namespace Titanic z
diff --git a/engines/titanic/input_handler.h b/engines/titanic/input_handler.h
index 288630c633..1bc6dc9fe7 100644
--- a/engines/titanic/input_handler.h
+++ b/engines/titanic/input_handler.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_INPUT_HANDLER_H
#define TITANIC_INPUT_HANDLER_H
+#include "common/rect.h"
#include "titanic/input_translator.h"
namespace Titanic {
@@ -38,14 +39,23 @@ public:
int _fieldC;
int _field10;
int _field14;
- int _field18;
- int _field1C;
- int _field20;
+ Common::Point _mousePos;
+ int _lockCount;
int _field24;
public:
CInputHandler(CGameManager *owner);
void setTranslator(CInputTranslator *translator);
+
+ /**
+ * Increment the lock count
+ */
+ void incLockCount();
+
+ /**
+ * Decrement the lock count on the input handler
+ */
+ void decLockCount();
};
} // End of namespace Titanic
diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h
index 914fc85eb7..d0bcc5dbd8 100644
--- a/engines/titanic/screen_manager.h
+++ b/engines/titanic/screen_manager.h
@@ -47,6 +47,11 @@ public:
CScreenManagerRec();
};
+struct MouseCursor {
+ void show() {}
+ void hide() {}
+};
+
class CScreenManager {
protected:
TitanicEngine *_vm;
@@ -62,7 +67,7 @@ public:
Common::Array<CVideoSurface *> _backSurfaces;
CVideoSurface *_frontRenderSurface;
CScreenManagerRec _entries[2];
- void *_mouseCursor;
+ MouseCursor *_mouseCursor;
void *_textCursor;
CInputHandler *_inputHandler;
int _fontNumber;