2016-02-22 20:43:14 -05:00
|
|
|
/* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TITANIC_GAME_MANAGER_H
|
|
|
|
#define TITANIC_GAME_MANAGER_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2016-03-08 22:34:51 -05:00
|
|
|
#include "titanic/game_state.h"
|
|
|
|
#include "titanic/input_handler.h"
|
|
|
|
#include "titanic/input_translator.h"
|
2017-08-24 04:05:49 -07:00
|
|
|
#include "titanic/support/time_event_info.h" // class CTimeEventInfo
|
|
|
|
#include "titanic/true_talk/true_talk_manager.h" // class CTrueTalkManager
|
2016-03-08 22:34:51 -05:00
|
|
|
#include "titanic/sound/music_room.h"
|
|
|
|
#include "titanic/sound/sound.h"
|
2016-02-22 20:43:14 -05:00
|
|
|
|
|
|
|
namespace Titanic {
|
|
|
|
|
2017-08-24 04:05:49 -07:00
|
|
|
class CBackgroundSoundMaker;
|
2016-02-22 20:43:14 -05:00
|
|
|
class CGameView;
|
2017-08-24 04:05:49 -07:00
|
|
|
class CMovie;
|
|
|
|
class CMovieClip;
|
|
|
|
class CProjectItem;
|
|
|
|
class CRoomItem;
|
|
|
|
class CScreenManager;
|
|
|
|
class CTreeItem;
|
|
|
|
class CViewItem;
|
|
|
|
class CVideoSurface;
|
|
|
|
class SimpleFile;
|
2016-02-22 20:43:14 -05:00
|
|
|
|
|
|
|
class CGameManager {
|
|
|
|
private:
|
2016-03-08 22:34:51 -05:00
|
|
|
CTrueTalkManager _trueTalkManager;
|
2016-04-09 19:36:12 -04:00
|
|
|
CTimeEventInfoList _timers;
|
2016-06-26 23:00:00 -04:00
|
|
|
CTreeItem *_treeItem;
|
2016-03-19 22:43:02 -04:00
|
|
|
CBackgroundSoundMaker *_soundMaker;
|
2016-06-26 23:00:00 -04:00
|
|
|
CMovie *_movie;
|
|
|
|
CRoomItem *_movieRoom;
|
2016-11-12 19:49:09 -05:00
|
|
|
int _transitionCtr;
|
2016-06-26 23:00:00 -04:00
|
|
|
CVideoSurface *_movieSurface;
|
2016-03-19 07:48:23 -04:00
|
|
|
uint _lastDiskTicksCount;
|
2016-03-12 19:23:00 -05:00
|
|
|
uint _tickCount2;
|
2016-03-19 22:43:02 -04:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Generates a message for the next game frame
|
|
|
|
*/
|
|
|
|
void frameMessage(CRoomItem *room);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles any ongoing movie playback
|
|
|
|
*/
|
2016-04-08 20:46:03 -04:00
|
|
|
void updateMovies();
|
2016-06-26 23:00:00 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles a room transition
|
|
|
|
*/
|
|
|
|
void roomTransition(CRoomItem *oldRoom, CRoomItem *newRoom);
|
2016-03-12 19:23:00 -05:00
|
|
|
public:
|
|
|
|
CProjectItem *_project;
|
2016-03-19 18:19:45 -04:00
|
|
|
CGameView *_gameView;
|
2016-03-13 15:30:12 -04:00
|
|
|
CGameState _gameState;
|
2016-03-21 20:53:49 -04:00
|
|
|
Rect _bounds;
|
2016-03-18 21:34:04 -04:00
|
|
|
CInputHandler _inputHandler;
|
|
|
|
CInputTranslator _inputTranslator;
|
2016-03-18 23:15:31 -04:00
|
|
|
CTreeItem *_dragItem;
|
2016-03-19 20:56:29 -04:00
|
|
|
CSound _sound;
|
2017-10-15 21:14:33 -04:00
|
|
|
CMusicRoom _musicRoom;
|
2016-02-22 20:43:14 -05:00
|
|
|
public:
|
2016-08-05 13:11:12 -04:00
|
|
|
CGameManager(CProjectItem *project, CGameView *gameView, Audio::Mixer *mixer);
|
2016-03-08 22:34:51 -05:00
|
|
|
~CGameManager();
|
2016-02-23 20:59:57 -05:00
|
|
|
|
2016-07-22 12:44:14 -04:00
|
|
|
/**
|
|
|
|
* Destroys and allocated tree item
|
|
|
|
*/
|
|
|
|
void destroyTreeItem();
|
|
|
|
|
2016-07-20 21:51:44 -04:00
|
|
|
/**
|
|
|
|
* Save data to a save file
|
|
|
|
*/
|
|
|
|
void save(SimpleFile *file);
|
|
|
|
|
2016-02-23 20:59:57 -05:00
|
|
|
/**
|
|
|
|
* Load data from a save file
|
|
|
|
*/
|
|
|
|
void load(SimpleFile *file);
|
|
|
|
|
2016-03-19 07:48:23 -04:00
|
|
|
/**
|
|
|
|
* Called when a game is about to be loaded
|
|
|
|
*/
|
|
|
|
void preLoad();
|
|
|
|
|
2016-02-23 20:59:57 -05:00
|
|
|
/**
|
|
|
|
* Called after loading a game has finished
|
|
|
|
*/
|
2016-03-12 19:23:00 -05:00
|
|
|
void postLoad(CProjectItem *project);
|
|
|
|
|
2016-03-19 08:08:01 -04:00
|
|
|
/**
|
|
|
|
* Called when a game is about to be saved
|
|
|
|
*/
|
|
|
|
void preSave(CProjectItem *project);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a game has finished being saved
|
|
|
|
*/
|
|
|
|
void postSave();
|
|
|
|
|
2016-03-19 07:48:23 -04:00
|
|
|
/**
|
|
|
|
* Updates the game time when the last disk access started
|
|
|
|
*/
|
|
|
|
void updateDiskTicksCount();
|
|
|
|
|
2016-03-24 21:02:25 -04:00
|
|
|
/**
|
|
|
|
* Gets the current view
|
|
|
|
*/
|
2016-03-13 15:07:27 -04:00
|
|
|
CViewItem *getView() { return _gameState._gameLocation.getView(); }
|
2016-03-13 10:28:45 -04:00
|
|
|
|
2016-03-24 21:02:25 -04:00
|
|
|
/**
|
|
|
|
* Gets the current room node
|
|
|
|
*/
|
|
|
|
CNodeItem *getNode() { return _gameState._gameLocation.getNode(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current room
|
|
|
|
*/
|
|
|
|
CRoomItem *getRoom() { return _gameState._gameLocation.getRoom(); }
|
|
|
|
|
2016-03-13 10:28:45 -04:00
|
|
|
/**
|
|
|
|
* Lock the input handler
|
|
|
|
*/
|
|
|
|
void lockInputHandler() { _inputHandler.incLockCount(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlock the input handler
|
|
|
|
*/
|
|
|
|
void unlockInputHandler() { _inputHandler.decLockCount(); }
|
2016-03-13 15:30:12 -04:00
|
|
|
|
2016-03-19 20:56:29 -04:00
|
|
|
/**
|
|
|
|
* Plays a movie clip
|
|
|
|
*/
|
|
|
|
void playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *newRoom);
|
2016-03-19 18:19:45 -04:00
|
|
|
|
2016-03-18 21:34:04 -04:00
|
|
|
/**
|
2016-03-19 23:02:41 -04:00
|
|
|
* Main frame update method for the game
|
2016-03-18 21:34:04 -04:00
|
|
|
*/
|
|
|
|
void update();
|
2016-03-19 09:29:11 -04:00
|
|
|
|
|
|
|
/**
|
2017-06-11 16:19:54 -04:00
|
|
|
* Called when the room changes
|
2016-03-19 09:29:11 -04:00
|
|
|
*/
|
2017-06-11 16:19:54 -04:00
|
|
|
void roomChange();
|
2016-03-19 20:56:29 -04:00
|
|
|
|
2016-11-12 19:49:09 -05:00
|
|
|
/**
|
|
|
|
* Returns true if no transition is currently in progress
|
|
|
|
*/
|
|
|
|
bool isntTransitioning() const { return !_transitionCtr; }
|
2016-03-19 22:43:02 -04:00
|
|
|
|
2016-11-12 19:49:09 -05:00
|
|
|
/**
|
|
|
|
* Increments the number of active transitions
|
|
|
|
*/
|
|
|
|
void incTransitions() { ++_transitionCtr; }
|
2016-03-19 22:43:02 -04:00
|
|
|
|
2016-11-12 19:49:09 -05:00
|
|
|
/**
|
|
|
|
* Decremenst the number of active transitions
|
|
|
|
*/
|
|
|
|
void decTransitions() { --_transitionCtr; }
|
2016-03-22 07:44:45 -04:00
|
|
|
|
|
|
|
/**
|
2017-01-14 18:19:12 -05:00
|
|
|
* 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
|
2016-03-22 07:44:45 -04:00
|
|
|
*/
|
2017-01-14 18:19:12 -05:00
|
|
|
void markAllDirty();
|
2016-04-09 14:24:52 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set and return the current screen manager
|
|
|
|
*/
|
|
|
|
CScreenManager *setScreenManager() const;
|
2016-04-09 19:36:12 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a timer
|
|
|
|
*/
|
|
|
|
void addTimer(CTimeEventInfo *timer) { _timers.push_back(timer); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops a timer
|
|
|
|
*/
|
|
|
|
void stopTimer(uint id) { _timers.stop(id); }
|
|
|
|
|
2016-07-23 19:15:26 -04:00
|
|
|
/**
|
|
|
|
* Flags whether the timer will be persisent across save & loads
|
|
|
|
*/
|
2016-10-09 14:59:58 +02:00
|
|
|
void setTimerPersisent(uint id, bool flag) {
|
2016-07-23 19:15:26 -04:00
|
|
|
_timers.setPersisent(id, flag);
|
|
|
|
}
|
2016-04-15 22:30:50 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the true talk manager
|
|
|
|
*/
|
|
|
|
CTrueTalkManager *getTalkManager() { return &_trueTalkManager; }
|
2016-05-02 19:23:29 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the full Id of the current view in a
|
|
|
|
* room.node.view tuplet form
|
|
|
|
*/
|
|
|
|
CString getFullViewName();
|
2016-02-22 20:43:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Titanic
|
|
|
|
|
|
|
|
#endif /* TITANIC_GAME_MANAGER_H */
|