aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-16 19:05:16 -0400
committerPaul Gilbert2016-03-16 19:05:16 -0400
commit8ec499c177d88e11930b8550c47c352d65dc603a (patch)
tree8c66770c49673985aa7ad27b77e8922df670b53d
parenteaead0c6aee10f1fdd347a723bd9b816f80abff6 (diff)
downloadscummvm-rg350-8ec499c177d88e11930b8550c47c352d65dc603a.tar.gz
scummvm-rg350-8ec499c177d88e11930b8550c47c352d65dc603a.tar.bz2
scummvm-rg350-8ec499c177d88e11930b8550c47c352d65dc603a.zip
TITANIC: Implementing setActiveView, surface clearing
-rw-r--r--engines/titanic/direct_draw.cpp18
-rw-r--r--engines/titanic/direct_draw.h6
-rw-r--r--engines/titanic/game_manager.cpp2
-rw-r--r--engines/titanic/game_manager.h2
-rw-r--r--engines/titanic/game_state.cpp8
-rw-r--r--engines/titanic/game_state.h6
-rw-r--r--engines/titanic/game_view.cpp19
-rw-r--r--engines/titanic/game_view.h4
-rw-r--r--engines/titanic/main_game_window.cpp26
-rw-r--r--engines/titanic/screen_manager.cpp9
-rw-r--r--engines/titanic/screen_manager.h14
-rw-r--r--engines/titanic/video_surface.cpp8
-rw-r--r--engines/titanic/video_surface.h2
13 files changed, 98 insertions, 26 deletions
diff --git a/engines/titanic/direct_draw.cpp b/engines/titanic/direct_draw.cpp
index 71f0d35630..17e13610e0 100644
--- a/engines/titanic/direct_draw.cpp
+++ b/engines/titanic/direct_draw.cpp
@@ -108,4 +108,22 @@ DirectDrawSurface *DirectDrawManager::createSurface(int w, int h, int surfaceNum
return _directDraw.createSurfaceFromDesc(DDSurfaceDesc(w, h));
}
+/*------------------------------------------------------------------------*/
+
+void DirectDrawSurface::fill(const Common::Rect *bounds, uint32 color) {
+ Common::Rect tempBounds;
+
+ if (bounds) {
+ // Bounds are provided, clip them to the bounds of this surface
+ tempBounds = *bounds;
+ tempBounds.clip(Common::Rect(0, 0, this->w, this->h));
+ } else {
+ // No bounds provided, so use the entire surface
+ tempBounds = Common::Rect(0, 0, this->w, this->h);
+ }
+
+ // Fill the area
+ fillRect(tempBounds, color);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/direct_draw.h b/engines/titanic/direct_draw.h
index 6dedcd0e52..bd6a77dc2d 100644
--- a/engines/titanic/direct_draw.h
+++ b/engines/titanic/direct_draw.h
@@ -41,6 +41,12 @@ struct DDSurfaceDesc {
};
class DirectDrawSurface : public Graphics::Surface {
+public:
+ /**
+ * Fills an area of the surfae with the specified color. If no bounds are passed,
+ * then the entire surface is filled
+ */
+ void fill(const Common::Rect *bounds, uint32 color);
};
class DirectDraw {
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index 5d5dc164ed..efa816d8e2 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -69,7 +69,7 @@ void CGameManager::postLoad(CProjectItem *project) {
if (_gameView) {
_gameView->postLoad();
- if (!_gameView->_fieldC) {
+ if (!_gameView->_surface) {
CViewItem *view = getView();
if (view)
_gameView->setView(view);
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 6a4905239e..1509554bf8 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -58,7 +58,6 @@ private:
CInputTranslator _inputTranslator;
CMusicRoom _musicRoom;
CTrueTalkManager _trueTalkManager;
- Common::Rect _bounds;
CGameManagerList _list;
int _field30;
int _field34;
@@ -72,6 +71,7 @@ private:
public:
CProjectItem *_project;
CGameState _gameState;
+ Common::Rect _bounds;
public:
CGameManager(CProjectItem *project, CGameView *gameView);
~CGameManager();
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index b8b5ec1362..3ce8b2b42e 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -28,7 +28,7 @@ namespace Titanic {
CGameState::CGameState(CGameManager *gameManager) :
_gameManager(gameManager), _gameLocation(this),
- _field8(0), _fieldC(0), _mode(10), _field14(0), _field18(0),
+ _field8(0), _fieldC(0), _mode(GSMODE_0), _field14(0), _field18(0),
_field1C(0), _field20(0), _field24(0), _field28(0), _field2C(0),
_field30(0), _field34(0), _field38(0) {
}
@@ -57,17 +57,17 @@ void CGameState::load(SimpleFile *file) {
_field28 = _field2C = 0;
}
-void CGameState::setMode(int newMode) {
+void CGameState::setMode(GameStateMode newMode) {
CScreenManager *sm = CScreenManager::_screenManagerPtr;
- if (newMode == 2 && newMode != _mode) {
+ if (newMode == GSMODE_2 && newMode != _mode) {
if (_gameManager)
_gameManager->lockInputHandler();
if (sm && sm->_mouseCursor)
sm->_mouseCursor->hide();
- } else if (newMode != 2 && newMode != _mode) {
+ } else if (newMode != GSMODE_2 && newMode != _mode) {
if (sm && sm->_mouseCursor)
sm->_mouseCursor->show();
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index f08216383e..3c3b720d95 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -31,6 +31,8 @@ namespace Titanic {
class CGameManager;
+enum GameStateMode { GSMODE_0 = 0, GSMODE_1 = 1, GSMODE_2 = 2, GSMODE_3 = 3, GSMODE_4 = 4, GSMODE_5 = 5 };
+
class CGameStateList : public List<ListItem> {
public:
int _field10;
@@ -46,7 +48,7 @@ public:
CGameStateList _list;
int _field8;
int _fieldC;
- int _mode;
+ GameStateMode _mode;
int _field14;
int _field18;
int _field1C;
@@ -73,7 +75,7 @@ public:
/**
* Sets a new mode
*/
- void setMode(int newMode);
+ void setMode(GameStateMode newMode);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_view.cpp b/engines/titanic/game_view.cpp
index a2905d148c..315b2a8909 100644
--- a/engines/titanic/game_view.cpp
+++ b/engines/titanic/game_view.cpp
@@ -23,11 +23,11 @@
#include "titanic/game_view.h"
#include "titanic/game_manager.h"
#include "titanic/main_game_window.h"
+#include "titanic/screen_manager.h"
namespace Titanic {
-CGameView::CGameView() : _gameManager(nullptr), _fieldC(nullptr),
- _field8(0) {
+CGameView::CGameView() : _gameManager(nullptr), _surface(nullptr) {
}
void CGameView::setGameManager(CGameManager *gameManager) {
@@ -35,10 +35,8 @@ void CGameView::setGameManager(CGameManager *gameManager) {
}
void CGameView::postLoad() {
- if (_fieldC)
- warning("TODO");
-
- _fieldC = nullptr;
+ delete _surface;
+ _surface = nullptr;
}
void CGameView::deleteView(int roomNumber, int nodeNumber, int viewNumber) {
@@ -48,7 +46,14 @@ void CGameView::deleteView(int roomNumber, int nodeNumber, int viewNumber) {
}
void CGameView::createSurface(const CResourceKey &key) {
-
+ // Reset any current view surface
+ _gameManager->initBounds();
+ delete _surface;
+ _surface = nullptr;
+
+ // Create a fresh surface
+ CScreenManager::setCurrent();
+ _surface = CScreenManager::_currentScreenManagerPtr->createSurface(key);
}
/*------------------------------------------------------------------------*/
diff --git a/engines/titanic/game_view.h b/engines/titanic/game_view.h
index bf406b5acc..9ede9d6c36 100644
--- a/engines/titanic/game_view.h
+++ b/engines/titanic/game_view.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "titanic/core/view_item.h"
+#include "titanic/video_surface.h"
namespace Titanic {
@@ -34,9 +35,8 @@ class CGameManager;
class CGameView {
protected:
CGameManager *_gameManager;
- int _field8;
public:
- void *_fieldC;
+ CVideoSurface *_surface;
public:
CGameView();
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index 6bde296453..a964f928f9 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -107,7 +107,31 @@ void CMainGameWindow::setActiveView(CViewItem *viewItem) {
}
void CMainGameWindow::fn2() {
- warning("TODO");
+ if (_gameManager) {
+ if (_gameView->_surface) {
+ CViewItem *view = _gameManager->getView();
+ if (view)
+ setActiveView(view);
+ }
+
+ CScreenManager *scrManager = CScreenManager::setCurrent();
+ scrManager->clearSurface(0, &_gameManager->_bounds);
+
+ switch (_gameManager->_gameState._mode) {
+ case GSMODE_1:
+ case GSMODE_2:
+ if (_gameManager->_gameState._field18)
+ warning("TODO: Field18_fn1(this)");
+ warning("TODO: Stuff");
+
+ case GSMODE_5:
+ warning("TODO: FilesManager::fn1");
+ break;
+
+ default:
+ break;
+ }
+ }
}
} // End of namespace Titanic
diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp
index e2d62bec54..f64468e90b 100644
--- a/engines/titanic/screen_manager.cpp
+++ b/engines/titanic/screen_manager.cpp
@@ -122,7 +122,14 @@ void OSScreenManager::proc16() {}
void OSScreenManager::getFont() {}
void OSScreenManager::proc18() {}
void OSScreenManager::proc19() {}
-void OSScreenManager::proc20() {}
+
+void OSScreenManager::clearSurface(int surfaceNum, Common::Rect *bounds) {
+ if (surfaceNum == -1)
+ _directDrawManager._mainSurface->fill(bounds, 0);
+ else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size())
+ _directDrawManager._backSurfaces[surfaceNum]->fill(bounds, 0);
+}
+
void OSScreenManager::proc21() {}
CVideoSurface *OSScreenManager::createSurface(int w, int h) {
diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h
index 0fd6bfad8b..075e36cadf 100644
--- a/engines/titanic/screen_manager.h
+++ b/engines/titanic/screen_manager.h
@@ -99,7 +99,12 @@ public:
virtual void getFont() = 0;
virtual void proc18() = 0;
virtual void proc19() = 0;
- virtual void proc20() = 0;
+
+ /**
+ * Clear a portion of a specified surface
+ */
+ virtual void clearSurface(int surfaceNum, Common::Rect *_bounds) = 0;
+
virtual void proc21() = 0;
/**
@@ -157,7 +162,12 @@ public:
virtual void getFont();
virtual void proc18();
virtual void proc19();
- virtual void proc20();
+
+ /**
+ * Clear a portion of the screen surface
+ */
+ virtual void clearSurface(int surfaceNum, Common::Rect *bounds);
+
virtual void proc21();
/**
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index c7643cf656..1db23830b4 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -35,19 +35,19 @@ CVideoSurface::CVideoSurface(CScreenManager *screenManager) :
void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) {
_screenManager = screenManager;
- _surface = surface;
+ _ddSurface = surface;
}
/*------------------------------------------------------------------------*/
OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) :
CVideoSurface(screenManager) {
- _surface = surface;
+ _ddSurface = surface;
}
OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag) :
CVideoSurface(screenManager) {
- _surface = nullptr;
+ _ddSurface = nullptr;
_field38 = flag;
if (_field38) {
@@ -67,7 +67,7 @@ void OSVideoSurface::proc8(const CResourceKey &key) {
}
bool OSVideoSurface::hasSurface() {
- return _surface != nullptr;
+ return _ddSurface != nullptr;
}
void OSVideoSurface::proc43() {
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index 71a2fd668c..d0fa54bf85 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -40,7 +40,7 @@ private:
protected:
CScreenManager *_screenManager;
CResourceKey _resourceKey;
- DirectDrawSurface *_surface;
+ DirectDrawSurface *_ddSurface;
int _field2C;
int _field34;
bool _field38;