Skip to content

Commit

Permalink
TITANIC: Clarify dirty rect methods in CGameManager
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 14, 2017
1 parent 4510c3e commit 61db719
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions engines/titanic/core/game_object.cpp
Expand Up @@ -425,7 +425,7 @@ void CGameObject::processMoveRangeInfo() {
void CGameObject::makeDirty(const Rect &r) {
CGameManager *gameManager = getGameManager();
if (gameManager)
gameManager->extendBounds(r);
gameManager->addDirtyRect(r);
}

void CGameObject::makeDirty() {
Expand Down Expand Up @@ -581,7 +581,7 @@ void CGameObject::petShow() {
if (gameManager) {
gameManager->_gameState._petActive = true;
gameManager->_gameState.setMode(GSMODE_INTERACTIVE);
gameManager->initBounds();
gameManager->markAllDirty();
}
}

Expand All @@ -590,7 +590,7 @@ void CGameObject::petHide() {
if (gameManager) {
gameManager->_gameState._petActive = false;
gameManager->_gameState.setMode(GSMODE_INTERACTIVE);
gameManager->initBounds();
gameManager->markAllDirty();
}
}

Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/debugger.cpp
Expand Up @@ -197,7 +197,7 @@ bool Debugger::cmdPET(int argc, const char **argv) {

if (s == "on") {
gameState._petActive = true;
gameManager.initBounds();
gameManager.markAllDirty();
debugPrintf("PET is now on\n");
return true;
} else if (s == "off") {
Expand Down Expand Up @@ -251,7 +251,7 @@ bool Debugger::cmdItem(int argc, const char **argv) {
} else if (CString(argv[2]) == "add") {
// Ensure the PET is active and add the item to the inventory
gameState._petActive = true;
gameManager.initBounds();
gameManager.markAllDirty();
item->petAddToInventory();

return false;
Expand Down
12 changes: 6 additions & 6 deletions engines/titanic/game_manager.cpp
Expand Up @@ -126,10 +126,6 @@ void CGameManager::postSave() {
_sound.postSave();
}

void CGameManager::initBounds() {
_bounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

void CGameManager::roomTransition(CRoomItem *oldRoom, CRoomItem *newRoom) {
delete _movie;
_movie = nullptr;
Expand Down Expand Up @@ -271,7 +267,7 @@ void CGameManager::viewChange() {
for (CTreeItem *treeItem = _project; treeItem; treeItem = treeItem->scan(_project))
treeItem->viewChange();

initBounds();
markAllDirty();
}

void CGameManager::frameMessage(CRoomItem *room) {
Expand All @@ -292,13 +288,17 @@ void CGameManager::frameMessage(CRoomItem *room) {
}
}

void CGameManager::extendBounds(const Rect &r) {
void CGameManager::addDirtyRect(const Rect &r) {
if (_bounds.isEmpty())
_bounds = r;
else
_bounds.combine(r);
}

void CGameManager::markAllDirty() {
_bounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

CScreenManager *CGameManager::setScreenManager() const {
return CScreenManager::setCurrent();
}
Expand Down
16 changes: 8 additions & 8 deletions engines/titanic/game_manager.h
Expand Up @@ -146,11 +146,6 @@ class CGameManager {
*/
void unlockInputHandler() { _inputHandler.decLockCount(); }

/**
* Set default screen bounds
*/
void initBounds();

/**
* Plays a movie clip
*/
Expand Down Expand Up @@ -182,10 +177,15 @@ class CGameManager {
void decTransitions() { --_transitionCtr; }

/**
* Extends the bounds of the currently affected game display area
* to include the passed rect
* Extends the bounds of the currently dirty area of the
* game screen to include the specified area
*/
void addDirtyRect(const Rect &r);

/**
* Marks the entire screen as dirty, requiring redraw
*/
void extendBounds(const Rect &r);
void markAllDirty();

/**
* Set and return the current screen manager
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/game_view.cpp
Expand Up @@ -55,7 +55,7 @@ void CGameView::deleteView(int roomNumber, int nodeNumber, int viewNumber) {

void CGameView::createSurface(const CResourceKey &key) {
// Reset any current view surface
_gameManager->initBounds();
_gameManager->markAllDirty();
delete _surface;
_surface = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/main_game_window.cpp
Expand Up @@ -96,7 +96,7 @@ void CMainGameWindow::applicationStarting() {
CEnterRoomMsg enterRoomMsg(nullptr, room);
enterRoomMsg.execute(room, nullptr, MSGFLAG_SCAN);

_gameManager->initBounds();
_gameManager->markAllDirty();
}

int CMainGameWindow::getSavegameSlot() {
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/support/files_manager.cpp
Expand Up @@ -113,7 +113,7 @@ void CFilesManager::insertCD(CScreenManager *screenManager) {
void CFilesManager::resetView() {
if (_gameManager) {
_gameManager->_gameState.setMode(GSMODE_INTERACTIVE);
_gameManager->initBounds();
_gameManager->markAllDirty();
}
}

Expand Down

0 comments on commit 61db719

Please sign in to comment.