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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "titanic/game_view.h"
|
|
|
|
#include "titanic/game_manager.h"
|
2016-03-12 19:23:00 -05:00
|
|
|
#include "titanic/main_game_window.h"
|
2016-03-16 19:05:16 -04:00
|
|
|
#include "titanic/screen_manager.h"
|
2016-02-22 20:43:14 -05:00
|
|
|
|
|
|
|
namespace Titanic {
|
|
|
|
|
2016-03-16 19:05:16 -04:00
|
|
|
CGameView::CGameView() : _gameManager(nullptr), _surface(nullptr) {
|
2016-02-22 20:43:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameView::setGameManager(CGameManager *gameManager) {
|
|
|
|
_gameManager = gameManager;
|
|
|
|
}
|
|
|
|
|
2016-03-12 19:23:00 -05:00
|
|
|
void CGameView::postLoad() {
|
2016-03-16 19:05:16 -04:00
|
|
|
delete _surface;
|
|
|
|
_surface = nullptr;
|
2016-03-12 19:23:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameView::deleteView(int roomNumber, int nodeNumber, int viewNumber) {
|
|
|
|
CViewItem *view = _gameManager->_project->findView(roomNumber, nodeNumber, viewNumber);
|
|
|
|
if (view)
|
|
|
|
delete view;
|
|
|
|
}
|
|
|
|
|
2016-03-16 07:56:26 -04:00
|
|
|
void CGameView::createSurface(const CResourceKey &key) {
|
2016-03-16 19:05:16 -04:00
|
|
|
// Reset any current view surface
|
|
|
|
_gameManager->initBounds();
|
|
|
|
delete _surface;
|
|
|
|
_surface = nullptr;
|
|
|
|
|
|
|
|
// Create a fresh surface
|
|
|
|
CScreenManager::setCurrent();
|
|
|
|
_surface = CScreenManager::_currentScreenManagerPtr->createSurface(key);
|
2016-03-20 20:47:25 -04:00
|
|
|
_surface->_blitFlag = true;
|
2016-03-16 07:56:26 -04:00
|
|
|
}
|
2016-03-12 19:23:00 -05:00
|
|
|
|
2016-03-21 20:53:49 -04:00
|
|
|
void CGameView::drawView() {
|
2016-03-20 17:29:58 -04:00
|
|
|
CScreenManager::setCurrent();
|
2016-03-21 21:51:29 -04:00
|
|
|
Rect srcRect = _gameManager->_bounds;
|
|
|
|
|
2016-03-21 20:53:49 -04:00
|
|
|
Rect rect2(0, 0, 600, 340);
|
2016-03-20 17:29:58 -04:00
|
|
|
rect2.translate(20, 10);
|
2016-03-21 21:51:29 -04:00
|
|
|
srcRect.combine2(rect2);
|
|
|
|
srcRect.translate(-20, -10);
|
|
|
|
Common::Point destPos(srcRect.left, srcRect.top);
|
2016-03-20 17:29:58 -04:00
|
|
|
|
2016-03-21 21:51:29 -04:00
|
|
|
CScreenManager::_currentScreenManagerPtr->blitFrom(0, _surface,
|
|
|
|
&destPos, &srcRect);
|
2016-03-20 17:29:58 -04:00
|
|
|
}
|
|
|
|
|
2016-02-22 20:43:14 -05:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2016-03-12 19:23:00 -05:00
|
|
|
CSTGameView::CSTGameView(CMainGameWindow *gameWindow) :
|
2016-02-22 20:43:14 -05:00
|
|
|
CGameView(), _gameWindow(gameWindow) {
|
|
|
|
}
|
|
|
|
|
2016-03-13 15:07:27 -04:00
|
|
|
void CSTGameView::setView(CViewItem *view) {
|
|
|
|
_gameWindow->setActiveView(view);
|
2016-03-12 19:23:00 -05:00
|
|
|
}
|
|
|
|
|
2016-03-21 20:53:49 -04:00
|
|
|
void CSTGameView::draw(const Rect &bounds) {
|
2016-03-20 00:01:40 -04:00
|
|
|
_gameWindow->draw();
|
2016-03-12 19:23:00 -05:00
|
|
|
}
|
|
|
|
|
2016-02-22 20:43:14 -05:00
|
|
|
} // End of namespace Titanic
|