diff options
Diffstat (limited to 'engines/wintermute')
124 files changed, 2591 insertions, 2137 deletions
diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 94df17c543..33ad39b411 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -119,7 +119,7 @@ AdActor::~AdActor() { ////////////////////////////////////////////////////////////////////////// bool AdActor::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -179,7 +179,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdActor::loadBuffer(byte *buffer, bool complete) { +bool AdActor::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -219,12 +219,12 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ACTOR) { _gameRef->LOG(0, "'ACTOR' keyword expected."); return STATUS_FAILED; } @@ -234,55 +234,55 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { AdGame *adGame = (AdGame *)_gameRef; AdSpriteSet *spr = nullptr; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_FONT: - setFont((char *)params); + setFont(params); break; case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); + parser.scanStr(params, "%b", &_zoomable); break; case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); + parser.scanStr(params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); + parser.scanStr(params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); + parser.scanStr(params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); + parser.scanStr(params, "%b", &_active); break; case TOKEN_WALK: @@ -348,7 +348,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_CURSOR: @@ -362,12 +362,12 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); + parser.scanStr(params, "%d", &_sFXVolume); break; case TOKEN_SCALE: { int s; - parser.scanStr((char *)params, "%d", &s); + parser.scanStr(params, "%d", &s); _scale = (float)s; } @@ -375,14 +375,14 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_RELATIVE_SCALE: { int s; - parser.scanStr((char *)params, "%d", &s); + parser.scanStr(params, "%d", &s); _relativeScale = (float)s; } break; case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); + parser.scanStr(params, "%b", &_autoSoundPanning); break; case TOKEN_PROPERTY: @@ -432,15 +432,15 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); + parser.scanStr(params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: @@ -1319,29 +1319,29 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { bool AdActor::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_dir)); + persistMgr->transferSint32(TMEMBER_INT(_dir)); persistMgr->transferPtr(TMEMBER_PTR(_path)); - persistMgr->transfer(TMEMBER(_pFCount)); - persistMgr->transfer(TMEMBER(_pFStepX)); - persistMgr->transfer(TMEMBER(_pFStepY)); - persistMgr->transfer(TMEMBER(_pFX)); - persistMgr->transfer(TMEMBER(_pFY)); + persistMgr->transferSint32(TMEMBER(_pFCount)); + persistMgr->transferDouble(TMEMBER(_pFStepX)); + persistMgr->transferDouble(TMEMBER(_pFStepY)); + persistMgr->transferDouble(TMEMBER(_pFX)); + persistMgr->transferDouble(TMEMBER(_pFY)); persistMgr->transferPtr(TMEMBER_PTR(_standSprite)); _talkSprites.persist(persistMgr); _talkSpritesEx.persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_targetDir)); - persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); + persistMgr->transferSint32(TMEMBER_INT(_targetDir)); + persistMgr->transferSint32(TMEMBER_INT(_afterWalkDir)); persistMgr->transferPtr(TMEMBER_PTR(_targetPoint)); persistMgr->transferPtr(TMEMBER_PTR(_turnLeftSprite)); persistMgr->transferPtr(TMEMBER_PTR(_turnRightSprite)); persistMgr->transferPtr(TMEMBER_PTR(_walkSprite)); persistMgr->transferPtr(TMEMBER_PTR(_animSprite2)); - persistMgr->transfer(TMEMBER(_talkAnimName)); - persistMgr->transfer(TMEMBER(_idleAnimName)); - persistMgr->transfer(TMEMBER(_walkAnimName)); - persistMgr->transfer(TMEMBER(_turnLeftAnimName)); - persistMgr->transfer(TMEMBER(_turnRightAnimName)); + persistMgr->transferString(TMEMBER(_talkAnimName)); + persistMgr->transferString(TMEMBER(_idleAnimName)); + persistMgr->transferString(TMEMBER(_walkAnimName)); + persistMgr->transferString(TMEMBER(_turnLeftAnimName)); + persistMgr->transferString(TMEMBER(_turnRightAnimName)); _anims.persist(persistMgr); @@ -1376,7 +1376,7 @@ TDirection AdActor::angleToDirection(int angle) { ////////////////////////////////////////////////////////////////////////// -int AdActor::getHeight() { +int32 AdActor::getHeight() { // if no current sprite is set, set some if (_currentSprite == nullptr) { if (_standSprite) { @@ -1410,20 +1410,20 @@ bool AdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_END - byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); + char *fileBuffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); if (fileBuffer == nullptr) { _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); return STATUS_FAILED; } - byte *buffer = fileBuffer; - byte *params; + char *buffer = fileBuffer; + char *params; int cmd; BaseParser parser; bool ret = STATUS_OK; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { AdSpriteSet *anim = new AdSpriteSet(_gameRef, this); diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 582b41b8b0..3225eb44ec 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -47,7 +47,7 @@ class AdActor : public AdTalkHolder { public: TDirection angleToDirection(int angle); DECLARE_PERSISTENT(AdActor, AdTalkHolder) - virtual int getHeight(); + virtual int32 getHeight() override; BaseSprite *getTalkStance(const char *stance); virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); BasePoint *_targetPoint; @@ -57,7 +57,7 @@ public: AdActor(BaseGame *inGame/*=nullptr*/); virtual ~AdActor(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); private: diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 388accf34f..098da49750 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -100,7 +100,7 @@ const char *AdEntity::getItemName() const { ////////////////////////////////////////////////////////////////////////// bool AdEntity::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -166,7 +166,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdEntity::loadBuffer(byte *buffer, bool complete) { +bool AdEntity::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -212,12 +212,12 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(SAVE_STATE) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ENTITY) { _gameRef->LOG(0, "'ENTITY' keyword expected."); return STATUS_FAILED; } @@ -227,27 +227,27 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { AdGame *adGame = (AdGame *)_gameRef; BaseSprite *spr = nullptr; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_SPRITE: { delete _sprite; _sprite = nullptr; spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params))) { + if (!spr || DID_FAIL(spr->loadFile(params))) { cmd = PARSERR_GENERIC; } else { _sprite = spr; @@ -257,7 +257,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: { spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { + if (!spr || DID_FAIL(spr->loadFile(params, adGame->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSprites.add(spr); @@ -267,7 +267,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK_SPECIAL: { spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { + if (!spr || DID_FAIL(spr->loadFile(params, adGame->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSpritesEx.add(spr); @@ -276,28 +276,28 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_ITEM: - setItem((char *)params); + setItem(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_FONT: - setFont((char *)params); + setFont(params); break; case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); + parser.scanStr(params, "%b", &_zoomable); break; case TOKEN_SCALE: { int s; - parser.scanStr((char *)params, "%d", &s); + parser.scanStr(params, "%d", &s); _scale = (float)s; } @@ -305,7 +305,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_RELATIVE_SCALE: { int s; - parser.scanStr((char *)params, "%d", &s); + parser.scanStr(params, "%d", &s); _relativeScale = (float)s; } @@ -313,27 +313,27 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); + parser.scanStr(params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); + parser.scanStr(params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); + parser.scanStr(params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); + parser.scanStr(params, "%b", &_active); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -341,7 +341,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); + parser.scanStr(params, "%b", &_editorSelected); break; case TOKEN_REGION: { @@ -402,11 +402,11 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_SUBTYPE: { - if (scumm_stricmp((char *)params, "sound") == 0) { + if (scumm_stricmp(params, "sound") == 0) { delete _sprite; _sprite = nullptr; if (_gameRef->_editorMode) { @@ -430,23 +430,23 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SOUND: - playSFX((char *)params, false, false); + playSFX(params, false, false); break; case TOKEN_SOUND_START_TIME: - parser.scanStr((char *)params, "%d", &_sFXStart); + parser.scanStr(params, "%d", &_sFXStart); break; case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); + parser.scanStr(params, "%d", &_sFXVolume); break; case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); + parser.scanStr(params, "%b", &_autoSoundPanning); break; case TOKEN_SAVE_STATE: - parser.scanStr((char *)params, "%b", &_saveState); + parser.scanStr(params, "%b", &_saveState); break; case TOKEN_PROPERTY: @@ -454,15 +454,15 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); + parser.scanStr(params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: @@ -470,16 +470,16 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WALK_TO_X: - parser.scanStr((char *)params, "%d", &_walkToX); + parser.scanStr(params, "%d", &_walkToX); break; case TOKEN_WALK_TO_Y: - parser.scanStr((char *)params, "%d", &_walkToY); + parser.scanStr(params, "%d", &_walkToY); break; case TOKEN_WALK_TO_DIR: { int i; - parser.scanStr((char *)params, "%d", &i); + parser.scanStr(params, "%d", &i); if (i < 0) { i = 0; } @@ -1067,7 +1067,7 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -int AdEntity::getHeight() { +int32 AdEntity::getHeight() { if (_region && !_sprite) { return _region->_rect.bottom - _region->_rect.top; } else { @@ -1092,16 +1092,16 @@ void AdEntity::updatePosition() { bool AdEntity::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); - persistMgr->transfer(TMEMBER(_item)); + persistMgr->transferCharPtr(TMEMBER(_item)); persistMgr->transferPtr(TMEMBER_PTR(_region)); //persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER_INT(_subtype)); + persistMgr->transferSint32(TMEMBER_INT(_subtype)); _talkSprites.persist(persistMgr); _talkSpritesEx.persist(persistMgr); - persistMgr->transfer(TMEMBER(_walkToX)); - persistMgr->transfer(TMEMBER(_walkToY)); - persistMgr->transfer(TMEMBER_INT(_walkToDir)); + persistMgr->transferSint32(TMEMBER(_walkToX)); + persistMgr->transferSint32(TMEMBER(_walkToY)); + persistMgr->transferSint32(TMEMBER_INT(_walkToDir)); persistMgr->transferPtr(TMEMBER_PTR(_theora)); diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h index bdbd271667..c3ed5622e5 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -40,7 +40,7 @@ public: void setItem(const char *itemName); DECLARE_PERSISTENT(AdEntity, AdTalkHolder) void updatePosition(); - virtual int getHeight(); + virtual int32 getHeight() override; BaseRegion *_region; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; virtual bool update(); @@ -48,7 +48,7 @@ public: AdEntity(BaseGame *inGame); virtual ~AdEntity(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); int32 getWalkToX() const; int32 getWalkToY() const; diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index d5799e851b..904b8a541c 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -1245,7 +1245,7 @@ bool AdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// bool AdGame::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -1281,7 +1281,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdGame::loadBuffer(byte *buffer, bool complete) { +bool AdGame::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1295,14 +1295,14 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(DEBUG_STARTUP_SCENE) TOKEN_TABLE_END - byte *params; - byte *params2; + char *params; + char *params2; int cmd = 1; BaseParser parser; bool itemFound = false, itemsFound = false; - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: if (DID_FAIL(BaseGame::loadBuffer(params, false))) { @@ -1311,12 +1311,12 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AD_GAME: - while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(¶ms, commands, ¶ms2)) > 0) { switch (cmd) { case TOKEN_RESPONSE_BOX: delete _responseBox; _responseBox = new AdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) { + if (_responseBox && !DID_FAIL(_responseBox->loadFile(params2))) { registerObject(_responseBox); } else { delete _responseBox; @@ -1328,7 +1328,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; _inventoryBox = new AdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) { + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(params2))) { registerObject(_inventoryBox); } else { delete _inventoryBox; @@ -1339,7 +1339,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ITEMS: itemsFound = true; - BaseUtils::setString(&_itemsFile, (char *)params2); + BaseUtils::setString(&_itemsFile, params2); if (DID_FAIL(loadItemsFile(_itemsFile))) { delete[] _itemsFile; _itemsFile = nullptr; @@ -1348,9 +1348,9 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) { + if (scumm_stricmp(params2, "right") == 0) { _talkSkipButton = TALK_SKIP_RIGHT; - } else if (scumm_stricmp((char *)params2, "both") == 0) { + } else if (scumm_stricmp(params2, "both") == 0) { _talkSkipButton = TALK_SKIP_BOTH; } else { _talkSkipButton = TALK_SKIP_LEFT; @@ -1359,7 +1359,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCENE_VIEWPORT: { Rect32 rc; - parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + parser.scanStr(params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) { _sceneViewport = new BaseViewport(_gameRef); } @@ -1374,11 +1374,11 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_STARTUP_SCENE: - BaseUtils::setString(&_startupScene, (char *)params2); + BaseUtils::setString(&_startupScene, params2); break; case TOKEN_DEBUG_STARTUP_SCENE: - BaseUtils::setString(&_debugStartupScene, (char *)params2); + BaseUtils::setString(&_debugStartupScene, params2); break; } } @@ -1417,41 +1417,41 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { _objects.persist(persistMgr); - persistMgr->transfer(TMEMBER(_prevSceneName)); - persistMgr->transfer(TMEMBER(_prevSceneFilename)); + persistMgr->transferCharPtr(TMEMBER(_prevSceneName)); + persistMgr->transferCharPtr(TMEMBER(_prevSceneFilename)); persistMgr->transferPtr(TMEMBER_PTR(_responseBox)); _responsesBranch.persist(persistMgr); _responsesGame.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_scene)); _sceneStates.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scheduledFadeIn)); - persistMgr->transfer(TMEMBER(_scheduledScene)); + persistMgr->transferBool(TMEMBER(_scheduledFadeIn)); + persistMgr->transferCharPtr(TMEMBER(_scheduledScene)); persistMgr->transferPtr(TMEMBER_PTR(_selectedItem)); - persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); + persistMgr->transferSint32(TMEMBER_INT(_talkSkipButton)); _sentences.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_sceneViewport)); - persistMgr->transfer(TMEMBER_INT(_stateEx)); - persistMgr->transfer(TMEMBER(_initialScene)); - persistMgr->transfer(TMEMBER(_debugStartupScene)); + persistMgr->transferSint32(TMEMBER_INT(_stateEx)); + persistMgr->transferBool(TMEMBER(_initialScene)); + persistMgr->transferCharPtr(TMEMBER(_debugStartupScene)); persistMgr->transferPtr(TMEMBER_PTR(_invObject)); persistMgr->transferPtr(TMEMBER_PTR(_inventoryOwner)); - persistMgr->transfer(TMEMBER(_tempDisableSaveState)); + persistMgr->transferBool(TMEMBER(_tempDisableSaveState)); _items.persist(persistMgr); - persistMgr->transfer(TMEMBER(_itemsFile)); + persistMgr->transferCharPtr(TMEMBER(_itemsFile)); _speechDirs.persist(persistMgr); - persistMgr->transfer(TMEMBER(_smartItemCursor)); + persistMgr->transferBool(TMEMBER(_smartItemCursor)); if (!persistMgr->getIsSaving()) { _initialScene = false; } - persistMgr->transfer(TMEMBER(_startupScene)); + persistMgr->transferCharPtr(TMEMBER(_startupScene)); return STATUS_OK; @@ -1518,7 +1518,7 @@ bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex ////////////////////////////////////////////////////////////////////////// bool AdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; @@ -1541,12 +1541,12 @@ bool AdGame::loadItemsFile(const char *filename, bool merge) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { +bool AdGame::loadItemsBuffer(char *buffer, bool merge) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; @@ -1556,7 +1556,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { } } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_ITEM: { AdItem *item = new AdItem(_gameRef); @@ -1637,7 +1637,7 @@ bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { switch (cmd) { case TOKEN_ENTITY_CONTAINER: { UIEntity *ent = new UIEntity(_gameRef); - if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { + if (!ent || DID_FAIL(ent->loadBuffer(*params, false))) { delete ent; ent = nullptr; cmd = PARSERR_GENERIC; @@ -2160,7 +2160,6 @@ bool AdGame::onMouseLeftDown() { _gameRef->_capturedObject = _gameRef->_activeObject; } _mouseLeftDown = true; - BasePlatform::setCapture(/*_renderer->_window*/); return STATUS_OK; } @@ -2171,7 +2170,6 @@ bool AdGame::onMouseLeftUp() { _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); } - BasePlatform::releaseCapture(); _capturedObject = nullptr; _mouseLeftDown = false; diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index cb5147501d..019f2e6478 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -120,10 +120,10 @@ public: BaseArray<AdObject *> _objects; virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); + virtual bool loadBuffer(char *buffer, bool complete = true); bool loadItemsFile(const char *filename, bool merge = false); - bool loadItemsBuffer(byte *buffer, bool merge = false); + bool loadItemsBuffer(char *buffer, bool merge = false); // scripting interface virtual ScValue *scGetProperty(const Common::String &name) override; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 544d8310d0..f9352c77c6 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -128,7 +128,7 @@ bool AdInventory::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); _takenItems.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transferSint32(TMEMBER(_scrollOffset)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index d703de1714..5d7f053bb5 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -120,8 +120,8 @@ bool AdInventoryBox::display() { if (_closeButton) { _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = _gameRef->_renderer->getWidth(); - _closeButton->_height = _gameRef->_renderer->getHeight(); + _closeButton->setWidth(_gameRef->_renderer->getWidth()); + _closeButton->setHeight(_gameRef->_renderer->getHeight()); _closeButton->display(); } @@ -165,7 +165,7 @@ bool AdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// bool AdInventoryBox::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -203,7 +203,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { +bool AdInventoryBox::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -221,34 +221,34 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; bool alwaysVisible = false; _exclusive = false; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_INVENTORY_BOX) { _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_WINDOW: @@ -264,35 +264,35 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); break; case TOKEN_EXCLUSIVE: - parser.scanStr((char *)params, "%b", &_exclusive); + parser.scanStr(params, "%b", &_exclusive); break; case TOKEN_HIDE_SELECTED: - parser.scanStr((char *)params, "%b", &_hideSelected); + parser.scanStr(params, "%b", &_hideSelected); break; case TOKEN_ALWAYS_VISIBLE: - parser.scanStr((char *)params, "%b", &alwaysVisible); + parser.scanStr(params, "%b", &alwaysVisible); break; case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); + parser.scanStr(params, "%d", &_spacing); break; case TOKEN_ITEM_WIDTH: - parser.scanStr((char *)params, "%d", &_itemWidth); + parser.scanStr(params, "%d", &_itemWidth); break; case TOKEN_ITEM_HEIGHT: - parser.scanStr((char *)params, "%d", &_itemHeight); + parser.scanStr(params, "%d", &_itemHeight); break; case TOKEN_SCROLL_BY: - parser.scanStr((char *)params, "%d", &_scrollBy); + parser.scanStr(params, "%d", &_scrollBy); break; case TOKEN_EDITOR_PROPERTY: @@ -323,7 +323,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { if (_window) { for (uint32 i = 0; i < _window->_widgets.size(); i++) { - if (!_window->_widgets[i]->_listenerObject) { + if (!_window->_widgets[i]->getListener()) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } } @@ -372,16 +372,16 @@ bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_closeButton)); - persistMgr->transfer(TMEMBER(_hideSelected)); - persistMgr->transfer(TMEMBER(_itemHeight)); - persistMgr->transfer(TMEMBER(_itemsArea)); - persistMgr->transfer(TMEMBER(_itemWidth)); - persistMgr->transfer(TMEMBER(_scrollBy)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transferBool(TMEMBER(_hideSelected)); + persistMgr->transferSint32(TMEMBER(_itemHeight)); + persistMgr->transferRect32(TMEMBER(_itemsArea)); + persistMgr->transferSint32(TMEMBER(_itemWidth)); + persistMgr->transferSint32(TMEMBER(_scrollBy)); + persistMgr->transferSint32(TMEMBER(_scrollOffset)); + persistMgr->transferSint32(TMEMBER(_spacing)); + persistMgr->transferBool(TMEMBER(_visible)); persistMgr->transferPtr(TMEMBER_PTR(_window)); - persistMgr->transfer(TMEMBER(_exclusive)); + persistMgr->transferBool(TMEMBER(_exclusive)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h index f65bd8d8f0..4d576625b2 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -51,7 +51,7 @@ public: AdInventoryBox(BaseGame *inGame); virtual ~AdInventoryBox(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; private: bool _exclusive; diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 7d05461169..1f19a3eeae 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -84,7 +84,7 @@ AdItem::~AdItem() { ////////////////////////////////////////////////////////////////////////// bool AdItem::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdItem::loadBuffer(byte *buffer, bool complete) { +bool AdItem::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -164,12 +164,12 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(AMOUNT) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ITEM) { _gameRef->LOG(0, "'ITEM' keyword expected."); return STATUS_FAILED; } @@ -177,31 +177,31 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { } int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_FONT: - setFont((char *)params); + setFont(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_IMAGE: case TOKEN_SPRITE: delete _sprite; _sprite = new BaseSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + if (!_sprite || DID_FAIL(_sprite->loadFile(params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _sprite; cmd = PARSERR_GENERIC; } @@ -211,32 +211,32 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE_HOVER: delete _spriteHover; _spriteHover = new BaseSprite(_gameRef, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile(params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _spriteHover; cmd = PARSERR_GENERIC; } break; case TOKEN_AMOUNT: - parser.scanStr((char *)params, "%d", &_amount); + parser.scanStr(params, "%d", &_amount); break; case TOKEN_DISPLAY_AMOUNT: - parser.scanStr((char *)params, "%b", &_displayAmount); + parser.scanStr(params, "%b", &_displayAmount); break; case TOKEN_AMOUNT_OFFSET_X: - parser.scanStr((char *)params, "%d", &_amountOffsetX); + parser.scanStr(params, "%d", &_amountOffsetX); break; case TOKEN_AMOUNT_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_amountOffsetY); + parser.scanStr(params, "%d", &_amountOffsetY); break; case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) { + if (scumm_stricmp(params, "left") == 0) { _amountAlign = TAL_LEFT; - } else if (scumm_stricmp((char *)params, "right") == 0) { + } else if (scumm_stricmp(params, "right") == 0) { _amountAlign = TAL_RIGHT; } else { _amountAlign = TAL_CENTER; @@ -244,12 +244,12 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AMOUNT_STRING: - BaseUtils::setString(&_amountString, (char *)params); + BaseUtils::setString(&_amountString, params); break; case TOKEN_TALK: { BaseSprite *spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { + if (!spr || DID_FAIL(spr->loadFile(params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSprites.add(spr); @@ -259,7 +259,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK_SPECIAL: { BaseSprite *spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { + if (!spr || DID_FAIL(spr->loadFile(params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSpritesEx.add(spr); @@ -270,7 +270,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursorNormal; _cursorNormal = new BaseSprite(_gameRef); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile(params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorNormal; _cursorNormal = nullptr; cmd = PARSERR_GENERIC; @@ -280,7 +280,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR_HOVER: delete _cursorHover; _cursorHover = new BaseSprite(_gameRef); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile(params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorHover; _cursorHover = nullptr; cmd = PARSERR_GENERIC; @@ -288,11 +288,11 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_CURSOR_COMBINED: - parser.scanStr((char *)params, "%b", &_cursorCombined); + parser.scanStr(params, "%b", &_cursorCombined); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PROPERTY: @@ -300,11 +300,11 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: @@ -783,17 +783,17 @@ bool AdItem::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); - persistMgr->transfer(TMEMBER(_cursorCombined)); + persistMgr->transferBool(TMEMBER(_cursorCombined)); persistMgr->transferPtr(TMEMBER_PTR(_cursorHover)); persistMgr->transferPtr(TMEMBER_PTR(_cursorNormal)); persistMgr->transferPtr(TMEMBER_PTR(_spriteHover)); - persistMgr->transfer(TMEMBER(_inInventory)); - persistMgr->transfer(TMEMBER(_displayAmount)); - persistMgr->transfer(TMEMBER(_amount)); - persistMgr->transfer(TMEMBER(_amountOffsetX)); - persistMgr->transfer(TMEMBER(_amountOffsetY)); - persistMgr->transfer(TMEMBER_INT(_amountAlign)); - persistMgr->transfer(TMEMBER(_amountString)); + persistMgr->transferBool(TMEMBER(_inInventory)); + persistMgr->transferBool(TMEMBER(_displayAmount)); + persistMgr->transferSint32(TMEMBER(_amount)); + persistMgr->transferSint32(TMEMBER(_amountOffsetX)); + persistMgr->transferSint32(TMEMBER(_amountOffsetY)); + persistMgr->transferSint32(TMEMBER_INT(_amountAlign)); + persistMgr->transferCharPtr(TMEMBER(_amountString)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index dd7039db43..935ea5d73d 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -35,6 +35,8 @@ namespace Wintermute { class AdItem : public AdTalkHolder { + using Wintermute::AdObject::display; + public: bool update(); DECLARE_PERSISTENT(AdItem, AdTalkHolder) @@ -48,7 +50,7 @@ public: AdItem(BaseGame *inGame); virtual ~AdItem(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); // scripting interface virtual ScValue *scGetProperty(const Common::String &name) override; diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index c833b59163..17dd83a8b7 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -62,7 +62,7 @@ AdLayer::~AdLayer() { ////////////////////////////////////////////////////////////////////////// bool AdLayer::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -100,7 +100,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdLayer::loadBuffer(byte *buffer, bool complete) { +bool AdLayer::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -119,52 +119,52 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_LAYER) { _gameRef->LOG(0, "'LAYER' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_MAIN: - parser.scanStr((char *)params, "%b", &_main); + parser.scanStr(params, "%b", &_main); break; case TOKEN_CLOSE_UP: - parser.scanStr((char *)params, "%b", &_closeUp); + parser.scanStr(params, "%b", &_closeUp); break; case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); + parser.scanStr(params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); + parser.scanStr(params, "%d", &_height); break; case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); + parser.scanStr(params, "%b", &_active); break; case TOKEN_REGION: { @@ -203,11 +203,11 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); + parser.scanStr(params, "%b", &_editorSelected); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PROPERTY: @@ -551,12 +551,12 @@ bool AdLayer::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_closeUp)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_main)); + persistMgr->transferBool(TMEMBER(_active)); + persistMgr->transferBool(TMEMBER(_closeUp)); + persistMgr->transferSint32(TMEMBER(_height)); + persistMgr->transferBool(TMEMBER(_main)); _nodes.persist(persistMgr); - persistMgr->transfer(TMEMBER(_width)); + persistMgr->transferSint32(TMEMBER(_width)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index b260b919fd..af7c3a364c 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -43,7 +43,7 @@ public: virtual ~AdLayer(); BaseArray<AdSceneNode *> _nodes; bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; // scripting interface diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 876c5a8bb4..dd07f23762 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -95,13 +95,13 @@ void AdNodeState::setCursor(const char *filename) { bool AdNodeState::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transferBool(TMEMBER(_active)); + persistMgr->transferCharPtr(TMEMBER(_name)); + persistMgr->transferCharPtr(TMEMBER(_filename)); + persistMgr->transferCharPtr(TMEMBER(_cursor)); + persistMgr->transferUint32(TMEMBER(_alphaColor)); for (int i = 0; i < 7; i++) { - persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transferCharPtr(TMEMBER(_caption[i])); } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 0d5011f92d..3664e0fd8a 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -859,7 +859,7 @@ bool AdObject::setFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -int AdObject::getHeight() { +int32 AdObject::getHeight() { if (!_currentSprite) { return 0; } else { @@ -1030,30 +1030,30 @@ bool AdObject::reset() { bool AdObject::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_active)); + persistMgr->transferBool(TMEMBER(_active)); persistMgr->transferPtr(TMEMBER_PTR(_blockRegion)); persistMgr->transferPtr(TMEMBER_PTR(_currentBlockRegion)); persistMgr->transferPtr(TMEMBER_PTR(_currentWptGroup)); persistMgr->transferPtr(TMEMBER_PTR(_currentSprite)); - persistMgr->transfer(TMEMBER(_drawn)); + persistMgr->transferBool(TMEMBER(_drawn)); persistMgr->transferPtr(TMEMBER_PTR(_font)); - persistMgr->transfer(TMEMBER(_ignoreItems)); - persistMgr->transfer(TMEMBER_INT(_nextState)); + persistMgr->transferBool(TMEMBER(_ignoreItems)); + persistMgr->transferSint32(TMEMBER_INT(_nextState)); persistMgr->transferPtr(TMEMBER_PTR(_sentence)); - persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transferSint32(TMEMBER_INT(_state)); persistMgr->transferPtr(TMEMBER_PTR(_animSprite)); - persistMgr->transfer(TMEMBER(_sceneIndependent)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); + persistMgr->transferBool(TMEMBER(_sceneIndependent)); + persistMgr->transferCharPtr(TMEMBER(_forcedTalkAnimName)); + persistMgr->transferBool(TMEMBER(_forcedTalkAnimUsed)); persistMgr->transferPtr(TMEMBER_PTR(_tempSprite2)); - persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transferSint32(TMEMBER_INT(_type)); persistMgr->transferPtr(TMEMBER_PTR(_wptGroup)); persistMgr->transferPtr(TMEMBER_PTR(_stickRegion)); - persistMgr->transfer(TMEMBER(_subtitlesModRelative)); - persistMgr->transfer(TMEMBER(_subtitlesModX)); - persistMgr->transfer(TMEMBER(_subtitlesModY)); - persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); - persistMgr->transfer(TMEMBER(_subtitlesWidth)); + persistMgr->transferBool(TMEMBER(_subtitlesModRelative)); + persistMgr->transferSint32(TMEMBER(_subtitlesModX)); + persistMgr->transferSint32(TMEMBER(_subtitlesModY)); + persistMgr->transferBool(TMEMBER(_subtitlesModXCenter)); + persistMgr->transferSint32(TMEMBER(_subtitlesWidth)); persistMgr->transferPtr(TMEMBER_PTR(_inventory)); persistMgr->transferPtr(TMEMBER_PTR(_partEmitter)); @@ -1065,9 +1065,9 @@ bool AdObject::persist(BasePersistenceManager *persistMgr) { _attachmentsPost.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_registerAlias)); - persistMgr->transfer(TMEMBER(_partFollowParent)); - persistMgr->transfer(TMEMBER(_partOffsetX)); - persistMgr->transfer(TMEMBER(_partOffsetY)); + persistMgr->transferBool(TMEMBER(_partFollowParent)); + persistMgr->transferSint32(TMEMBER(_partOffsetX)); + persistMgr->transferSint32(TMEMBER(_partOffsetY)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index 9e30f69855..ba984ef8d1 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -61,7 +61,7 @@ public: bool reset(); DECLARE_PERSISTENT(AdObject, BaseObject) virtual void talk(const char *text, const char *sound = nullptr, uint32 duration = 0, const char *stances = nullptr, TTextAlign align = TAL_CENTER); - virtual int getHeight() override; + virtual int32 getHeight() override; bool setFont(const char *filename); virtual bool update() override; diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 91a24cbf7d..156fc80958 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -110,9 +110,9 @@ bool AdPath::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_currIndex)); + persistMgr->transferSint32(TMEMBER(_currIndex)); _points.persist(persistMgr); - persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transferBool(TMEMBER(_ready)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp index d5108ad8c1..5ee9568608 100644 --- a/engines/wintermute/ad/ad_path_point.cpp +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -65,8 +65,8 @@ bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { BasePoint::persist(persistMgr); - persistMgr->transfer(TMEMBER(_distance)); - persistMgr->transfer(TMEMBER(_marked)); + persistMgr->transferSint32(TMEMBER(_distance)); + persistMgr->transferBool(TMEMBER(_marked)); persistMgr->transferPtr(TMEMBER_PTR(_origin)); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index bc9ac903c6..2e8e73a1cf 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -69,7 +69,7 @@ bool AdRegion::hasDecoration() const { ////////////////////////////////////////////////////////////////////////// bool AdRegion::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -110,7 +110,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdRegion::loadBuffer(byte *buffer, bool complete) { +bool AdRegion::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -131,12 +131,12 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_REGION) { _gameRef->LOG(0, "'REGION' keyword expected."); return STATUS_FAILED; } @@ -150,67 +150,67 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { int ar = 255, ag = 255, ab = 255, alpha = 255; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); + parser.scanStr(params, "%b", &_active); break; case TOKEN_BLOCKED: - parser.scanStr((char *)params, "%b", &_blocked); + parser.scanStr(params, "%b", &_blocked); break; case TOKEN_DECORATION: - parser.scanStr((char *)params, "%b", &_decoration); + parser.scanStr(params, "%b", &_decoration); break; case TOKEN_ZOOM: case TOKEN_SCALE: { int j; - parser.scanStr((char *)params, "%d", &j); + parser.scanStr(params, "%d", &j); _zoom = (float)j; } break; case TOKEN_POINT: { int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr(params, "%d,%d", &x, &y); _points.add(new BasePoint(x, y)); } break; case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); + parser.scanStr(params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr(params, "%d", &_editorSelectedPoint); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PROPERTY: @@ -401,9 +401,9 @@ bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool AdRegion::persist(BasePersistenceManager *persistMgr) { BaseRegion::persist(persistMgr); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_blocked)); - persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transferUint32(TMEMBER(_alpha)); + persistMgr->transferBool(TMEMBER(_blocked)); + persistMgr->transferBool(TMEMBER(_decoration)); persistMgr->transferFloat(TMEMBER(_zoom)); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h index 637c742c9c..f3674dcbfb 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -40,7 +40,7 @@ public: AdRegion(BaseGame *inGame); virtual ~AdRegion(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool hasDecoration() const; diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index fa05224b06..e7b4188de6 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -134,10 +134,10 @@ bool AdResponse::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_icon)); persistMgr->transferPtr(TMEMBER_PTR(_iconHover)); persistMgr->transferPtr(TMEMBER_PTR(_iconPressed)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_textOrig)); - persistMgr->transfer(TMEMBER_INT(_responseType)); + persistMgr->transferSint32(TMEMBER(_iD)); + persistMgr->transferCharPtr(TMEMBER(_text)); + persistMgr->transferCharPtr(TMEMBER(_textOrig)); + persistMgr->transferSint32(TMEMBER_INT(_responseType)); persistMgr->transferPtr(TMEMBER_PTR(_font)); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 9d7c17ac74..f2e986cbdc 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -58,7 +58,7 @@ AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { _shieldWindow = new UIWindow(_gameRef); _horizontal = false; - BasePlatform::setRectEmpty(&_responseArea); + _responseArea.setEmpty(); _scrollOffset = 0; _spacing = 0; @@ -121,12 +121,12 @@ void AdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::invalidateButtons() { for (uint32 i = 0; i < _respButtons.size(); i++) { - _respButtons[i]->_image = nullptr; - _respButtons[i]->_cursor = nullptr; - _respButtons[i]->_font = nullptr; - _respButtons[i]->_fontHover = nullptr; - _respButtons[i]->_fontPress = nullptr; + _respButtons[i]->setImage(nullptr); + _respButtons[i]->setFont(nullptr); _respButtons[i]->setText(""); + _respButtons[i]->_cursor = nullptr; + _respButtons[i]->setFontHover(nullptr); + _respButtons[i]->setFontPress(nullptr); } return STATUS_OK; } @@ -141,16 +141,17 @@ bool AdResponseBox::createButtons() { UIButton *btn = new UIButton(_gameRef); if (btn) { btn->_parent = _window; - btn->_sharedFonts = btn->_sharedImages = true; + btn->setSharedFonts(true); + btn->setSharedImages(true); btn->_sharedCursors = true; // iconic if (_responses[i]->getIcon()) { - btn->_image = _responses[i]->getIcon(); + btn->setImage(_responses[i]->getIcon()); if (_responses[i]->getIconHover()) { - btn->_imageHover = _responses[i]->getIconHover(); + btn->setImageHover(_responses[i]->getIconHover()); } if (_responses[i]->getIconPressed()) { - btn->_imagePress = _responses[i]->getIconPressed(); + btn->setImagePress(_responses[i]->getIconPressed()); } btn->setCaption(_responses[i]->getText()); @@ -163,23 +164,30 @@ bool AdResponseBox::createButtons() { // textual else { btn->setText(_responses[i]->getText()); - btn->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font; - btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; - btn->_fontPress = btn->_fontHover; - btn->_align = _align; + if (_font == nullptr) { + btn->setFont(_gameRef->getSystemFont()); + } else { + btn->setFont(_font); + } + btn->setFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover); + btn->setFontPress(btn->getFontHover()); + btn->setTextAlign(_align); if (_gameRef->_touchInterface) { - btn->_fontHover = btn->_font; + btn->setFontHover(btn->getFont()); } if (_responses[i]->getFont()) { - btn->_font = _responses[i]->getFont(); + btn->setFont(_responses[i]->getFont()); } - btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) { - btn->_width = _gameRef->_renderer->getWidth(); + int width = _responseArea.right - _responseArea.left; + + if (width <= 0) { + btn->setWidth(_gameRef->_renderer->getWidth()); + } else { + btn->setWidth(width); } } btn->setName("response"); @@ -187,17 +195,17 @@ bool AdResponseBox::createButtons() { // make the responses touchable if (_gameRef->_touchInterface) { - btn->_height = MAX<int32>(btn->_height, 50); + btn->setHeight(MAX<int32>(btn->getHeight(), 50)); } //btn->SetListener(this, btn, _responses[i]->_iD); btn->setListener(this, btn, i); - btn->_visible = false; + btn->setVisible(false); _respButtons.add(btn); - if (_responseArea.bottom - _responseArea.top < btn->_height) { + if (_responseArea.bottom - _responseArea.top < btn->getHeight()) { _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->getText()); - _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); + _responseArea.bottom += (btn->getHeight() - (_responseArea.bottom - _responseArea.top)); } } } @@ -209,7 +217,7 @@ bool AdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -245,7 +253,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { +bool AdResponseBox::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -262,22 +270,22 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_RESPONSE_BOX) { _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; @@ -298,7 +306,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { if (_font) { _gameRef->_fontStorage->removeFont(_font); } - _font = _gameRef->_fontStorage->addFont((char *)params); + _font = _gameRef->_fontStorage->addFont(params); if (!_font) { cmd = PARSERR_GENERIC; } @@ -308,24 +316,24 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { if (_fontHover) { _gameRef->_fontStorage->removeFont(_fontHover); } - _fontHover = _gameRef->_fontStorage->addFont((char *)params); + _fontHover = _gameRef->_fontStorage->addFont(params); if (!_fontHover) { cmd = PARSERR_GENERIC; } break; case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); break; case TOKEN_HORIZONTAL: - parser.scanStr((char *)params, "%b", &_horizontal); + parser.scanStr(params, "%b", &_horizontal); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) { + if (scumm_stricmp(params, "center") == 0) { _align = TAL_CENTER; - } else if (scumm_stricmp((char *)params, "right") == 0) { + } else if (scumm_stricmp(params, "right") == 0) { _align = TAL_RIGHT; } else { _align = TAL_LEFT; @@ -333,9 +341,9 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) { + if (scumm_stricmp(params, "top") == 0) { _verticalAlign = VAL_TOP; - } else if (scumm_stricmp((char *)params, "center") == 0) { + } else if (scumm_stricmp(params, "center") == 0) { _verticalAlign = VAL_CENTER; } else { _verticalAlign = VAL_BOTTOM; @@ -343,7 +351,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); + parser.scanStr(params, "%d", &_spacing); break; case TOKEN_EDITOR_PROPERTY: @@ -353,7 +361,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -368,7 +376,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { if (_window) { for (uint32 i = 0; i < _window->_widgets.size(); i++) { - if (!_window->_widgets[i]->_listenerObject) { + if (!_window->_widgets[i]->getListener()) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } } @@ -461,7 +469,7 @@ bool AdResponseBox::display() { if (!_horizontal) { int totalHeight = 0; for (i = 0; i < _respButtons.size(); i++) { - totalHeight += (_respButtons[i]->_height + _spacing); + totalHeight += (_respButtons[i]->getHeight() + _spacing); } totalHeight -= _spacing; @@ -487,22 +495,22 @@ bool AdResponseBox::display() { // prepare response buttons bool scrollNeeded = false; for (i = _scrollOffset; i < _respButtons.size(); i++) { - if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) - || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { + if ((_horizontal && xxx + _respButtons[i]->getWidth() > rect.right) + || (!_horizontal && yyy + _respButtons[i]->getHeight() > rect.bottom)) { scrollNeeded = true; - _respButtons[i]->_visible = false; + _respButtons[i]->setVisible(false); break; } - _respButtons[i]->_visible = true; + _respButtons[i]->setVisible(true); _respButtons[i]->_posX = xxx; _respButtons[i]->_posY = yyy; if (_horizontal) { - xxx += (_respButtons[i]->_width + _spacing); + xxx += (_respButtons[i]->getWidth() + _spacing); } else { - yyy += (_respButtons[i]->_height + _spacing); + yyy += (_respButtons[i]->getHeight() + _spacing); } } @@ -515,8 +523,8 @@ bool AdResponseBox::display() { // go exclusive if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->getWidth(); - _shieldWindow->_height = _gameRef->_renderer->getHeight(); + _shieldWindow->setWidth(_gameRef->_renderer->getWidth()); + _shieldWindow->setHeight(_gameRef->_renderer->getHeight()); _shieldWindow->display(); } @@ -575,20 +583,20 @@ bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_font)); persistMgr->transferPtr(TMEMBER_PTR(_fontHover)); - persistMgr->transfer(TMEMBER(_horizontal)); - persistMgr->transfer(TMEMBER(_lastResponseText)); - persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); + persistMgr->transferBool(TMEMBER(_horizontal)); + persistMgr->transferCharPtr(TMEMBER(_lastResponseText)); + persistMgr->transferCharPtr(TMEMBER(_lastResponseTextOrig)); _respButtons.persist(persistMgr); - persistMgr->transfer(TMEMBER(_responseArea)); + persistMgr->transferRect32(TMEMBER(_responseArea)); _responses.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transferSint32(TMEMBER(_scrollOffset)); persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow)); - persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transferSint32(TMEMBER(_spacing)); persistMgr->transferPtr(TMEMBER_PTR(_waitingScript)); persistMgr->transferPtr(TMEMBER_PTR(_window)); - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transferSint32(TMEMBER_INT(_verticalAlign)); + persistMgr->transferSint32(TMEMBER_INT(_align)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index 7598e8b569..9469bfda43 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -72,7 +72,7 @@ public: virtual ~AdResponseBox(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; UIWindow *getResponseWindow(); diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 0b58f5ba0c..44b43a6077 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -50,8 +50,8 @@ AdResponseContext::~AdResponseContext() { ////////////////////////////////////////////////////////////////////////// bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_context)); - persistMgr->transfer(TMEMBER(_id)); + persistMgr->transferCharPtr(TMEMBER(_context)); + persistMgr->transferSint32(TMEMBER(_id)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index d925b0d57a..b5bdc8ebe9 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -53,7 +53,7 @@ AdRotLevel::~AdRotLevel() { ////////////////////////////////////////////////////////////////////////// bool AdRotLevel::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdRotLevel::loadBuffer(byte *buffer, bool complete) { +bool AdRotLevel::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -91,33 +91,33 @@ bool AdRotLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ROTATION_LEVEL) { _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_ROTATION: { int i; - parser.scanStr((char *)params, "%d", &i); + parser.scanStr(params, "%d", &i); _rotation = (float)i; } break; diff --git a/engines/wintermute/ad/ad_rot_level.h b/engines/wintermute/ad/ad_rot_level.h index fe2d1691cd..47c621845a 100644 --- a/engines/wintermute/ad/ad_rot_level.h +++ b/engines/wintermute/ad/ad_rot_level.h @@ -42,7 +42,7 @@ public: float getRotation() const { return _rotation; } virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); }; } // End of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 59e6d57787..aa7f6f89cf 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -54,7 +54,7 @@ float AdScaleLevel::getScale() const { ////////////////////////////////////////////////////////////////////////// bool AdScaleLevel::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -83,7 +83,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) { +bool AdScaleLevel::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -92,33 +92,33 @@ bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_SCALE_LEVEL) { _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_SCALE: { int i; - parser.scanStr((char *)params, "%d", &i); + parser.scanStr(params, "%d", &i); _scale = (float)i; } break; diff --git a/engines/wintermute/ad/ad_scale_level.h b/engines/wintermute/ad/ad_scale_level.h index b2dd7aa91f..768e79bbf7 100644 --- a/engines/wintermute/ad/ad_scale_level.h +++ b/engines/wintermute/ad/ad_scale_level.h @@ -41,7 +41,7 @@ public: virtual ~AdScaleLevel(); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); float getScale() const; private: float _scale; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 668b39853b..ab7ab51f30 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -538,7 +538,7 @@ bool AdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// bool AdScene::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -600,7 +600,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdScene::loadBuffer(byte *buffer, bool complete) { +bool AdScene::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -643,12 +643,12 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { cleanup(); - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_SCENE) { _gameRef->LOG(0, "'SCENE' keyword expected."); return STATUS_FAILED; } @@ -659,20 +659,20 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { char camera[MAX_PATH_LENGTH] = ""; /* float waypointHeight = -1.0f; */ - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_LAYER: { @@ -747,7 +747,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -755,99 +755,99 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_CAMERA: - Common::strlcpy(camera, (char *)params, MAX_PATH_LENGTH); + Common::strlcpy(camera, params, MAX_PATH_LENGTH); break; case TOKEN_EDITOR_MARGIN_H: - parser.scanStr((char *)params, "%d", &_editorMarginH); + parser.scanStr(params, "%d", &_editorMarginH); break; case TOKEN_EDITOR_MARGIN_V: - parser.scanStr((char *)params, "%d", &_editorMarginV); + parser.scanStr(params, "%d", &_editorMarginV); break; case TOKEN_EDITOR_COLOR_FRAME: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColFrame = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColEntity = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColRegion = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColDecor = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_SCALE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr(params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColScale = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_SHOW_REGIONS: - parser.scanStr((char *)params, "%b", &_editorShowRegions); + parser.scanStr(params, "%b", &_editorShowRegions); break; case TOKEN_EDITOR_SHOW_BLOCKED: - parser.scanStr((char *)params, "%b", &_editorShowBlocked); + parser.scanStr(params, "%b", &_editorShowBlocked); break; case TOKEN_EDITOR_SHOW_DECORATION: - parser.scanStr((char *)params, "%b", &_editorShowDecor); + parser.scanStr(params, "%b", &_editorShowDecor); break; case TOKEN_EDITOR_SHOW_ENTITIES: - parser.scanStr((char *)params, "%b", &_editorShowEntities); + parser.scanStr(params, "%b", &_editorShowEntities); break; case TOKEN_EDITOR_SHOW_SCALE: - parser.scanStr((char *)params, "%b", &_editorShowScale); + parser.scanStr(params, "%b", &_editorShowScale); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PROPERTY: @@ -856,7 +856,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: { Rect32 rc; - parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) { _viewport = new BaseViewport(_gameRef); } @@ -864,13 +864,14 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); } } + break; case TOKEN_PERSISTENT_STATE: - parser.scanStr((char *)params, "%b", &_persistentState); + parser.scanStr(params, "%b", &_persistentState); break; case TOKEN_PERSISTENT_STATE_SPRITES: - parser.scanStr((char *)params, "%b", &_persistentStateSprites); + parser.scanStr(params, "%b", &_persistentStateSprites); break; case TOKEN_EDITOR_PROPERTY: @@ -1014,8 +1015,8 @@ bool AdScene::traverseNodes(bool doUpdate) { } if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->getWidth(); - _shieldWindow->_height = _gameRef->_renderer->getHeight(); + _shieldWindow->setWidth(_gameRef->_renderer->getWidth()); + _shieldWindow->setHeight(_gameRef->_renderer->getHeight()); _shieldWindow->display(); } } @@ -2299,58 +2300,58 @@ float AdScene::getScaleAt(int Y) { bool AdScene::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_autoScroll)); - persistMgr->transfer(TMEMBER(_editorColBlocked)); - persistMgr->transfer(TMEMBER(_editorColBlockedSel)); - persistMgr->transfer(TMEMBER(_editorColDecor)); - persistMgr->transfer(TMEMBER(_editorColDecorSel)); - persistMgr->transfer(TMEMBER(_editorColEntity)); - persistMgr->transfer(TMEMBER(_editorColEntitySel)); - persistMgr->transfer(TMEMBER(_editorColFrame)); - persistMgr->transfer(TMEMBER(_editorColRegion)); - persistMgr->transfer(TMEMBER(_editorColRegionSel)); - persistMgr->transfer(TMEMBER(_editorColScale)); - persistMgr->transfer(TMEMBER(_editorColWaypoints)); - persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); - persistMgr->transfer(TMEMBER(_editorMarginH)); - persistMgr->transfer(TMEMBER(_editorMarginV)); - persistMgr->transfer(TMEMBER(_editorShowBlocked)); - persistMgr->transfer(TMEMBER(_editorShowDecor)); - persistMgr->transfer(TMEMBER(_editorShowEntities)); - persistMgr->transfer(TMEMBER(_editorShowRegions)); - persistMgr->transfer(TMEMBER(_editorShowScale)); + persistMgr->transferBool(TMEMBER(_autoScroll)); + persistMgr->transferUint32(TMEMBER(_editorColBlocked)); + persistMgr->transferUint32(TMEMBER(_editorColBlockedSel)); + persistMgr->transferUint32(TMEMBER(_editorColDecor)); + persistMgr->transferUint32(TMEMBER(_editorColDecorSel)); + persistMgr->transferUint32(TMEMBER(_editorColEntity)); + persistMgr->transferUint32(TMEMBER(_editorColEntitySel)); + persistMgr->transferUint32(TMEMBER(_editorColFrame)); + persistMgr->transferUint32(TMEMBER(_editorColRegion)); + persistMgr->transferUint32(TMEMBER(_editorColRegionSel)); + persistMgr->transferUint32(TMEMBER(_editorColScale)); + persistMgr->transferUint32(TMEMBER(_editorColWaypoints)); + persistMgr->transferUint32(TMEMBER(_editorColWaypointsSel)); + persistMgr->transferSint32(TMEMBER(_editorMarginH)); + persistMgr->transferSint32(TMEMBER(_editorMarginV)); + persistMgr->transferBool(TMEMBER(_editorShowBlocked)); + persistMgr->transferBool(TMEMBER(_editorShowDecor)); + persistMgr->transferBool(TMEMBER(_editorShowEntities)); + persistMgr->transferBool(TMEMBER(_editorShowRegions)); + persistMgr->transferBool(TMEMBER(_editorShowScale)); persistMgr->transferPtr(TMEMBER_PTR(_fader)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_initialized)); - persistMgr->transfer(TMEMBER(_lastTimeH)); - persistMgr->transfer(TMEMBER(_lastTimeV)); + persistMgr->transferSint32(TMEMBER(_height)); + persistMgr->transferBool(TMEMBER(_initialized)); + persistMgr->transferUint32(TMEMBER(_lastTimeH)); + persistMgr->transferUint32(TMEMBER(_lastTimeV)); _layers.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_mainLayer)); _objects.persist(persistMgr); - persistMgr->transfer(TMEMBER(_offsetLeft)); - persistMgr->transfer(TMEMBER(_offsetTop)); - persistMgr->transfer(TMEMBER(_paralaxScrolling)); - persistMgr->transfer(TMEMBER(_persistentState)); - persistMgr->transfer(TMEMBER(_persistentStateSprites)); - persistMgr->transfer(TMEMBER(_pfMaxTime)); + persistMgr->transferSint32(TMEMBER(_offsetLeft)); + persistMgr->transferSint32(TMEMBER(_offsetTop)); + persistMgr->transferBool(TMEMBER(_paralaxScrolling)); + persistMgr->transferBool(TMEMBER(_persistentState)); + persistMgr->transferBool(TMEMBER(_persistentStateSprites)); + persistMgr->transferUint32(TMEMBER(_pfMaxTime)); _pfPath.persist(persistMgr); - persistMgr->transfer(TMEMBER(_pfPointsNum)); - persistMgr->transfer(TMEMBER(_pfReady)); + persistMgr->transferSint32(TMEMBER(_pfPointsNum)); + persistMgr->transferBool(TMEMBER(_pfReady)); persistMgr->transferPtr(TMEMBER_PTR(_pfRequester)); persistMgr->transferPtr(TMEMBER_PTR(_pfTarget)); persistMgr->transferPtr(TMEMBER_PTR(_pfTargetPath)); _rotLevels.persist(persistMgr); _scaleLevels.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollPixelsH)); - persistMgr->transfer(TMEMBER(_scrollPixelsV)); - persistMgr->transfer(TMEMBER(_scrollTimeH)); - persistMgr->transfer(TMEMBER(_scrollTimeV)); + persistMgr->transferSint32(TMEMBER(_scrollPixelsH)); + persistMgr->transferSint32(TMEMBER(_scrollPixelsV)); + persistMgr->transferUint32(TMEMBER(_scrollTimeH)); + persistMgr->transferUint32(TMEMBER(_scrollTimeV)); persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow)); - persistMgr->transfer(TMEMBER(_targetOffsetLeft)); - persistMgr->transfer(TMEMBER(_targetOffsetTop)); + persistMgr->transferSint32(TMEMBER(_targetOffsetLeft)); + persistMgr->transferSint32(TMEMBER(_targetOffsetTop)); _waypointGroups.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_viewport)); - persistMgr->transfer(TMEMBER(_width)); + persistMgr->transferSint32(TMEMBER(_width)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index 5beb10e546..1f35a776b5 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -124,7 +124,7 @@ public: BaseArray<AdObject *> _objects; BaseArray<AdWaypointGroup *> _waypointGroups; bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); int32 _width; int32 _height; bool addObject(AdObject *Object); diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index 8548da91db..5f6207c23a 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -74,7 +74,7 @@ bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_entity)); persistMgr->transferPtr(TMEMBER_PTR(_region)); - persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transferSint32(TMEMBER_INT(_type)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 58cb5f514a..a4218751c3 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -56,7 +56,7 @@ AdSceneState::~AdSceneState() { ////////////////////////////////////////////////////////////////////////// bool AdSceneState::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transferCharPtr(TMEMBER(_filename)); _nodeStates.persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index d5baa8291f..21ffac5aaf 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -249,23 +249,23 @@ bool AdSentence::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER_INT(_align)); - persistMgr->transfer(TMEMBER(_currentStance)); + persistMgr->transferSint32(TMEMBER_INT(_align)); + persistMgr->transferSint32(TMEMBER(_currentStance)); persistMgr->transferPtr(TMEMBER_PTR(_currentSprite)); - persistMgr->transfer(TMEMBER(_currentSkelAnim)); - persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transferCharPtr(TMEMBER(_currentSkelAnim)); + persistMgr->transferUint32(TMEMBER(_duration)); persistMgr->transferPtr(TMEMBER_PTR(_font)); - persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transferPoint32(TMEMBER(_pos)); persistMgr->transferPtr(TMEMBER_PTR(_sound)); - persistMgr->transfer(TMEMBER(_soundStarted)); - persistMgr->transfer(TMEMBER(_stances)); - persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transferBool(TMEMBER(_soundStarted)); + persistMgr->transferCharPtr(TMEMBER(_stances)); + persistMgr->transferUint32(TMEMBER(_startTime)); persistMgr->transferPtr(TMEMBER_PTR(_talkDef)); - persistMgr->transfer(TMEMBER(_tempStance)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_fixedPos)); - persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transferCharPtr(TMEMBER(_tempStance)); + persistMgr->transferCharPtr(TMEMBER(_text)); + persistMgr->transferSint32(TMEMBER(_width)); + persistMgr->transferBool(TMEMBER(_fixedPos)); + persistMgr->transferBool(TMEMBER(_freezable)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 9eb3bd0686..dd920492de 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -60,7 +60,7 @@ AdSpriteSet::~AdSpriteSet() { ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -93,7 +93,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +bool AdSpriteSet::loadBuffer(char *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -109,12 +109,12 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_SPRITESET) { _gameRef->LOG(0, "'SPRITESET' keyword expected."); return STATUS_FAILED; } @@ -122,23 +122,23 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC } BaseSprite *spr = nullptr; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params, lifeTime, cacheType))) { + if (DID_FAIL(loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_LEFT: delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_LEFT] = spr; @@ -149,7 +149,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_RIGHT] = spr; @@ -160,7 +160,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_UP]; _sprites[DI_UP] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_UP] = spr; @@ -171,7 +171,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_DOWN] = spr; @@ -182,7 +182,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_UPLEFT] = spr; @@ -193,7 +193,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_UPRIGHT] = spr; @@ -204,7 +204,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_DOWNLEFT] = spr; @@ -215,7 +215,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + if (!spr || DID_FAIL(spr->loadFile(params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; } else { _sprites[DI_DOWNRIGHT] = spr; diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h index ef5ef3a94f..ece71f7adb 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -44,7 +44,7 @@ public: AdSpriteSet(BaseGame *inGame, BaseObject *owner = nullptr); virtual ~AdSpriteSet(); bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(char *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); BaseSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index f10a0e2fb9..22e3d7b4cc 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -71,7 +71,7 @@ AdTalkDef::~AdTalkDef() { ////////////////////////////////////////////////////////////////////////// bool AdTalkDef::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -101,7 +101,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { +bool AdTalkDef::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -112,22 +112,22 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_TALK) { _gameRef->LOG(0, "'TALK' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; @@ -145,11 +145,11 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_DEFAULT_SPRITE: - BaseUtils::setString(&_defaultSpriteFilename, (char *)params); + BaseUtils::setString(&_defaultSpriteFilename, params); break; case TOKEN_DEFAULT_SPRITESET_FILE: - BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params); + BaseUtils::setString(&_defaultSpriteSetFilename, params); break; case TOKEN_DEFAULT_SPRITESET: { @@ -209,9 +209,9 @@ bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_defaultSprite)); - persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); + persistMgr->transferCharPtr(TMEMBER(_defaultSpriteFilename)); persistMgr->transferPtr(TMEMBER_PTR(_defaultSpriteSet)); - persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); + persistMgr->transferCharPtr(TMEMBER(_defaultSpriteSetFilename)); _nodes.persist(persistMgr); diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index 726eefbe4c..5711906b4b 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -46,7 +46,7 @@ public: AdTalkDef(BaseGame *inGame); virtual ~AdTalkDef(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); BaseArray<AdTalkNode *> _nodes; char *_defaultSpriteFilename; BaseSprite *_defaultSprite; diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index ce86dccd8e..6c0d2e1f06 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -79,7 +79,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { +bool AdTalkNode::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -92,12 +92,12 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ACTION) { _gameRef->LOG(0, "'ACTION' keyword expected."); return STATUS_FAILED; } @@ -108,14 +108,14 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { _playToEnd = false; _preCache = false; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: - BaseUtils::setString(&_spriteFilename, (char *)params); + BaseUtils::setString(&_spriteFilename, params); break; case TOKEN_SPRITESET_FILE: - BaseUtils::setString(&_spriteSetFilename, (char *)params); + BaseUtils::setString(&_spriteSetFilename, params); break; case TOKEN_SPRITESET: { @@ -130,20 +130,20 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_START_TIME: - parser.scanStr((char *)params, "%d", &_startTime); + parser.scanStr(params, "%d", &_startTime); break; case TOKEN_END_TIME: - parser.scanStr((char *)params, "%d", &_endTime); + parser.scanStr(params, "%d", &_endTime); break; case TOKEN_PRECACHE: - parser.scanStr((char *)params, "%b", &_preCache); + parser.scanStr(params, "%b", &_preCache); break; case TOKEN_COMMENT: if (_gameRef->_editorMode) { - BaseUtils::setString(&_comment, (char *)params); + BaseUtils::setString(&_comment, params); } break; @@ -191,14 +191,14 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdTalkNode::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_comment)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_endTime)); - persistMgr->transfer(TMEMBER(_playToEnd)); + persistMgr->transferCharPtr(TMEMBER(_comment)); + persistMgr->transferUint32(TMEMBER(_startTime)); + persistMgr->transferUint32(TMEMBER(_endTime)); + persistMgr->transferBool(TMEMBER(_playToEnd)); persistMgr->transferPtr(TMEMBER_PTR(_sprite)); - persistMgr->transfer(TMEMBER(_spriteFilename)); + persistMgr->transferCharPtr(TMEMBER(_spriteFilename)); persistMgr->transferPtr(TMEMBER_PTR(_spriteSet)); - persistMgr->transfer(TMEMBER(_spriteSetFilename)); + persistMgr->transferCharPtr(TMEMBER(_spriteSetFilename)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_talk_node.h b/engines/wintermute/ad/ad_talk_node.h index 01dfb6b4ff..7a014b2d9f 100644 --- a/engines/wintermute/ad/ad_talk_node.h +++ b/engines/wintermute/ad/ad_talk_node.h @@ -46,7 +46,7 @@ public: AdTalkNode(BaseGame *inGame); virtual ~AdTalkNode(); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0) override; char *_spriteFilename; BaseSprite *_sprite; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index cc7982cb9d..ae6b18e266 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -66,7 +66,7 @@ void AdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// bool AdWaypointGroup::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -98,7 +98,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { +bool AdWaypointGroup::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -110,43 +110,43 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_WAYPOINTS) { _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_POINT: { int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr(params, "%d,%d", &x, &y); _points.add(new BasePoint(x, y)); } break; case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); + parser.scanStr(params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr(params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: @@ -194,11 +194,11 @@ bool AdWaypointGroup::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transferBool(TMEMBER(_active)); + persistMgr->transferSint32(TMEMBER(_editorSelectedPoint)); persistMgr->transferFloat(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); + persistMgr->transferSint32(TMEMBER(_lastMimicX)); + persistMgr->transferSint32(TMEMBER(_lastMimicY)); _points.persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index af97a21290..47fd611be6 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -41,7 +41,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; AdWaypointGroup(BaseGame *inGame); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual ~AdWaypointGroup(); bool _active; diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index a64770c577..6a0666b36e 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -60,7 +60,7 @@ Common::String BaseClass::getEditorProp(const Common::String &propName, const Co if (_editorPropsIter != _editorProps.end()) { return _editorPropsIter->_value.c_str(); } else { - return initVal; + return initVal; // Used to be NULL } } @@ -87,7 +87,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { +bool BaseClass::parseEditorProperty(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -100,12 +100,12 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { } - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_EDITOR_PROPERTY) { BaseEngine::LOG(0, "'EDITOR_PROPERTY' keyword expected."); return STATUS_FAILED; } @@ -115,13 +115,13 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { char *propName = nullptr; char *propValue = nullptr; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] propName; - propName = new char[strlen((char *)params) + 1]; + propName = new char[strlen(params) + 1]; if (propName) { - strcpy(propName, (char *)params); + strcpy(propName, params); } else { cmd = PARSERR_GENERIC; } @@ -129,9 +129,9 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { case TOKEN_VALUE: delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; + propValue = new char[strlen(params) + 1]; if (propValue) { - strcpy(propValue, (char *)params); + strcpy(propValue, params); } else { cmd = PARSERR_GENERIC; } diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index 48ebe49a97..8767cc9bdd 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -44,9 +44,9 @@ class BaseClass { public: bool _persistable; bool setEditorProp(const Common::String &propName, const Common::String &propValue); - Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = nullptr); + Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = Common::String()); BaseClass(TDynamicConstructor, TDynamicConstructor) {} - bool parseEditorProperty(byte *buffer, bool complete = true); + bool parseEditorProperty(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); BaseClass(); BaseClass(BaseGame *GameOwner); diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index abeaa18d54..69cc7b02b6 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -37,7 +37,7 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); _owner = nullptr; _frame = nullptr; _region = nullptr; @@ -52,7 +52,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise) : BaseClass(inGame) { _owner = owner; _frame = frame; - BasePlatform::setRect(&_rect, x, y, x + width, y + height); + _rect.setRect(x, y, x + width, y + height); _zoomX = zoomX; _zoomY = zoomY; _precise = precise; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 7978230964..c7dac8be27 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -175,16 +175,16 @@ uint32 BaseFader::getCurrentColor() const { bool BaseFader::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blue)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_green)); - persistMgr->transfer(TMEMBER(_red)); - persistMgr->transfer(TMEMBER(_sourceAlpha)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_targetAlpha)); - persistMgr->transfer(TMEMBER(_system)); + persistMgr->transferBool(TMEMBER(_active)); + persistMgr->transferByte(TMEMBER(_blue)); + persistMgr->transferByte(TMEMBER(_currentAlpha)); + persistMgr->transferUint32(TMEMBER(_duration)); + persistMgr->transferByte(TMEMBER(_green)); + persistMgr->transferByte(TMEMBER(_red)); + persistMgr->transferByte(TMEMBER(_sourceAlpha)); + persistMgr->transferUint32(TMEMBER(_startTime)); + persistMgr->transferByte(TMEMBER(_targetAlpha)); + persistMgr->transferBool(TMEMBER(_system)); if (_system && !persistMgr->getIsSaving()) { _startTime = 0; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index eaad024120..1455733461 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -142,7 +142,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseFrame::loadBuffer(char *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -181,10 +181,10 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { bool decoration = false; bool mirrorX = false; bool mirrorY = false; - BasePlatform::setRectEmpty(&rect); + rect.setEmpty(); char *surface_file = nullptr; - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_DELAY: parser.scanStr(params, "%d", &_delay); @@ -249,7 +249,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { case TOKEN_SUBFRAME: { BaseSubFrame *subframe = new BaseSubFrame(_gameRef); - if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + if (!subframe || DID_FAIL(subframe->loadBuffer(params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; } else { @@ -290,7 +290,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); + parseEditorProperty(params, false); break; } } @@ -325,7 +325,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } } - if (BasePlatform::isRectEmpty(&rect)) { + if (rect.isRectEmpty()) { sub->setDefaultRect(); } else { sub->setRect(rect); @@ -352,7 +352,7 @@ bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float if (!rect) { return false; } - BasePlatform::setRectEmpty(rect); + rect->setEmpty(); Rect32 subRect; @@ -414,12 +414,12 @@ bool BaseFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); _applyEvent.persist(persistMgr); - persistMgr->transfer(TMEMBER(_delay)); - persistMgr->transfer(TMEMBER(_editorExpanded)); - persistMgr->transfer(TMEMBER(_keyframe)); - persistMgr->transfer(TMEMBER(_killSound)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transferUint32(TMEMBER(_delay)); + persistMgr->transferBool(TMEMBER(_editorExpanded)); + persistMgr->transferBool(TMEMBER(_keyframe)); + persistMgr->transferBool(TMEMBER(_killSound)); + persistMgr->transferSint32(TMEMBER(_moveX)); + persistMgr->transferSint32(TMEMBER(_moveY)); persistMgr->transferPtr(TMEMBER_PTR(_sound)); _subframes.persist(persistMgr); diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index bf1e40daa1..c4cfc443fa 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -52,7 +52,7 @@ public: uint32 _delay; BaseArray<BaseSubFrame *> _subframes; bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool loadBuffer(char *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); virtual ~BaseFrame(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b2c05d271d..6b7e1cf803 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -185,7 +185,7 @@ BaseGame::BaseGame(const Common::String &targetName) : BaseObject(this), _target _lastCursor = nullptr; - BasePlatform::setRectEmpty(&_mouseLockRect); + _mouseLockRect.setEmpty(); _suppressScriptErrors = false; _lastMiniUpdate = 0; @@ -573,7 +573,7 @@ bool BaseGame::initLoop() { _focusedWindow = nullptr; for (int i = _windows.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { + if (_windows[i]->isVisible()) { _focusedWindow = _windows[i]; break; } @@ -620,7 +620,7 @@ void BaseGame::getOffset(int *offsetX, int *offsetY) const { ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -690,7 +690,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadBuffer(byte *buffer, bool complete) { +bool BaseGame::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -740,32 +740,32 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { Common::String loadImageName = ""; Common::String saveImageName = ""; - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_GAME) { _gameRef->LOG(0, "'GAME' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_SYSTEM_FONT: @@ -774,7 +774,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } _systemFont = nullptr; - _systemFont = _gameRef->_fontStorage->addFont((char *)params); + _systemFont = _gameRef->_fontStorage->addFont(params); break; case TOKEN_VIDEO_FONT: @@ -783,14 +783,14 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } _videoFont = nullptr; - _videoFont = _gameRef->_fontStorage->addFont((char *)params); + _videoFont = _gameRef->_fontStorage->addFont(params); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -801,7 +801,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { delete _activeCursor; _activeCursor = nullptr; _activeCursor = new BaseSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(params))) { delete _activeCursor; _activeCursor = nullptr; cmd = PARSERR_GENERIC; @@ -811,7 +811,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; _cursorNoninteractive = new BaseSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(params))) { delete _cursorNoninteractive; _cursorNoninteractive = nullptr; cmd = PARSERR_GENERIC; @@ -819,23 +819,23 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PERSONAL_SAVEGAMES: - parser.scanStr((char *)params, "%b", &_personalizedSave); + parser.scanStr(params, "%b", &_personalizedSave); break; case TOKEN_SUBTITLES: - parser.scanStr((char *)params, "%b", &_subtitles); + parser.scanStr(params, "%b", &_subtitles); break; case TOKEN_SUBTITLES_SPEED: - parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + parser.scanStr(params, "%d", &_subtitlesSpeed); break; case TOKEN_VIDEO_SUBTITLES: - parser.scanStr((char *)params, "%b", &_videoSubtitles); + parser.scanStr(params, "%b", &_videoSubtitles); break; case TOKEN_PROPERTY: @@ -847,66 +847,66 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_THUMBNAIL_WIDTH: - parser.scanStr((char *)params, "%d", &_thumbnailWidth); + parser.scanStr(params, "%d", &_thumbnailWidth); break; case TOKEN_THUMBNAIL_HEIGHT: - parser.scanStr((char *)params, "%d", &_thumbnailHeight); + parser.scanStr(params, "%d", &_thumbnailHeight); break; case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &indicatorX); + parser.scanStr(params, "%d", &indicatorX); break; case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &indicatorY); + parser.scanStr(params, "%d", &indicatorY); break; case TOKEN_INDICATOR_COLOR: { int r, g, b, a; - parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + parser.scanStr(params, "%d,%d,%d,%d", &r, &g, &b, &a); indicatorColor = BYTETORGBA(r, g, b, a); } break; case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &indicatorWidth); + parser.scanStr(params, "%d", &indicatorWidth); break; case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &indicatorHeight); + parser.scanStr(params, "%d", &indicatorHeight); break; case TOKEN_SAVE_IMAGE: - saveImageName = (char *) params; + saveImageName = params; break; case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &saveImageX); + parser.scanStr(params, "%d", &saveImageX); break; case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &saveImageY); + parser.scanStr(params, "%d", &saveImageY); break; case TOKEN_LOAD_IMAGE: - loadImageName = (char *) params; + loadImageName = params; break; case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &loadImageX); + parser.scanStr(params, "%d", &loadImageX); break; case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &loadImageY); + parser.scanStr(params, "%d", &loadImageY); break; case TOKEN_LOCAL_SAVE_DIR: - _localSaveDir = (char *)params; + _localSaveDir = params; break; case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + parser.scanStr(params, "%b", &_compatKillMethodThreads); break; } } @@ -1123,7 +1123,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack BaseUtils::swap(&top, &bottom); } - BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); + _mouseLockRect.setRect(left, top, right, bottom); stack->pushNULL(); return STATUS_OK; @@ -3019,10 +3019,10 @@ bool BaseGame::displayWindows(bool inGame) { bool res; // did we lose focus? focus topmost window - if (_focusedWindow == nullptr || !_focusedWindow->_visible || _focusedWindow->_disable) { + if (_focusedWindow == nullptr || !_focusedWindow->isVisible() || _focusedWindow->isDisabled()) { _focusedWindow = nullptr; for (int i = _windows.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { + if (_windows[i]->isVisible() && !_windows[i]->isDisabled()) { _focusedWindow = _windows[i]; break; } @@ -3031,7 +3031,7 @@ bool BaseGame::displayWindows(bool inGame) { // display all windows for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + if (_windows[i]->isVisible() && _windows[i]->getInGame() == inGame) { res = _windows[i]->display(); if (DID_FAIL(res)) { @@ -3054,61 +3054,61 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_activeObject)); persistMgr->transferPtr(TMEMBER_PTR(_capturedObject)); persistMgr->transferPtr(TMEMBER_PTR(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transferBool(TMEMBER(_editorMode)); persistMgr->transferPtr(TMEMBER_PTR(_fader)); - persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transferSint32(TMEMBER(_freezeLevel)); persistMgr->transferPtr(TMEMBER_PTR(_focusedWindow)); persistMgr->transferPtr(TMEMBER_PTR(_fontStorage)); - persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transferBool(TMEMBER(_interactive)); persistMgr->transferPtr(TMEMBER_PTR(_keyboardState)); - persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transferUint32(TMEMBER(_lastTime)); persistMgr->transferPtr(TMEMBER_PTR(_mainObject)); _musicSystem->persistChannels(persistMgr); _musicSystem->persistCrossfadeSettings(persistMgr); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transferSint32(TMEMBER(_offsetX)); + persistMgr->transferSint32(TMEMBER(_offsetY)); persistMgr->transferFloat(TMEMBER(_offsetPercentX)); persistMgr->transferFloat(TMEMBER(_offsetPercentY)); - persistMgr->transfer(TMEMBER(_origInteractive)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_personalizedSave)); - persistMgr->transfer(TMEMBER(_quitting)); + persistMgr->transferBool(TMEMBER(_origInteractive)); + persistMgr->transferSint32(TMEMBER_INT(_origState)); + persistMgr->transferBool(TMEMBER(_personalizedSave)); + persistMgr->transferBool(TMEMBER(_quitting)); _regObjects.persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_scEngine)); //persistMgr->transfer(TMEMBER(_soundMgr)); - persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transferSint32(TMEMBER_INT(_state)); //persistMgr->transfer(TMEMBER(_surfaceStorage)); - persistMgr->transfer(TMEMBER(_subtitles)); - persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transferBool(TMEMBER(_subtitles)); + persistMgr->transferSint32(TMEMBER(_subtitlesSpeed)); persistMgr->transferPtr(TMEMBER_PTR(_systemFont)); persistMgr->transferPtr(TMEMBER_PTR(_videoFont)); - persistMgr->transfer(TMEMBER(_videoSubtitles)); + persistMgr->transferBool(TMEMBER(_videoSubtitles)); _timerNormal.persist(persistMgr); _timerLive.persist(persistMgr); _renderer->persistSaveLoadImages(persistMgr); - persistMgr->transfer(TMEMBER_INT(_textEncoding)); - persistMgr->transfer(TMEMBER(_textRTL)); + persistMgr->transferSint32(TMEMBER_INT(_textEncoding)); + persistMgr->transferBool(TMEMBER(_textRTL)); - persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); - persistMgr->transfer(TMEMBER(_suspendedRendering)); + persistMgr->transferSint32(TMEMBER(_soundBufferSizeSec)); + persistMgr->transferBool(TMEMBER(_suspendedRendering)); - persistMgr->transfer(TMEMBER(_mouseLockRect)); + persistMgr->transferRect32(TMEMBER(_mouseLockRect)); _windows.persist(persistMgr); - persistMgr->transfer(TMEMBER(_suppressScriptErrors)); - persistMgr->transfer(TMEMBER(_autorunDisabled)); + persistMgr->transferBool(TMEMBER(_suppressScriptErrors)); + persistMgr->transferBool(TMEMBER(_autorunDisabled)); - persistMgr->transfer(TMEMBER(_autoSaveOnExit)); - persistMgr->transfer(TMEMBER(_autoSaveSlot)); - persistMgr->transfer(TMEMBER(_cursorHidden)); + persistMgr->transferBool(TMEMBER(_autoSaveOnExit)); + persistMgr->transferUint32(TMEMBER(_autoSaveSlot)); + persistMgr->transferBool(TMEMBER(_cursorHidden)); if (!persistMgr->getIsSaving()) { _quitting = false; @@ -3131,7 +3131,7 @@ bool BaseGame::focusWindow(UIWindow *window) { _gameRef->_focusedWindow = window; } - if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) { + if (window->getMode() == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->getMode() == WINDOW_EXCLUSIVE || prev->getMode() == WINDOW_SYSTEM_EXCLUSIVE)) { return focusWindow(prev); } else { return STATUS_OK; @@ -3361,10 +3361,10 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) const { *custom = true; } } else { - BasePlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->getWidth() + _renderer->_drawOffsetX, - _renderer->getHeight() + _renderer->_drawOffsetY); + rect->setRect(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->getWidth() + _renderer->_drawOffsetX, + _renderer->getHeight() + _renderer->_drawOffsetY); if (custom) { *custom = false; } @@ -3577,7 +3577,6 @@ bool BaseGame::onMouseLeftDown() { _capturedObject = _activeObject; } _mouseLeftDown = true; - BasePlatform::setCapture(/*_renderer->_window*/); return STATUS_OK; } @@ -3588,7 +3587,6 @@ bool BaseGame::onMouseLeftUp() { _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); } - BasePlatform::releaseCapture(); _capturedObject = nullptr; _mouseLeftDown = false; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index d295bb6b1a..742d6f548d 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -157,7 +157,7 @@ public: int32 _sequence; virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); + virtual bool loadBuffer(char *buffer, bool complete = true); int32 _viewportSP; diff --git a/engines/wintermute/base/base_game_music.cpp b/engines/wintermute/base/base_game_music.cpp index c50969df76..8894fb843f 100644 --- a/engines/wintermute/base/base_game_music.cpp +++ b/engines/wintermute/base/base_game_music.cpp @@ -215,18 +215,18 @@ bool BaseGameMusic::updateMusicCrossfade() { bool BaseGameMusic::persistChannels(BasePersistenceManager *persistMgr) { for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { persistMgr->transferPtr(TMEMBER_PTR(_music[i])); - persistMgr->transfer(TMEMBER(_musicStartTime[i])); + persistMgr->transferUint32(TMEMBER(_musicStartTime[i])); } return true; } bool BaseGameMusic::persistCrossfadeSettings(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); - persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); - persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); - persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + persistMgr->transferBool(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transferUint32(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transferUint32(TMEMBER(_musicCrossfadeLength)); + persistMgr->transferSint32(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transferSint32(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transferBool(TMEMBER(_musicCrossfadeSwap)); return true; } diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp index 1de8b31ca7..43809b5d1e 100644 --- a/engines/wintermute/base/base_game_settings.cpp +++ b/engines/wintermute/base/base_game_settings.cpp @@ -103,7 +103,7 @@ bool BaseGameSettings::loadSettings(const char *filename) { TOKEN_TABLE_END - byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *origBuffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (origBuffer == nullptr) { BaseEngine::LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; @@ -111,78 +111,78 @@ bool BaseGameSettings::loadSettings(const char *filename) { bool ret = STATUS_OK; - byte *buffer = origBuffer; - byte *params; + char *buffer = origBuffer; + char *params; int cmd; BaseParser parser; - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_SETTINGS) { BaseEngine::LOG(0, "'SETTINGS' keyword expected in game settings file."); return STATUS_FAILED; } buffer = params; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: delete[] _gameFile; - _gameFile = new char[strlen((char *)params) + 1]; + _gameFile = new char[strlen(params) + 1]; if (_gameFile) { - strcpy(_gameFile, (char *)params); + strcpy(_gameFile, params); } break; case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) { + if (DID_FAIL(_stringTable->loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_RESOLUTION: - parser.scanStr((char *)params, "%d,%d", &_resWidth, &_resHeight); + parser.scanStr(params, "%d,%d", &_resWidth, &_resHeight); break; case TOKEN_REQUIRE_3D_ACCELERATION: - parser.scanStr((char *)params, "%b", &_requireAcceleration); + parser.scanStr(params, "%b", &_requireAcceleration); break; case TOKEN_REQUIRE_SOUND: - parser.scanStr((char *)params, "%b", &_requireSound); + parser.scanStr(params, "%b", &_requireSound); break; case TOKEN_HWTL_MODE: - parser.scanStr((char *)params, "%d", &_TLMode); + parser.scanStr(params, "%d", &_TLMode); break; case TOKEN_ALLOW_WINDOWED_MODE: - parser.scanStr((char *)params, "%b", &_allowWindowed); + parser.scanStr(params, "%b", &_allowWindowed); break; case TOKEN_ALLOW_DESKTOP_RES: - parser.scanStr((char *)params, "%b", &_allowDesktopRes); + parser.scanStr(params, "%b", &_allowDesktopRes); break; case TOKEN_ALLOW_ADVANCED: - parser.scanStr((char *)params, "%b", &_allowAdvanced); + parser.scanStr(params, "%b", &_allowAdvanced); break; case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.scanStr((char *)params, "%b", &_allowAccessTab); + parser.scanStr(params, "%b", &_allowAccessTab); break; case TOKEN_ALLOW_ABOUT_TAB: - parser.scanStr((char *)params, "%b", &_allowAboutTab); + parser.scanStr(params, "%b", &_allowAboutTab); break; case TOKEN_REGISTRY_PATH: - //BaseEngine::instance().getRegistry()->setBasePath((char *)params); + //BaseEngine::instance().getRegistry()->setBasePath(params); break; case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); + parser.scanStr(params, "%b", &_richSavedGames); break; case TOKEN_SAVED_GAME_EXT: - _savedGameExt = (char *)params; + _savedGameExt = params; break; case TOKEN_GUID: diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index aeb56ad282..77469e07a5 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -221,12 +221,12 @@ bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { //if (!persistMgr->getIsSaving()) cleanup(); BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_currentAlt)); - persistMgr->transfer(TMEMBER(_currentCharCode)); - persistMgr->transfer(TMEMBER(_currentControl)); - persistMgr->transfer(TMEMBER(_currentKeyData)); - persistMgr->transfer(TMEMBER(_currentPrintable)); - persistMgr->transfer(TMEMBER(_currentShift)); + persistMgr->transferBool(TMEMBER(_currentAlt)); + persistMgr->transferUint32(TMEMBER(_currentCharCode)); + persistMgr->transferBool(TMEMBER(_currentControl)); + persistMgr->transferUint32(TMEMBER(_currentKeyData)); + persistMgr->transferBool(TMEMBER(_currentPrintable)); + persistMgr->transferBool(TMEMBER(_currentShift)); if (!persistMgr->getIsSaving()) { _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum @@ -276,17 +276,21 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { } enum VKeyCodes { - kVkSpace = 32, - kVkLeft = 37, - kVkUp = 38, - kVkRight = 39, - kVkDown = 40 + kVkEscape = 27, + kVkSpace = 32, + kVkLeft = 37, + kVkUp = 38, + kVkRight = 39, + kVkDown = 40 }; ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { + case kVkEscape: + return Common::KEYCODE_ESCAPE; + break; case kVkSpace: return Common::KEYCODE_SPACE; break; diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index ea754f8f23..540c7dd164 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -63,7 +63,7 @@ BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { _iD = _gameRef->getSequence(); - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); _rectSet = false; _cursor = nullptr; @@ -953,53 +953,53 @@ bool BaseObject::persist(BasePersistenceManager *persistMgr) { BaseScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) { - persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transferCharPtr(TMEMBER(_caption[i])); } persistMgr->transferPtr(TMEMBER_PTR(_activeCursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transferUint32(TMEMBER(_alphaColor)); + persistMgr->transferBool(TMEMBER(_autoSoundPanning)); persistMgr->transferPtr(TMEMBER_PTR(_cursor)); - persistMgr->transfer(TMEMBER(_sharedCursors)); - persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); - persistMgr->transfer(TMEMBER(_editorOnly)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_is3D)); - persistMgr->transfer(TMEMBER(_movable)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transferBool(TMEMBER(_sharedCursors)); + persistMgr->transferBool(TMEMBER(_editorAlwaysRegister)); + persistMgr->transferBool(TMEMBER(_editorOnly)); + persistMgr->transferBool(TMEMBER(_editorSelected)); + persistMgr->transferSint32(TMEMBER(_iD)); + persistMgr->transferBool(TMEMBER(_is3D)); + persistMgr->transferBool(TMEMBER(_movable)); + persistMgr->transferSint32(TMEMBER(_posX)); + persistMgr->transferSint32(TMEMBER(_posY)); persistMgr->transferFloat(TMEMBER(_relativeScale)); - persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transferBool(TMEMBER(_rotatable)); persistMgr->transferFloat(TMEMBER(_scale)); persistMgr->transferPtr(TMEMBER_PTR(_sFX)); - persistMgr->transfer(TMEMBER(_sFXStart)); - persistMgr->transfer(TMEMBER(_sFXVolume)); - persistMgr->transfer(TMEMBER(_ready)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_rectSet)); - persistMgr->transfer(TMEMBER(_registrable)); - persistMgr->transfer(TMEMBER(_shadowable)); - persistMgr->transfer(TMEMBER(_soundEvent)); - persistMgr->transfer(TMEMBER(_zoomable)); + persistMgr->transferUint32(TMEMBER(_sFXStart)); + persistMgr->transferSint32(TMEMBER(_sFXVolume)); + persistMgr->transferBool(TMEMBER(_ready)); + persistMgr->transferRect32(TMEMBER(_rect)); + persistMgr->transferBool(TMEMBER(_rectSet)); + persistMgr->transferBool(TMEMBER(_registrable)); + persistMgr->transferBool(TMEMBER(_shadowable)); + persistMgr->transferCharPtr(TMEMBER(_soundEvent)); + persistMgr->transferBool(TMEMBER(_zoomable)); persistMgr->transferFloat(TMEMBER(_scaleX)); persistMgr->transferFloat(TMEMBER(_scaleY)); persistMgr->transferFloat(TMEMBER(_rotate)); - persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transferBool(TMEMBER(_rotateValid)); persistMgr->transferFloat(TMEMBER(_relativeRotate)); - persistMgr->transfer(TMEMBER(_saveState)); - persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + persistMgr->transferBool(TMEMBER(_saveState)); + persistMgr->transferBool(TMEMBER(_nonIntMouseEvents)); - persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transferSint32(TMEMBER_INT(_sFXType)); persistMgr->transferFloat(TMEMBER(_sFXParam1)); persistMgr->transferFloat(TMEMBER(_sFXParam2)); persistMgr->transferFloat(TMEMBER(_sFXParam3)); persistMgr->transferFloat(TMEMBER(_sFXParam4)); - persistMgr->transfer(TMEMBER_INT(_blendMode)); + persistMgr->transferSint32(TMEMBER_INT(_blendMode)); return STATUS_OK; } @@ -1039,7 +1039,7 @@ bool BaseObject::setActiveCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -int BaseObject::getHeight() { +int32 BaseObject::getHeight() { return 0; } diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 42041c5e3c..a190b1bcb4 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -89,7 +89,7 @@ public: virtual bool handleMouseWheel(int delta); virtual bool handleMouse(TMouseEvent event, TMouseButton button); virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual int getHeight(); + virtual int32 getHeight(); bool setCursor(const char *filename); bool setActiveCursor(const char *filename); bool cleanup(); diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 0b677b6cb2..ff9c6c81b0 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -250,10 +250,10 @@ Common::String BaseParser::getToken(char **buf) { *t++ = 0; } else if (*b == 0) { *buf = b; - return nullptr; + return Common::String(); } else { // Error. - return nullptr; + return Common::String(); } *buf = b; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 2e2726f361..3d0fc0e925 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -465,44 +465,53 @@ uint32 BasePersistenceManager::getDWORD() { ////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::putString(const Common::String &val) { - if (!val.size()) { - putString("(null)"); - } else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); +void BasePersistenceManager::putString(const char *val) { + if (!val) { + _saveStream->writeUint32LE(0); + return; } -} -Common::String BasePersistenceManager::getStringObj() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; + uint32 len = strlen(val); - Common::String retString = ret; - delete[] ret; - - if (retString == "(null)") { - retString = ""; - } + _saveStream->writeUint32LE(len + 1); + _saveStream->write(val, len); +} - return retString; +Common::String BasePersistenceManager::getStringObj() { + return getString(); } ////////////////////////////////////////////////////////////////////////// char *BasePersistenceManager::getString() { uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - if (!strcmp(ret, "(null)")) { - delete[] ret; - return nullptr; + if (checkVersion(1,2,2)) { + // Version 1.2.2 and above: len == strlen() + 1, NULL has len == 0 + + if (len == 0) + return nullptr; + + char *ret = new char[len]; + _loadStream->read(ret, len - 1); + ret[len - 1] = '\0'; + + return ret; + } else { + + // Version 1.2.1 and older: NULL strings are represented as "(null)" + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return nullptr; + } + return ret; } + } bool BasePersistenceManager::putTimeDate(const TimeDate &t) { @@ -536,8 +545,7 @@ void BasePersistenceManager::putFloat(float val) { int exponent = 0; float significand = frexp(val, &exponent); Common::String str = Common::String::format("FS%f", significand); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); + putString(str.c_str()); _saveStream->writeSint32LE(exponent); } @@ -559,8 +567,7 @@ void BasePersistenceManager::putDouble(double val) { int exponent = 0; double significand = frexp(val, &exponent); Common::String str = Common::String::format("DS%f", significand); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); + putString(str.c_str()); _saveStream->writeSint32LE(exponent); } @@ -580,7 +587,7 @@ double BasePersistenceManager::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -bool BasePersistenceManager::transfer(const char *name, bool *val) { +bool BasePersistenceManager::transferBool(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) { @@ -599,7 +606,7 @@ bool BasePersistenceManager::transfer(const char *name, bool *val) { ////////////////////////////////////////////////////////////////////////// // int -bool BasePersistenceManager::transfer(const char *name, int32 *val) { +bool BasePersistenceManager::transferSint32(const char *name, int32 *val) { if (_saving) { _saveStream->writeSint32LE(*val); if (_saveStream->err()) { @@ -618,7 +625,7 @@ bool BasePersistenceManager::transfer(const char *name, int32 *val) { ////////////////////////////////////////////////////////////////////////// // DWORD -bool BasePersistenceManager::transfer(const char *name, uint32 *val) { +bool BasePersistenceManager::transferUint32(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); if (_saveStream->err()) { @@ -656,7 +663,7 @@ bool BasePersistenceManager::transferFloat(const char *name, float *val) { ////////////////////////////////////////////////////////////////////////// // double -bool BasePersistenceManager::transfer(const char *name, double *val) { +bool BasePersistenceManager::transferDouble(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) { @@ -675,7 +682,7 @@ bool BasePersistenceManager::transfer(const char *name, double *val) { ////////////////////////////////////////////////////////////////////////// // char* -bool BasePersistenceManager::transfer(const char *name, char **val) { +bool BasePersistenceManager::transferCharPtr(const char *name, char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -692,7 +699,7 @@ bool BasePersistenceManager::transfer(const char *name, char **val) { ////////////////////////////////////////////////////////////////////////// // const char* -bool BasePersistenceManager::transfer(const char *name, const char **val) { +bool BasePersistenceManager::transferConstChar(const char *name, const char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -709,9 +716,9 @@ bool BasePersistenceManager::transfer(const char *name, const char **val) { ////////////////////////////////////////////////////////////////////////// // Common::String -bool BasePersistenceManager::transfer(const char *name, Common::String *val) { +bool BasePersistenceManager::transferString(const char *name, Common::String *val) { if (_saving) { - putString(*val); + putString(val->c_str()); return STATUS_OK; } else { char *str = getString(); @@ -730,39 +737,8 @@ bool BasePersistenceManager::transfer(const char *name, Common::String *val) { } ////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { - size_t size; - - if (_saving) { - size = val.size(); - _saveStream->writeUint32LE(size); - - for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { - putString((*it).c_str()); - } - } else { - val.clear(); - size = _loadStream->readUint32LE(); - - for (size_t i = 0; i < size; i++) { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - val.push_back(str); - } - delete[] str; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// // BYTE -bool BasePersistenceManager::transfer(const char *name, byte *val) { +bool BasePersistenceManager::transferByte(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) { @@ -781,7 +757,7 @@ bool BasePersistenceManager::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { +bool BasePersistenceManager::transferRect32(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -806,7 +782,7 @@ bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { ////////////////////////////////////////////////////////////////////////// // POINT -bool BasePersistenceManager::transfer(const char *name, Point32 *val) { +bool BasePersistenceManager::transferPoint32(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); @@ -827,7 +803,7 @@ bool BasePersistenceManager::transfer(const char *name, Point32 *val) { ////////////////////////////////////////////////////////////////////////// // Vector2 -bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { +bool BasePersistenceManager::transferVector2(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index c09b3345b7..43259b26ff 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -52,7 +52,7 @@ public: void putDWORD(uint32 val); char *getString(); Common::String getStringObj(); - void putString(const Common::String &val); + void putString(const char *val); float getFloat(); void putFloat(float val); double getDouble(); @@ -74,19 +74,18 @@ public: byte *_richBuffer; bool transferPtr(const char *name, void *val); - bool transfer(const char *name, int32 *val); - bool transfer(const char *name, uint32 *val); + bool transferSint32(const char *name, int32 *val); + bool transferUint32(const char *name, uint32 *val); bool transferFloat(const char *name, float *val); - bool transfer(const char *name, double *val); - bool transfer(const char *name, bool *val); - bool transfer(const char *name, byte *val); - bool transfer(const char *name, Rect32 *val); - bool transfer(const char *name, Point32 *val); - bool transfer(const char *name, const char **val); - bool transfer(const char *name, char **val); - bool transfer(const char *name, Common::String *val); - bool transfer(const char *name, Vector2 *val); - bool transfer(const char *name, AnsiStringArray &Val); + bool transferDouble(const char *name, double *val); + bool transferBool(const char *name, bool *val); + bool transferByte(const char *name, byte *val); + bool transferRect32(const char *name, Rect32 *val); + bool transferPoint32(const char *name, Point32 *val); + bool transferConstChar(const char *name, const char **val); + bool transferCharPtr(const char *name, char **val); + bool transferString(const char *name, Common::String *val); + bool transferVector2(const char *name, Vector2 *val); BasePersistenceManager(const char *savePrefix = nullptr, bool deleteSingleton = false); virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index fe6ca941f3..84b6a629c7 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -54,8 +54,8 @@ BasePoint::BasePoint(int initX, int initY) { ////////////////////////////////////////////////////////////////////////// bool BasePoint::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); + persistMgr->transferSint32(TMEMBER(x)); + persistMgr->transferSint32(TMEMBER(y)); return STATUS_OK; } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 36036a1f18..dc17b18ea2 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -48,7 +48,7 @@ BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { _lastMimicScale = -1; _lastMimicX = _lastMimicY = INT_MIN; - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); } @@ -65,7 +65,7 @@ void BaseRegion::cleanup() { } _points.clear(); - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); _editorSelectedPoint = -1; } @@ -102,7 +102,7 @@ bool BaseRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { BaseEngine::LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -135,7 +135,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseRegion::loadBuffer(byte *buffer, bool complete) { +bool BaseRegion::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -148,12 +148,12 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_REGION) { BaseEngine::LOG(0, "'REGION' keyword expected."); return STATUS_FAILED; } @@ -165,39 +165,39 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { } _points.clear(); - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); + parser.scanStr(params, "%b", &_active); break; case TOKEN_POINT: { int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr(params, "%d,%d", &x, &y); _points.add(new BasePoint(x, y)); } break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr(params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: @@ -430,11 +430,11 @@ bool BaseRegion::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transferBool(TMEMBER(_active)); + persistMgr->transferSint32(TMEMBER(_editorSelectedPoint)); persistMgr->transferFloat(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); + persistMgr->transferSint32(TMEMBER(_lastMimicX)); + persistMgr->transferSint32(TMEMBER(_lastMimicY)); _points.persist(persistMgr); return STATUS_OK; @@ -491,7 +491,7 @@ bool BaseRegion::ptInPolygon(int32 x, int32 y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::getBoundingRect(Rect32 *rect) { if (_points.size() == 0) { - BasePlatform::setRectEmpty(rect); + rect->setEmpty(); } else { int32 minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; @@ -502,7 +502,7 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) { maxX = MAX(maxX, _points[i]->x); maxY = MAX(maxY, _points[i]->y); } - BasePlatform::setRect(rect, minX, minY, maxX, maxY); + rect->setRect(minX, minY, maxX, maxY); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 93ad6a6fbe..846dcfc341 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -48,7 +48,7 @@ public: bool pointInRegion(int x, int y); bool createRegion(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); Rect32 _rect; BaseArray<BasePoint *> _points; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, nullptr); } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 25b8775a98..5fb0b62713 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -280,14 +280,14 @@ bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transferCharPtr(TMEMBER(_filename)); + persistMgr->transferBool(TMEMBER(_freezable)); if (persistMgr->getIsSaving()) { const char *name = getName(); - persistMgr->transfer(TMEMBER(name)); + persistMgr->transferConstChar(TMEMBER(name)); } else { char *name; - persistMgr->transfer(TMEMBER(name)); + persistMgr->transferCharPtr(TMEMBER(name)); setName(name); delete[] name; } @@ -370,19 +370,19 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { +bool BaseScriptHolder::parseProperty(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) TOKEN_TABLE(VALUE) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_PROPERTY) { BaseEngine::LOG(0, "'PROPERTY' keyword expected."); return STATUS_FAILED; } @@ -392,13 +392,13 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { char *propName = nullptr; char *propValue = nullptr; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] propName; - propName = new char[strlen((char *)params) + 1]; + propName = new char[strlen(params) + 1]; if (propName) { - strcpy(propName, (char *)params); + strcpy(propName, params); } else { cmd = PARSERR_GENERIC; } @@ -406,9 +406,9 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { case TOKEN_VALUE: delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; + propValue = new char[strlen(params) + 1]; if (propValue) { - strcpy(propValue, (char *)params); + strcpy(propValue, params); } else { cmd = PARSERR_GENERIC; } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index c34b0378a1..b4e22a59ee 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -53,7 +53,7 @@ public: bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); const char *getFilename() { return _filename; } - bool parseProperty(byte *buffer, bool complete = true); + bool parseProperty(char *buffer, bool complete = true); bool _freezable; bool _ready; diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index be1e18c2c4..d2ff627f0a 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -153,7 +153,7 @@ void BaseScriptable::scSetBool(bool val) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transferSint32(TMEMBER(_refCount)); persistMgr->transferPtr(TMEMBER_PTR(_scProp)); persistMgr->transferPtr(TMEMBER_PTR(_scValue)); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index ab78c5ac7c..b1fcb42dcc 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -168,7 +168,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC ret = STATUS_OK; } } else { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { BaseEngine::LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); @@ -204,7 +204,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadBuffer(char *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -223,7 +223,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; @@ -231,7 +231,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_SPRITE) { BaseEngine::LOG(0, "'SPRITE' keyword expected."); return STATUS_FAILED; } @@ -240,30 +240,30 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa int frameCount = 1; BaseFrame *frame; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: - parser.scanStr((char *)params, "%b", &_continuous); + parser.scanStr(params, "%b", &_continuous); break; case TOKEN_EDITOR_MUTED: - parser.scanStr((char *)params, "%b", &_editorMuted); + parser.scanStr(params, "%b", &_editorMuted); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_LOOPING: - parser.scanStr((char *)params, "%b", &_looping); + parser.scanStr(params, "%b", &_looping); break; case TOKEN_PRECISE: - parser.scanStr((char *)params, "%b", &_precise); + parser.scanStr(params, "%b", &_precise); break; case TOKEN_STREAMED: - parser.scanStr((char *)params, "%b", &_streamed); + parser.scanStr(params, "%b", &_streamed); if (_streamed && lifeTime == -1) { lifeTime = 500; cacheType = CACHE_ALL; @@ -271,33 +271,33 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa break; case TOKEN_STREAMED_KEEP_LOADED: - parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + parser.scanStr(params, "%b", &_streamedKeepLoaded); break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_EDITOR_BG_FILE: if (_gameRef->_editorMode) { delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; + _editorBgFile = new char[strlen(params) + 1]; if (_editorBgFile) { - strcpy(_editorBgFile, (char *)params); + strcpy(_editorBgFile, params); } } break; case TOKEN_EDITOR_BG_OFFSET_X: - parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + parser.scanStr(params, "%d", &_editorBgOffsetX); break; case TOKEN_EDITOR_BG_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + parser.scanStr(params, "%d", &_editorBgOffsetY); break; case TOKEN_EDITOR_BG_ALPHA: - parser.scanStr((char *)params, "%d", &_editorBgAlpha); + parser.scanStr(params, "%d", &_editorBgAlpha); _editorBgAlpha = MIN<int32>(_editorBgAlpha, 255); _editorBgAlpha = MAX<int32>(_editorBgAlpha, 0); break; @@ -462,7 +462,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float return false; } - BasePlatform::setRectEmpty(rect); + rect->setEmpty(); for (uint32 i = 0; i < _frames.size(); i++) { Rect32 frame; Rect32 temp; @@ -520,29 +520,29 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool BaseSprite::persist(BasePersistenceManager *persistMgr) { BaseScriptHolder::persist(persistMgr); - persistMgr->transfer(TMEMBER(_canBreak)); - persistMgr->transfer(TMEMBER(_changed)); - persistMgr->transfer(TMEMBER(_paused)); - persistMgr->transfer(TMEMBER(_continuous)); - persistMgr->transfer(TMEMBER(_currentFrame)); - persistMgr->transfer(TMEMBER(_editorAllFrames)); - persistMgr->transfer(TMEMBER(_editorBgAlpha)); - persistMgr->transfer(TMEMBER(_editorBgFile)); - persistMgr->transfer(TMEMBER(_editorBgOffsetX)); - persistMgr->transfer(TMEMBER(_editorBgOffsetY)); - persistMgr->transfer(TMEMBER(_editorMuted)); - persistMgr->transfer(TMEMBER(_finished)); + persistMgr->transferBool(TMEMBER(_canBreak)); + persistMgr->transferBool(TMEMBER(_changed)); + persistMgr->transferBool(TMEMBER(_paused)); + persistMgr->transferBool(TMEMBER(_continuous)); + persistMgr->transferSint32(TMEMBER(_currentFrame)); + persistMgr->transferBool(TMEMBER(_editorAllFrames)); + persistMgr->transferSint32(TMEMBER(_editorBgAlpha)); + persistMgr->transferCharPtr(TMEMBER(_editorBgFile)); + persistMgr->transferSint32(TMEMBER(_editorBgOffsetX)); + persistMgr->transferSint32(TMEMBER(_editorBgOffsetY)); + persistMgr->transferBool(TMEMBER(_editorMuted)); + persistMgr->transferBool(TMEMBER(_finished)); _frames.persist(persistMgr); - persistMgr->transfer(TMEMBER(_lastFrameTime)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transferUint32(TMEMBER(_lastFrameTime)); + persistMgr->transferBool(TMEMBER(_looping)); + persistMgr->transferSint32(TMEMBER(_moveX)); + persistMgr->transferSint32(TMEMBER(_moveY)); persistMgr->transferPtr(TMEMBER_PTR(_owner)); - persistMgr->transfer(TMEMBER(_precise)); - persistMgr->transfer(TMEMBER(_streamed)); - persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + persistMgr->transferBool(TMEMBER(_precise)); + persistMgr->transferBool(TMEMBER(_streamed)); + persistMgr->transferBool(TMEMBER(_streamedKeepLoaded)); return STATUS_OK; diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 1387796895..54d595f655 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -53,7 +53,7 @@ public: void reset(); bool isChanged(); bool isFinished(); - bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(char *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY, uint32 alpha = kDefaultRgbaMod); bool _looping; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 8a8f63240b..38eebb067b 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -34,7 +34,6 @@ #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" @@ -54,7 +53,7 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _transparent = 0xFFFF00FF; _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); _editorSelected = false; @@ -97,7 +96,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::loadBuffer(char *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -121,13 +120,13 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; - BasePlatform::setRectEmpty(&rect); + rect.setEmpty(); char *surfaceFile = nullptr; delete _surface; _surface = nullptr; - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: surfaceFile = params; @@ -179,7 +178,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); + parseEditorProperty(params, false); break; } } @@ -208,7 +207,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } */ - if (BasePlatform::isRectEmpty(&rect)) { + if (rect.isRectEmpty()) { setDefaultRect(); } else { setRect(rect); @@ -219,7 +218,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { Rect32 BaseSubFrame::getRect() { if (_wantsDefaultRect && _surface) { - BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _rect.setRect(0, 0, _surface->getWidth(), _surface->getHeight()); _wantsDefaultRect = false; } return _rect; @@ -269,7 +268,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl Point32 origin(x, y); Rect32 oldRect = getRect(); Point32 newHotspot; - TransformStruct transform = TransformStruct(zoomX, zoomY, rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0); + TransformStruct transform = TransformStruct(zoomX, zoomY, (uint32)rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0); Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot); newOrigin = origin - newHotspot; res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform); @@ -294,11 +293,10 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; - BasePlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), - (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); + rect->setRect((int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), + (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); return true; } @@ -318,9 +316,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple } Rect32 rect; - BasePlatform::setRectEmpty(&rect); + rect.setEmpty(); if (_surface) { - BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + rect.setRect(0, 0, _surface->getWidth(), _surface->getHeight()); } if (!(rect == getRect())) { buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", getRect().left, getRect().top, getRect().right, getRect().bottom); @@ -376,7 +374,7 @@ void BaseSubFrame::setDefaultRect() { _wantsDefaultRect = true; } else { _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); } } @@ -386,27 +384,27 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_2DOnly)); - persistMgr->transfer(TMEMBER(_3DOnly)); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_hotspotX)); - persistMgr->transfer(TMEMBER(_hotspotY)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_wantsDefaultRect)); - - persistMgr->transfer(TMEMBER(_surfaceFilename)); - persistMgr->transfer(TMEMBER(_cKDefault)); - persistMgr->transfer(TMEMBER(_cKRed)); - persistMgr->transfer(TMEMBER(_cKGreen)); - persistMgr->transfer(TMEMBER(_cKBlue)); - persistMgr->transfer(TMEMBER(_lifeTime)); - - persistMgr->transfer(TMEMBER(_keepLoaded)); - persistMgr->transfer(TMEMBER(_mirrorX)); - persistMgr->transfer(TMEMBER(_mirrorY)); - persistMgr->transfer(TMEMBER(_transparent)); + persistMgr->transferBool(TMEMBER(_2DOnly)); + persistMgr->transferBool(TMEMBER(_3DOnly)); + persistMgr->transferUint32(TMEMBER(_alpha)); + persistMgr->transferBool(TMEMBER(_decoration)); + persistMgr->transferBool(TMEMBER(_editorSelected)); + persistMgr->transferSint32(TMEMBER(_hotspotX)); + persistMgr->transferSint32(TMEMBER(_hotspotY)); + persistMgr->transferRect32(TMEMBER(_rect)); + persistMgr->transferBool(TMEMBER(_wantsDefaultRect)); + + persistMgr->transferCharPtr(TMEMBER(_surfaceFilename)); + persistMgr->transferBool(TMEMBER(_cKDefault)); + persistMgr->transferByte(TMEMBER(_cKRed)); + persistMgr->transferByte(TMEMBER(_cKGreen)); + persistMgr->transferByte(TMEMBER(_cKBlue)); + persistMgr->transferSint32(TMEMBER(_lifeTime)); + + persistMgr->transferBool(TMEMBER(_keepLoaded)); + persistMgr->transferBool(TMEMBER(_mirrorX)); + persistMgr->transferBool(TMEMBER(_mirrorY)); + persistMgr->transferUint32(TMEMBER(_transparent)); return STATUS_OK; } diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index ba3d5b955a..4e164467e2 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -51,7 +51,7 @@ public: bool _editorSelected; BaseSubFrame(BaseGame *inGame); virtual ~BaseSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool loadBuffer(char *buffer, int lifeTime, bool keepLoaded); bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); const char* getSurfaceFilename(); diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index 09ac80e9de..a6e8b17927 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/base_viewport.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_persistence_manager.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/gfx/base_renderer.h" namespace Wintermute { @@ -38,7 +37,7 @@ IMPLEMENT_PERSISTENT(BaseViewport, false) ////////////////////////////////////////////////////////////////////////// BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); + _rect.setEmpty(); _mainObject = nullptr; _offsetX = _offsetY = 0; } @@ -56,9 +55,9 @@ bool BaseViewport::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); persistMgr->transferPtr(TMEMBER_PTR(_mainObject)); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transferSint32(TMEMBER(_offsetX)); + persistMgr->transferSint32(TMEMBER(_offsetY)); + persistMgr->transferRect32(TMEMBER(_rect)); return STATUS_OK; } @@ -73,7 +72,7 @@ bool BaseViewport::setRect(int32 left, int32 top, int32 right, int32 bottom, boo bottom = MIN(bottom, BaseEngine::instance().getRenderer()->getHeight()); } - BasePlatform::setRect(&_rect, left, top, right, bottom); + _rect.setRect(left, top, right, bottom); _offsetX = left; _offsetY = top; return STATUS_OK; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 7391d819fc..808dc9e00d 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -117,6 +117,8 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { if (fixedFilename.contains(':')) { if (fixedFilename.hasPrefix("c:/windows/fonts/")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" fixedFilename = filename.c_str() + 14; + } else if (fixedFilename.hasPrefix("c:/carol6/svn/data/")) { // Carol Reed 6: Black Circle refers to "c:\carol6\svn\data\sprites\system\help.png" + fixedFilename = fixedFilename.c_str() + 19; } else { error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); } @@ -149,7 +151,8 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { } if (compressed) { - uint32 dataOffset, compSize, uncompSize; + uint32 dataOffset, compSize; + unsigned long uncompSize; dataOffset = file->readUint32LE(); compSize = file->readUint32LE(); uncompSize = file->readUint32LE(); @@ -171,7 +174,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { file->seek(dataOffset + prefixSize, SEEK_SET); file->read(compBuffer, compSize); - if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { + if (Common::uncompress(data, &uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); delete[] compBuffer; delete file; diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 26bc0e7985..2a394616d1 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -118,18 +118,18 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_END - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { return false; } - byte *workBuffer = buffer; + char *workBuffer = buffer; char *params; BaseParser parser; bool ret = false; - if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { + if (parser.getCommand(&workBuffer, commands, ¶ms) == TOKEN_TTFONT) { ret = true; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 890a9a2f83..95f9a83a6a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -37,7 +37,6 @@ #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" namespace Wintermute { @@ -253,7 +252,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { tileWidth = _widths[c]; } - BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + rect.setRect(col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1) * _tileHeight); bool handled = false; if (_sprite) { _sprite->getCurrentFrame(); @@ -272,7 +271,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// bool BaseFontBitmap::loadFile(const Common::String &filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -311,7 +310,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadBuffer(byte *buffer) { +bool BaseFontBitmap::loadBuffer(char *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -335,11 +334,11 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { int cmd; BaseParser parser; - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_FONT) { _gameRef->LOG(0, "'FONT' keyword expected."); return STATUS_FAILED; } - buffer = (byte *)params; + buffer = params; int widths[300]; int num = 0, defaultWidth = 8; @@ -354,15 +353,15 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { int spaceWidth = 0; int expandWidth = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: - surfaceFile = (char *)params; + surfaceFile = params; break; case TOKEN_SPRITE: - spriteFile = (char *)params; + spriteFile = params; break; case TOKEN_TRANSPARENT: @@ -418,7 +417,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); + parseEditorProperty(params, false); break; } @@ -496,13 +495,13 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { BaseFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); + persistMgr->transferSint32(TMEMBER(_numColumns)); persistMgr->transferPtr(TMEMBER_PTR(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transferSint32(TMEMBER(_tileHeight)); + persistMgr->transferSint32(TMEMBER(_tileWidth)); persistMgr->transferPtr(TMEMBER_PTR(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); + persistMgr->transferSint32(TMEMBER(_widthsFrame)); if (persistMgr->getIsSaving()) { persistMgr->putBytes(_widths, sizeof(_widths)); @@ -511,8 +510,8 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { } - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); + persistMgr->transferBool(TMEMBER(_fontextFix)); + persistMgr->transferBool(TMEMBER(_wholeCell)); return STATUS_OK; diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index c810777446..77620d8b88 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -37,7 +37,7 @@ class BaseSubFrame; class BaseFontBitmap : public BaseFont { public: DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) - bool loadBuffer(byte *Buffer); + bool loadBuffer(char *buffer); bool loadFile(const Common::String &filename); virtual int getTextWidth(const byte *text, int maxLength = -1) override; virtual int getTextHeight(const byte *text, int width) override; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index e073f27970..55481c7c03 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -34,7 +34,6 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" @@ -227,7 +226,7 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign // and paint it if (surface) { Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + rc.setRect(0, 0, surface->getWidth(), surface->getHeight()); for (uint32 i = 0; i < _layers.size(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = renderer->_forceAlphaColor; @@ -286,6 +285,26 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, BaseSurface *retSurface = _gameRef->_renderer->createSurface(); Graphics::Surface *convertedSurface = surface->convertTo(_gameRef->_renderer->getPixelFormat()); + + if (_deletableFont) { + // Reconstruct the alpha channel of the font. + + // Since we painted it with color 0xFFFFFFFF onto a black background, + // the alpha channel is gone, but the color value of each pixel corresponds + // to its original alpha value. + + Graphics::PixelFormat format = _gameRef->_renderer->getPixelFormat(); + uint32 *pixels = (uint32 *)convertedSurface->getPixels(); + + // This is a Surface we created ourselves, so no empty space between rows. + for (int i = 0; i < surface->w * surface->h; ++i) { + uint8 a, r, g, b; + format.colorToRGB(*pixels, r, g, b); + a = r; + *pixels++ = format.ARGBToColor(a, r, g, b); + } + } + retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); surface->free(); @@ -304,7 +323,7 @@ int BaseFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// bool BaseFontTT::loadFile(const Common::String &filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -341,7 +360,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadBuffer(byte *buffer) { +bool BaseFontTT::loadBuffer(char *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -361,15 +380,15 @@ bool BaseFontTT::loadBuffer(byte *buffer) { int cmd; BaseParser parser; - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_TTFONT) { _gameRef->LOG(0, "'TTFONT' keyword expected."); return STATUS_FAILED; } - buffer = (byte *)params; + buffer = params; uint32 baseColor = 0x00000000; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_SIZE: parser.scanStr(params, "%d", &_fontHeight); @@ -419,7 +438,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { case TOKEN_LAYER: { BaseTTFontLayer *layer = new BaseTTFontLayer; - if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) { + if (layer && DID_SUCCEED(parseLayer(layer, params))) { _layers.add(layer); } else { delete layer; @@ -452,7 +471,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { +bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, char *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -464,7 +483,7 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { int cmd; BaseParser parser; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_OFFSET_X: parser.scanStr(params, "%d", &layer->_offsetX); @@ -501,25 +520,25 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { BaseFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); + persistMgr->transferBool(TMEMBER(_isBold)); + persistMgr->transferBool(TMEMBER(_isItalic)); + persistMgr->transferBool(TMEMBER(_isUnderline)); + persistMgr->transferBool(TMEMBER(_isStriked)); + persistMgr->transferSint32(TMEMBER(_fontHeight)); + persistMgr->transferCharPtr(TMEMBER(_fontFile)); // persist layers int32 numLayers; if (persistMgr->getIsSaving()) { numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); + persistMgr->transferSint32(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { _layers[i]->persist(persistMgr); } } else { numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); + persistMgr->transferSint32(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { BaseTTFontLayer *layer = new BaseTTFontLayer; layer->persist(persistMgr); @@ -559,7 +578,7 @@ bool BaseFontTT::initFont() { } if (file) { - _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight, 96); // Use the same dpi as WME (96 vs 72). _font = _deletableFont; BaseFileManager::getEngineInstance()->closeFile(file); file = nullptr; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index fdbae30684..2d7ebba691 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -84,9 +84,9 @@ public: } bool persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); + persistMgr->transferSint32(TMEMBER(_offsetX)); + persistMgr->transferSint32(TMEMBER(_offsetY)); + persistMgr->transferUint32(TMEMBER(_color)); return STATUS_OK; } @@ -105,7 +105,7 @@ public: virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1) override; virtual int getLetterHeight() override; - bool loadBuffer(byte *buffer); + bool loadBuffer(char *buffer); bool loadFile(const Common::String &filename); float getLineHeight() const { @@ -116,7 +116,7 @@ public: void initLoop(); private: - bool parseLayer(BaseTTFontLayer *layer, byte *buffer); + bool parseLayer(BaseTTFontLayer *layer, char *buffer); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 1f171209d7..858a7fc6dc 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -65,7 +65,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _loadImageX = _loadImageY = 0; _width = _height = _bPP = 0; - BasePlatform::setRectEmpty(&_monitorRect); + _monitorRect.setEmpty(); _realWidth = _realHeight = 0; _drawOffsetX = _drawOffsetY = 0; @@ -173,12 +173,12 @@ void BaseRenderer::endSaveLoad() { } void BaseRenderer::persistSaveLoadImages(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); + persistMgr->transferString(TMEMBER(_loadImageName)); + persistMgr->transferString(TMEMBER(_saveImageName)); + persistMgr->transferSint32(TMEMBER(_saveImageX)); + persistMgr->transferSint32(TMEMBER(_saveImageY)); + persistMgr->transferSint32(TMEMBER(_loadImageX)); + persistMgr->transferSint32(TMEMBER(_loadImageY)); } ////////////////////////////////////////////////////////////////////// @@ -374,7 +374,7 @@ bool BaseRenderer::displayIndicator() { } if (_saveLoadImage && !_hasDrawnSaveLoadImage) { Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + rc.setRect(0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) { _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); } else { diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 31dc2a022d..b6615bc8fc 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -84,7 +84,7 @@ public: * @param a the alpha component to fade too. * @param rect the portion of the screen to fade (if nullptr, the entire screen will be faded). */ - virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = nullptr) = 0; + virtual void fadeToColor(byte r, byte g, byte b, byte a) = 0; virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); // Unused outside indicator-display virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); // Unused outside indicator-display diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 8a0603734e..a53748e9aa 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -50,13 +50,13 @@ public: virtual bool displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); - virtual bool displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) = 0; virtual bool restore(); virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual bool create(int width, int height); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index e6d769c653..ff63789d18 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -51,22 +51,19 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); _blankSurface = new Graphics::Surface(); - _drawNum = 1; + _lastFrameIter = _renderQueue.end(); _needsFlip = true; - _spriteBatch = false; - _batchNum = 0; _skipThisFrame = false; - _previousTicket = nullptr; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; - _colorMod = kDefaultRgbaMod; _dirtyRect = nullptr; _disableDirtyRects = false; - _tempDisableDirtyRects = 0; if (ConfMan.hasKey("dirty_rects")) { _disableDirtyRects = !ConfMan.getBool("dirty_rects"); } + + _lastScreenChangeID = g_system->getScreenChangeID(); } ////////////////////////////////////////////////////////////////////////// @@ -155,20 +152,24 @@ bool BaseRenderOSystem::indicatorFlip() { } bool BaseRenderOSystem::flip() { - if (_renderQueue.size() > DIRTY_RECT_LIMIT) { - _tempDisableDirtyRects++; - } if (_skipThisFrame) { _skipThisFrame = false; delete _dirtyRect; _dirtyRect = nullptr; g_system->updateScreen(); _needsFlip = false; - _drawNum = 1; + + // Reset ticketing state + _lastFrameIter = _renderQueue.end(); + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + (*it)->_wantsDraw = false; + } + addDirtyRect(_renderRect); return true; } - if (!_tempDisableDirtyRects && !_disableDirtyRects) { + if (!_disableDirtyRects) { drawTickets(); } else { // Clear the scale-buffered tickets that wasn't reused. @@ -184,33 +185,23 @@ bool BaseRenderOSystem::flip() { } } } - if (_needsFlip || _disableDirtyRects || _tempDisableDirtyRects) { - if (_disableDirtyRects || _tempDisableDirtyRects) { + + int oldScreenChangeID = _lastScreenChangeID; + _lastScreenChangeID = g_system->getScreenChangeID(); + bool screenChanged = _lastScreenChangeID != oldScreenChangeID; + + if (_needsFlip || _disableDirtyRects || screenChanged) { + if (_disableDirtyRects || screenChanged) { g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); } // g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); delete _dirtyRect; _dirtyRect = nullptr; - g_system->updateScreen(); _needsFlip = false; } - _drawNum = 1; - - if (_tempDisableDirtyRects && !_disableDirtyRects) { - _tempDisableDirtyRects--; - if (!_tempDisableDirtyRects) { - Common::Rect screen(_screenRect.top, _screenRect.left, _screenRect.bottom, _screenRect.right); - addDirtyRect(screen); - - // The queue has been ignored but updated, and is guaranteed to be in draw-order when run without dirty-rects. - RenderQueueIterator it = _renderQueue.begin(); - int drawNum = 1; - while (it != _renderQueue.end()) { - (*it)->_drawNum = drawNum++; - ++it; - } - } - } + _lastFrameIter = _renderQueue.end(); + + g_system->updateScreen(); return STATUS_OK; } @@ -218,7 +209,7 @@ bool BaseRenderOSystem::flip() { ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects && !_tempDisableDirtyRects) { + if (!_disableDirtyRects) { return STATUS_OK; } if (!rect) { @@ -243,22 +234,16 @@ void BaseRenderOSystem::fade(uint16 alpha) { } ////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { +void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a) { Common::Rect fillRect; - if (rect) { - fillRect.left = rect->left; - fillRect.top = rect->top; - fillRect.setWidth(rect->width()); - fillRect.setHeight(rect->height()); - } else { - Rect32 rc; - _gameRef->getCurrentViewportRect(&rc); - fillRect.left = (int16)rc.left; - fillRect.top = (int16)rc.top; - fillRect.setWidth((int16)(rc.right - rc.left)); - fillRect.setHeight((int16)(rc.bottom - rc.top)); - } + Rect32 rc; + _gameRef->getCurrentViewportRect(&rc); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); + modTargetRect(&fillRect); //TODO: This is only here until I'm sure about the final pixelformat @@ -285,22 +270,14 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform) { - if (_tempDisableDirtyRects || _disableDirtyRects) { + if (_disableDirtyRects) { RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform); - ticket->_transform._rgbaMod = _colorMod; ticket->_wantsDraw = true; _renderQueue.push_back(ticket); - _previousTicket = ticket; drawFromSurface(ticket); return; } - // Start searching from the beginning for the first and second items (since it's empty the first time around - // then keep incrementing the start-position, to avoid comparing against already used tickets. - if (_drawNum == 0 || _drawNum == 1) { - _lastAddedTicket = _renderQueue.begin(); - } - // Skip rects that are completely outside the screen: if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; @@ -308,28 +285,19 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (owner) { // Fade-tickets are owner-less RenderTicket compare(owner, nullptr, srcRect, dstRect, transform); - compare._batchNum = _batchNum; - if (_spriteBatch) { - _batchNum++; - } - RenderQueueIterator it; + RenderQueueIterator it = _lastFrameIter; + ++it; // Avoid calling end() and operator* every time, when potentially going through // LOTS of tickets. RenderQueueIterator endIterator = _renderQueue.end(); RenderTicket *compareTicket = nullptr; - for (it = _lastAddedTicket; it != endIterator; ++it) { + for (; it != endIterator; ++it) { compareTicket = *it; if (*(compareTicket) == compare && compareTicket->_isValid) { - compareTicket->_transform._rgbaMod = transform._rgbaMod; if (_disableDirtyRects) { drawFromSurface(compareTicket); } else { - drawFromTicket(compareTicket); - _previousTicket = compareTicket; - } - if (_renderQueue.size() > DIRTY_RECT_LIMIT) { - drawTickets(); - _tempDisableDirtyRects = 3; + drawFromQueuedTicket(it); } return; } @@ -338,57 +306,13 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform); if (!_disableDirtyRects) { drawFromTicket(ticket); - _previousTicket = ticket; } else { ticket->_wantsDraw = true; _renderQueue.push_back(ticket); - _previousTicket = ticket; drawFromSurface(ticket); } } -void BaseRenderOSystem::repeatLastDraw(int offsetX, int offsetY, int numTimesX, int numTimesY) { - if (_previousTicket && _lastAddedTicket != _renderQueue.end()) { - RenderTicket *origTicket = _previousTicket; - - // Make sure drawSurface WILL start from the correct _lastAddedTicket - if (!_tempDisableDirtyRects && !_disableDirtyRects && *_lastAddedTicket != origTicket) { - RenderQueueIterator it; - RenderQueueIterator endIterator = _renderQueue.end(); - for (it = _renderQueue.begin(); it != endIterator; ++it) { - if ((*it) == _previousTicket) { - _lastAddedTicket = it; - break; - } - } - } - Common::Rect srcRect(0, 0, 0, 0); - srcRect.setWidth(origTicket->getSrcRect()->width()); - srcRect.setHeight(origTicket->getSrcRect()->height()); - - Common::Rect dstRect = origTicket->_dstRect; - int initLeft = dstRect.left; - int initRight = dstRect.right; - - TransformStruct temp = TransformStruct(kDefaultZoomX, kDefaultZoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, BLEND_NORMAL, kDefaultRgbaMod, false, false, kDefaultOffsetX, kDefaultOffsetY); - - for (int i = 0; i < numTimesY; i++) { - if (i == 0) { - dstRect.translate(offsetX, 0); - } - for (int j = (i == 0 ? 1 : 0); j < numTimesX; j++) { - drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, temp); - dstRect.translate(offsetX, 0); - } - dstRect.left = initLeft; - dstRect.right = initRight; - dstRect.translate(0, offsetY); - } - } else { - error("Repeat-draw failed (did you forget to draw something before this?)"); - } -} - void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); renderTicket->_isValid = false; @@ -406,59 +330,37 @@ void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { renderTicket->_wantsDraw = true; - // A new item always has _drawNum == 0 - if (renderTicket->_drawNum == 0) { - // In-order - if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { - renderTicket->_drawNum = _drawNum++; - _renderQueue.push_back(renderTicket); - addDirtyRect(renderTicket->_dstRect); - ++_lastAddedTicket; - } else { - // Before something - RenderQueueIterator pos; - for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { - if ((*pos)->_drawNum >= _drawNum) { - break; - } - } - _renderQueue.insert(pos, renderTicket); - renderTicket->_drawNum = _drawNum++; - // Increment the following tickets, so they still are in line - RenderQueueIterator it; - for (it = pos; it != _renderQueue.end(); ++it) { - (*it)->_drawNum++; - (*it)->_wantsDraw = false; - } - addDirtyRect(renderTicket->_dstRect); - _lastAddedTicket = pos; - } + + ++_lastFrameIter; + // In-order + if (_renderQueue.empty() || _lastFrameIter == _renderQueue.end()) { + _lastFrameIter--; + _renderQueue.push_back(renderTicket); + ++_lastFrameIter; + addDirtyRect(renderTicket->_dstRect); } else { - // Was drawn last round, still in the same order - if (_drawNum == renderTicket->_drawNum) { - _drawNum++; - ++_lastAddedTicket; - } else { - // Remove the ticket from the list - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it) == renderTicket) { - it = _renderQueue.erase(it); - break; - } else { - ++it; - } - } - if (it != _renderQueue.end()) { - // Decreement the following tickets. - for (; it != _renderQueue.end(); ++it) { - (*it)->_drawNum--; - } - } - // Is not in order, so readd it as if it was a new ticket - renderTicket->_drawNum = 0; - drawFromTicket(renderTicket); - } + // Before something + RenderQueueIterator pos = _lastFrameIter; + _renderQueue.insert(pos, renderTicket); + --_lastFrameIter; + addDirtyRect(renderTicket->_dstRect); + } +} + +void BaseRenderOSystem::drawFromQueuedTicket(const RenderQueueIterator &ticket) { + RenderTicket *renderTicket = *ticket; + assert(!renderTicket->_wantsDraw); + renderTicket->_wantsDraw = true; + + ++_lastFrameIter; + // Not in the same order? + if (*_lastFrameIter != renderTicket) { + --_lastFrameIter; + // Remove the ticket from the list + assert(*_lastFrameIter != renderTicket); + _renderQueue.erase(ticket); + // Is not in order, so readd it as if it was a new ticket + drawFromTicket(renderTicket); } } @@ -477,16 +379,13 @@ void BaseRenderOSystem::drawTickets() { // Note: We draw invalid tickets too, otherwise we wouldn't be honouring // the draw request they obviously made BEFORE becoming invalid, either way // we have a copy of their data, so their invalidness won't affect us. - uint32 decrement = 0; while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false) { RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); it = _renderQueue.erase(it); delete ticket; - decrement++; } else { - (*it)->_drawNum -= decrement; ++it; } } @@ -499,17 +398,12 @@ void BaseRenderOSystem::drawTickets() { } return; } - // The color-mods are stored in the RenderTickets on add, since we set that state again during - // draw, we need to keep track of what it was prior to draw. - uint32 oldColorMod = _colorMod; // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); - _drawNum = 1; + _lastFrameIter = _renderQueue.end(); for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { RenderTicket *ticket = *it; - assert(ticket->_drawNum == _drawNum); - ++_drawNum; if (ticket->_dstRect.intersects(*_dirtyRect)) { // dstClip is the area we want redrawn. Common::Rect dstClip(ticket->_dstRect); @@ -522,7 +416,6 @@ void BaseRenderOSystem::drawTickets() { // convert from screen-coords to surface-coords. dstClip.translate(-offsetX, -offsetY); - _colorMod = ticket->_transform._rgbaMod; drawFromSurface(ticket, &pos, &dstClip); _needsFlip = true; } @@ -531,21 +424,15 @@ void BaseRenderOSystem::drawTickets() { } g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - // Revert the colorMod-state. - _colorMod = oldColorMod; - it = _renderQueue.begin(); // Clean out the old tickets - decrement = 0; while (it != _renderQueue.end()) { if ((*it)->_isValid == false) { RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); it = _renderQueue.erase(it); delete ticket; - decrement++; } else { - (*it)->_drawNum -= decrement; ++it; } } @@ -565,7 +452,7 @@ void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *dstR bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { // This function isn't used outside of indicator-displaying, and thus quite unused in // BaseRenderOSystem when dirty-rects are enabled. - if (!_tempDisableDirtyRects && !_disableDirtyRects && !_indicatorDisplay) { + if (!_disableDirtyRects && !_indicatorDisplay) { error("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); } @@ -671,12 +558,10 @@ void BaseRenderOSystem::endSaveLoad() { it = _renderQueue.erase(it); delete ticket; } - _lastAddedTicket = _renderQueue.begin(); - _previousTicket = nullptr; // HACK: After a save the buffer will be drawn before the scripts get to update it, // so just skip this single frame. _skipThisFrame = true; - _drawNum = 1; + _lastFrameIter = _renderQueue.end(); _renderSurface->fillRect(Common::Rect(0, 0, _renderSurface->h, _renderSurface->w), _renderSurface->format.ARGBToColor(255, 0, 0, 0)); g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); @@ -684,14 +569,10 @@ void BaseRenderOSystem::endSaveLoad() { } bool BaseRenderOSystem::startSpriteBatch() { - _spriteBatch = true; - _batchNum = 1; return STATUS_OK; } bool BaseRenderOSystem::endSpriteBatch() { - _spriteBatch = false; - _batchNum = 0; return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 928a52d4fc..8996c8b2e8 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -62,6 +62,8 @@ public: BaseRenderOSystem(BaseGame *inGame); ~BaseRenderOSystem(); + typedef Common::List<RenderTicket *>::iterator RenderQueueIterator; + Common::String getName() const; bool initRenderer(int width, int height, bool windowed) override; @@ -70,7 +72,7 @@ public: bool fill(byte r, byte g, byte b, Common::Rect *rect = nullptr) override; Graphics::PixelFormat getPixelFormat() const override; void fade(uint16 alpha) override; - void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = nullptr) override; + void fadeToColor(byte r, byte g, byte b, byte a) override; bool drawLine(int x1, int y1, int x2, int y2, uint32 color) override; @@ -79,11 +81,16 @@ public: void invalidateTicket(RenderTicket *renderTicket); void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); /** - * Insert a ticket into the queue, adding a dirty rect if it's - * new, or out-of-order from last draw from the ticket. - * param renderTicket the ticket to be added. + * Insert a new ticket into the queue, adding a dirty rect + * @param renderTicket the ticket to be added. */ void drawFromTicket(RenderTicket *renderTicket); + /** + * Re-insert an existing ticket into the queue, adding a dirty rect + * out-of-order from last draw from the ticket. + * @param ticket iterator pointing to the ticket to be added. + */ + void drawFromQueuedTicket(const RenderQueueIterator &ticket); bool setViewport(int left, int top, int right, int bottom) override; bool setViewport(Rect32 *rect) override { return BaseRenderer::setViewport(rect); } @@ -104,7 +111,6 @@ public: virtual bool endSpriteBatch() override; void endSaveLoad(); void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform); - void repeatLastDraw(int offsetX, int offsetY, int numTimesX, int numTimesY); BaseSurface *createSurface() override; private: /** @@ -120,14 +126,11 @@ private: void drawFromSurface(RenderTicket *ticket); // Dirty-rects: void drawFromSurface(RenderTicket *ticket, Common::Rect *dstRect, Common::Rect *clipRect); - typedef Common::List<RenderTicket *>::iterator RenderQueueIterator; Common::Rect *_dirtyRect; Common::List<RenderTicket *> _renderQueue; - RenderQueueIterator _lastAddedTicket; - RenderTicket *_previousTicket; bool _needsFlip; - uint32 _drawNum; ///< The global number of the current draw-operation. + RenderQueueIterator _lastFrameIter; Common::Rect _renderRect; Graphics::Surface *_renderSurface; Graphics::Surface *_blankSurface; @@ -138,15 +141,12 @@ private: int _borderBottom; bool _disableDirtyRects; - uint32 _tempDisableDirtyRects; - bool _spriteBatch; - uint32 _batchNum; float _ratioX; float _ratioY; - uint32 _colorMod; uint32 _clearColor; bool _skipThisFrame; + int _lastScreenChangeID; // previous value of OSystem::getScreenChangeID() }; } // End of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index df8cabd974..9ec8573a87 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -37,6 +37,7 @@ #include "graphics/decoders/jpeg.h" #include "graphics/decoders/tga.h" #include "engines/wintermute/graphics/transparent_surface.h" +#include "engines/wintermute/graphics/transform_tools.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/stream.h" @@ -143,39 +144,36 @@ bool BaseSurfaceOSystem::finishLoad() { _width = image->getSurface()->w; _height = image->getSurface()->h; - bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); + bool isSaveGameGrayscale = _filename.matchString("savegame:*g", true); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); // FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO } - // no alpha, set color key - /* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. _surface->free(); delete _surface; bool needsColorKey = false; bool replaceAlpha = true; - if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - needsColorKey = true; - replaceAlpha = false; - } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + if (image->getSurface()->format.bytesPerPixel == 1) { + if (!image->getPalette()) { + error("Missing palette while loading 8bit image %s", _filename.c_str()); + } _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); needsColorKey = true; - } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); - if (image->getSurface()->format.bytesPerPixel == 3) { - needsColorKey = true; - } } else { - _surface = new Graphics::Surface(); - _surface->copyFrom(*image->getSurface()); - if (_surface->format.aBits() == 0) { + if (image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*image->getSurface()); + } + + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + // 32 bpp BMPs have nothing useful in their alpha-channel -> color-key + needsColorKey = true; + replaceAlpha = false; + } else if (image->getSurface()->format.aBits() == 0) { needsColorKey = true; } } @@ -353,20 +351,20 @@ bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 al } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; - return drawSprite(x, y, &rect, nullptr, TransformStruct(zoomX, zoomY, blendMode, alpha, mirrorX, mirrorY)); + return drawSprite(x, y, &rect, nullptr, TransformStruct((int32)zoomX, (int32)zoomY, blendMode, alpha, mirrorX, mirrorY)); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; TransformStruct transform; if (transparent) { - transform = TransformStruct(zoomX, zoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY); + transform = TransformStruct((int32)zoomX, (int32)zoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY); } else { - transform = TransformStruct(zoomX, zoomY, mirrorX, mirrorY); + transform = TransformStruct((int32)zoomX, (int32)zoomY, mirrorX, mirrorY); } return drawSprite(x, y, &rect, nullptr, transform); } @@ -384,6 +382,14 @@ bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newR } ////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) { + assert(numTimesX > 0 && numTimesY > 0); + TransformStruct transform(numTimesX, numTimesY); + return drawSprite(x, y, &rect, nullptr, transform); +} + + +////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transform) { BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); @@ -395,13 +401,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, transform._rgbaMod = renderer->_forceAlphaColor; } -#if 0 // These are kept for reference if BlendMode is reimplemented at some point. - if (alphaDisable) { - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - } else { - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); - } -#endif // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. Common::Rect srcRect; @@ -411,26 +410,26 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, srcRect.setHeight(rect->bottom - rect->top); Common::Rect position; - position.left = x + transform._offset.x; - position.top = y + transform._offset.y; - // Crop off-by-ones: - if (position.left == -1) { - position.left = 0; // TODO: Something is wrong - } - if (position.top == -1) { - position.top = 0; // TODO: Something is wrong - } if (newRect) { position.top = y; position.left = x; - position.right = x + newRect->width(); - position.bottom = y + newRect->height(); position.setWidth(newRect->width()); position.setHeight(newRect->height()); } else { - position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / kDefaultZoomX)); - position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / kDefaultZoomY)); + + Rect32 r; + r.top = 0; + r.left = 0; + r.setWidth(rect->width()); + r.setHeight(rect->height()); + + r = TransformTools::newRect(r, transform, 0); + + position.top = r.top + y + transform._offset.y; + position.left = r.left + x + transform._offset.x; + position.setWidth(r.width() * transform._numTimesX); + position.setHeight(r.height() * transform._numTimesY); } renderer->modTargetRect(&position); @@ -446,12 +445,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, return STATUS_OK; } -bool BaseSurfaceOSystem::repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) { - BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); - renderer->repeatLastDraw(offsetX, offsetY, numTimesX, numTimesY); - return STATUS_OK; -} - bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->free(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 6cf19d00fb..67f45f66db 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -52,13 +52,13 @@ public: bool endPixelOp() override; - bool displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override; bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; - bool displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) override; - bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override; + virtual bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override; /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp index b1720c1b0b..1cd35e3b04 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp +++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp @@ -38,11 +38,9 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), - _drawNum(0), _isValid(true), _wantsDraw(true), _transform(transform) { - _batchNum = 0; if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -52,13 +50,22 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); } // Then scale it if necessary + // + // NB: The numTimesX/numTimesY properties don't yet mix well with + // scaling and rotation, but there is no need for that functionality at + // the moment. + // NB: Mirroring and rotation are probably done in the wrong order. + // (Mirroring should most likely be done before rotation. See also + // TransformTools.) if (_transform._angle != kDefaultAngle) { TransparentSurface src(*_surface, false); Graphics::Surface *temp = src.rotoscale(transform); _surface->free(); delete _surface; _surface = temp; - } else if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + } else if ((dstRect->width() != srcRect->width() || + dstRect->height() != srcRect->height()) && + _transform._numTimesX * _transform._numTimesY == 1) { TransparentSurface src(*_surface, false); Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); _surface->free(); @@ -67,14 +74,6 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s } } else { _surface = nullptr; - - if (transform._angle != kDefaultAngle) { // Make sure comparison-tickets get the correct width - Rect32 newDstRect; - Point32 newHotspot; - newDstRect = TransformTools::newRect(_srcRect, transform, &newHotspot); - _dstRect.setWidth(newDstRect.right - newDstRect.left); - _dstRect.setHeight(newDstRect.bottom - newDstRect.top); - } } } @@ -87,7 +86,6 @@ RenderTicket::~RenderTicket() { bool RenderTicket::operator==(const RenderTicket &t) const { if ((t._owner != _owner) || - (t._batchNum != _batchNum) || (t._transform != _transform) || (t._dstRect != _dstRect) || (t._srcRect != _srcRect) @@ -107,12 +105,24 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const { if (_owner) { if (_transform._alphaDisable) { - src._alphaMode = TransparentSurface::ALPHA_OPAQUE; + src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE); } else { - src._alphaMode = _owner->getAlphaType(); + src.setAlphaMode(_owner->getAlphaType()); + } + } + + int y = _dstRect.top; + int w = _dstRect.width() / _transform._numTimesX; + int h = _dstRect.height() / _transform._numTimesY; + + for (int ry = 0; ry < _transform._numTimesY; ++ry) { + int x = _dstRect.left; + for (int rx = 0; rx < _transform._numTimesX; ++rx) { + src.blit(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height()); + x += w; } + y += h; } - src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height()); } void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const { @@ -121,18 +131,58 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect if (!clipRect) { doDelete = true; clipRect = new Common::Rect(); - clipRect->setWidth(getSurface()->w); - clipRect->setHeight(getSurface()->h); + clipRect->setWidth(getSurface()->w * _transform._numTimesX); + clipRect->setHeight(getSurface()->h * _transform._numTimesY); } if (_owner) { if (_transform._alphaDisable) { - src._alphaMode = TransparentSurface::ALPHA_OPAQUE; + src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE); } else { - src._alphaMode = _owner->getAlphaType(); + src.setAlphaMode(_owner->getAlphaType()); + } + } + + if (_transform._numTimesX * _transform._numTimesY == 1) { + + src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height(), _transform._blendMode); + + } else { + + // clipRect is a subrect of the full numTimesX*numTimesY rect + Common::Rect subRect; + + int y = 0; + int w = getSurface()->w; + int h = getSurface()->h; + assert(w == _dstRect.width() / _transform._numTimesX); + assert(h == _dstRect.height() / _transform._numTimesY); + + int basex = dstRect->left - clipRect->left; + int basey = dstRect->top - clipRect->top; + + for (int ry = 0; ry < _transform._numTimesY; ++ry) { + int x = 0; + for (int rx = 0; rx < _transform._numTimesX; ++rx) { + + subRect.left = x; + subRect.top = y; + subRect.setWidth(w); + subRect.setHeight(h); + + if (subRect.intersects(*clipRect)) { + subRect.clip(*clipRect); + subRect.translate(-x, -y); + src.blit(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect, _transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode); + + } + + x += w; + } + y += h; } } - src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height()); + if (doDelete) { delete clipRect; } diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.h b/engines/wintermute/base/gfx/osystem/render_ticket.h index 875102d01c..e824c09fe7 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.h +++ b/engines/wintermute/base/gfx/osystem/render_ticket.h @@ -52,7 +52,7 @@ class BaseSurfaceOSystem; class RenderTicket { public: RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, TransformStruct transform); - RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0), _transform(TransformStruct()) {} + RenderTicket() : _isValid(true), _wantsDraw(false), _transform(TransformStruct()) {} ~RenderTicket(); const Graphics::Surface *getSurface() const { return _surface; } // Non-dirty-rects: @@ -61,11 +61,9 @@ public: void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const; Common::Rect _dstRect; - uint32 _batchNum; bool _isValid; bool _wantsDraw; - uint32 _drawNum; TransformStruct _transform; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index aaffa0965a..061352b60f 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -38,7 +38,6 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/math.h" @@ -50,7 +49,7 @@ IMPLEMENT_PERSISTENT(PartEmitter, false) PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { _width = _height = 0; - BasePlatform::setRectEmpty(&_border); + _border.setEmpty(); _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; _angle1 = _angle2 = 0; @@ -198,7 +197,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); - if (!BasePlatform::isRectEmpty(&_border)) { + if (!_border.isRectEmpty()) { int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); @@ -386,7 +385,7 @@ bool PartEmitter::compareZ(const PartParticle *p1, const PartParticle *p2) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::setBorder(int x, int y, int width, int height) { - BasePlatform::setRect(&_border, x, y, x + width, y + height); + _border.setRect(x, y, x + width, y + height); return STATUS_OK; } @@ -1157,44 +1156,44 @@ const char *PartEmitter::scToString() { bool PartEmitter::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); + persistMgr->transferSint32(TMEMBER(_width)); + persistMgr->transferSint32(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); + persistMgr->transferSint32(TMEMBER(_angle1)); + persistMgr->transferSint32(TMEMBER(_angle2)); persistMgr->transferFloat(TMEMBER(_velocity1)); persistMgr->transferFloat(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); + persistMgr->transferBool(TMEMBER(_velocityZBased)); persistMgr->transferFloat(TMEMBER(_scale1)); persistMgr->transferFloat(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); + persistMgr->transferBool(TMEMBER(_scaleZBased)); - persistMgr->transfer(TMEMBER(_maxParticles)); + persistMgr->transferSint32(TMEMBER(_maxParticles)); - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + persistMgr->transferSint32(TMEMBER(_lifeTime1)); + persistMgr->transferSint32(TMEMBER(_lifeTime2)); + persistMgr->transferBool(TMEMBER(_lifeTimeZBased)); - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); + persistMgr->transferSint32(TMEMBER(_genInterval)); + persistMgr->transferSint32(TMEMBER(_genAmount)); - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); + persistMgr->transferBool(TMEMBER(_running)); + persistMgr->transferSint32(TMEMBER(_overheadTime)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + persistMgr->transferRect32(TMEMBER(_border)); + persistMgr->transferSint32(TMEMBER(_borderThicknessLeft)); + persistMgr->transferSint32(TMEMBER(_borderThicknessRight)); + persistMgr->transferSint32(TMEMBER(_borderThicknessTop)); + persistMgr->transferSint32(TMEMBER(_borderThicknessBottom)); - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); + persistMgr->transferSint32(TMEMBER(_fadeInTime)); + persistMgr->transferSint32(TMEMBER(_fadeOutTime)); - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); + persistMgr->transferSint32(TMEMBER(_alpha1)); + persistMgr->transferSint32(TMEMBER(_alpha2)); + persistMgr->transferBool(TMEMBER(_alphaTimeBased)); persistMgr->transferFloat(TMEMBER(_angVelocity1)); persistMgr->transferFloat(TMEMBER(_angVelocity2)); @@ -1204,14 +1203,14 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { persistMgr->transferFloat(TMEMBER(_growthRate1)); persistMgr->transferFloat(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transferBool(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_useRegion)); + persistMgr->transferBool(TMEMBER(_useRegion)); - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + persistMgr->transferSint32(TMEMBER_INT(_maxBatches)); + persistMgr->transferSint32(TMEMBER_INT(_batchesGenerated)); - persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transferCharPtr(TMEMBER(_emitEvent)); persistMgr->transferPtr(TMEMBER_PTR(_owner)); @@ -1220,12 +1219,12 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { uint32 numForces; if (persistMgr->getIsSaving()) { numForces = _forces.size(); - persistMgr->transfer(TMEMBER(numForces)); + persistMgr->transferUint32(TMEMBER(numForces)); for (uint32 i = 0; i < _forces.size(); i++) { _forces[i]->persist(persistMgr); } } else { - persistMgr->transfer(TMEMBER(numForces)); + persistMgr->transferUint32(TMEMBER(numForces)); for (uint32 i = 0; i < numForces; i++) { PartForce *force = new PartForce(_gameRef); force->persist(persistMgr); @@ -1236,12 +1235,12 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { uint32 numParticles; if (persistMgr->getIsSaving()) { numParticles = _particles.size(); - persistMgr->transfer(TMEMBER(numParticles)); + persistMgr->transferUint32(TMEMBER(numParticles)); for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->persist(persistMgr); } } else { - persistMgr->transfer(TMEMBER(numParticles)); + persistMgr->transferUint32(TMEMBER(numParticles)); for (uint32 i = 0; i < numParticles; i++) { PartParticle *particle = new PartParticle(_gameRef); particle->persist(persistMgr); diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 122cdf1afe..39d98c182e 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -49,15 +49,15 @@ PartForce::~PartForce(void) { bool PartForce::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving()) { const char *name = getName(); - persistMgr->transfer(TMEMBER(name)); + persistMgr->transferConstChar(TMEMBER(name)); } else { const char *name; - persistMgr->transfer(TMEMBER(name)); + persistMgr->transferConstChar(TMEMBER(name)); setName(name); } - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transferVector2(TMEMBER(_pos)); + persistMgr->transferVector2(TMEMBER(_direction)); + persistMgr->transferSint32(TMEMBER_INT(_type)); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 86cacacb5c..11470561f0 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -45,7 +45,7 @@ PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { _creationTime = 0; _lifeTime = 0; _isDead = true; - BasePlatform::setRectEmpty(&_border); + _border.setEmpty(); _state = PARTICLE_NORMAL; _fadeStart = 0; @@ -125,7 +125,7 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer } // particle hit the border - if (!_isDead && !BasePlatform::isRectEmpty(&_border)) { + if (!_isDead && !_border.isRectEmpty()) { Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; @@ -230,32 +230,32 @@ bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { ////////////////////////////////////////////////////////////////////////// bool PartParticle::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transferSint32(TMEMBER(_alpha1)); + persistMgr->transferSint32(TMEMBER(_alpha2)); + persistMgr->transferRect32(TMEMBER(_border)); + persistMgr->transferVector2(TMEMBER(_pos)); persistMgr->transferFloat(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transferVector2(TMEMBER(_velocity)); persistMgr->transferFloat(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transferUint32(TMEMBER(_creationTime)); + persistMgr->transferSint32(TMEMBER(_lifeTime)); + persistMgr->transferBool(TMEMBER(_isDead)); + persistMgr->transferSint32(TMEMBER_INT(_state)); + persistMgr->transferUint32(TMEMBER(_fadeStart)); + persistMgr->transferSint32(TMEMBER(_fadeTime)); + persistMgr->transferSint32(TMEMBER(_currentAlpha)); persistMgr->transferFloat(TMEMBER(_angVelocity)); persistMgr->transferFloat(TMEMBER(_rotation)); persistMgr->transferFloat(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + persistMgr->transferBool(TMEMBER(_exponentialGrowth)); + persistMgr->transferSint32(TMEMBER(_fadeStartAlpha)); if (persistMgr->getIsSaving()) { const char *filename = _sprite->getFilename(); - persistMgr->transfer(TMEMBER(filename)); + persistMgr->transferConstChar(TMEMBER(filename)); } else { char *filename; - persistMgr->transfer(TMEMBER(filename)); + persistMgr->transferCharPtr(TMEMBER(filename)); SystemClassRegistry::getInstance()->_disabled = true; setSprite(filename); SystemClassRegistry::getInstance()->_disabled = false; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 5aeff78c50..5e4ae3ea95 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1249,15 +1249,15 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { // buffer if (persistMgr->getIsSaving()) { if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->transferUint32(TMEMBER(_bufferSize)); persistMgr->putBytes(_buffer, _bufferSize); } else { // don't save idle/finished scripts int32 bufferSize = 0; - persistMgr->transfer(TMEMBER(bufferSize)); + persistMgr->transferSint32(TMEMBER(bufferSize)); } } else { - persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->transferUint32(TMEMBER(_bufferSize)); if (_bufferSize > 0) { _buffer = new byte[_bufferSize]; persistMgr->getBytes(_buffer, _bufferSize); @@ -1270,31 +1270,31 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { } persistMgr->transferPtr(TMEMBER_PTR(_callStack)); - persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transferSint32(TMEMBER(_currentLine)); persistMgr->transferPtr(TMEMBER_PTR(_engine)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transferCharPtr(TMEMBER(_filename)); + persistMgr->transferBool(TMEMBER(_freezable)); persistMgr->transferPtr(TMEMBER_PTR(_globals)); - persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transferUint32(TMEMBER(_iP)); persistMgr->transferPtr(TMEMBER_PTR(_scopeStack)); persistMgr->transferPtr(TMEMBER_PTR(_stack)); - persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transferSint32(TMEMBER_INT(_state)); persistMgr->transferPtr(TMEMBER_PTR(_operand)); - persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transferSint32(TMEMBER_INT(_origState)); persistMgr->transferPtr(TMEMBER_PTR(_owner)); persistMgr->transferPtr(TMEMBER_PTR(_reg1)); - persistMgr->transfer(TMEMBER(_thread)); - persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transferBool(TMEMBER(_thread)); + persistMgr->transferCharPtr(TMEMBER(_threadEvent)); persistMgr->transferPtr(TMEMBER_PTR(_thisStack)); - persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transferUint32(TMEMBER(_timeSlice)); persistMgr->transferPtr(TMEMBER_PTR(_waitObject)); persistMgr->transferPtr(TMEMBER_PTR(_waitScript)); - persistMgr->transfer(TMEMBER(_waitTime)); - persistMgr->transfer(TMEMBER(_waitFrozen)); + persistMgr->transferUint32(TMEMBER(_waitTime)); + persistMgr->transferBool(TMEMBER(_waitFrozen)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transferBool(TMEMBER(_methodThread)); + persistMgr->transferBool(TMEMBER(_methodThread)); // TODO-SAVE: Deduplicate. + persistMgr->transferBool(TMEMBER(_unbreakable)); persistMgr->transferPtr(TMEMBER_PTR(_parentScript)); if (!persistMgr->getIsSaving()) { diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index dd24457d6c..bb819b23e4 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -362,6 +362,8 @@ bool ScEngine::tick() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::tickUnbreakable() { + ScScript *oldScript = _currentScript; + // execute unbreakable scripts for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_unbreakable) { @@ -373,9 +375,12 @@ bool ScEngine::tickUnbreakable() { _scripts[i]->executeInstruction(); } _scripts[i]->finish(); - _currentScript = nullptr; + _currentScript = oldScript; } - removeFinishedScripts(); + + // NB: Don't remove finished scripts here since we could be recursively + // executing scripts. Doing so could invalidate the outer iteration in + // ::tick() over _scripts. return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 7f1c769ec5..c4ad045557 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -214,7 +214,7 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) { bool SXArray::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_length)); + persistMgr->transferSint32(TMEMBER(_length)); persistMgr->transferPtr(TMEMBER_PTR(_values)); return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index d88bfc5851..6b9c5ff68a 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -243,15 +243,15 @@ bool SXDate::persist(BasePersistenceManager *persistMgr) { int32 hour = _tm.tm_hour; int32 min = _tm.tm_min; int32 sec = _tm.tm_sec; - persistMgr->transfer(TMEMBER(year)); - persistMgr->transfer(TMEMBER(mon)); - persistMgr->transfer(TMEMBER(mday)); - persistMgr->transfer(TMEMBER(hour)); - persistMgr->transfer(TMEMBER(min)); - persistMgr->transfer(TMEMBER(sec)); + persistMgr->transferSint32(TMEMBER(year)); + persistMgr->transferSint32(TMEMBER(mon)); + persistMgr->transferSint32(TMEMBER(mday)); + persistMgr->transferSint32(TMEMBER(hour)); + persistMgr->transferSint32(TMEMBER(min)); + persistMgr->transferSint32(TMEMBER(sec)); if (persistMgr->checkVersion(1, 2, 1)) { int32 wday = _tm.tm_wday; - persistMgr->transfer(TMEMBER(wday)); + persistMgr->transferSint32(TMEMBER(wday)); _tm.tm_wday = wday; } _tm.tm_year = year; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 18f7b8213a..dcd4f01f7c 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -766,16 +766,16 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); + persistMgr->transferCharPtr(TMEMBER(_filename)); + persistMgr->transferSint32(TMEMBER(_mode)); + persistMgr->transferBool(TMEMBER(_textMode)); uint32 pos = 0; if (persistMgr->getIsSaving()) { pos = getPos(); - persistMgr->transfer(TMEMBER(pos)); + persistMgr->transferUint32(TMEMBER(pos)); } else { - persistMgr->transfer(TMEMBER(pos)); + persistMgr->transferUint32(TMEMBER(pos)); // try to re-open file if needed _writeFile = nullptr; diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 6a47c09136..39f8b58644 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -498,7 +498,7 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_size)); + persistMgr->transferSint32(TMEMBER(_size)); if (persistMgr->getIsSaving()) { if (_size > 0) { diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 2f2422cdf9..b6d284442d 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -406,7 +406,7 @@ bool SXString::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_capacity)); + persistMgr->transferSint32(TMEMBER(_capacity)); if (persistMgr->getIsSaving()) { if (_capacity > 0) { diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 801ac6ab52..c828b3918e 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -186,7 +186,7 @@ bool ScStack::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_sP)); + persistMgr->transferSint32(TMEMBER(_sP)); _values.persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 3532e127d0..52367646a5 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -791,32 +791,32 @@ void ScValue::setValue(ScValue *val) { bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_persistent)); - persistMgr->transfer(TMEMBER(_isConstVar)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_valBool)); - persistMgr->transfer(TMEMBER(_valFloat)); - persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transferBool(TMEMBER(_persistent)); + persistMgr->transferBool(TMEMBER(_isConstVar)); + persistMgr->transferSint32(TMEMBER_INT(_type)); + persistMgr->transferBool(TMEMBER(_valBool)); + persistMgr->transferDouble(TMEMBER(_valFloat)); + persistMgr->transferSint32(TMEMBER(_valInt)); persistMgr->transferPtr(TMEMBER_PTR(_valNative)); int32 size; const char *str; if (persistMgr->getIsSaving()) { size = _valObject.size(); - persistMgr->transfer("", &size); + persistMgr->transferSint32("", &size); _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { str = _valIter->_key.c_str(); - persistMgr->transfer("", &str); + persistMgr->transferConstChar("", &str); persistMgr->transferPtr("", &_valIter->_value); _valIter++; } } else { ScValue *val = nullptr; - persistMgr->transfer("", &size); + persistMgr->transferSint32("", &size); for (int i = 0; i < size; i++) { - persistMgr->transfer("", &str); + persistMgr->transferConstChar("", &str); persistMgr->transferPtr("", &val); _valObject[str] = val; @@ -825,7 +825,18 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { } persistMgr->transferPtr(TMEMBER_PTR(_valRef)); - persistMgr->transfer(TMEMBER(_valString)); + persistMgr->transferCharPtr(TMEMBER(_valString)); + + if (!persistMgr->getIsSaving() && !persistMgr->checkVersion(1,2,2)) { + // Savegames prior to 1.2.2 stored empty strings as NULL. + // We disambiguate those by turning NULL strings into empty + // strings if _type is VAL_STRING instead of VAL_NULL. + + if (_type == VAL_STRING && !_valString) { + _valString = new char[1]; + _valString[0] = '\0'; + } + } /* // TODO: Convert to Debug-statements. FILE* f = fopen("c:\\val.log", "a+"); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index c1923b3ca8..f9cd59e4fb 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -166,16 +166,16 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_soundFilename)); - persistMgr->transfer(TMEMBER(_soundLooping)); - persistMgr->transfer(TMEMBER(_soundPaused)); - persistMgr->transfer(TMEMBER(_soundFreezePaused)); - persistMgr->transfer(TMEMBER(_soundPlaying)); - persistMgr->transfer(TMEMBER(_soundPosition)); - persistMgr->transfer(TMEMBER(_soundPrivateVolume)); - persistMgr->transfer(TMEMBER(_soundStreamed)); - persistMgr->transfer(TMEMBER_INT(_soundType)); - persistMgr->transfer(TMEMBER(_soundLoopStart)); + persistMgr->transferString(TMEMBER(_soundFilename)); + persistMgr->transferBool(TMEMBER(_soundLooping)); + persistMgr->transferBool(TMEMBER(_soundPaused)); + persistMgr->transferBool(TMEMBER(_soundFreezePaused)); + persistMgr->transferBool(TMEMBER(_soundPlaying)); + persistMgr->transferUint32(TMEMBER(_soundPosition)); + persistMgr->transferSint32(TMEMBER(_soundPrivateVolume)); + persistMgr->transferBool(TMEMBER(_soundStreamed)); + persistMgr->transferSint32(TMEMBER_INT(_soundType)); + persistMgr->transferUint32(TMEMBER(_soundLoopStart)); return STATUS_OK; } diff --git a/engines/wintermute/base/timer.cpp b/engines/wintermute/base/timer.cpp index 96097c10d5..f1f79af760 100644 --- a/engines/wintermute/base/timer.cpp +++ b/engines/wintermute/base/timer.cpp @@ -66,9 +66,9 @@ uint32 Timer::getTimeLast() const { } void Timer::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_timer)); - persistMgr->transfer(TMEMBER(_timerDelta)); - persistMgr->transfer(TMEMBER(_timerLast)); + persistMgr->transferUint32(TMEMBER(_timer)); + persistMgr->transferUint32(TMEMBER(_timerDelta)); + persistMgr->transferUint32(TMEMBER(_timerLast)); } } // End of namespace Wintermute diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index a3df92d6c8..307989e58d 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -67,7 +67,7 @@ class BaseArray : public BaseArrayBase<TYPE> { int32 j; if (persistMgr->getIsSaving()) { j = Common::Array<TYPE>::size(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); typename Common::Array<TYPE>::const_iterator it = Common::Array<TYPE>::begin(); for (; it != Common::Array<TYPE>::end(); ++it) { TYPE obj = *it; @@ -75,7 +75,7 @@ class BaseArray : public BaseArrayBase<TYPE> { } } else { Common::Array<TYPE>::clear(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); for (int i = 0; i < j; i++) { TYPE obj = nullptr; persistMgr->transferPtr("", &obj); @@ -93,18 +93,18 @@ class BaseArray<char *> : public BaseArrayBase<char *> { int32 j; if (persistMgr->getIsSaving()) { j = Common::Array<char *>::size(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); Common::Array<char *>::const_iterator it = Common::Array<char *>::begin(); for (; it != Common::Array<char *>::end(); ++it) { char * obj = *it; - persistMgr->transfer("", &obj); + persistMgr->transferCharPtr("", &obj); } } else { Common::Array<char *>::clear(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); for (int i = 0; i < j; i++) { char * obj = nullptr; - persistMgr->transfer("", &obj); + persistMgr->transferCharPtr("", &obj); add(obj); } } @@ -119,18 +119,18 @@ public: int32 j; if (persistMgr->getIsSaving()) { j = Common::Array<const char *>::size(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); Common::Array<const char *>::const_iterator it = Common::Array<const char *>::begin(); for (; it != Common::Array<const char *>::end(); ++it) { const char * obj = *it; - persistMgr->transfer("", &obj); + persistMgr->transferConstChar("", &obj); } } else { Common::Array<const char *>::clear(); - persistMgr->transfer("ArraySize", &j); + persistMgr->transferSint32("ArraySize", &j); for (int i = 0; i < j; i++) { const char * obj = nullptr; - persistMgr->transfer("", &obj); + persistMgr->transferConstChar("", &obj); add(obj); } } diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index fe92194443..3db443965e 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -33,7 +33,7 @@ ////////////////////////////////////////////////////////////////////////// #define DCGF_VER_MAJOR 1 #define DCGF_VER_MINOR 2 -#define DCGF_VER_BUILD 1 +#define DCGF_VER_BUILD 2 #define DCGF_VER_SUFFIX "ScummVM" #define DCGF_VER_BETA true diff --git a/engines/wintermute/graphics/transform_struct.cpp b/engines/wintermute/graphics/transform_struct.cpp index 8edbf765b5..822c06f42f 100644 --- a/engines/wintermute/graphics/transform_struct.cpp +++ b/engines/wintermute/graphics/transform_struct.cpp @@ -35,9 +35,10 @@ void TransformStruct::init(Point32 zoom, uint32 angle, Point32 hotspot, bool alp _flip += TransparentSurface::FLIP_H * mirrorX; _flip += TransparentSurface::FLIP_V * mirrorY; _offset = offset; + _numTimesX = 1; + _numTimesY = 1; } - TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY, int32 offsetX, int32 offsetY) { init(Point32(zoomX, zoomY), angle, @@ -49,6 +50,18 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 h Point32(offsetX, offsetY)); } +TransformStruct::TransformStruct(float zoomX, float zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY, int32 offsetX, int32 offsetY) { + init(Point32((int32)(zoomX / 100.0 * kDefaultZoomX), + (int32)(zoomY / 100.0 * kDefaultZoomY)), + angle, + Point32(hotspotX, hotspotY), + false, + blendMode, + rgbaMod, + mirrorX, mirrorY, + Point32(offsetX, offsetY)); +} + TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY) { init(Point32(zoomX, zoomY), kDefaultAngle, @@ -72,6 +85,19 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 h Point32(kDefaultOffsetX, kDefaultOffsetY)); } +TransformStruct::TransformStruct(int32 numTimesX, int32 numTimesY) { + init(Point32(kDefaultZoomX, kDefaultZoomY), + kDefaultAngle, + Point32(kDefaultHotspotX, kDefaultHotspotY), + false, + BLEND_NORMAL, + kDefaultRgbaMod, + false, false, + Point32(kDefaultOffsetX, kDefaultOffsetY)); + _numTimesX = numTimesX; + _numTimesY = numTimesY; +} + TransformStruct::TransformStruct() { init(Point32(kDefaultZoomX, kDefaultZoomY), kDefaultAngle, diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h index a54c4cc5d0..d5a03ea331 100644 --- a/engines/wintermute/graphics/transform_struct.h +++ b/engines/wintermute/graphics/transform_struct.h @@ -33,14 +33,14 @@ namespace Wintermute { * Has a number of overloaded constructors to accomodate various argument lists. */ -const uint32 kDefaultZoomX = 100; -const uint32 kDefaultZoomY = 100; +const int32 kDefaultZoomX = 100; +const int32 kDefaultZoomY = 100; const uint32 kDefaultRgbaMod = 0xFFFFFFFF; const int32 kDefaultHotspotX = 0; const int32 kDefaultHotspotY = 0; const int32 kDefaultOffsetX = 0; const int32 kDefaultOffsetY = 0; -const int32 kDefaultAngle = 0; +const int32 kDefaultAngle = 0; struct TransformStruct { private: @@ -48,18 +48,22 @@ private: public: TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false, int32 offsetX = 0, int32 offsetY = 0); + TransformStruct(float zoomX, float zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false, int32 offsetX = 0, int32 offsetY = 0); TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false); TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX = 0, int32 hotspotY = 0); + TransformStruct(int32 numTimesX, int32 numTimesY); TransformStruct(); Point32 _zoom; ///< Zoom; 100 = no zoom Point32 _hotspot; ///< Position of the hotspot - uint32 _angle; ///< Rotation angle, in degrees + int32 _angle; ///< Rotation angle, in degrees byte _flip; ///< Bitflag: see TransparentSurface::FLIP_XXX bool _alphaDisable; TSpriteBlendMode _blendMode; uint32 _rgbaMod; ///< RGBa Point32 _offset; + int32 _numTimesX; + int32 _numTimesY; bool getMirrorX() const; bool getMirrorY() const; @@ -71,7 +75,9 @@ public: compare._offset == _offset && compare._alphaDisable == _alphaDisable && compare._rgbaMod == _rgbaMod && - compare._blendMode == _blendMode + compare._blendMode == _blendMode && + compare._numTimesX == _numTimesX && + compare._numTimesY == _numTimesY ); } diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp index ebf9092aaa..dc92cdbbfd 100644 --- a/engines/wintermute/graphics/transform_tools.cpp +++ b/engines/wintermute/graphics/transform_tools.cpp @@ -26,11 +26,23 @@ namespace Wintermute { -FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) { +FloatPoint TransformTools::transformPoint(FloatPoint point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) { float rotateRad = rotate * M_PI / 180.0f; + float x = point.x; + float y = point.y; + x = (x * zoom.x) / kDefaultZoomX; + y = (y * zoom.y) / kDefaultZoomY; +#if 0 + // TODO: Mirroring should be done before rotation, but the blitting + // code does the inverse, so we match that for now. + if (mirrorX) + x *= -1; + if (mirrorY) + y *= -1; +#endif FloatPoint newPoint; - newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad)) * zoom.x / kDefaultZoomX; - newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad)) * zoom.y / kDefaultZoomY; + newPoint.x = x * cos(rotateRad) - y * sin(rotateRad); + newPoint.y = x * sin(rotateRad) + y * cos(rotateRad); if (mirrorX) { newPoint.x *= -1; } @@ -58,10 +70,12 @@ Rect32 TransformTools::newRect(const Rect32 &oldRect, const TransformStruct &tra float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x))); float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x))); - Rect32 res; - newHotspot->y = (uint32)(-floor(top)); - newHotspot->x = (uint32)(-floor(left)); + if (newHotspot) { + newHotspot->y = (uint32)(-floor(top)); + newHotspot->x = (uint32)(-floor(left)); + } + Rect32 res; res.top = (int32)(floor(top)) + transform._hotspot.y; res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y; res.left = (int32)(floor(left)) + transform._hotspot.x; diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h index c92b81fd11..9a73e3b69f 100644 --- a/engines/wintermute/graphics/transform_tools.h +++ b/engines/wintermute/graphics/transform_tools.h @@ -34,7 +34,7 @@ public: /** * Basic transform (scale + rotate) for a single point */ - static FloatPoint transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false); + static FloatPoint transformPoint(FloatPoint point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false); /** * @param &point the point on which the transform is to be applied diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 249d30f7d9..053acf29e9 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -17,8 +17,16 @@ * 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. + * + * + * The bottom part of this is file is adapted from SDL_rotozoom.c. The + * relevant copyright notice for those specific functions can be found at the + * top of that section. + * */ + + #include "common/algorithm.h" #include "common/endian.h" #include "common/util.h" @@ -29,116 +37,244 @@ #include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/transform_tools.h" +//#define ENABLE_BILINEAR + namespace Wintermute { +void doBlitOpaqueFast(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep); +void doBlitBinaryFast(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep); + +// These gather together various blendPixel functions for use with templates. + +class BlenderAdditive { +public: + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb); + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb); + inline void blendPixel(byte *in, byte *out); + inline void blendPixel(byte *in, byte *out, int colorMod); +}; + +class BlenderSubtractive { +public: + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb); + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb); + inline void blendPixel(byte *in, byte *out); + inline void blendPixel(byte *in, byte *out, int colorMod); +}; + +class BlenderNormal { +public: + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb); + inline void blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb); + inline void blendPixel(byte *in, byte *out); + inline void blendPixel(byte *in, byte *out, int colorMod); +}; -#if ENABLE_BILINEAR -void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) { - int srcW = srcRect.width(); - int srcH = srcRect.height(); - int dstW = dstRect.width(); - int dstH = dstRect.height(); +/** + * Perform additive blending of a pixel, applying beforehand a given colormod. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + * @param *outa, *outr, *outg, *outb pointer to the colormod components. + */ +void BlenderAdditive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb) { + if (*ca != 255) { + ina = (ina) * (*ca) >> 8; + } - assert(dstX >= 0 && dstX < dstW); - assert(dstY >= 0 && dstY < dstH); + if (ina == 0) { + return; + } else { + if (*cb != 255) + *outb = MIN(*outb + ((inb * (*cb) * ina) >> 16), 255); + else + *outb = MIN(*outb + (inb * ina >> 8), 255); + + if (*cg != 255) + *outg = MIN(*outg + ((ing * (*cg) * ina) >> 16), 255); + else + *outg = MIN(*outg + (ing * ina >> 8), 255); + + if (*cr != 255) + *outr = MIN(*outr + ((inr * (*cr) * ina) >> 16), 255); + else + *outr = MIN(*outr + (inr * ina >> 8), 255); + } +} - float x1 = floor(projX); - float x2 = ceil(projX); - float y1 = floor(projY); - float y2 = ceil(projY); +/** + * Perform subtractive blending of a pixel, applying beforehand a given colormod. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + * @param *outa, *outr, *outg, *outb pointer to the colormod components. + */ +void BlenderSubtractive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb) { + //if (*ca != 255) { + // ina = ina * (*ca) >> 8; + // } - uint32 Q11, Q12, Q21, Q22; + // As weird as it is, evidence suggests that alphamod is ignored when doing + // subtractive... - if (x1 >= srcW || x1 < 0 || y1 >= srcH || y1 < 0) { - Q11 = 0; - } else { - Q11 = READ_UINT32((const byte *)src->getBasePtr((int)(x1 + srcRect.left), (int)(y1 + srcRect.top))); - } + // TODO if ina == 255 fast version - if (x1 >= srcW || x1 < 0 || y2 >= srcH || y2 < 0) { - Q12 = 0; + if (ina == 0) { + return; } else { - Q12 = READ_UINT32((const byte *)src->getBasePtr((int)(x1 + srcRect.left), (int)(y2 + srcRect.top))); + if (*cb != 255) + *outb = MAX(*outb - ((inb * (*cb) * (*outb) * ina) >> 24), 0); + else + *outb = MAX(*outb - (inb * (*outb) * ina >> 16), 0); + + if (*cg != 255) + *outg = MAX(*outg - ((ing * (*cg) * (*outg) * ina) >> 24), 0); + else + *outg = MAX(*outg - (ing * (*outg) * ina >> 16), 0); + + if (*cr != 255) + *outr = MAX(*outr - ((inr * (*cr) * (*outr) * ina) >> 24), 0); + else + *outr = MAX(*outr - (inr * (*outr) * ina >> 16), 0); } +} - if (x2 >= srcW || x2 < 0 || y1 >= srcH || y1 < 0) { - Q21 = 0; - } else { - Q21 = READ_UINT32((const byte *)src->getBasePtr((int)(x2 + srcRect.left), (int)(y1 + srcRect.top))); - } +/** + * Perform "regular" alphablending of a pixel, applying beforehand a given colormod. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + * @param *outa, *outr, *outg, *outb pointer to the colormod components. + */ - if (x2 >= srcW || x2 < 0 || y2 >= srcH || y2 < 0) { - Q22 = 0; - } else { - Q22 = READ_UINT32((const byte *)src->getBasePtr((int)(x2 + srcRect.left), (int)(y2 + srcRect.top))); +void BlenderNormal::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb, byte *ca, byte *cr, byte *cg, byte *cb) { + if (*ca != 255) { + ina = ina * (*ca) >> 8; } - byte *Q11s = (byte *)&Q11; - byte *Q12s = (byte *)&Q12; - byte *Q21s = (byte *)&Q21; - byte *Q22s = (byte *)&Q22; + if (ina == 0) { + return; + } else if (ina == 255) { + if (*cb != 255) + *outb = (inb * (*cb)) >> 8; + else + *outb = inb; - uint32 color; - byte *dest = (byte *)&color; + if (*cr != 255) + *outr = (inr * (*cr)) >> 8; + else + *outr = inr; - float q11x = (x2 - projX); - float q11y = (y2 - projY); - float q21x = (projX - x1); - float q21y = (y2 - projY); - float q12x = (x2 - projX); - float q12y = (projY - y1); + if (*cg != 255) + *outg = (ing * (*cg)) >> 8; + else + *outg = ing; - if (x1 == x2 && y1 == y2) { - for (int c = 0; c < 4; c++) { - dest[c] = ((float)Q11s[c]); - } - } else { + *outa = ina; - if (x1 == x2) { - q11x = 0.5; - q12x = 0.5; - q21x = 0.5; - } else if (y1 == y2) { - q11y = 0.5; - q12y = 0.5; - q21y = 0.5; - } + return; - for (int c = 0; c < 4; c++) { - dest[c] = (byte)( - ((float)Q11s[c]) * q11x * q11y + - ((float)Q21s[c]) * q21x * q21y + - ((float)Q12s[c]) * q12x * q12y + - ((float)Q22s[c]) * (1.0 - - q11x * q11y - - q21x * q21y - - q12x * q12y) - ); - } + } else { + + *outa = 255; + *outb = (*outb * (255 - ina) >> 8); + *outr = (*outr * (255 - ina) >> 8); + *outg = (*outg * (255 - ina) >> 8); + + if (*cb == 0) + *outb = *outb; + else if (*cb != 255) + *outb = *outb + (inb * ina * (*cb) >> 16); + else + *outb = *outb + (inb * ina >> 8); + + if (*cr == 0) + *outr = *outr; + else if (*cr != 255) + *outr = *outr + (inr * ina * (*cr) >> 16); + else + *outr = *outr + (inr * ina >> 8); + + if (*cg == 0) + *outg = *outg; + else if (*cg != 255) + *outg = *outg + (ing * ina * (*cg) >> 16); + else + *outg = *outg + (ing * ina >> 8); + + return; } - WRITE_UINT32((byte *)dst->getBasePtr(dstX + dstRect.left, dstY + dstRect.top), color); } -#else -void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) { - int srcW = srcRect.width(); - int srcH = srcRect.height(); - int dstW = dstRect.width(); - int dstH = dstRect.height(); - assert(dstX >= 0 && dstX < dstW); - assert(dstY >= 0 && dstY < dstH); +/** + * Perform "regular" alphablending of a pixel. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + */ - uint32 color; +void BlenderNormal::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb) { - if (projX >= srcW || projX < 0 || projY >= srcH || projY < 0) { - color = 0; + if (ina == 0) { + return; + } else if (ina == 255) { + *outb = inb; + *outg = ing; + *outr = inr; + *outa = ina; + return; } else { - color = READ_UINT32((const byte *)src->getBasePtr((int)projX, (int)projY)); + *outa = 255; + *outb = ((inb * ina) + *outb * (255 - ina)) >> 8; + *outg = ((ing * ina) + *outg * (255 - ina)) >> 8; + *outr = ((inr * ina) + *outr * (255 - ina)) >> 8; } +} - WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color); +/** + * Perform subtractive blending of a pixel. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + */ +void BlenderSubtractive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb) { + + if (ina == 0) { + return; + } else if (ina == 255) { + *outa = *outa; + *outr = *outr - (inr * (*outr) >> 8); + *outg = *outg - (ing * (*outg) >> 8); + *outb = *outb - (inb * (*outb) >> 8); + return; + } else { + *outa = *outa; + *outb = MAX(*outb - ((inb * (*outb)) * ina >> 16), 0); + *outg = MAX(*outg - ((ing * (*outg)) * ina >> 16), 0); + *outr = MAX(*outr - ((inr * (*outr)) * ina >> 16), 0); + return; + } } -#endif + +/** + * Perform additive blending of a pixel. + * @param ina, inr, ing, inb: the input pixel, split into its components. + * @param *outa, *outr, *outg, *outb pointer to the output pixel. + */ +void BlenderAdditive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *outa, byte *outr, byte *outg, byte *outb) { + + if (ina == 0) { + return; + } else if (ina == 255) { + *outa = *outa; + *outr = MIN(*outr + inr, 255); + *outg = MIN(*outg + ing, 255); + *outb = MIN(*outb + inb, 255); + return; + } else { + *outa = *outa; + *outb = MIN((inb * ina >> 8) + *outb, 255); + *outg = MIN((ing * ina >> 8) + *outg, 255); + *outr = MIN((inr * ina >> 8) + *outr, 255); + return; + } +} + TransparentSurface::TransparentSurface() : Surface(), _alphaMode(ALPHA_FULL) {} @@ -157,21 +293,20 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur } } -void doBlitOpaque(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { - byte *in, *out; +/** + * Optimized version of doBlit to be used w/opaque blitting (no alpha). + */ +void doBlitOpaqueFast(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; -#else - const int aIndex = 3; -#endif + byte *in; + byte *out; for (uint32 i = 0; i < height; i++) { out = outo; in = ino; memcpy(out, in, width * 4); for (uint32 j = 0; j < width; j++) { - out[aIndex] = 0xFF; + out[TransparentSurface::kAIndex] = 0xFF; out += 4; } outo += pitch; @@ -179,112 +314,110 @@ void doBlitOpaque(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pit } } -void doBlitBinary(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { - byte *in, *out; - -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; -#else - const int aIndex = 3; -#endif - const int aShift = 0;//img->format.aShift; +/** + * Optimized version of doBlit to be used w/binary blitting (blit or no-blit, no blending). + */ +void doBlitBinaryFast(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { + + byte *in; + byte *out; for (uint32 i = 0; i < height; i++) { out = outo; in = ino; for (uint32 j = 0; j < width; j++) { uint32 pix = *(uint32 *)in; - int a = (pix >> aShift) & 0xff; - in += inStep; + int a = (pix >> TransparentSurface::kAShift) & 0xff; if (a == 0) { // Full transparency - out += 4; } else { // Full opacity (Any value not exactly 0 is Opaque here) *(uint32 *)out = pix; - out[aIndex] = 0xFF; - out += 4; + out[TransparentSurface::kAIndex] = 0xFF; } + out += 4; + in += inStep; } outo += pitch; ino += inoStep; } } -void doBlitAlpha(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { - byte *in, *out; +/** + * What we have here is a template method that calls blendPixel() from a different + * class - the one we call it with - thus performing a different type of blending. + * + * @param ino a pointer to the input surface + * @param outo a pointer to the output surface + * @param width width of the input surface + * @param height height of the input surface + * @param pitch pitch of the output surface - that is, width in bytes of every row, usually bpp * width of the TARGET surface (the area we are blitting to might be smaller, do the math) + * @inStep size in bytes to skip to address each pixel, usually bpp of the source surface + * @inoStep width in bytes of every row on the *input* surface / kind of like pitch + * @color colormod in 0xAARRGGBB format - 0xFFFFFFFF for no colormod + */ -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else - const int aIndex = 3; - const int bIndex = 2; - const int gIndex = 1; - const int rIndex = 0; -#endif +template<class Blender> +void doBlit(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep, uint32 color) { + Blender b; + byte *in; + byte *out; - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; + if (color == 0xffffffff) { - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; + for (uint32 i = 0; i < height; i++) { + out = outo; + in = ino; + for (uint32 j = 0; j < width; j++) { - for (uint32 i = 0; i < height; i++) { - out = outo; - in = ino; - for (uint32 j = 0; j < width; j++) { - uint32 pix = *(uint32 *)in; - uint32 oPix = *(uint32 *) out; - int b = (pix >> bShift) & 0xff; - int g = (pix >> gShift) & 0xff; - int r = (pix >> rShift) & 0xff; - int a = (pix >> aShift) & 0xff; - int outb, outg, outr, outa; - in += inStep; + byte *outa = &out[TransparentSurface::kAIndex]; + byte *outr = &out[TransparentSurface::kRIndex]; + byte *outg = &out[TransparentSurface::kGIndex]; + byte *outb = &out[TransparentSurface::kBIndex]; + + b.blendPixel(in[TransparentSurface::kAIndex], + in[TransparentSurface::kRIndex], + in[TransparentSurface::kGIndex], + in[TransparentSurface::kBIndex], + outa, outr, outg, outb); - switch (a) { - case 0: // Full transparency - out += 4; - break; - case 255: // Full opacity - outb = b; - outg = g; - outr = r; - outa = a; - - out[aIndex] = outa; - out[bIndex] = outb; - out[gIndex] = outg; - out[rIndex] = outr; - out += 4; - break; - - default: // alpha blending - outa = 255; - outb = ((b * a) + ((oPix >> bShiftTarget) & 0xff) * (255-a)) >> 8; - outg = ((g * a) + ((oPix >> gShiftTarget) & 0xff) * (255-a)) >> 8; - outr = ((r * a) + ((oPix >> rShiftTarget) & 0xff) * (255-a)) >> 8; - - out[aIndex] = outa; - out[bIndex] = outb; - out[gIndex] = outg; - out[rIndex] = outr; - out += 4; + in += inStep; + out += 4; } + outo += pitch; + ino += inoStep; + } + } else { + + byte ca = (color >> TransparentSurface::kAModShift) & 0xFF; + byte cr = (color >> TransparentSurface::kRModShift) & 0xFF; + byte cg = (color >> TransparentSurface::kGModShift) & 0xFF; + byte cb = (color >> TransparentSurface::kBModShift) & 0xFF; + + for (uint32 i = 0; i < height; i++) { + out = outo; + in = ino; + for (uint32 j = 0; j < width; j++) { + + byte *outa = &out[TransparentSurface::kAIndex]; + byte *outr = &out[TransparentSurface::kRIndex]; + byte *outg = &out[TransparentSurface::kGIndex]; + byte *outb = &out[TransparentSurface::kBIndex]; + + b.blendPixel(in[TransparentSurface::kAIndex], + in[TransparentSurface::kRIndex], + in[TransparentSurface::kGIndex], + in[TransparentSurface::kBIndex], + outa, outr, outg, outb, &ca, &cr, &cg, &cb); + in += inStep; + out += 4; + } + outo += pitch; + ino += inoStep; } - outo += pitch; - ino += inoStep; } } - -Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height) { - int ca = (color >> 24) & 0xff; +Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height, TSpriteBlendMode blendMode) { Common::Rect retSize; retSize.top = 0; @@ -292,21 +425,11 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p retSize.setWidth(0); retSize.setHeight(0); // Check if we need to draw anything at all + int ca = (color >> 24) & 0xff; + if (ca == 0) return retSize; - int cr = (color >> 16) & 0xff; - int cg = (color >> 8) & 0xff; - int cb = (color >> 0) & 0xff; - - // Compensate for transparency. Since we're coming - // down to 255 alpha, we just compensate for the colors here - if (ca != 255) { - cr = cr * ca >> 8; - cg = cg * ca >> 8; - cb = cb * ca >> 8; - } - // Create an encapsulating surface for the data TransparentSurface srcImage(*this, false); // TODO: Is the data really in the screen format? @@ -333,11 +456,11 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p srcImage.h = pPartRect->height(); debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, - pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); + pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); } else { debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0, - srcImage.w, srcImage.h, color, width, height); + srcImage.w, srcImage.h, color, width, height); } if (width == -1) @@ -393,118 +516,24 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p yp = img->h - 1; } - byte *ino = (byte *)img->getBasePtr(xp, yp); + byte *ino= (byte *)img->getBasePtr(xp, yp); byte *outo = (byte *)target.getBasePtr(posX, posY); - byte *in, *out; - -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else - const int aIndex = 3; - const int bIndex = 2; - const int gIndex = 1; - const int rIndex = 0; -#endif - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; - - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; - - if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { - if (_alphaMode == ALPHA_FULL) { - doBlitAlpha(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); - } else if (_alphaMode == ALPHA_BINARY) { - doBlitBinary(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); - } else if (_alphaMode == ALPHA_OPAQUE) { - doBlitOpaque(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); - } + if (color == 0xFFFFFF && blendMode == BLEND_NORMAL && _alphaMode == ALPHA_OPAQUE) { + doBlitOpaqueFast(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } else if (color == 0xFFFFFF && blendMode == BLEND_NORMAL && _alphaMode == ALPHA_BINARY) { + doBlitBinaryFast(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); } else { - for (int i = 0; i < img->h; i++) { - out = outo; - in = ino; - for (int j = 0; j < img->w; j++) { - uint32 pix = *(uint32 *)in; - uint32 o_pix = *(uint32 *) out; - int b = (pix >> bShift) & 0xff; - int g = (pix >> gShift) & 0xff; - int r = (pix >> rShift) & 0xff; - int a = (pix >> aShift) & 0xff; - int outb, outg, outr, outa; - in += inStep; - - if (ca != 255) { - a = a * ca >> 8; - } - - switch (a) { - case 0: // Full transparency - out += 4; - break; - case 255: // Full opacity - if (cb != 255) - outb = (b * cb) >> 8; - else - outb = b; - - if (cg != 255) - outg = (g * cg) >> 8; - else - outg = g; - - if (cr != 255) - outr = (r * cr) >> 8; - else - outr = r; - outa = a; - out[aIndex] = outa; - out[bIndex] = outb; - out[gIndex] = outg; - out[rIndex] = outr; - out += 4; - break; - - default: // alpha blending - outa = 255; - outb = (o_pix >> bShiftTarget) & 0xff; - outg = (o_pix >> gShiftTarget) & 0xff; - outr = (o_pix >> rShiftTarget) & 0xff; - if (cb == 0) - outb = 0; - else if (cb != 255) - outb += ((b - outb) * a * cb) >> 16; - else - outb += ((b - outb) * a) >> 8; - if (cg == 0) - outg = 0; - else if (cg != 255) - outg += ((g - outg) * a * cg) >> 16; - else - outg += ((g - outg) * a) >> 8; - if (cr == 0) - outr = 0; - else if (cr != 255) - outr += ((r - outr) * a * cr) >> 16; - else - outr += ((r - outr) * a) >> 8; - out[aIndex] = outa; - out[bIndex] = outb; - out[gIndex] = outg; - out[rIndex] = outr; - out += 4; - } - } - outo += target.pitch; - ino += inoStep; + if (blendMode == BLEND_ADDITIVE) { + doBlit<BlenderAdditive>(ino, outo, img->w, img->h, target.pitch, inStep, inoStep, color); + } else if (blendMode == BLEND_SUBTRACTIVE) { + doBlit<BlenderSubtractive>(ino, outo, img->w, img->h, target.pitch, inStep, inoStep, color); + } else { + assert(blendMode == BLEND_NORMAL); + doBlit<BlenderNormal>(ino, outo, img->w, img->h, target.pitch, inStep, inoStep, color); } } + } retSize.setWidth(img->w); @@ -519,6 +548,88 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } +/** + * Writes a color key to the alpha channel of the surface + * @param rKey the red component of the color key + * @param gKey the green component of the color key + * @param bKey the blue component of the color key + * @param overwriteAlpha if true, all other alpha will be set fully opaque + */ +void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { + assert(format.bytesPerPixel == 4); + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + uint32 pix = ((uint32 *)pixels)[i * w + j]; + uint8 r, g, b, a; + format.colorToARGB(pix, a, r, g, b); + if (r == rKey && g == gKey && b == bKey) { + a = 0; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } else if (overwriteAlpha) { + a = 255; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } + } + } +} + +TransparentSurface::AlphaType TransparentSurface::getAlphaMode() const { + return _alphaMode; +} + +void TransparentSurface::setAlphaMode(TransparentSurface::AlphaType mode) { + _alphaMode = mode; +} + + + + + + +/* + +The below two functions are adapted from SDL_rotozoom.c, +taken from SDL_gfx-2.0.18. + +Its copyright notice: + +============================================================================= +SDL_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces + +Copyright (C) 2001-2012 Andreas Schiffler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. + +Andreas Schiffler -- aschiffler at ferzkopp dot net +============================================================================= + + +The functions have been adapted for different structures and coordinate +systems. + +*/ + + + + + TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transform) const { assert(transform._angle != 0); // This would not be ideal; rotoscale() should never be called in conditional branches where angle = 0 anyway. @@ -531,39 +642,105 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo TransparentSurface *target = new TransparentSurface(); assert(format.bytesPerPixel == 4); + int srcW = w; + int srcH = h; int dstW = dstRect.width(); int dstH = dstRect.height(); target->create((uint16)dstW, (uint16)dstH, this->format); + if (transform._zoom.x == 0 || transform._zoom.y == 0) + return target; + uint32 invAngle = 360 - (transform._angle % 360); float invCos = cos(invAngle * M_PI / 180.0); float invSin = sin(invAngle * M_PI / 180.0); - float targX; - float targY; - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - int x1 = x - newHotspot.x; - int y1 = y - newHotspot.y; + struct tColorRGBA { byte r; byte g; byte b; byte a; }; + int icosx = (int)(invCos * (65536.0f * kDefaultZoomX / transform._zoom.x)); + int isinx = (int)(invSin * (65536.0f * kDefaultZoomX / transform._zoom.x)); + int icosy = (int)(invCos * (65536.0f * kDefaultZoomY / transform._zoom.y)); + int isiny = (int)(invSin * (65536.0f * kDefaultZoomY / transform._zoom.y)); + - targX = ((x1 * invCos - y1 * invSin)) * kDefaultZoomX / transform._zoom.x + srcRect.left; - targY = ((x1 * invSin + y1 * invCos)) * kDefaultZoomY / transform._zoom.y + srcRect.top; + bool flipx = false, flipy = false; // TODO: See mirroring comment in RenderTicket ctor - targX += transform._hotspot.x; - targY += transform._hotspot.y; + int xd = (srcRect.left + transform._hotspot.x) << 16; + int yd = (srcRect.top + transform._hotspot.y) << 16; + int cx = newHotspot.x; + int cy = newHotspot.y; -#if ENABLE_BILINEAR - copyPixelBilinear(targX, targY, x, y, srcRect, dstRect, this, target); + int ax = -icosx * cx; + int ay = -isiny * cx; + int sw = srcW - 1; + int sh = srcH - 1; + + tColorRGBA *pc = (tColorRGBA*)target->getBasePtr(0, 0); + + for (int y = 0; y < dstH; y++) { + int t = cy - y; + int sdx = ax + (isinx * t) + xd; + int sdy = ay - (icosy * t) + yd; + for (int x = 0; x < dstW; x++) { + int dx = (sdx >> 16); + int dy = (sdy >> 16); + if (flipx) dx = sw - dx; + if (flipy) dy = sh - dy; + +#ifdef ENABLE_BILINEAR + if ((dx > -1) && (dy > -1) && (dx < sw) && (dy < sh)) { + const tColorRGBA *sp = (const tColorRGBA *)getBasePtr(dx, dy); + tColorRGBA c00, c01, c10, c11, cswap; + c00 = *sp; + sp += 1; + c01 = *sp; + sp += (this->pitch/4); + c11 = *sp; + sp -= 1; + c10 = *sp; + if (flipx) { + cswap = c00; c00=c01; c01=cswap; + cswap = c10; c10=c11; c11=cswap; + } + if (flipy) { + cswap = c00; c00=c10; c10=cswap; + cswap = c01; c01=c11; c11=cswap; + } + /* + * Interpolate colors + */ + int ex = (sdx & 0xffff); + int ey = (sdy & 0xffff); + int t1, t2; + t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff; + t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff; + pc->r = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff; + t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff; + pc->g = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff; + t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff; + pc->b = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff; + t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff; + pc->a = (((t2 - t1) * ey) >> 16) + t1; + } #else - copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target); + if ((dx >= 0) && (dy >= 0) && (dx < srcW) && (dy < srcH)) { + const tColorRGBA *sp = (const tColorRGBA *)getBasePtr(dx, dy); + *pc = *sp; + } #endif + sdx += icosx; + sdy += isiny; + pc++; } } return target; } TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const { + Common::Rect srcRect(0, 0, (int16)w, (int16)h); Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight); @@ -578,47 +755,169 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) target->create((uint16)dstW, (uint16)dstH, this->format); +#ifdef ENABLE_BILINEAR - float projX; - float projY; - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - projX = x / (float)dstW * srcW; - projY = y / (float)dstH * srcH; -#if ENABLE_BILINEAR - copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target); -#else - copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target); -#endif + // NB: The actual order of these bytes may not be correct, but + // since all values are treated equal, that does not matter. + struct tColorRGBA { byte r; byte g; byte b; byte a; }; + + bool flipx = false, flipy = false; // TODO: See mirroring comment in RenderTicket ctor + + + int *sax = new int[dstW+1]; + int *say = new int[dstH+1]; + assert(sax && say); + + /* + * Precalculate row increments + */ + int spixelw = (srcW - 1); + int spixelh = (srcH - 1); + int sx = (int) (65536.0f * (float) spixelw / (float) (dstW - 1)); + int sy = (int) (65536.0f * (float) spixelh / (float) (dstH - 1)); + + /* Maximum scaled source size */ + int ssx = (srcW << 16) - 1; + int ssy = (srcH << 16) - 1; + + /* Precalculate horizontal row increments */ + int csx = 0; + int *csax = sax; + for (int x = 0; x <= dstW; x++) { + *csax = csx; + csax++; + csx += sx; + + /* Guard from overflows */ + if (csx > ssx) { + csx = ssx; } } - return target; -} + /* Precalculate vertical row increments */ + int csy = 0; + int *csay = say; + for (int y = 0; y <= dstH; y++) { + *csay = csy; + csay++; + csy += sy; + + /* Guard from overflows */ + if (csy > ssy) { + csy = ssy; + } + } -/** - * Writes a color key to the alpha channel of the surface - * @param rKey the red component of the color key - * @param gKey the green component of the color key - * @param bKey the blue component of the color key - * @param overwriteAlpha if true, all other alpha will be set fully opaque - */ -void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { - assert(format.bytesPerPixel == 4); - for (int i = 0; i < h; i++) { - for (int j = 0; j < w; j++) { - uint32 pix = ((uint32 *)pixels)[i * w + j]; - uint8 r, g, b, a; - format.colorToARGB(pix, a, r, g, b); - if (r == rKey && g == gKey && b == bKey) { - a = 0; - ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); - } else if (overwriteAlpha) { - a = 255; - ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + const tColorRGBA *sp = (const tColorRGBA *) getBasePtr(0,0); + tColorRGBA *dp = (tColorRGBA *) target->getBasePtr(0,0); + int spixelgap = srcW; + + if (flipx) + sp += spixelw; + if (flipy) + sp += spixelgap * spixelh; + + csay = say; + for (int y = 0; y < dstH; y++) { + const tColorRGBA *csp = sp; + csax = sax; + for (int x = 0; x < dstW; x++) { + /* + * Setup color source pointers + */ + int ex = (*csax & 0xffff); + int ey = (*csay & 0xffff); + int cx = (*csax >> 16); + int cy = (*csay >> 16); + + const tColorRGBA *c00, *c01, *c10, *c11; + c00 = sp; + c01 = sp; + c10 = sp; + if (cy < spixelh) { + if (flipy) + c10 -= spixelgap; + else + c10 += spixelgap; + } + c11 = c10; + if (cx < spixelw) { + if (flipx) { + c01--; + c11--; + } else { + c01++; + c11++; + } } + + /* + * Draw and interpolate colors + */ + int t1, t2; + t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff; + t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff; + dp->r = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01->g - c00->g) * ex) >> 16) + c00->g) & 0xff; + t2 = ((((c11->g - c10->g) * ex) >> 16) + c10->g) & 0xff; + dp->g = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01->b - c00->b) * ex) >> 16) + c00->b) & 0xff; + t2 = ((((c11->b - c10->b) * ex) >> 16) + c10->b) & 0xff; + dp->b = (((t2 - t1) * ey) >> 16) + t1; + t1 = ((((c01->a - c00->a) * ex) >> 16) + c00->a) & 0xff; + t2 = ((((c11->a - c10->a) * ex) >> 16) + c10->a) & 0xff; + dp->a = (((t2 - t1) * ey) >> 16) + t1; + + /* + * Advance source pointer x + */ + int *salastx = csax; + csax++; + int sstepx = (*csax >> 16) - (*salastx >> 16); + if (flipx) + sp -= sstepx; + else + sp += sstepx; + + /* + * Advance destination pointer x + */ + dp++; } + /* + * Advance source pointer y + */ + int *salasty = csay; + csay++; + int sstepy = (*csay >> 16) - (*salasty >> 16); + sstepy *= spixelgap; + if (flipy) + sp = csp - sstepy; + else + sp = csp + sstepy; } + + delete[] sax; + delete[] say; + +#else + + int *scaleCacheX = new int[dstW]; + for (int x = 0; x < dstW; x++) + scaleCacheX[x] = (x * srcW) / dstW; + + for (int y = 0; y < dstH; y++) { + uint32 *destP = (uint32 *)target->getBasePtr(0, y); + const uint32 *srcP = (const uint32 *)getBasePtr(0, (y * srcH) / dstH); + for (int x = 0; x < dstW; x++) + *destP++ = srcP[scaleCacheX[x]]; + } + delete[] scaleCacheX; + +#endif + + return target; + } } // End of namespace Wintermute diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 598aaa55d7..1f3827d1a9 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -25,9 +25,6 @@ #include "graphics/surface.h" #include "engines/wintermute/graphics/transform_struct.h" -#define ENABLE_BILINEAR 0 - - /* * This code is based on Broken Sword 2.5 engine * @@ -53,73 +50,111 @@ struct TransparentSurface : public Graphics::Surface { void setColorKey(char r, char g, char b); void disableColorKey(); -#if ENABLE_BILINEAR - static void copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst); -#else - static void copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst); -#endif // Enums /** @brief The possible flipping parameters for the blit methode. */ enum FLIP_FLAGS { - /// The image will not be flipped. - FLIP_NONE = 0, - /// The image will be flipped at the horizontal axis. - FLIP_H = 1, - /// The image will be flipped at the vertical axis. - FLIP_V = 2, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_HV = FLIP_H | FLIP_V, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_VH = FLIP_H | FLIP_V + /// The image will not be flipped. + FLIP_NONE = 0, + /// The image will be flipped at the horizontal axis. + FLIP_H = 1, + /// The image will be flipped at the vertical axis. + FLIP_V = 2, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_HV = FLIP_H | FLIP_V, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_VH = FLIP_H | FLIP_V }; enum AlphaType { - ALPHA_OPAQUE = 0, - ALPHA_BINARY = 1, - ALPHA_FULL = 2 + ALPHA_OPAQUE = 0, + ALPHA_BINARY = 1, + ALPHA_FULL = 2 }; - AlphaType _alphaMode; + #ifdef SCUMM_LITTLE_ENDIAN + static const int kAIndex = 0; + static const int kBIndex = 1; + static const int kGIndex = 2; + static const int kRIndex = 3; + #else + static const int kAIndex = 3; + static const int kBIndex = 2; + static const int kGIndex = 1; + static const int kRIndex = 0; + #endif + + static const int kBShift = 8;//img->format.bShift; + static const int kGShift = 16;//img->format.gShift; + static const int kRShift = 24;//img->format.rShift; + static const int kAShift = 0;//img->format.aShift; + + + static const int kBModShift = 0;//img->format.bShift; + static const int kGModShift = 8;//img->format.gShift; + static const int kRModShift = 16;//img->format.rShift; + static const int kAModShift = 24;//img->format.aShift; + /** @brief renders the surface to another surface - @param pDest a pointer to the target image. In most cases this is the framebuffer. - @param PosX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.<br> + @param target a pointer to the target surface. In most cases this is the framebuffer. + @param posX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.<br> The default value is 0. - @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br> + @param posY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br> The default value is 0. - @param Flipping how the the image should be flipped.<br> + @param flipping how the the image should be flipped.<br> The default value is BS_Image::FLIP_NONE (no flipping) - @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br> + @param pPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br> This referes to the unflipped and unscaled image.<br> The default value is NULL. - @param Color an ARGB color value, which determines the parameters for the color modulation und alpha blending.<br> + @param color an ARGB color value, which determines the parameters for the color modulation und alpha blending.<br> The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).<br> The color components determines the color for color modulation.<br> The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation). The macros BS_RGB and BS_ARGB can be used for the creation of the color value. - @param Width the output width of the screen section. + @param width the output width of the screen section. The images will be scaled if the output width of the screen section differs from the image section.<br> The value -1 determines that the image should not be scaled.<br> The default value is -1. - @param Width the output height of the screen section. + @param height the output height of the screen section. The images will be scaled if the output width of the screen section differs from the image section.<br> The value -1 determines that the image should not be scaled.<br> The default value is -1. @return returns false if the rendering failed. */ - Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0, int flipping = FLIP_NONE, Common::Rect *pPartRect = nullptr, uint color = BS_ARGB(255, 255, 255, 255), - int width = -1, int height = -1); + int width = -1, int height = -1, + TSpriteBlendMode blend = BLEND_NORMAL); void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); - + + /** + * @brief Scale function; this returns a transformed version of this surface after rotation and + * scaling. Please do not use this if angle != 0, use rotoscale. + * + * @param newWidth the resulting width. + * @param newHeight the resulting height. + * @see TransformStruct + */ TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; + + /** + * @brief Rotoscale function; this returns a transformed version of this surface after rotation and + * scaling. Please do not use this if angle == 0, use plain old scaling function. + * + * @param transform a TransformStruct wrapping the required info. @see TransformStruct + * + */ TransparentSurface *rotoscale(const TransformStruct &transform) const; + AlphaType getAlphaMode() const; + void setAlphaMode(AlphaType); +private: + AlphaType _alphaMode; + }; /** @@ -134,7 +169,6 @@ struct TransparentSurface : public Graphics::Surface { } };*/ - } // End of namespace Wintermute diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index f522ab3a35..a4a64690e2 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -94,12 +94,24 @@ struct Rect32 { left = right = top = bottom = 0; } + bool isRectEmpty() const { + return (left >= right) || (top >= bottom); + } + void offsetRect(int dx, int dy) { left += dx; top += dy; right += dx; bottom += dy; } + + void setRect(int32 newLeft, int32 newTop, int32 newRight, int32 newBottom) { + this->left = newLeft; + this->top = newTop; + this->right = newRight; + this->bottom = newBottom; + } + /** * Check if the given rect is equal to this one. * diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 87a127d001..9fa23c6074 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -169,52 +169,16 @@ bool BasePlatform::setCursorPos(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool BasePlatform::showWindow(int nCmdShow) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -void BasePlatform::setCapture() { - return; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::releaseCapture() { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::setRectEmpty(Rect32 *lprc) { - lprc->left = lprc->right = lprc->top = lprc->bottom = 0; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::isRectEmpty(const Rect32 *lprc) { - return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); -} - -////////////////////////////////////////////////////////////////////////// bool BasePlatform::ptInRect(Rect32 *lprc, Point32 p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool BasePlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { - lprc->left = left; - lprc->top = top; - lprc->right = right; - lprc->bottom = bottom; - - return true; -} - -////////////////////////////////////////////////////////////////////////// bool BasePlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { - if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || + if (lprcSrc1->isRectEmpty() || lprcSrc2->isRectEmpty() || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { - setRectEmpty(lprcDst); + lprcDst->setEmpty(); return false; } lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); @@ -227,15 +191,15 @@ bool BasePlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const ////////////////////////////////////////////////////////////////////////// bool BasePlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { - if (isRectEmpty(lprcSrc1)) { - if (isRectEmpty(lprcSrc2)) { - setRectEmpty(lprcDst); + if (lprcSrc1->isRectEmpty()) { + if (lprcSrc2->isRectEmpty()) { + lprcDst->setEmpty(); return false; } else { *lprcDst = *lprcSrc2; } } else { - if (isRectEmpty(lprcSrc2)) { + if (lprcSrc2->isRectEmpty()) { *lprcDst = *lprcSrc1; } else { lprcDst->left = MIN(lprcSrc1->left, lprcSrc2->left); diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 46c86df909..16d55745b9 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -48,13 +48,7 @@ public: // Win32 API bindings static bool getCursorPos(Point32 *lpPoint); static bool setCursorPos(int x, int y); - static bool showWindow(int nCmdShow); - static void setCapture(); - static bool releaseCapture(); - - static bool setRectEmpty(Rect32 *lprc); - static bool isRectEmpty(const Rect32 *lprc); static bool ptInRect(Rect32 *lprc, Point32 p); static bool setRect(Rect32 *lprc, int left, int top, int right, int bottom); static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index b2e6c3953b..7526174b64 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -103,7 +103,7 @@ UIButton::~UIButton() { ////////////////////////////////////////////////////////////////////////// bool UIButton::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -162,7 +162,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UIButton::loadBuffer(byte *buffer, bool complete) { +bool UIButton::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -202,38 +202,38 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_BUTTON) { _gameRef->LOG(0, "'BUTTON' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_BACK: delete _back; _back = new UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile(params))) { delete _back; _back = nullptr; cmd = PARSERR_GENERIC; @@ -243,7 +243,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_HOVER: delete _backHover; _backHover = new UITiledImage(_gameRef); - if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { + if (!_backHover || DID_FAIL(_backHover->loadFile(params))) { delete _backHover; _backHover = nullptr; cmd = PARSERR_GENERIC; @@ -253,7 +253,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_PRESS: delete _backPress; _backPress = new UITiledImage(_gameRef); - if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { + if (!_backPress || DID_FAIL(_backPress->loadFile(params))) { delete _backPress; _backPress = nullptr; cmd = PARSERR_GENERIC; @@ -263,7 +263,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_DISABLE: delete _backDisable; _backDisable = new UITiledImage(_gameRef); - if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { + if (!_backDisable || DID_FAIL(_backDisable->loadFile(params))) { delete _backDisable; _backDisable = nullptr; cmd = PARSERR_GENERIC; @@ -273,7 +273,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_FOCUS: delete _backFocus; _backFocus = new UITiledImage(_gameRef); - if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { + if (!_backFocus || DID_FAIL(_backFocus->loadFile(params))) { delete _backFocus; _backFocus = nullptr; cmd = PARSERR_GENERIC; @@ -283,7 +283,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new BaseSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile(params))) { delete _image; _image = nullptr; cmd = PARSERR_GENERIC; @@ -293,7 +293,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: delete _imageHover; _imageHover = new BaseSprite(_gameRef); - if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { + if (!_imageHover || DID_FAIL(_imageHover->loadFile(params))) { delete _imageHover; _imageHover = nullptr; cmd = PARSERR_GENERIC; @@ -303,7 +303,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_PRESS: delete _imagePress; _imagePress = new BaseSprite(_gameRef); - if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { + if (!_imagePress || DID_FAIL(_imagePress->loadFile(params))) { delete _imagePress; _imagePress = nullptr; cmd = PARSERR_GENERIC; @@ -313,7 +313,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_DISABLE: delete _imageDisable; _imageDisable = new BaseSprite(_gameRef); - if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(params))) { delete _imageDisable; _imageDisable = nullptr; cmd = PARSERR_GENERIC; @@ -323,7 +323,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_FOCUS: delete _imageFocus; _imageFocus = new BaseSprite(_gameRef); - if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(params))) { delete _imageFocus; _imageFocus = nullptr; cmd = PARSERR_GENERIC; @@ -334,7 +334,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { if (_font) { _gameRef->_fontStorage->removeFont(_font); } - _font = _gameRef->_fontStorage->addFont((char *)params); + _font = _gameRef->_fontStorage->addFont(params); if (!_font) { cmd = PARSERR_GENERIC; } @@ -344,7 +344,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { if (_fontHover) { _gameRef->_fontStorage->removeFont(_fontHover); } - _fontHover = _gameRef->_fontStorage->addFont((char *)params); + _fontHover = _gameRef->_fontStorage->addFont(params); if (!_fontHover) { cmd = PARSERR_GENERIC; } @@ -354,7 +354,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { if (_fontPress) { _gameRef->_fontStorage->removeFont(_fontPress); } - _fontPress = _gameRef->_fontStorage->addFont((char *)params); + _fontPress = _gameRef->_fontStorage->addFont(params); if (!_fontPress) { cmd = PARSERR_GENERIC; } @@ -364,7 +364,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { if (_fontDisable) { _gameRef->_fontStorage->removeFont(_fontDisable); } - _fontDisable = _gameRef->_fontStorage->addFont((char *)params); + _fontDisable = _gameRef->_fontStorage->addFont(params); if (!_fontDisable) { cmd = PARSERR_GENERIC; } @@ -374,21 +374,21 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { if (_fontFocus) { _gameRef->_fontStorage->removeFont(_fontFocus); } - _fontFocus = _gameRef->_fontStorage->addFont((char *)params); + _fontFocus = _gameRef->_fontStorage->addFont(params); if (!_fontFocus) { cmd = PARSERR_GENERIC; } break; case TOKEN_TEXT: - setText((char *)params); + setText(params); _gameRef->expandStringByStringTable(&_text); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) { + if (scumm_stricmp(params, "left") == 0) { _align = TAL_LEFT; - } else if (scumm_stricmp((char *)params, "right") == 0) { + } else if (scumm_stricmp(params, "right") == 0) { _align = TAL_RIGHT; } else { _align = TAL_CENTER; @@ -396,25 +396,25 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); + parser.scanStr(params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); + parser.scanStr(params, "%d", &_height); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -422,35 +422,35 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); + parser.scanStr(params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); + parser.scanStr(params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); + parser.scanStr(params, "%b", &_visible); break; case TOKEN_FOCUSABLE: - parser.scanStr((char *)params, "%b", &_canFocus); + parser.scanStr(params, "%b", &_canFocus); break; case TOKEN_CENTER_IMAGE: - parser.scanStr((char *)params, "%b", &_centerImage); + parser.scanStr(params, "%b", &_centerImage); break; case TOKEN_PRESSED: - parser.scanStr((char *)params, "%b", &_stayPressed); + parser.scanStr(params, "%b", &_stayPressed); break; case TOKEN_PIXEL_PERFECT: - parser.scanStr((char *)params, "%b", &_pixelPerfect); + parser.scanStr(params, "%b", &_pixelPerfect); break; case TOKEN_EDITOR_PROPERTY: @@ -655,12 +655,12 @@ bool UIButton::display(int offsetX, int offsetY) { BaseFont *font = 0; //RECT rect; - //BasePlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //rect.setRect(OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); //_hover = (!_disable && BasePlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) { + (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) { press(); } @@ -1178,25 +1178,25 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { UIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transferSint32(TMEMBER_INT(_align)); persistMgr->transferPtr(TMEMBER_PTR(_backDisable)); persistMgr->transferPtr(TMEMBER_PTR(_backFocus)); persistMgr->transferPtr(TMEMBER_PTR(_backHover)); persistMgr->transferPtr(TMEMBER_PTR(_backPress)); - persistMgr->transfer(TMEMBER(_centerImage)); + persistMgr->transferBool(TMEMBER(_centerImage)); persistMgr->transferPtr(TMEMBER_PTR(_fontDisable)); persistMgr->transferPtr(TMEMBER_PTR(_fontFocus)); persistMgr->transferPtr(TMEMBER_PTR(_fontHover)); persistMgr->transferPtr(TMEMBER_PTR(_fontPress)); - persistMgr->transfer(TMEMBER(_hover)); + persistMgr->transferBool(TMEMBER(_hover)); persistMgr->transferPtr(TMEMBER_PTR(_image)); persistMgr->transferPtr(TMEMBER_PTR(_imageDisable)); persistMgr->transferPtr(TMEMBER_PTR(_imageFocus)); persistMgr->transferPtr(TMEMBER_PTR(_imageHover)); persistMgr->transferPtr(TMEMBER_PTR(_imagePress)); - persistMgr->transfer(TMEMBER(_pixelPerfect)); - persistMgr->transfer(TMEMBER(_press)); - persistMgr->transfer(TMEMBER(_stayPressed)); + persistMgr->transferBool(TMEMBER(_pixelPerfect)); + persistMgr->transferBool(TMEMBER(_press)); + persistMgr->transferBool(TMEMBER(_stayPressed)); if (!persistMgr->getIsSaving()) { _oneTimePress = false; @@ -1206,4 +1206,28 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } +void UIButton::setFontHover(BaseFont *font) { + _fontHover = font; +} + +BaseFont *UIButton::getFontHover() { + return _fontHover; +} + +void UIButton::setFontPress(BaseFont *font) { + _fontPress = font; +} + +void UIButton::setImageHover(BaseSprite *sprite) { + _imageHover = sprite; +} + +void UIButton::setImagePress(BaseSprite *sprite) { + _imagePress = sprite; +} + +void UIButton::setTextAlign(TTextAlign align) { + _align = align; +} + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index b5002f3166..6452cfc4f7 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -37,35 +37,18 @@ namespace Wintermute { class UIButton : public UIObject { public: - bool _pixelPerfect; - bool _stayPressed; - bool _centerImage; - bool _oneTimePress; - uint32 _oneTimePressTime; + DECLARE_PERSISTENT(UIButton, UIObject) void press(); virtual bool display() { return display(0, 0); } virtual bool display(int offsetX, int offsetY); - bool _press; - bool _hover; + void correctSize(); - TTextAlign _align; - BaseSprite *_imageHover; - BaseSprite *_imagePress; - BaseSprite *_imageDisable; - BaseSprite *_imageFocus; - BaseFont *_fontDisable; - BaseFont *_fontPress; - BaseFont *_fontHover; - BaseFont *_fontFocus; - UITiledImage *_backPress; - UITiledImage *_backHover; - UITiledImage *_backDisable; - UITiledImage *_backFocus; + UIButton(BaseGame *inGame = nullptr); virtual ~UIButton(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; // scripting interface @@ -73,6 +56,39 @@ public: virtual bool scSetProperty(const char *name, ScValue *value) override; virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString() override; + + + void setFontHover(BaseFont *font); + BaseFont *getFontHover(); + void setFontPress(BaseFont *font); + + void setTextAlign(TTextAlign align); + + void setImageHover(BaseSprite *sprite); + void setImagePress(BaseSprite *sprite); + +private: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + UITiledImage *_backPress; + UITiledImage *_backHover; + UITiledImage *_backDisable; + UITiledImage *_backFocus; + bool _press; + bool _hover; + BaseFont *_fontDisable; + BaseFont *_fontPress; + BaseFont *_fontHover; + BaseFont *_fontFocus; + BaseSprite *_imageHover; + BaseSprite *_imagePress; + BaseSprite *_imageDisable; + BaseSprite *_imageFocus; + uint32 _oneTimePressTime; + TTextAlign _align; + }; } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index caed157e0b..1f224c79c8 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -94,7 +94,7 @@ UIEdit::~UIEdit() { ////////////////////////////////////////////////////////////////////////// bool UIEdit::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -139,7 +139,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UIEdit::loadBuffer(byte *buffer, bool complete) { +bool UIEdit::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -165,34 +165,34 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(CAPTION) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_EDIT) { _gameRef->LOG(0, "'EDIT' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_BACK: delete _back; _back = new UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile(params))) { delete _back; _back = nullptr; cmd = PARSERR_GENERIC; @@ -202,7 +202,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new BaseSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile(params))) { delete _image; _image = nullptr; cmd = PARSERR_GENERIC; @@ -213,7 +213,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { if (_font) { _gameRef->_fontStorage->removeFont(_font); } - _font = _gameRef->_fontStorage->addFont((char *)params); + _font = _gameRef->_fontStorage->addFont(params); if (!_font) { cmd = PARSERR_GENERIC; } @@ -223,45 +223,45 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { if (_fontSelected) { _gameRef->_fontStorage->removeFont(_fontSelected); } - _fontSelected = _gameRef->_fontStorage->addFont((char *)params); + _fontSelected = _gameRef->_fontStorage->addFont(params); if (!_fontSelected) { cmd = PARSERR_GENERIC; } break; case TOKEN_TEXT: - setText((char *)params); + setText(params); _gameRef->expandStringByStringTable(&_text); break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); + parser.scanStr(params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); + parser.scanStr(params, "%d", &_height); break; case TOKEN_MAX_LENGTH: - parser.scanStr((char *)params, "%d", &_maxLength); + parser.scanStr(params, "%d", &_maxLength); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -269,27 +269,27 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_CURSOR_BLINK_RATE: - parser.scanStr((char *)params, "%d", &_cursorBlinkRate); + parser.scanStr(params, "%d", &_cursorBlinkRate); break; case TOKEN_FRAME_WIDTH: - parser.scanStr((char *)params, "%d", &_frameWidth); + parser.scanStr(params, "%d", &_frameWidth); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); + parser.scanStr(params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); + parser.scanStr(params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); + parser.scanStr(params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: @@ -627,9 +627,9 @@ bool UIEdit::display(int offsetX, int offsetY) { curFirst = true; } else { while (font->getTextWidth((byte *)_text + _scrollOffset, MAX<int32>(0, _selStart - _scrollOffset)) + - sfont->getTextWidth((byte *)(_text + MAX<int32>(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + sfont->getTextWidth((byte *)(_text + MAX<int32>(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - > _width - cursorWidth - 2 * _frameWidth) { + > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= (int)strlen(_text)) { break; @@ -932,14 +932,14 @@ bool UIEdit::persist(BasePersistenceManager *persistMgr) { UIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_cursorBlinkRate)); - persistMgr->transfer(TMEMBER(_cursorChar)); + persistMgr->transferUint32(TMEMBER(_cursorBlinkRate)); + persistMgr->transferCharPtr(TMEMBER(_cursorChar)); persistMgr->transferPtr(TMEMBER_PTR(_fontSelected)); - persistMgr->transfer(TMEMBER(_frameWidth)); - persistMgr->transfer(TMEMBER(_maxLength)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_selEnd)); - persistMgr->transfer(TMEMBER(_selStart)); + persistMgr->transferSint32(TMEMBER(_frameWidth)); + persistMgr->transferSint32(TMEMBER(_maxLength)); + persistMgr->transferSint32(TMEMBER(_scrollOffset)); + persistMgr->transferSint32(TMEMBER(_selEnd)); + persistMgr->transferSint32(TMEMBER(_selStart)); if (!persistMgr->getIsSaving()) { _cursorVisible = false; diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index a057be9ead..19ea5ecc5d 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -38,26 +38,20 @@ class BaseFont; class UIEdit : public UIObject { public: DECLARE_PERSISTENT(UIEdit, UIObject) - int32 _maxLength; + int insertChars(int pos, const byte *chars, int num); int deleteChars(int start, int end); - bool _cursorVisible; - uint32 _lastBlinkTime; + virtual bool display(int offsetX, int offsetY); virtual bool handleKeypress(Common::Event *event, bool printable = false); - int32 _scrollOffset; - int32 _frameWidth; - uint32 _cursorBlinkRate; + void setCursorChar(const char *character); - char *_cursorChar; - int32 _selEnd; - int32 _selStart; - BaseFont *_fontSelected; + UIEdit(BaseGame *inGame); virtual ~UIEdit(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface @@ -65,6 +59,17 @@ public: virtual bool scSetProperty(const char *name, ScValue *value) override; virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString() override; +private: + uint32 _cursorBlinkRate; + uint32 _lastBlinkTime; + int32 _selEnd; + int32 _selStart; + int32 _scrollOffset; + int32 _frameWidth; + BaseFont *_fontSelected; + int32 _maxLength; + bool _cursorVisible; + char *_cursorChar; }; } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 6d4cfdb7eb..0dbf8df00b 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -58,7 +58,7 @@ UIEntity::~UIEntity() { ////////////////////////////////////////////////////////////////////////// bool UIEntity::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -92,7 +92,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UIEntity::loadBuffer(byte *buffer, bool complete) { +bool UIEntity::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -106,54 +106,54 @@ bool UIEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_ENTITY_CONTAINER) { _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); + parser.scanStr(params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); + parser.scanStr(params, "%b", &_visible); break; case TOKEN_ENTITY: - if (DID_FAIL(setEntity((char *)params))) { + if (DID_FAIL(setEntity(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index 1b6e8a10d6..63f0026412 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -39,12 +39,11 @@ public: UIEntity(BaseGame *inGame); virtual ~UIEntity(); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete); + bool loadBuffer(char *buffer, bool complete); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; virtual bool display() override { return display(0, 0); } virtual bool display(int offsetX, int offsetY) override; - AdEntity *_entity; bool setEntity(const char *filename); // scripting interface @@ -52,6 +51,9 @@ public: virtual bool scSetProperty(const char *name, ScValue *value) override; virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); + +private: + AdEntity *_entity; }; } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index c32ae75c20..c04c7cbd28 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -622,23 +622,23 @@ bool UIObject::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_back)); - persistMgr->transfer(TMEMBER(_canFocus)); - persistMgr->transfer(TMEMBER(_disable)); + persistMgr->transferBool(TMEMBER(_canFocus)); + persistMgr->transferBool(TMEMBER(_disable)); persistMgr->transferPtr(TMEMBER_PTR(_focusedWidget)); persistMgr->transferPtr(TMEMBER_PTR(_font)); - persistMgr->transfer(TMEMBER(_height)); + persistMgr->transferSint32(TMEMBER(_height)); persistMgr->transferPtr(TMEMBER_PTR(_image)); persistMgr->transferPtr(TMEMBER_PTR(_listenerObject)); persistMgr->transferPtr(TMEMBER_PTR(_listenerParamObject)); - persistMgr->transfer(TMEMBER(_listenerParamDWORD)); + persistMgr->transferUint32(TMEMBER(_listenerParamDWORD)); persistMgr->transferPtr(TMEMBER_PTR(_parent)); - persistMgr->transfer(TMEMBER(_parentNotify)); - persistMgr->transfer(TMEMBER(_sharedFonts)); - persistMgr->transfer(TMEMBER(_sharedImages)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_width)); + persistMgr->transferBool(TMEMBER(_parentNotify)); + persistMgr->transferBool(TMEMBER(_sharedFonts)); + persistMgr->transferBool(TMEMBER(_sharedImages)); + persistMgr->transferCharPtr(TMEMBER(_text)); + persistMgr->transferSint32(TMEMBER_INT(_type)); + persistMgr->transferBool(TMEMBER(_visible)); + persistMgr->transferSint32(TMEMBER(_width)); return STATUS_OK; } @@ -648,4 +648,82 @@ bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_FAILED; } +int32 UIObject::getWidth() const { + return _width; +} + +// Has to be non-const to allow the virtual override to work, +// as other getHeight()-functions currently have the potential +// of having side-effects. +int32 UIObject::getHeight() { + return _height; +} + +void UIObject::setWidth(int32 width) { + assert(width >= 0); + _width = width; +} + +void UIObject::setHeight(int32 height) { + assert(height >= 0); + _height = height; +} + +bool UIObject::isDisabled() const { + return _disable; +} + +bool UIObject::isVisible() const { + return _visible; +} + +void UIObject::setVisible(bool visible) { + _visible = visible; +} + +void UIObject::setDisabled(bool disable) { + _disable = disable; +} + +bool UIObject::hasSharedFonts() const { + return _sharedFonts; +} + +void UIObject::setSharedFonts(bool shared) { + _sharedFonts = shared; +} + +bool UIObject::hasSharedImages() const { + return _sharedImages; +} + +void UIObject::setSharedImages(bool shared) { + _sharedImages = shared; +} + +BaseSprite *UIObject::getImage() const { + return _image; +} + +void UIObject::setImage(BaseSprite *image) { + _image = image; +} + +bool UIObject::canFocus() const { + return _canFocus; +} + +void UIObject::setFont(BaseFont *font) { + _font = font; +} + +BaseFont *UIObject::getFont() { + return _font; +} + +BaseScriptHolder *UIObject::getListener() const { + return _listenerObject; +} + + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 5d9508c2cf..ecbaebcee6 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -41,35 +41,23 @@ class UIObject : public BaseObject { public: bool getTotalOffset(int *offsetX, int *offsetY); - bool _canFocus; bool focus(); virtual bool handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); - bool _parentNotify; + DECLARE_PERSISTENT(UIObject, BaseObject) UIObject *_parent; virtual bool display() override { return display(0, 0); } virtual bool display(int offsetX) { return display(offsetX, 0); } virtual bool display(int offsetX, int offsetY); virtual void correctSize(); - bool _sharedFonts; - bool _sharedImages; void setText(const char *text); - char *_text; - BaseFont *_font; - bool _visible; - UITiledImage *_back; - bool _disable; + UIObject(BaseGame *inGame = nullptr); virtual ~UIObject(); - int32 _width; - int32 _height; - TUIObjectType _type; - BaseSprite *_image; void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); - BaseScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - BaseScriptHolder *_listenerObject; + BaseScriptHolder *getListener() const; + UIObject *_focusedWidget; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; @@ -78,6 +66,42 @@ public: virtual bool scSetProperty(const char *name, ScValue *value) override; virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString() override; + TUIObjectType _type; + + int32 getWidth() const; + int32 getHeight() override; + void setHeight(int32 height); + void setWidth(int32 width); + bool isDisabled() const; + void setDisabled(bool disable); + bool isVisible() const; + void setVisible(bool visible); + bool hasSharedFonts() const; + void setSharedFonts(bool shared); + bool hasSharedImages() const; + void setSharedImages(bool shared); + BaseSprite *getImage() const; + void setImage(BaseSprite *image); + void setFont(BaseFont *font); + BaseFont *getFont(); + bool canFocus() const; + +protected: + BaseScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + BaseScriptHolder *_listenerObject; + BaseSprite *_image; + BaseFont *_font; + bool _sharedFonts; + bool _sharedImages; + char *_text; + bool _visible; + bool _disable; + int32 _width; + int32 _height; + bool _canFocus; + bool _parentNotify; + UITiledImage *_back; }; } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 5dc25f5852..b255e6e790 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -103,7 +103,7 @@ bool UIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIText::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -146,7 +146,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UIText::loadBuffer(byte *buffer, bool complete) { +bool UIText::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -170,38 +170,38 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_STATIC) { _gameRef->LOG(0, "'STATIC' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_BACK: delete _back; _back = new UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile(params))) { delete _back; _back = nullptr; cmd = PARSERR_GENERIC; @@ -211,7 +211,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new BaseSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile(params))) { delete _image; _image = nullptr; cmd = PARSERR_GENERIC; @@ -222,21 +222,21 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { if (_font) { _gameRef->_fontStorage->removeFont(_font); } - _font = _gameRef->_fontStorage->addFont((char *)params); + _font = _gameRef->_fontStorage->addFont(params); if (!_font) { cmd = PARSERR_GENERIC; } break; case TOKEN_TEXT: - setText((char *)params); + setText(params); _gameRef->expandStringByStringTable(&_text); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) { + if (scumm_stricmp(params, "left") == 0) { _textAlign = TAL_LEFT; - } else if (scumm_stricmp((char *)params, "right") == 0) { + } else if (scumm_stricmp(params, "right") == 0) { _textAlign = TAL_RIGHT; } else { _textAlign = TAL_CENTER; @@ -244,9 +244,9 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) { + if (scumm_stricmp(params, "top") == 0) { _verticalAlign = VAL_TOP; - } else if (scumm_stricmp((char *)params, "bottom") == 0) { + } else if (scumm_stricmp(params, "bottom") == 0) { _verticalAlign = VAL_BOTTOM; } else { _verticalAlign = VAL_CENTER; @@ -254,25 +254,25 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); + parser.scanStr(params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); + parser.scanStr(params, "%d", &_height); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -280,19 +280,19 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); + parser.scanStr(params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); + parser.scanStr(params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); + parser.scanStr(params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: @@ -503,8 +503,8 @@ const char *UIText::scToString() { bool UIText::persist(BasePersistenceManager *persistMgr) { UIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_textAlign)); - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + persistMgr->transferSint32(TMEMBER_INT(_textAlign)); + persistMgr->transferSint32(TMEMBER_INT(_verticalAlign)); return STATUS_OK; } diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index 29ed62a5ef..c39260b228 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -37,15 +37,15 @@ namespace Wintermute { class UIText : public UIObject { private: bool sizeToFit(); + TTextAlign _textAlign; + TVerticalAlign _verticalAlign; public: virtual bool display(int offsetX, int offsetY); DECLARE_PERSISTENT(UIText, UIObject) UIText(BaseGame *inGame = nullptr); virtual ~UIText(); - TTextAlign _textAlign; - TVerticalAlign _verticalAlign; bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; // scripting interface diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index de4b86a6dd..e895477a36 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -44,15 +44,15 @@ IMPLEMENT_PERSISTENT(UITiledImage, false) UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { _image = nullptr; - BasePlatform::setRectEmpty(&_upLeft); - BasePlatform::setRectEmpty(&_upMiddle); - BasePlatform::setRectEmpty(&_upRight); - BasePlatform::setRectEmpty(&_middleLeft); - BasePlatform::setRectEmpty(&_middleMiddle); - BasePlatform::setRectEmpty(&_middleRight); - BasePlatform::setRectEmpty(&_downLeft); - BasePlatform::setRectEmpty(&_downMiddle); - BasePlatform::setRectEmpty(&_downRight); + _upLeft.setEmpty(); + _upMiddle.setEmpty(); + _upRight.setEmpty(); + _middleLeft.setEmpty(); + _middleMiddle.setEmpty(); + _middleRight.setEmpty(); + _downLeft.setEmpty(); + _downMiddle.setEmpty(); + _downRight.setEmpty(); } @@ -75,8 +75,6 @@ bool UITiledImage::display(int x, int y, int width, int height) { int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - int col, row; - _gameRef->_renderer->startSpriteBatch(); // top left/right @@ -88,27 +86,24 @@ bool UITiledImage::display(int x, int y, int width, int height) { _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); // left/right - int yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { - _image->_surface->displayTrans(x, yyy, _middleLeft); - _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); - yyy += tileWidth; + if (nuRows > 0) { + int yyy = y + (_upMiddle.bottom - _upMiddle.top); + _image->_surface->displayTiled(x, yyy, _middleLeft, 1, nuRows); + _image->_surface->displayTiled(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight, 1, nuRows); } // top/bottom - int xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, y, _upMiddle); - _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); - xxx += tileWidth; + if (nuColumns > 0) { + int xxx = x + (_upLeft.right - _upLeft.left); + _image->_surface->displayTiled(xxx, y, _upMiddle, nuColumns, 1); + _image->_surface->displayTiled(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle, nuColumns, 1); } // tiles if (nuRows > 0 && nuColumns > 0) { - yyy = y + (_upMiddle.bottom - _upMiddle.top); - xxx = x + (_upLeft.right - _upLeft.left); - _image->_surface->displayTrans(xxx, yyy, _middleMiddle); - _image->_surface->repeatLastDisplayOp(tileWidth, tileWidth, nuColumns, nuRows); + int yyy = y + (_upMiddle.bottom - _upMiddle.top); + int xxx = x + (_upLeft.right - _upLeft.left); + _image->_surface->displayTiled(xxx, yyy, _middleMiddle, nuColumns, nuRows); } _gameRef->_renderer->endSpriteBatch(); @@ -119,7 +114,7 @@ bool UITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// bool UITiledImage::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -158,7 +153,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UITiledImage::loadBuffer(byte *buffer, bool complete) { +bool UITiledImage::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -177,7 +172,7 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - byte *params; + char *params; int cmd; BaseParser parser; bool hTiles = false, vTiles = false; @@ -185,17 +180,17 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { int v1 = 0, v2 = 0, v3 = 0; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_TILED_IMAGE) { _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); return STATUS_FAILED; } buffer = params; } - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand(&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; @@ -203,7 +198,7 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new BaseSubFrame(_gameRef); - if (!_image || DID_FAIL(_image->setSurface((char *)params))) { + if (!_image || DID_FAIL(_image->setSurface(params))) { delete _image; _image = nullptr; cmd = PARSERR_GENERIC; @@ -211,48 +206,48 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_UP_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); break; case TOKEN_UP_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); break; case TOKEN_UP_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); break; case TOKEN_DOWN_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); break; case TOKEN_DOWN_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); break; case TOKEN_DOWN_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); break; case TOKEN_MIDDLE_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); break; case TOKEN_MIDDLE_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); break; case TOKEN_MIDDLE_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); break; case TOKEN_HORIZONTAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); + parser.scanStr(params, "%d,%d,%d", &h1, &h2, &h3); hTiles = true; break; case TOKEN_VERTICAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); + parser.scanStr(params, "%d,%d,%d", &v1, &v2, &v3); vTiles = true; break; @@ -272,19 +267,19 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { if (vTiles && hTiles) { // up row - BasePlatform::setRect(&_upLeft, 0, 0, h1, v1); - BasePlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); - BasePlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); + _upLeft.setRect(0, 0, h1, v1); + _upMiddle.setRect(h1, 0, h1 + h2, v1); + _upRight.setRect(h1 + h2, 0, h1 + h2 + h3, v1); // middle row - BasePlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); - BasePlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); - BasePlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); + _middleLeft.setRect(0, v1, h1, v1 + v2); + _middleMiddle.setRect(h1, v1, h1 + h2, v1 + v2); + _middleRight.setRect(h1 + h2, v1, h1 + h2 + h3, v1 + v2); // down row - BasePlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); - BasePlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); - BasePlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); + _downLeft.setRect(0, v1 + v2, h1, v1 + v2 + v3); + _downMiddle.setRect(h1, v1 + v2, h1 + h2, v1 + v2 + v3); + _downRight.setRect(h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); } // default @@ -292,34 +287,34 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { int width = _image->_surface->getWidth() / 3; int height = _image->_surface->getHeight() / 3; - if (BasePlatform::isRectEmpty(&_upLeft)) { - BasePlatform::setRect(&_upLeft, 0, 0, width, height); + if (_upLeft.isRectEmpty()) { + _upLeft.setRect(0, 0, width, height); } - if (BasePlatform::isRectEmpty(&_upMiddle)) { - BasePlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + if (_upMiddle.isRectEmpty()) { + _upMiddle.setRect(width, 0, 2 * width, height); } - if (BasePlatform::isRectEmpty(&_upRight)) { - BasePlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + if (_upRight.isRectEmpty()) { + _upRight.setRect(2 * width, 0, 3 * width, height); } - if (BasePlatform::isRectEmpty(&_middleLeft)) { - BasePlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + if (_middleLeft.isRectEmpty()) { + _middleLeft.setRect(0, height, width, 2 * height); } - if (BasePlatform::isRectEmpty(&_middleMiddle)) { - BasePlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (_middleMiddle.isRectEmpty()) { + _middleMiddle.setRect(width, height, 2 * width, 2 * height); } - if (BasePlatform::isRectEmpty(&_middleRight)) { - BasePlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + if (_middleRight.isRectEmpty()) { + _middleRight.setRect(2 * width, height, 3 * width, 2 * height); } - if (BasePlatform::isRectEmpty(&_downLeft)) { - BasePlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (_downLeft.isRectEmpty()) { + _downLeft.setRect(0, 2 * height, width, 3 * height); } - if (BasePlatform::isRectEmpty(&_downMiddle)) { - BasePlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (_downMiddle.isRectEmpty()) { + _downMiddle.setRect(width, 2 * height, 2 * width, 3 * height); } - if (BasePlatform::isRectEmpty(&_downRight)) { - BasePlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + if (_downRight.isRectEmpty()) { + _downRight.setRect(2 * width, 2 * height, 3 * width, 3 * height); } } @@ -374,16 +369,16 @@ void UITiledImage::correctSize(int32 *width, int32 *height) { bool UITiledImage::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_downLeft)); - persistMgr->transfer(TMEMBER(_downMiddle)); - persistMgr->transfer(TMEMBER(_downRight)); + persistMgr->transferRect32(TMEMBER(_downLeft)); + persistMgr->transferRect32(TMEMBER(_downMiddle)); + persistMgr->transferRect32(TMEMBER(_downRight)); persistMgr->transferPtr(TMEMBER_PTR(_image)); - persistMgr->transfer(TMEMBER(_middleLeft)); - persistMgr->transfer(TMEMBER(_middleMiddle)); - persistMgr->transfer(TMEMBER(_middleRight)); - persistMgr->transfer(TMEMBER(_upLeft)); - persistMgr->transfer(TMEMBER(_upMiddle)); - persistMgr->transfer(TMEMBER(_upRight)); + persistMgr->transferRect32(TMEMBER(_middleLeft)); + persistMgr->transferRect32(TMEMBER(_middleMiddle)); + persistMgr->transferRect32(TMEMBER(_middleRight)); + persistMgr->transferRect32(TMEMBER(_upLeft)); + persistMgr->transferRect32(TMEMBER(_upMiddle)); + persistMgr->transferRect32(TMEMBER(_upRight)); return STATUS_OK; } diff --git a/engines/wintermute/ui/ui_tiled_image.h b/engines/wintermute/ui/ui_tiled_image.h index 39bc6495a9..fa92c46781 100644 --- a/engines/wintermute/ui/ui_tiled_image.h +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -36,11 +36,13 @@ namespace Wintermute { class BaseSubFrame; class UITiledImage : public BaseObject { + using Wintermute::BaseObject::display; + public: DECLARE_PERSISTENT(UITiledImage, BaseObject) void correctSize(int32 *width, int32 *height); bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); + bool loadBuffer(char *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool display(int x, int y, int width, int height); diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 9066ee9f5b..842bf700b5 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -54,8 +54,8 @@ IMPLEMENT_PERSISTENT(UIWindow, false) ////////////////////////////////////////////////////////////////////////// UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { - BasePlatform::setRectEmpty(&_titleRect); - BasePlatform::setRectEmpty(&_dragRect); + _titleRect.setEmpty(); + _dragRect.setEmpty(); _titleAlign = TAL_LEFT; _transparent = false; @@ -141,8 +141,8 @@ bool UIWindow::display(int offsetX, int offsetY) { } if (_shieldButton) { _shieldButton->_posX = _shieldButton->_posY = 0; - _shieldButton->_width = _gameRef->_renderer->getWidth(); - _shieldButton->_height = _gameRef->_renderer->getHeight(); + _shieldButton->setWidth(_gameRef->_renderer->getWidth()); + _shieldButton->setHeight(_gameRef->_renderer->getHeight()); _shieldButton->display(); } @@ -170,7 +170,7 @@ bool UIWindow::display(int offsetX, int offsetY) { _dragFrom.y = _gameRef->_mousePos.y; } - if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { + if (!_focusedWidget || (!_focusedWidget->canFocus() || _focusedWidget->isDisabled() || !_focusedWidget->isVisible())) { moveFocus(); } @@ -213,7 +213,7 @@ bool UIWindow::display(int offsetX, int offsetY) { image->draw(_posX + offsetX, _posY + offsetY, _transparent ? nullptr : this); } - if (!BasePlatform::isRectEmpty(&_titleRect) && font && _text) { + if (!_titleRect.isRectEmpty() && font && _text) { font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } @@ -239,7 +239,7 @@ bool UIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == nullptr) { _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -298,7 +298,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool UIWindow::loadBuffer(byte *buffer, bool complete) { +bool UIWindow::loadBuffer(char *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -338,7 +338,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(EDIT) TOKEN_TABLE_END - byte *params; + char *params; int cmd = 2; BaseParser parser; @@ -346,33 +346,33 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { int ar = 0, ag = 0, ab = 0, alpha = 0; if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + if (parser.getCommand(&buffer, commands, ¶ms) != TOKEN_WINDOW) { _gameRef->LOG(0, "'WINDOW' keyword expected."); return STATUS_FAILED; } buffer = params; } - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand(&buffer, commands, ¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { + if (DID_FAIL(loadFile(params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_NAME: - setName((char *)params); + setName(params); break; case TOKEN_CAPTION: - setCaption((char *)params); + setCaption(params); break; case TOKEN_BACK: delete _back; _back = new UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile(params))) { delete _back; _back = nullptr; cmd = PARSERR_GENERIC; @@ -382,7 +382,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_INACTIVE: delete _backInactive; _backInactive = new UITiledImage(_gameRef); - if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { + if (!_backInactive || DID_FAIL(_backInactive->loadFile(params))) { delete _backInactive; _backInactive = nullptr; cmd = PARSERR_GENERIC; @@ -392,7 +392,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new BaseSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile(params))) { delete _image; _image = nullptr; cmd = PARSERR_GENERIC; @@ -400,9 +400,9 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IMAGE_INACTIVE: - delete _imageInactive, - _imageInactive = new BaseSprite(_gameRef); - if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { + delete _imageInactive; + _imageInactive = new BaseSprite(_gameRef); + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(params))) { delete _imageInactive; _imageInactive = nullptr; cmd = PARSERR_GENERIC; @@ -413,7 +413,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { if (_font) { _gameRef->_fontStorage->removeFont(_font); } - _font = _gameRef->_fontStorage->addFont((char *)params); + _font = _gameRef->_fontStorage->addFont(params); if (!_font) { cmd = PARSERR_GENERIC; } @@ -423,21 +423,21 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { if (_fontInactive) { _gameRef->_fontStorage->removeFont(_fontInactive); } - _fontInactive = _gameRef->_fontStorage->addFont((char *)params); + _fontInactive = _gameRef->_fontStorage->addFont(params); if (!_fontInactive) { cmd = PARSERR_GENERIC; } break; case TOKEN_TITLE: - setText((char *)params); + setText(params); _gameRef->expandStringByStringTable(&_text); break; case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) { + if (scumm_stricmp(params, "left") == 0) { _titleAlign = TAL_LEFT; - } else if (scumm_stricmp((char *)params, "right") == 0) { + } else if (scumm_stricmp(params, "right") == 0) { _titleAlign = TAL_RIGHT; } else { _titleAlign = TAL_CENTER; @@ -445,33 +445,33 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TITLE_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); break; case TOKEN_DRAG_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); break; case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); + parser.scanStr(params, "%d", &_posX); break; case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); + parser.scanStr(params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); + parser.scanStr(params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); + parser.scanStr(params, "%d", &_height); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; @@ -532,48 +532,48 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_TRANSPARENT: - parser.scanStr((char *)params, "%b", &_transparent); + parser.scanStr(params, "%b", &_transparent); break; case TOKEN_SCRIPT: - addScript((char *)params); + addScript(params); break; case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); + parser.scanStr(params, "%b", &_parentNotify); break; case TOKEN_PAUSE_MUSIC: - parser.scanStr((char *)params, "%b", &_pauseMusic); + parser.scanStr(params, "%b", &_pauseMusic); break; case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); + parser.scanStr(params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); + parser.scanStr(params, "%b", &_visible); break; case TOKEN_MENU: - parser.scanStr((char *)params, "%b", &_isMenu); + parser.scanStr(params, "%b", &_isMenu); break; case TOKEN_IN_GAME: - parser.scanStr((char *)params, "%b", &_inGame); + parser.scanStr(params, "%b", &_inGame); break; case TOKEN_CLIP_CONTENTS: - parser.scanStr((char *)params, "%b", &_clipContents); + parser.scanStr(params, "%b", &_clipContents); break; case TOKEN_FADE_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); + parser.scanStr(params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); _fadeBackground = true; break; case TOKEN_FADE_ALPHA: - parser.scanStr((char *)params, "%d", &fadeA); + parser.scanStr(params, "%d", &fadeA); _fadeBackground = true; break; @@ -582,16 +582,16 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; default: - if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { + if (DID_FAIL(_gameRef->windowLoadHook(this, &buffer, ¶ms))) { cmd = PARSERR_GENERIC; } } @@ -676,11 +676,11 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } - if (!BasePlatform::isRectEmpty(&_titleRect)) { + if (!_titleRect.isRectEmpty()) { buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } - if (!BasePlatform::isRectEmpty(&_dragRect)) { + if (!_dragRect.isRectEmpty()) { buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } @@ -737,7 +737,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool UIWindow::enableWidget(const char *name, bool enable) { for (uint32 i = 0; i < _widgets.size(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_disable = !enable; + _widgets[i]->setDisabled(!enable); } } return STATUS_OK; @@ -748,7 +748,7 @@ bool UIWindow::enableWidget(const char *name, bool enable) { bool UIWindow::showWidget(const char *name, bool visible) { for (uint32 i = 0; i < _widgets.size(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_visible = visible; + _widgets[i]->setVisible(visible); } } return STATUS_OK; @@ -1227,7 +1227,7 @@ bool UIWindow::handleMouse(TMouseEvent event, TMouseButton button) { bool res = UIObject::handleMouse(event, button); // handle window dragging - if (!BasePlatform::isRectEmpty(&_dragRect)) { + if (!_dragRect.isRectEmpty()) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { Rect32 dragRect = _dragRect; @@ -1258,24 +1258,24 @@ bool UIWindow::persist(BasePersistenceManager *persistMgr) { UIObject::persist(persistMgr); persistMgr->transferPtr(TMEMBER_PTR(_backInactive)); - persistMgr->transfer(TMEMBER(_clipContents)); - persistMgr->transfer(TMEMBER(_dragFrom)); - persistMgr->transfer(TMEMBER(_dragging)); - persistMgr->transfer(TMEMBER(_dragRect)); - persistMgr->transfer(TMEMBER(_fadeBackground)); - persistMgr->transfer(TMEMBER(_fadeColor)); + persistMgr->transferBool(TMEMBER(_clipContents)); + persistMgr->transferPoint32(TMEMBER(_dragFrom)); + persistMgr->transferBool(TMEMBER(_dragging)); + persistMgr->transferRect32(TMEMBER(_dragRect)); + persistMgr->transferBool(TMEMBER(_fadeBackground)); + persistMgr->transferUint32(TMEMBER(_fadeColor)); persistMgr->transferPtr(TMEMBER_PTR(_fontInactive)); persistMgr->transferPtr(TMEMBER_PTR(_imageInactive)); - persistMgr->transfer(TMEMBER(_inGame)); - persistMgr->transfer(TMEMBER(_isMenu)); - persistMgr->transfer(TMEMBER_INT(_mode)); + persistMgr->transferBool(TMEMBER(_inGame)); + persistMgr->transferBool(TMEMBER(_isMenu)); + persistMgr->transferSint32(TMEMBER_INT(_mode)); persistMgr->transferPtr(TMEMBER_PTR(_shieldButton)); persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow)); - persistMgr->transfer(TMEMBER_INT(_titleAlign)); - persistMgr->transfer(TMEMBER(_titleRect)); - persistMgr->transfer(TMEMBER(_transparent)); + persistMgr->transferSint32(TMEMBER_INT(_titleAlign)); + persistMgr->transferRect32(TMEMBER(_titleRect)); + persistMgr->transferBool(TMEMBER(_transparent)); persistMgr->transferPtr(TMEMBER_PTR(_viewport)); - persistMgr->transfer(TMEMBER(_pauseMusic)); + persistMgr->transferBool(TMEMBER(_pauseMusic)); _widgets.persist(persistMgr); @@ -1309,7 +1309,7 @@ bool UIWindow::moveFocus(bool forward) { bool done = false; while (numTries <= (int32)_widgets.size()) { - if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + if (_widgets[i] != _focusedWidget && _widgets[i]->canFocus() && _widgets[i]->isVisible() && !_widgets[i]->isDisabled()) { _focusedWidget = _widgets[i]; done = true; break; @@ -1419,7 +1419,7 @@ void UIWindow::makeFreezable(bool freezable) { bool UIWindow::getWindowObjects(BaseArray<UIObject *> &objects, bool interactiveOnly) { for (uint32 i = 0; i < _widgets.size(); i++) { UIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) { + if (control->isDisabled() && interactiveOnly) { continue; } @@ -1442,4 +1442,14 @@ bool UIWindow::getWindowObjects(BaseArray<UIObject *> &objects, bool interactive return STATUS_OK; } +bool UIWindow::getInGame() const { + return _inGame; +} + +TWindowMode UIWindow::getMode() const { + return _mode; +} + + + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 8a726fdff8..6b4d970581 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -38,47 +38,32 @@ namespace Wintermute { class UIButton; class BaseViewport; class UIWindow : public UIObject { - uint32 _fadeColor; public: bool getWindowObjects(BaseArray<UIObject *> &Objects, bool InteractiveOnly); - bool _pauseMusic; void cleanup(); virtual void makeFreezable(bool freezable); - BaseViewport *_viewport; - bool _clipContents; - bool _inGame; - bool _isMenu; - bool _fadeBackground; virtual bool handleMouseWheel(int delta); - UIWindow *_shieldWindow; - UIButton *_shieldButton; + bool close(); bool goSystemExclusive(); bool goExclusive(); - TWindowMode _mode; bool moveFocus(bool forward = true); virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); - Point32 _dragFrom; - bool _dragging; DECLARE_PERSISTENT(UIWindow, UIObject) - bool _transparent; bool showWidget(const char *name, bool visible = true); bool enableWidget(const char *name, bool enable = true); - Rect32 _titleRect; - Rect32 _dragRect; + virtual bool display(int offsetX = 0, int offsetY = 0) override; UIWindow(BaseGame *inGame); virtual ~UIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false) override; BaseArray<UIObject *> _widgets; - TTextAlign _titleAlign; + bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - UITiledImage *_backInactive; - BaseFont *_fontInactive; - BaseSprite *_imageInactive; + bool loadBuffer(char *buffer, bool complete = true); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; @@ -87,6 +72,30 @@ public: virtual bool scSetProperty(const char *name, ScValue *value) override; virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString(); + + bool getInGame() const; + TWindowMode getMode() const; + +private: + bool _pauseMusic; + BaseViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + TWindowMode _mode; + Point32 _dragFrom; + bool _dragging; + bool _transparent; + uint32 _fadeColor; + UIWindow *_shieldWindow; + UIButton *_shieldButton; + Rect32 _titleRect; + Rect32 _dragRect; + UITiledImage *_backInactive; + BaseFont *_fontInactive; + BaseSprite *_imageInactive; + TTextAlign _titleAlign; }; } // End of namespace Wintermute diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index f3317684b5..44eecf93a8 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -34,7 +34,6 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/platform_osystem.h" #include "video/theora_decoder.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" @@ -396,7 +395,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) { bool res; if (_texture && _videoFrameReady) { - BasePlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); + rc.setRect(0, 0, _texture->getWidth(), _texture->getHeight()); if (_playZoom == 100.0f) { res = _texture->displayTrans(_posX, _posY, rc, alpha); } else { @@ -492,16 +491,16 @@ bool VideoTheoraPlayer::persist(BasePersistenceManager *persistMgr) { } persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); - persistMgr->transfer(TMEMBER(_savedPos)); - persistMgr->transfer(TMEMBER(_savedState)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_alphaFilename)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transferUint32(TMEMBER(_savedPos)); + persistMgr->transferSint32(TMEMBER(_savedState)); + persistMgr->transferString(TMEMBER(_filename)); + persistMgr->transferString(TMEMBER(_alphaFilename)); + persistMgr->transferSint32(TMEMBER(_posX)); + persistMgr->transferSint32(TMEMBER(_posY)); persistMgr->transferFloat(TMEMBER(_playZoom)); - persistMgr->transfer(TMEMBER_INT(_playbackType)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_volume)); + persistMgr->transferSint32(TMEMBER_INT(_playbackType)); + persistMgr->transferBool(TMEMBER(_looping)); + persistMgr->transferSint32(TMEMBER(_volume)); if (!persistMgr->getIsSaving() && (_savedState != THEORA_STATE_NONE)) { initializeSimple(); diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index ddeba48bbc..7b28a71e17 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -62,7 +62,7 @@ public: //CVidSubtitler *_subtitler; // control methods - bool initialize(const Common::String &filename, const Common::String &subtitleFile = nullptr); + bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String()); bool initializeSimple(); bool update(); bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); @@ -90,7 +90,7 @@ public: BaseImage *_alphaImage; Common::String _alphaFilename; bool setAlphaImage(const Common::String &filename); - __inline byte getAlphaAt(int x, int y) const; + byte getAlphaAt(int x, int y) const; void writeAlpha(); bool seekToTime(uint32 Time); |