From 176f32bfa166a6c842092abdd9cc936b0260f31d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 8 Oct 2005 15:20:11 +0000 Subject: _vm->getSceneHeight() --> _vm->_scene->getHeight() and make it return different scene height for individual panel modes. svn-id: r18959 --- saga/actor.cpp | 33 ++++++++++++++++----------------- saga/events.cpp | 2 +- saga/interface.cpp | 8 ++++---- saga/isomap.cpp | 8 ++++---- saga/saga.h | 7 +++++-- saga/scene.cpp | 20 ++++++++++---------- saga/scene.h | 9 +++++++++ saga/script.cpp | 2 +- saga/sfuncs.cpp | 4 ++-- saga/sprite.cpp | 1 + 10 files changed, 53 insertions(+), 41 deletions(-) (limited to 'saga') diff --git a/saga/actor.cpp b/saga/actor.cpp index bb76f114a0..ecbfe5584d 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -22,27 +22,26 @@ */ #include "saga/saga.h" -#include "saga/gfx.h" +#include "saga/actor.h" #include "saga/animation.h" #include "saga/console.h" +#include "saga/events.h" +#include "saga/gfx.h" +#include "saga/interface.h" +#include "saga/isomap.h" +#include "saga/itedata.h" +#include "saga/objectmap.h" +#include "saga/resnames.h" +#include "saga/rscfile.h" #include "saga/script.h" #include "saga/sndres.h" #include "saga/sprite.h" +#include "saga/stream.h" #include "saga/font.h" #include "saga/sound.h" #include "saga/scene.h" -#include "saga/isomap.h" -#include "saga/actor.h" -#include "saga/itedata.h" -#include "saga/stream.h" -#include "saga/interface.h" -#include "saga/events.h" -#include "saga/objectmap.h" -#include "saga/rscfile.h" -#include "saga/resnames.h" - #include "common/config-manager.h" namespace Saga { @@ -200,7 +199,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { _protagState = 0; _lastTickMsec = 0; - _yCellCount = _vm->getSceneHeight(); + _yCellCount = _vm->_scene->getHeight(); _xCellCount = _vm->getDisplayWidth(); _pathCell = (int8 *)malloc(_yCellCount * _xCellCount * sizeof(*_pathCell)); @@ -208,7 +207,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { _pathRect.left = 0; _pathRect.right = _vm->getDisplayWidth(); _pathRect.top = _vm->getDisplayInfo().pathStartY; - _pathRect.bottom = _vm->getSceneHeight(); + _pathRect.bottom = _vm->_scene->getHeight(); // Get actor resource file context _actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE); @@ -736,7 +735,7 @@ bool Actor::validFollowerLocation(const Location &location) { location.toScreenPointXY(point); if ((point.x < 5) || (point.x >= _vm->getDisplayWidth() - 5) || - (point.y < 0) || (point.y > _vm->getSceneHeight())) { + (point.y < 0) || (point.y > _vm->_scene->getHeight())) { return false; } @@ -1435,7 +1434,7 @@ bool Actor::calcScreenPosition(CommonObjectData *commonObjectData) { _vm->_isoMap->tileCoordsToScreenPoint(commonObjectData->_location, commonObjectData->_screenPosition); commonObjectData->_screenScale = 256; } else { - middle = _vm->getSceneHeight() - commonObjectData->_location.y / ACTOR_LMULT; + middle = _vm->_scene->getHeight() - commonObjectData->_location.y / ACTOR_LMULT; _vm->_scene->getSlopes(beginSlope, endSlope); @@ -1457,7 +1456,7 @@ bool Actor::calcScreenPosition(CommonObjectData *commonObjectData) { result = commonObjectData->_screenPosition.x > -64 && commonObjectData->_screenPosition.x < _vm->getDisplayWidth() + 64 && commonObjectData->_screenPosition.y > -64 && - commonObjectData->_screenPosition.y < _vm->getSceneHeight() + 64; + commonObjectData->_screenPosition.y < _vm->_scene->getHeight() + 64; return result; } @@ -1632,7 +1631,7 @@ void Actor::drawSpeech(void) { calcScreenPosition(actor); textPoint.x = clamp( 10, actor->_screenPosition.x - width / 2, _vm->getDisplayWidth() - 10 - width); - textPoint.y = clamp( 10, actor->_screenPosition.y - 58, _vm->getSceneHeight() - 10 - height); + textPoint.y = clamp( 10, actor->_screenPosition.y - 58, _vm->_scene->getHeight() - 10 - height); _vm->_font->textDraw((_vm->getGameType() == GType_ITE ? kMediumFont : kIHNMMainFont), backBuffer, _activeSpeech.strings[0], textPoint, _activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], _activeSpeech.getFontFlags(i)); diff --git a/saga/events.cpp b/saga/events.cpp index 457051e35a..5af2de814e 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -313,7 +313,7 @@ int Events::handleOneShot(Event *event) { backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border - if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->getSceneHeight()) { + if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); diff --git a/saga/interface.cpp b/saga/interface.cpp index 946d845ade..d5e4355e5e 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -1330,8 +1330,8 @@ void Interface::update(const Point& mousePoint, int updateFlag) { switch (_panelMode) { case kPanelMain: if (updateFlag & UPDATE_MOUSEMOVE) { - bool lastWasPlayfield = _lastMousePoint.y < _vm->getSceneHeight(); - if (mousePoint.y < _vm->getSceneHeight()) { + bool lastWasPlayfield = _lastMousePoint.y < _vm->_scene->getHeight(); + if (mousePoint.y < _vm->_scene->getHeight()) { if (!lastWasPlayfield) { handleMainUpdate(mousePoint); } @@ -1346,7 +1346,7 @@ void Interface::update(const Point& mousePoint, int updateFlag) { } else { if (updateFlag & UPDATE_MOUSECLICK) { - if (mousePoint.y < _vm->getSceneHeight()) { + if (mousePoint.y < _vm->_scene->getHeight()) { _vm->_script->playfieldClick(mousePoint, (updateFlag & UPDATE_LEFTBUTTONCLICK) != 0); } else { handleMainClick(mousePoint); @@ -2280,7 +2280,7 @@ void Interface::mapPanelDrawCrossHair() { _mapPanelCrossHairState = !_mapPanelCrossHairState; Point mapPosition = _vm->_isoMap->getMapPosition(); - Rect screen(_vm->getDisplayWidth(), _vm->getSceneHeight()); + Rect screen(_vm->getDisplayWidth(), _vm->_scene->getHeight()); if (screen.contains(mapPosition)) { _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _vm->_sprite->_mainSprites, diff --git a/saga/isomap.cpp b/saga/isomap.cpp index aa8f6fa282..b3dddb07b2 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -296,7 +296,7 @@ void IsoMap::adjustScroll(bool jump) { playerPoint.y -= 28; playerPoint.x += _viewScroll.x - _vm->getDisplayWidth()/2; - playerPoint.y += _viewScroll.y - _vm->getSceneHeight()/2; + playerPoint.y += _viewScroll.y - _vm->_scene->getHeight()/2; minScrollPos.x = playerPoint.x - SAGA_SCROLL_LIMIT_X1; minScrollPos.y = playerPoint.y - SAGA_SCROLL_LIMIT_Y1; @@ -417,8 +417,8 @@ void IsoMap::drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, c if (_tileClip.top < 0) { _tileClip.top = 0; } - if (_tileClip.bottom > _vm->getSceneHeight()) { - _tileClip.bottom = _vm->getSceneHeight(); + if (_tileClip.bottom > _vm->_scene->getHeight()) { + _tileClip.bottom = _vm->_scene->getHeight(); } _vm->_sprite->drawClip(ds, clip, spritePointer, width, height, spriteBuffer); @@ -457,7 +457,7 @@ void IsoMap::drawTiles(Surface *ds, const Location *location) { metaTileY.y = (view1.y * 16 - fineScroll.y) - (u0 + v0) * 64; workAreaWidth = _vm->getDisplayWidth() + 128; - workAreaHeight = _vm->getSceneHeight() + 128 + 80; + workAreaHeight = _vm->_scene->getHeight() + 128 + 80; for (u1 = u0, v1 = v0; metaTileY.y < workAreaHeight; u1--, v1-- ) { metaTileX = metaTileY; diff --git a/saga/saga.h b/saga/saga.h index 934d7a5bb8..677117dade 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -543,6 +543,8 @@ inline uint16 objectIndexToId(int type, int index) { DetectedGameList GAME_ProbeGame(const FSList &fslist); class SagaEngine : public Engine { + friend class Scene; + void errorString(const char *buf_input, char *buf_output); protected: @@ -655,9 +657,11 @@ public: //current game description int _gameNumber; GameDescription *_gameDescription; - GameDisplayInfo _gameDisplayInfo; Common::Rect _displayClip; +protected: + GameDisplayInfo _gameDisplayInfo; + public: int32 _frameCount; @@ -690,7 +694,6 @@ public: const Common::Rect &getDisplayClip() const { return _displayClip;} int getDisplayWidth() const { return _gameDisplayInfo.logicalWidth; } int getDisplayHeight() const { return _gameDisplayInfo.logicalHeight;} - int getSceneHeight() const { return _gameDisplayInfo.sceneHeight; } const GameDisplayInfo & getDisplayInfo() { return _gameDisplayInfo; } const char *getTextString(int textStringId); diff --git a/saga/scene.cpp b/saga/scene.cpp index ac40c69348..734b59147f 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -455,8 +455,8 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy _vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].title, Common::Rect(0, 7, _vm->getDisplayWidth(), 27), 1, 15, kFontOutline); _vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].message, - Common::Rect(24, _vm->getSceneHeight() - 33, _vm->getDisplayWidth() - 11, - _vm->getSceneHeight()), 1, 15, kFontOutline); + Common::Rect(24, getHeight() - 33, _vm->getDisplayWidth() - 11, + getHeight()), 1, 15, kFontOutline); return; } } @@ -479,8 +479,8 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy } void Scene::getSlopes(int &beginSlope, int &endSlope) { - beginSlope = _vm->getSceneHeight() - _sceneDescription.beginSlope; - endSlope = _vm->getSceneHeight() - _sceneDescription.endSlope; + beginSlope = getHeight() - _sceneDescription.beginSlope; + endSlope = getHeight() - _sceneDescription.endSlope; } void Scene::getBGInfo(BGInfo &bgInfo) { @@ -493,8 +493,8 @@ void Scene::getBGInfo(BGInfo &bgInfo) { bgInfo.bounds.left = (_vm->getDisplayWidth() - _bg.w) / 2; } - if (_bg.h < _vm->getSceneHeight()) { - bgInfo.bounds.top = (_vm->getSceneHeight() - _bg.h) / 2; + if (_bg.h < getHeight()) { + bgInfo.bounds.top = (getHeight() - _bg.h) / 2; } bgInfo.bounds.setWidth(_bg.w); @@ -696,12 +696,12 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { _sceneClip.left = 0; _sceneClip.top = 0; _sceneClip.right = _vm->getDisplayWidth(); - _sceneClip.bottom = _vm->getSceneHeight(); + _sceneClip.bottom = getHeight(); } else { BGInfo backGroundInfo; getBGInfo(backGroundInfo); _sceneClip = backGroundInfo.bounds; - if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < _vm->getSceneHeight())) + if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < getHeight())) _outsetSceneNumber = _sceneNumber; } @@ -1043,7 +1043,7 @@ void Scene::processSceneResources() { // At least in ITE the mask needs to be clipped. _bgMask.w = MIN(_bgMask.w, _vm->getDisplayWidth()); - _bgMask.h = MIN(_bgMask.h, _vm->getSceneHeight()); + _bgMask.h = MIN(_bgMask.h, getHeight()); debug(4, "BACKGROUND MASK width=%d height=%d length=%d", _bgMask.w, _bgMask.h, _bgMask.buf_len); break; @@ -1163,7 +1163,7 @@ void Scene::draw() { } else { backGroundSurface->getRect(rect); if (_sceneClip.bottom < rect.bottom) { - rect.bottom = _vm->getSceneHeight(); + rect.bottom = getHeight(); } backBuffer->blit(rect, (const byte *)backGroundSurface->pixels); } diff --git a/saga/scene.h b/saga/scene.h index def1d1ddd2..8a1ad20d02 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -29,6 +29,7 @@ #include "saga/font.h" #include "saga/list.h" #include "saga/actor.h" +#include "saga/interface.h" namespace Saga { @@ -273,6 +274,14 @@ class Scene { } void drawTextList(Surface *ds); + + int getHeight() const { + if (_vm->_interface->getMode() == kPanelChapterSelection) + return _vm->_gameDisplayInfo.logicalWidth; + else + return _vm->_gameDisplayInfo.sceneHeight; + } + private: void loadScene(LoadSceneParams *loadSceneParams); void loadSceneDescriptor(uint32 resourceId); diff --git a/saga/script.cpp b/saga/script.cpp index 745cb22f0f..c3088d5883 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -624,7 +624,7 @@ void Script::whichObject(const Point& mousePoint) { newRightButtonVerb = kVerbNone; if (_vm->_actor->_protagonist->_currentAction != kActionWalkDir) { - if (_vm->getSceneHeight() >= mousePoint.y) { + if (_vm->_scene->getHeight() >= mousePoint.y) { newObjectId = _vm->_actor->hitTest(mousePoint, true); if (newObjectId != ID_NOTHING) { diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index 286fd20901..d69e67be30 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -1289,7 +1289,7 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) { event.data = backBuffer; event.param = 138; event.param2 = 0; - event.param3 = _vm->getSceneHeight(); + event.param3 = _vm->_scene->getHeight(); event.param4 = 0; event.param5 = _vm->getDisplayWidth(); @@ -1306,7 +1306,7 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) { textEntry.color = kITEColorBrightWhite; textEntry.effectColor = kITEColorBlack; textEntry.point.x = _vm->getDisplayWidth() / 2; - textEntry.point.y = (_vm->getSceneHeight() - _vm->_font->getHeight(kMediumFont)) / 2; + textEntry.point.y = (_vm->_scene->getHeight() - _vm->_font->getHeight(kMediumFont)) / 2; textEntry.fontId = kMediumFont; textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered); textEntry.text = thread->_strings->getString(stringId); diff --git a/saga/sprite.cpp b/saga/sprite.cpp index b4eb44848d..23ca3f6955 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -118,6 +118,7 @@ void Sprite::loadList(int resourceId, SpriteList &spriteList) { spriteInfo->height = readS2.readUint16(); if (spriteInfo->width > 100) { // FIXME: HACK + warning("Width is too big: (%d x %d)", spriteInfo->width, spriteInfo->height); spriteInfo->width = spriteInfo->height = 0; } spriteDataPointer = spritePointer + readS2.pos(); -- cgit v1.2.3