ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

gamescreen.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/ui/world/gamescreen.h"
00024 
00025 #include "engines/stark/services/services.h"
00026 #include "engines/stark/services/userinterface.h"
00027 #include "engines/stark/services/global.h"
00028 
00029 #include "engines/stark/ui/cursor.h"
00030 #include "engines/stark/ui/world/actionmenu.h"
00031 #include "engines/stark/ui/world/dialogpanel.h"
00032 #include "engines/stark/ui/world/gamewindow.h"
00033 #include "engines/stark/ui/world/inventorywindow.h"
00034 #include "engines/stark/ui/world/topmenu.h"
00035 
00036 #include "engines/stark/resources/level.h"
00037 #include "engines/stark/resources/location.h"
00038 
00039 namespace Stark {
00040 
00041 GameScreen::GameScreen(Gfx::Driver *gfx, Cursor *cursor) :
00042         Screen(Screen::kScreenGame),
00043         _gfx(gfx),
00044         _cursor(cursor) {
00045 
00046     _topMenu = new TopMenu(_gfx, _cursor);
00047     _dialogPanel = new DialogPanel(_gfx, _cursor);
00048     _actionMenu = new ActionMenu(_gfx, _cursor);
00049     _inventoryWindow = new InventoryWindow(_gfx, _cursor, _actionMenu);
00050     _actionMenu->setInventory(_inventoryWindow);
00051     _gameWindow = new GameWindow(_gfx, _cursor, _actionMenu, _inventoryWindow);
00052 
00053     _gameScreenWindows.push_back(_actionMenu);
00054     _gameScreenWindows.push_back(_inventoryWindow);
00055     _gameScreenWindows.push_back(_gameWindow);
00056     _gameScreenWindows.push_back(_topMenu);
00057     _gameScreenWindows.push_back(_dialogPanel);
00058 }
00059 
00060 GameScreen::~GameScreen() {
00061     delete _gameWindow;
00062     delete _actionMenu;
00063     delete _topMenu;
00064     delete _dialogPanel;
00065     delete _inventoryWindow;
00066 }
00067 
00068 void GameScreen::open() {
00069     pauseGame(false);
00070     StarkUserInterface->freeGameScreenThumbnail();
00071 }
00072 
00073 void GameScreen::close() {
00074     _cursor->setMouseHint("");
00075     pauseGame(true);
00076     StarkUserInterface->saveGameScreenThumbnail();
00077 }
00078 
00079 void GameScreen::handleGameLoop() {
00080     for (int i = _gameScreenWindows.size() - 1; i >= 0; i--) {
00081         _gameScreenWindows[i]->handleGameLoop();
00082     }
00083 }
00084 
00085 void GameScreen::render() {
00086     for (int i = _gameScreenWindows.size() - 1; i >= 0; i--) {
00087         _gameScreenWindows[i]->render();
00088     }
00089 }
00090 
00091 InventoryWindow *GameScreen::getInventoryWindow() const {
00092     return _inventoryWindow;
00093 }
00094 
00095 void GameScreen::reset() {
00096     _dialogPanel->reset();
00097     _gameWindow->reset();
00098     _inventoryWindow->reset();
00099     _actionMenu->close();
00100 }
00101 
00102 GameWindow *GameScreen::getGameWindow() const {
00103     return _gameWindow;
00104 }
00105 
00106 DialogPanel *GameScreen::getDialogPanel() const {
00107     return _dialogPanel;
00108 }
00109 
00110 void GameScreen::handleMouseMove() {
00111     dispatchEvent(&Window::handleMouseMove);
00112 }
00113 
00114 void GameScreen::handleClick() {
00115     dispatchEvent(&Window::handleClick);
00116 }
00117 
00118 void GameScreen::handleRightClick() {
00119     dispatchEvent(&Window::handleRightClick);
00120 }
00121 
00122 void GameScreen::handleDoubleClick() {
00123     dispatchEvent(&Window::handleDoubleClick);
00124 }
00125 
00126 void GameScreen::dispatchEvent(WindowHandler handler) {
00127     for (uint i = 0; i < _gameScreenWindows.size(); i++) {
00128         if (_gameScreenWindows[i]->isMouseInside()) {
00129             (*_gameScreenWindows[i].*handler)();
00130             return;
00131         }
00132     }
00133 }
00134 
00135 void GameScreen::onScreenChanged() {
00136     _cursor->onScreenChanged();
00137     _dialogPanel->onScreenChanged();
00138     _topMenu->onScreenChanged();
00139     _gameWindow->onScreenChanged();
00140     _actionMenu->onScreenChanged();
00141 }
00142 
00143 void GameScreen::notifyInventoryItemEnabled(uint16 itemIndex) {
00144     _topMenu->notifyInventoryItemEnabled(itemIndex);
00145 }
00146 
00147 void GameScreen::notifyDiaryEntryEnabled() {
00148     _topMenu->notifyDiaryEntryEnabled();
00149 }
00150 
00151 void GameScreen::pauseGame(bool pause) {
00152     if (StarkGlobal->getLevel()) {
00153         StarkGlobal->getLevel()->onEnginePause(pause);
00154     }
00155     if (StarkGlobal->getCurrent()) {
00156         StarkGlobal->getCurrent()->getLevel()->onEnginePause(pause);
00157         StarkGlobal->getCurrent()->getLocation()->onEnginePause(pause);
00158     }
00159 }
00160 
00161 } // End of namespace Stark


Generated on Sat May 18 2019 05:01:03 for ResidualVM by doxygen 1.7.1
curved edge   curved edge