2009-06-14 20:11:23 +00: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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-06-14 20:15:43 +00:00
|
|
|
#include "asylum/gamestate.h"
|
2009-06-14 20:11:23 +00:00
|
|
|
|
|
|
|
namespace Asylum {
|
|
|
|
|
|
|
|
GameState::GameState(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
|
|
|
|
_sceneIdx = sceneIdx;
|
2009-06-15 14:04:42 +00:00
|
|
|
_scene = new SceneResource;
|
2009-06-14 21:44:23 +00:00
|
|
|
if (_scene->load(_sceneIdx)) {
|
2009-06-14 20:11:23 +00:00
|
|
|
_text = new Text(_screen);
|
|
|
|
_resPack = new ResourcePack(sceneIdx);
|
2009-06-14 21:49:39 +00:00
|
|
|
|
|
|
|
char musPackFileName[10];
|
|
|
|
sprintf(musPackFileName, "mus.%03d", sceneIdx);
|
|
|
|
_musPack = new ResourcePack(musPackFileName);
|
2009-06-14 20:11:23 +00:00
|
|
|
}
|
2009-06-15 13:06:06 +00:00
|
|
|
|
|
|
|
_cursorResource = new GraphicResource(_resPack, kCursorUpLeftArrow);
|
2009-06-14 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GameState::~GameState() {
|
2009-06-15 13:06:06 +00:00
|
|
|
delete _cursorResource;
|
|
|
|
delete _bgResource;
|
2009-06-15 10:54:32 +00:00
|
|
|
delete _musPack;
|
|
|
|
delete _resPack;
|
|
|
|
delete _text;
|
2009-06-14 20:11:23 +00:00
|
|
|
delete _scene;
|
|
|
|
}
|
|
|
|
|
2009-06-15 12:28:19 +00:00
|
|
|
void GameState::enterScene() {
|
|
|
|
_screen->setPalette(_resPack, _scene->getWorldStats()->_commonRes.palette);
|
|
|
|
|
|
|
|
_bgResource = new GraphicResource(_resPack, _scene->getWorldStats()->_commonRes.backgroundImage);
|
|
|
|
GraphicFrame *bg = _bgResource->getFrame(0);
|
|
|
|
_screen->copyToBackBuffer((byte *)bg->surface.pixels, 0, 0, bg->surface.w, bg->surface.h);
|
2009-06-15 13:06:06 +00:00
|
|
|
|
|
|
|
_cursorStep = 1;
|
|
|
|
_curMouseCursor = 0;
|
|
|
|
_screen->setCursor(_cursorResource, 0);
|
|
|
|
_screen->showCursor();
|
2009-06-15 12:28:19 +00:00
|
|
|
}
|
|
|
|
|
2009-06-14 18:46:29 +00:00
|
|
|
void GameState::handleEvent(Common::Event *event, bool doUpdate) {
|
|
|
|
_ev = event;
|
|
|
|
|
|
|
|
switch (_ev->type) {
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
_mouseX = _ev->mouse.x;
|
|
|
|
_mouseY = _ev->mouse.y;
|
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
_leftClick = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doUpdate || _leftClick)
|
|
|
|
update();
|
2009-06-14 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 13:06:06 +00:00
|
|
|
void GameState::updateCursor() {
|
|
|
|
_curMouseCursor += _cursorStep;
|
|
|
|
if (_curMouseCursor == 0)
|
|
|
|
_cursorStep = 1;
|
|
|
|
if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
|
|
|
|
_cursorStep = -1;
|
|
|
|
|
|
|
|
_screen->setCursor(_cursorResource, _curMouseCursor);
|
|
|
|
}
|
|
|
|
|
2009-06-14 20:11:23 +00:00
|
|
|
void GameState::update() {
|
2009-06-15 13:06:06 +00:00
|
|
|
// TODO
|
|
|
|
//updateCursor();
|
2009-06-14 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end of namespace Asylum
|