diff options
author | Willem Jan Palenstijn | 2013-04-18 23:55:01 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:44 +0200 |
commit | 102299630901d08a44ef3aec367fcbcae065b9fe (patch) | |
tree | 98db4bbe0c54176c0a43e2f5076f8b3d63b8065c /engines/wintermute/ad/ad_object.cpp | |
parent | 583f9abaf98f64895546b75573e9442ca47426e3 (diff) | |
parent | 78ba3210a57094086d44b25d5a8507c33ce9bef3 (diff) | |
download | scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.gz scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.bz2 scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.zip |
Merge branch 'master'
Diffstat (limited to 'engines/wintermute/ad/ad_object.cpp')
-rw-r--r-- | engines/wintermute/ad/ad_object.cpp | 112 |
1 files changed, 57 insertions, 55 deletions
diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 7b91daab2e..9026b2849c 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -38,7 +38,6 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/font/base_font.h" @@ -65,27 +64,27 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { _active = true; _drawn = false; - _currentSprite = NULL; - _animSprite = NULL; - _tempSprite2 = NULL; + _currentSprite = nullptr; + _animSprite = nullptr; + _tempSprite2 = nullptr; - _font = NULL; + _font = nullptr; - _sentence = NULL; + _sentence = nullptr; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; _forcedTalkAnimUsed = false; - _blockRegion = NULL; - _wptGroup = NULL; + _blockRegion = nullptr; + _wptGroup = nullptr; - _currentBlockRegion = NULL; - _currentWptGroup = NULL; + _currentBlockRegion = nullptr; + _currentWptGroup = nullptr; _ignoreItems = false; _sceneIndependent = false; - _stickRegion = NULL; + _stickRegion = nullptr; _subtitlesModRelative = true; _subtitlesModX = 0; @@ -93,13 +92,13 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { _subtitlesWidth = 0; _subtitlesModXCenter = true; - _inventory = NULL; + _inventory = nullptr; for (int i = 0; i < MAX_NUM_REGIONS; i++) { - _currentRegions[i] = NULL; + _currentRegions[i] = nullptr; } - _partEmitter = NULL; + _partEmitter = nullptr; _partFollowParent = false; _partOffsetX = _partOffsetY = 0; @@ -109,26 +108,26 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdObject::~AdObject() { - _currentSprite = NULL; // reference only, don't delete + _currentSprite = nullptr; // reference only, don't delete delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; delete _sentence; - _sentence = NULL; + _sentence = nullptr; delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; delete _blockRegion; - _blockRegion = NULL; + _blockRegion = nullptr; delete _wptGroup; - _wptGroup = NULL; + _wptGroup = nullptr; delete _currentBlockRegion; - _currentBlockRegion = NULL; + _currentBlockRegion = nullptr; delete _currentWptGroup; - _currentWptGroup = NULL; + _currentWptGroup = nullptr; - _tempSprite2 = NULL; // reference only - _stickRegion = NULL; + _tempSprite2 = nullptr; // reference only + _stickRegion = nullptr; if (_font) { _gameRef->_fontStorage->removeFont(_font); @@ -136,7 +135,7 @@ AdObject::~AdObject() { if (_inventory) { ((AdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; + _inventory = nullptr; } if (_partEmitter) { @@ -159,7 +158,7 @@ AdObject::~AdObject() { ////////////////////////////////////////////////////////////////////////// bool AdObject::playAnim(const char *filename) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; _animSprite = new BaseSprite(_gameRef, this); if (!_animSprite) { _gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); @@ -169,7 +168,7 @@ bool AdObject::playAnim(const char *filename) { if (DID_FAIL(res)) { _gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; return res; } _state = STATE_PLAYING_ANIM; @@ -274,7 +273,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int duration = stack->pop()->getInt(); ScValue *valStances = stack->pop(); - const char *stances = valStances->isNULL() ? NULL : valStances->getString(); + const char *stances = valStances->isNULL() ? nullptr : valStances->getString(); int align = 0; ScValue *val = stack->pop(); @@ -286,7 +285,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); - const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); + const char *sound = soundVal->isNULL() ? nullptr : soundVal->getString(); talk(text, sound, duration, stances, (TTextAlign)align); if (strcmp(name, "TalkAsync") != 0) { @@ -309,7 +308,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack uint32 i; ScValue *val = stack->pop(); if (val->isNULL() || !main) { - _stickRegion = NULL; + _stickRegion = nullptr; regFound = true; } else if (val->isString()) { const char *regionName = val->getString(); @@ -334,7 +333,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } if (!regFound) { - _stickRegion = NULL; + _stickRegion = nullptr; } stack->pushBool(regFound); return STATUS_OK; @@ -348,7 +347,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (val->isNULL()) { - setFont(NULL); + setFont(nullptr); } else { setFont(val->getString()); } @@ -385,7 +384,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (!val->isNULL()) { const char *itemName = val->getString(); val = stack->pop(); - const char *insertAfter = val->isNULL() ? NULL : val->getString(); + const char *insertAfter = val->isNULL() ? nullptr : val->getString(); if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) { script->runtimeError("Cannot add item '%s' to inventory", itemName); } else { @@ -512,7 +511,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); if (_partEmitter) { _gameRef->unregisterObject(_partEmitter); - _partEmitter = NULL; + _partEmitter = nullptr; } stack->pushNULL(); @@ -533,7 +532,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack AdEntity *ent = new AdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; - ent = NULL; + ent = nullptr; script->runtimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { @@ -611,7 +610,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); - AdObject *ret = NULL; + AdObject *ret = nullptr; if (val->isInt()) { int index = val->getInt(); int currIndex = 0; @@ -645,7 +644,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } - if (ret != NULL) { + if (ret != nullptr) { stack->pushNative(ret, true); } else { stack->pushNULL(); @@ -851,9 +850,9 @@ bool AdObject::setFont(const char *filename) { } if (filename) { _font = _gameRef->_fontStorage->addFont(filename); - return _font == NULL ? STATUS_FAILED : STATUS_OK; + return _font == nullptr ? STATUS_FAILED : STATUS_OK; } else { - _font = NULL; + _font = nullptr; return STATUS_OK; } } @@ -878,6 +877,9 @@ int AdObject::getHeight() { } } +TObjectType AdObject::getType() const { + return _type; +} ////////////////////////////////////////////////////////////////////////// void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { @@ -890,27 +892,27 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const if (_forcedTalkAnimName && _forcedTalkAnimUsed) { delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; _forcedTalkAnimUsed = false; } delete(_sentence->_sound); - _sentence->_sound = NULL; + _sentence->_sound = nullptr; _sentence->setText(text); - _gameRef->_stringTable->expand(&_sentence->_text); + _gameRef->expandStringByStringTable(&_sentence->_text); _sentence->setStances(stances); _sentence->_duration = duration; _sentence->_align = Align; - _sentence->_startTime = _gameRef->_timer; + _sentence->_startTime = _gameRef->getTimer()->getTime(); _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; + _sentence->_font = _font == nullptr ? _gameRef->getSystemFont() : _font; _sentence->_freezable = _freezable; // try to locate speech file automatically bool deleteSound = false; if (!sound) { - char *key = _gameRef->_stringTable->getKey(text); + char *key = _gameRef->getKeyFromStringTable(text); if (key) { sound = ((AdGame *)_gameRef)->findSpeechFile(key); delete[] key; @@ -957,10 +959,10 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const if (_subtitlesWidth > 0) { width = _subtitlesWidth; } else { - if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { - width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); + if ((x < _gameRef->_renderer->getWidth() / 4 || x > _gameRef->_renderer->getWidth() * 0.75) && !_gameRef->_touchInterface) { + width = MAX(_gameRef->_renderer->getWidth() / 4, MIN(x * 2, (_gameRef->_renderer->getWidth() - x) * 2)); } else { - width = _gameRef->_renderer->_width / 2; + width = _gameRef->_renderer->getWidth() / 2; } } @@ -979,8 +981,8 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const } - x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); - y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); + x = MIN(MAX(0, x), _gameRef->_renderer->getWidth() - width); + y = MIN(MAX(0, y), _gameRef->_renderer->getHeight() - height); _sentence->_width = width; @@ -1009,9 +1011,9 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const ////////////////////////////////////////////////////////////////////////// bool AdObject::reset() { - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + if (_state == STATE_PLAYING_ANIM && _animSprite != nullptr) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } else if (_state == STATE_TALKING && _sentence) { _sentence->finish(); } @@ -1154,7 +1156,7 @@ bool AdObject::afterMove() { bool regFound = false; for (int j = 0; j < MAX_NUM_REGIONS; j++) { if (_currentRegions[j] == newRegions[i]) { - _currentRegions[j] = NULL; + _currentRegions[j] = nullptr; regFound = true; break; } @@ -1177,7 +1179,7 @@ bool AdObject::afterMove() { ////////////////////////////////////////////////////////////////////////// bool AdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) { - _currentRegions[i] = NULL; + _currentRegions[i] = nullptr; } return STATUS_OK; } |