_vm->getSceneHeight() --> _vm->_scene->getHeight() and make it return different

scene height for individual panel modes.

svn-id: r18959
This commit is contained in:
Eugene Sandulenko 2005-10-08 15:20:11 +00:00
parent c4752fc320
commit 176f32bfa1
10 changed files with 53 additions and 41 deletions

View file

@ -22,27 +22,26 @@
*/ */
#include "saga/saga.h" #include "saga/saga.h"
#include "saga/gfx.h"
#include "saga/actor.h"
#include "saga/animation.h" #include "saga/animation.h"
#include "saga/console.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/script.h"
#include "saga/sndres.h" #include "saga/sndres.h"
#include "saga/sprite.h" #include "saga/sprite.h"
#include "saga/stream.h"
#include "saga/font.h" #include "saga/font.h"
#include "saga/sound.h" #include "saga/sound.h"
#include "saga/scene.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" #include "common/config-manager.h"
namespace Saga { namespace Saga {
@ -200,7 +199,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
_protagState = 0; _protagState = 0;
_lastTickMsec = 0; _lastTickMsec = 0;
_yCellCount = _vm->getSceneHeight(); _yCellCount = _vm->_scene->getHeight();
_xCellCount = _vm->getDisplayWidth(); _xCellCount = _vm->getDisplayWidth();
_pathCell = (int8 *)malloc(_yCellCount * _xCellCount * sizeof(*_pathCell)); _pathCell = (int8 *)malloc(_yCellCount * _xCellCount * sizeof(*_pathCell));
@ -208,7 +207,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
_pathRect.left = 0; _pathRect.left = 0;
_pathRect.right = _vm->getDisplayWidth(); _pathRect.right = _vm->getDisplayWidth();
_pathRect.top = _vm->getDisplayInfo().pathStartY; _pathRect.top = _vm->getDisplayInfo().pathStartY;
_pathRect.bottom = _vm->getSceneHeight(); _pathRect.bottom = _vm->_scene->getHeight();
// Get actor resource file context // Get actor resource file context
_actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE); _actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
@ -736,7 +735,7 @@ bool Actor::validFollowerLocation(const Location &location) {
location.toScreenPointXY(point); location.toScreenPointXY(point);
if ((point.x < 5) || (point.x >= _vm->getDisplayWidth() - 5) || 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; return false;
} }
@ -1435,7 +1434,7 @@ bool Actor::calcScreenPosition(CommonObjectData *commonObjectData) {
_vm->_isoMap->tileCoordsToScreenPoint(commonObjectData->_location, commonObjectData->_screenPosition); _vm->_isoMap->tileCoordsToScreenPoint(commonObjectData->_location, commonObjectData->_screenPosition);
commonObjectData->_screenScale = 256; commonObjectData->_screenScale = 256;
} else { } else {
middle = _vm->getSceneHeight() - commonObjectData->_location.y / ACTOR_LMULT; middle = _vm->_scene->getHeight() - commonObjectData->_location.y / ACTOR_LMULT;
_vm->_scene->getSlopes(beginSlope, endSlope); _vm->_scene->getSlopes(beginSlope, endSlope);
@ -1457,7 +1456,7 @@ bool Actor::calcScreenPosition(CommonObjectData *commonObjectData) {
result = commonObjectData->_screenPosition.x > -64 && result = commonObjectData->_screenPosition.x > -64 &&
commonObjectData->_screenPosition.x < _vm->getDisplayWidth() + 64 && commonObjectData->_screenPosition.x < _vm->getDisplayWidth() + 64 &&
commonObjectData->_screenPosition.y > -64 && commonObjectData->_screenPosition.y > -64 &&
commonObjectData->_screenPosition.y < _vm->getSceneHeight() + 64; commonObjectData->_screenPosition.y < _vm->_scene->getHeight() + 64;
return result; return result;
} }
@ -1632,7 +1631,7 @@ void Actor::drawSpeech(void) {
calcScreenPosition(actor); calcScreenPosition(actor);
textPoint.x = clamp( 10, actor->_screenPosition.x - width / 2, _vm->getDisplayWidth() - 10 - width); 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, _vm->_font->textDraw((_vm->getGameType() == GType_ITE ? kMediumFont : kIHNMMainFont), backBuffer, _activeSpeech.strings[0], textPoint,
_activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], _activeSpeech.getFontFlags(i)); _activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], _activeSpeech.getFontFlags(i));

View file

@ -313,7 +313,7 @@ int Events::handleOneShot(Event *event) {
backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer);
// If it is inset scene then draw black border // 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 rect1(2, bgInfo.bounds.height() + 4);
Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect2(bgInfo.bounds.width() + 4, 2);
Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect3(2, bgInfo.bounds.height() + 4);

View file

@ -1330,8 +1330,8 @@ void Interface::update(const Point& mousePoint, int updateFlag) {
switch (_panelMode) { switch (_panelMode) {
case kPanelMain: case kPanelMain:
if (updateFlag & UPDATE_MOUSEMOVE) { if (updateFlag & UPDATE_MOUSEMOVE) {
bool lastWasPlayfield = _lastMousePoint.y < _vm->getSceneHeight(); bool lastWasPlayfield = _lastMousePoint.y < _vm->_scene->getHeight();
if (mousePoint.y < _vm->getSceneHeight()) { if (mousePoint.y < _vm->_scene->getHeight()) {
if (!lastWasPlayfield) { if (!lastWasPlayfield) {
handleMainUpdate(mousePoint); handleMainUpdate(mousePoint);
} }
@ -1346,7 +1346,7 @@ void Interface::update(const Point& mousePoint, int updateFlag) {
} else { } else {
if (updateFlag & UPDATE_MOUSECLICK) { if (updateFlag & UPDATE_MOUSECLICK) {
if (mousePoint.y < _vm->getSceneHeight()) { if (mousePoint.y < _vm->_scene->getHeight()) {
_vm->_script->playfieldClick(mousePoint, (updateFlag & UPDATE_LEFTBUTTONCLICK) != 0); _vm->_script->playfieldClick(mousePoint, (updateFlag & UPDATE_LEFTBUTTONCLICK) != 0);
} else { } else {
handleMainClick(mousePoint); handleMainClick(mousePoint);
@ -2280,7 +2280,7 @@ void Interface::mapPanelDrawCrossHair() {
_mapPanelCrossHairState = !_mapPanelCrossHairState; _mapPanelCrossHairState = !_mapPanelCrossHairState;
Point mapPosition = _vm->_isoMap->getMapPosition(); Point mapPosition = _vm->_isoMap->getMapPosition();
Rect screen(_vm->getDisplayWidth(), _vm->getSceneHeight()); Rect screen(_vm->getDisplayWidth(), _vm->_scene->getHeight());
if (screen.contains(mapPosition)) { if (screen.contains(mapPosition)) {
_vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _vm->_sprite->_mainSprites, _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _vm->_sprite->_mainSprites,

View file

@ -296,7 +296,7 @@ void IsoMap::adjustScroll(bool jump) {
playerPoint.y -= 28; playerPoint.y -= 28;
playerPoint.x += _viewScroll.x - _vm->getDisplayWidth()/2; 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.x = playerPoint.x - SAGA_SCROLL_LIMIT_X1;
minScrollPos.y = playerPoint.y - SAGA_SCROLL_LIMIT_Y1; 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) { if (_tileClip.top < 0) {
_tileClip.top = 0; _tileClip.top = 0;
} }
if (_tileClip.bottom > _vm->getSceneHeight()) { if (_tileClip.bottom > _vm->_scene->getHeight()) {
_tileClip.bottom = _vm->getSceneHeight(); _tileClip.bottom = _vm->_scene->getHeight();
} }
_vm->_sprite->drawClip(ds, clip, spritePointer, width, height, spriteBuffer); _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; metaTileY.y = (view1.y * 16 - fineScroll.y) - (u0 + v0) * 64;
workAreaWidth = _vm->getDisplayWidth() + 128; 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-- ) { for (u1 = u0, v1 = v0; metaTileY.y < workAreaHeight; u1--, v1-- ) {
metaTileX = metaTileY; metaTileX = metaTileY;

View file

@ -543,6 +543,8 @@ inline uint16 objectIndexToId(int type, int index) {
DetectedGameList GAME_ProbeGame(const FSList &fslist); DetectedGameList GAME_ProbeGame(const FSList &fslist);
class SagaEngine : public Engine { class SagaEngine : public Engine {
friend class Scene;
void errorString(const char *buf_input, char *buf_output); void errorString(const char *buf_input, char *buf_output);
protected: protected:
@ -655,9 +657,11 @@ public:
//current game description //current game description
int _gameNumber; int _gameNumber;
GameDescription *_gameDescription; GameDescription *_gameDescription;
GameDisplayInfo _gameDisplayInfo;
Common::Rect _displayClip; Common::Rect _displayClip;
protected:
GameDisplayInfo _gameDisplayInfo;
public: public:
int32 _frameCount; int32 _frameCount;
@ -690,7 +694,6 @@ public:
const Common::Rect &getDisplayClip() const { return _displayClip;} const Common::Rect &getDisplayClip() const { return _displayClip;}
int getDisplayWidth() const { return _gameDisplayInfo.logicalWidth; } int getDisplayWidth() const { return _gameDisplayInfo.logicalWidth; }
int getDisplayHeight() const { return _gameDisplayInfo.logicalHeight;} int getDisplayHeight() const { return _gameDisplayInfo.logicalHeight;}
int getSceneHeight() const { return _gameDisplayInfo.sceneHeight; }
const GameDisplayInfo & getDisplayInfo() { return _gameDisplayInfo; } const GameDisplayInfo & getDisplayInfo() { return _gameDisplayInfo; }
const char *getTextString(int textStringId); const char *getTextString(int textStringId);

View file

@ -455,8 +455,8 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy
_vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].title, _vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].title,
Common::Rect(0, 7, _vm->getDisplayWidth(), 27), 1, 15, kFontOutline); Common::Rect(0, 7, _vm->getDisplayWidth(), 27), 1, 15, kFontOutline);
_vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].message, _vm->_font->textDrawRect(kMediumFont, backBuffer, sceneSubstitutes[i].message,
Common::Rect(24, _vm->getSceneHeight() - 33, _vm->getDisplayWidth() - 11, Common::Rect(24, getHeight() - 33, _vm->getDisplayWidth() - 11,
_vm->getSceneHeight()), 1, 15, kFontOutline); getHeight()), 1, 15, kFontOutline);
return; return;
} }
} }
@ -479,8 +479,8 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy
} }
void Scene::getSlopes(int &beginSlope, int &endSlope) { void Scene::getSlopes(int &beginSlope, int &endSlope) {
beginSlope = _vm->getSceneHeight() - _sceneDescription.beginSlope; beginSlope = getHeight() - _sceneDescription.beginSlope;
endSlope = _vm->getSceneHeight() - _sceneDescription.endSlope; endSlope = getHeight() - _sceneDescription.endSlope;
} }
void Scene::getBGInfo(BGInfo &bgInfo) { void Scene::getBGInfo(BGInfo &bgInfo) {
@ -493,8 +493,8 @@ void Scene::getBGInfo(BGInfo &bgInfo) {
bgInfo.bounds.left = (_vm->getDisplayWidth() - _bg.w) / 2; bgInfo.bounds.left = (_vm->getDisplayWidth() - _bg.w) / 2;
} }
if (_bg.h < _vm->getSceneHeight()) { if (_bg.h < getHeight()) {
bgInfo.bounds.top = (_vm->getSceneHeight() - _bg.h) / 2; bgInfo.bounds.top = (getHeight() - _bg.h) / 2;
} }
bgInfo.bounds.setWidth(_bg.w); bgInfo.bounds.setWidth(_bg.w);
@ -696,12 +696,12 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
_sceneClip.left = 0; _sceneClip.left = 0;
_sceneClip.top = 0; _sceneClip.top = 0;
_sceneClip.right = _vm->getDisplayWidth(); _sceneClip.right = _vm->getDisplayWidth();
_sceneClip.bottom = _vm->getSceneHeight(); _sceneClip.bottom = getHeight();
} else { } else {
BGInfo backGroundInfo; BGInfo backGroundInfo;
getBGInfo(backGroundInfo); getBGInfo(backGroundInfo);
_sceneClip = backGroundInfo.bounds; _sceneClip = backGroundInfo.bounds;
if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < _vm->getSceneHeight())) if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < getHeight()))
_outsetSceneNumber = _sceneNumber; _outsetSceneNumber = _sceneNumber;
} }
@ -1043,7 +1043,7 @@ void Scene::processSceneResources() {
// At least in ITE the mask needs to be clipped. // At least in ITE the mask needs to be clipped.
_bgMask.w = MIN(_bgMask.w, _vm->getDisplayWidth()); _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); debug(4, "BACKGROUND MASK width=%d height=%d length=%d", _bgMask.w, _bgMask.h, _bgMask.buf_len);
break; break;
@ -1163,7 +1163,7 @@ void Scene::draw() {
} else { } else {
backGroundSurface->getRect(rect); backGroundSurface->getRect(rect);
if (_sceneClip.bottom < rect.bottom) { if (_sceneClip.bottom < rect.bottom) {
rect.bottom = _vm->getSceneHeight(); rect.bottom = getHeight();
} }
backBuffer->blit(rect, (const byte *)backGroundSurface->pixels); backBuffer->blit(rect, (const byte *)backGroundSurface->pixels);
} }

View file

@ -29,6 +29,7 @@
#include "saga/font.h" #include "saga/font.h"
#include "saga/list.h" #include "saga/list.h"
#include "saga/actor.h" #include "saga/actor.h"
#include "saga/interface.h"
namespace Saga { namespace Saga {
@ -273,6 +274,14 @@ class Scene {
} }
void drawTextList(Surface *ds); void drawTextList(Surface *ds);
int getHeight() const {
if (_vm->_interface->getMode() == kPanelChapterSelection)
return _vm->_gameDisplayInfo.logicalWidth;
else
return _vm->_gameDisplayInfo.sceneHeight;
}
private: private:
void loadScene(LoadSceneParams *loadSceneParams); void loadScene(LoadSceneParams *loadSceneParams);
void loadSceneDescriptor(uint32 resourceId); void loadSceneDescriptor(uint32 resourceId);

View file

@ -624,7 +624,7 @@ void Script::whichObject(const Point& mousePoint) {
newRightButtonVerb = kVerbNone; newRightButtonVerb = kVerbNone;
if (_vm->_actor->_protagonist->_currentAction != kActionWalkDir) { if (_vm->_actor->_protagonist->_currentAction != kActionWalkDir) {
if (_vm->getSceneHeight() >= mousePoint.y) { if (_vm->_scene->getHeight() >= mousePoint.y) {
newObjectId = _vm->_actor->hitTest(mousePoint, true); newObjectId = _vm->_actor->hitTest(mousePoint, true);
if (newObjectId != ID_NOTHING) { if (newObjectId != ID_NOTHING) {

View file

@ -1289,7 +1289,7 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
event.data = backBuffer; event.data = backBuffer;
event.param = 138; event.param = 138;
event.param2 = 0; event.param2 = 0;
event.param3 = _vm->getSceneHeight(); event.param3 = _vm->_scene->getHeight();
event.param4 = 0; event.param4 = 0;
event.param5 = _vm->getDisplayWidth(); event.param5 = _vm->getDisplayWidth();
@ -1306,7 +1306,7 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
textEntry.color = kITEColorBrightWhite; textEntry.color = kITEColorBrightWhite;
textEntry.effectColor = kITEColorBlack; textEntry.effectColor = kITEColorBlack;
textEntry.point.x = _vm->getDisplayWidth() / 2; 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.fontId = kMediumFont;
textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered); textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered);
textEntry.text = thread->_strings->getString(stringId); textEntry.text = thread->_strings->getString(stringId);

View file

@ -118,6 +118,7 @@ void Sprite::loadList(int resourceId, SpriteList &spriteList) {
spriteInfo->height = readS2.readUint16(); spriteInfo->height = readS2.readUint16();
if (spriteInfo->width > 100) { // FIXME: HACK if (spriteInfo->width > 100) { // FIXME: HACK
warning("Width is too big: (%d x %d)", spriteInfo->width, spriteInfo->height);
spriteInfo->width = spriteInfo->height = 0; spriteInfo->width = spriteInfo->height = 0;
} }
spriteDataPointer = spritePointer + readS2.pos(); spriteDataPointer = spritePointer + readS2.pos();