diff options
Diffstat (limited to 'engines/wintermute/ui')
-rw-r--r-- | engines/wintermute/ui/ui_button.cpp | 78 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_button.h | 2 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_edit.cpp | 22 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_entity.cpp | 8 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_object.cpp | 26 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_object.h | 2 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_text.cpp | 12 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_text.h | 2 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_tiled_image.cpp | 19 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_tiled_image.h | 3 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_window.cpp | 50 |
11 files changed, 111 insertions, 113 deletions
diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 7967d566f9..6ee577f009 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -48,11 +48,11 @@ IMPLEMENT_PERSISTENT(UIButton, false) ////////////////////////////////////////////////////////////////////////// UIButton::UIButton(BaseGame *inGame) : UIObject(inGame) { - _backPress = _backHover = _backDisable = _backFocus = NULL; + _backPress = _backHover = _backDisable = _backFocus = nullptr; - _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; + _fontHover = _fontPress = _fontDisable = _fontFocus = nullptr; - _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; + _imageDisable = _imagePress = _imageHover = _imageFocus = nullptr; _align = TAL_CENTER; @@ -104,7 +104,7 @@ UIButton::~UIButton() { ////////////////////////////////////////////////////////////////////////// bool UIButton::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -235,7 +235,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; - _back = NULL; + _back = nullptr; cmd = PARSERR_GENERIC; } break; @@ -245,7 +245,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _backHover = new UITiledImage(_gameRef); if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { delete _backHover; - _backHover = NULL; + _backHover = nullptr; cmd = PARSERR_GENERIC; } break; @@ -255,7 +255,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _backPress = new UITiledImage(_gameRef); if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { delete _backPress; - _backPress = NULL; + _backPress = nullptr; cmd = PARSERR_GENERIC; } break; @@ -265,7 +265,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _backDisable = new UITiledImage(_gameRef); if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { delete _backDisable; - _backDisable = NULL; + _backDisable = nullptr; cmd = PARSERR_GENERIC; } break; @@ -275,7 +275,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _backFocus = new UITiledImage(_gameRef); if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { delete _backFocus; - _backFocus = NULL; + _backFocus = nullptr; cmd = PARSERR_GENERIC; } break; @@ -285,7 +285,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; - _image = NULL; + _image = nullptr; cmd = PARSERR_GENERIC; } break; @@ -295,7 +295,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _imageHover = new BaseSprite(_gameRef); if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { delete _imageHover; - _imageHover = NULL; + _imageHover = nullptr; cmd = PARSERR_GENERIC; } break; @@ -305,7 +305,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _imagePress = new BaseSprite(_gameRef); if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { delete _imagePress; - _imagePress = NULL; + _imagePress = nullptr; cmd = PARSERR_GENERIC; } break; @@ -315,7 +315,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _imageDisable = new BaseSprite(_gameRef); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { delete _imageDisable; - _imageDisable = NULL; + _imageDisable = nullptr; cmd = PARSERR_GENERIC; } break; @@ -325,7 +325,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _imageFocus = new BaseSprite(_gameRef); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { delete _imageFocus; - _imageFocus = NULL; + _imageFocus = nullptr; cmd = PARSERR_GENERIC; } break; @@ -416,7 +416,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -592,7 +592,7 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { void UIButton::correctSize() { Rect32 rect; - BaseSprite *img = NULL; + BaseSprite *img = nullptr; if (_image) { img = _image; } else if (_imageDisable) { @@ -622,15 +622,15 @@ void UIButton::correctSize() { } if (_text) { - int text_height; + int textHeight; if (_font) { - text_height = _font->getTextHeight((byte *)_text, _width); + textHeight = _font->getTextHeight((byte *)_text, _width); } else { - text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); + textHeight = _gameRef->getSystemFont()->getTextHeight((byte *)_text, _width); } - if (text_height > _height) { - _height = text_height; + if (textHeight > _height) { + _height = textHeight; } } @@ -650,8 +650,8 @@ bool UIButton::display(int offsetX, int offsetY) { return STATUS_OK; } - UITiledImage *back = NULL; - BaseSprite *image = NULL; + UITiledImage *back = nullptr; + BaseSprite *image = nullptr; BaseFont *font = 0; //RECT rect; @@ -717,7 +717,7 @@ bool UIButton::display(int offsetX, int offsetY) { if (_font) { font = _font; } else { - font = _gameRef->_systemFont; + font = _gameRef->getSystemFont(); } } @@ -734,9 +734,9 @@ bool UIButton::display(int offsetX, int offsetY) { if (back) { back->display(offsetX + _posX, offsetY + _posY, _width, _height); } - //if (image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + //if (image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), nullptr); if (image) { - image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : nullptr); } if (font && _text) { @@ -745,7 +745,7 @@ bool UIButton::display(int offsetX, int offsetY) { } if (!_pixelPerfect || !_image) { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, nullptr, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); } // reset unused sprites @@ -800,11 +800,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_fontDisable); } if (val->isNULL()) { - _fontDisable = NULL; + _fontDisable = nullptr; stack->pushBool(true); } else { _fontDisable = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontDisable != NULL); + stack->pushBool(_fontDisable != nullptr); } return STATUS_OK; } @@ -820,11 +820,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_fontHover); } if (val->isNULL()) { - _fontHover = NULL; + _fontHover = nullptr; stack->pushBool(true); } else { _fontHover = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontHover != NULL); + stack->pushBool(_fontHover != nullptr); } return STATUS_OK; } @@ -840,11 +840,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_fontPress); } if (val->isNULL()) { - _fontPress = NULL; + _fontPress = nullptr; stack->pushBool(true); } else { _fontPress = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontPress != NULL); + stack->pushBool(_fontPress != nullptr); } return STATUS_OK; } @@ -860,11 +860,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_fontFocus); } if (val->isNULL()) { - _fontFocus = NULL; + _fontFocus = nullptr; stack->pushBool(true); } else { _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontFocus != NULL); + stack->pushBool(_fontFocus != nullptr); } return STATUS_OK; } @@ -880,7 +880,7 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { delete _imageDisable; - _imageDisable = NULL; + _imageDisable = nullptr; stack->pushBool(false); } else { stack->pushBool(true); @@ -929,7 +929,7 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { delete _imageHover; - _imageHover = NULL; + _imageHover = nullptr; stack->pushBool(false); } else { stack->pushBool(true); @@ -977,7 +977,7 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { delete _imagePress; - _imagePress = NULL; + _imagePress = nullptr; stack->pushBool(false); } else { stack->pushBool(true); @@ -1025,7 +1025,7 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { delete _imageFocus; - _imageFocus = NULL; + _imageFocus = nullptr; stack->pushBool(false); } else { stack->pushBool(true); diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 93333a2534..fea264976f 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -62,7 +62,7 @@ public: UITiledImage *_backHover; UITiledImage *_backDisable; UITiledImage *_backFocus; - UIButton(BaseGame *inGame = NULL); + UIButton(BaseGame *inGame = nullptr); virtual ~UIButton(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index a3283d5a01..0a2e6f13bc 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -56,12 +56,12 @@ IMPLEMENT_PERSISTENT(UIEdit, false) UIEdit::UIEdit(BaseGame *inGame) : UIObject(inGame) { _type = UI_EDIT; - _fontSelected = NULL; + _fontSelected = nullptr; _selStart = _selEnd = 10000; _scrollOffset = 0; - _cursorChar = NULL; + _cursorChar = nullptr; setCursorChar("|"); _cursorBlinkRate = 600; @@ -88,14 +88,14 @@ UIEdit::~UIEdit() { } delete[] _cursorChar; - _cursorChar = NULL; + _cursorChar = nullptr; } ////////////////////////////////////////////////////////////////////////// bool UIEdit::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -194,7 +194,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; - _back = NULL; + _back = nullptr; cmd = PARSERR_GENERIC; } break; @@ -204,7 +204,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; - _image = NULL; + _image = nullptr; cmd = PARSERR_GENERIC; } break; @@ -263,7 +263,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -388,7 +388,7 @@ bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, _gameRef->_fontStorage->removeFont(_fontSelected); } _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontSelected != NULL); + stack->pushBool(_fontSelected != nullptr); return STATUS_OK; } else { @@ -579,7 +579,7 @@ bool UIEdit::display(int offsetX, int offsetY) { _back->display(offsetX + _posX, offsetY + _posY, _width, _height); } if (_image) { - _image->draw(offsetX + _posX, offsetY + _posY, NULL); + _image->draw(offsetX + _posX, offsetY + _posY, nullptr); } // prepare fonts @@ -589,7 +589,7 @@ bool UIEdit::display(int offsetX, int offsetY) { if (_font) { font = _font; } else { - font = _gameRef->_systemFont; + font = _gameRef->getSystemFont(); } if (_fontSelected) { @@ -726,7 +726,7 @@ bool UIEdit::display(int offsetX, int offsetY) { } - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, nullptr, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); _gameRef->_textEncoding = OrigEncoding; diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 1cb4e0926b..00d442e895 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -43,7 +43,7 @@ IMPLEMENT_PERSISTENT(UIEntity, false) ////////////////////////////////////////////////////////////////////////// UIEntity::UIEntity(BaseGame *inGame) : UIObject(inGame) { _type = UI_CUSTOM; - _entity = NULL; + _entity = nullptr; } @@ -52,14 +52,14 @@ UIEntity::~UIEntity() { if (_entity) { _gameRef->unregisterObject(_entity); } - _entity = NULL; + _entity = nullptr; } ////////////////////////////////////////////////////////////////////////// bool UIEntity::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -223,7 +223,7 @@ bool UIEntity::setEntity(const char *filename) { _entity = new AdEntity(_gameRef); if (!_entity || DID_FAIL(_entity->loadFile(filename))) { delete _entity; - _entity = NULL; + _entity = nullptr; return STATUS_FAILED; } else { _entity->_nonIntMouseEvents = true; diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 8e5bae993c..9dea3dadf9 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -43,27 +43,27 @@ IMPLEMENT_PERSISTENT(UIObject, false) ////////////////////////////////////////////////////////////////////////// UIObject::UIObject(BaseGame *inGame) : BaseObject(inGame) { - _back = NULL; - _image = NULL; - _font = NULL; - _text = NULL; + _back = nullptr; + _image = nullptr; + _font = nullptr; + _text = nullptr; _sharedFonts = _sharedImages = false; _width = _height = 0; - _listenerObject = NULL; - _listenerParamObject = NULL; + _listenerObject = nullptr; + _listenerParamObject = nullptr; _listenerParamDWORD = 0; _disable = false; _visible = true; _type = UI_UNKNOWN; - _parent = NULL; + _parent = nullptr; _parentNotify = false; - _focusedWidget = NULL; + _focusedWidget = nullptr; _canFocus = false; _nonIntMouseEvents = true; @@ -91,7 +91,7 @@ UIObject::~UIObject() { delete[] _text; } - _focusedWidget = NULL; // ref only + _focusedWidget = nullptr; // ref only } @@ -168,11 +168,11 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_font); } if (val->isNULL()) { - _font = NULL; + _font = nullptr; stack->pushBool(true); } else { _font = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_font != NULL); + stack->pushBool(_font != nullptr); } return STATUS_OK; } @@ -187,7 +187,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack /* const char *filename = */ val->getString(); delete _image; - _image = NULL; + _image = nullptr; if (val->isNULL()) { stack->pushBool(true); return STATUS_OK; @@ -196,7 +196,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { delete _image; - _image = NULL; + _image = nullptr; stack->pushBool(false); } else { stack->pushBool(true); diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index ec2ea33de1..c77acfef41 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -60,7 +60,7 @@ public: bool _visible; UITiledImage *_back; bool _disable; - UIObject(BaseGame *inGame = NULL); + UIObject(BaseGame *inGame = nullptr); virtual ~UIObject(); int _width; int _height; diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 2c10f176c7..3b5adf07b7 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -69,14 +69,14 @@ bool UIText::display(int offsetX, int offsetY) { BaseFont *font = _font; if (!font) { - font = _gameRef->_systemFont; + font = _gameRef->getSystemFont(); } if (_back) { _back->display(offsetX + _posX, offsetY + _posY, _width, _height); } if (_image) { - _image->draw(offsetX + _posX, offsetY + _posY, NULL); + _image->draw(offsetX + _posX, offsetY + _posY, nullptr); } if (font && _text) { @@ -104,7 +104,7 @@ bool UIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIText::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -203,7 +203,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; - _back = NULL; + _back = nullptr; cmd = PARSERR_GENERIC; } break; @@ -213,7 +213,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; - _image = NULL; + _image = nullptr; cmd = PARSERR_GENERIC; } break; @@ -274,7 +274,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index da4d113500..11dcdb166d 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -40,7 +40,7 @@ private: public: virtual bool display(int offsetX, int offsetY); DECLARE_PERSISTENT(UIText, UIObject) - UIText(BaseGame *inGame = NULL); + UIText(BaseGame *inGame = nullptr); virtual ~UIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 2b337330c7..be9f87cf58 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -42,7 +42,7 @@ IMPLEMENT_PERSISTENT(UITiledImage, false) ////////////////////////////////////////////////////////////////////////// UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { - _image = NULL; + _image = nullptr; BasePlatform::setRectEmpty(&_upLeft); BasePlatform::setRectEmpty(&_upMiddle); @@ -59,7 +59,7 @@ UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// UITiledImage::~UITiledImage() { delete _image; - _image = NULL; + _image = nullptr; } @@ -104,14 +104,11 @@ bool UITiledImage::display(int x, int y, int width, int height) { } // tiles - yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { + if (nuRows > 0 && nuColumns > 0) { + yyy = y + (_upMiddle.bottom - _upMiddle.top); xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, yyy, _middleMiddle); - xxx += tileWidth; - } - yyy += tileWidth; + _image->_surface->displayTrans(xxx, yyy, _middleMiddle); + _image->_surface->repeatLastDisplayOp(tileWidth, tileWidth, nuColumns, nuRows); } _gameRef->_renderer->endSpriteBatch(); @@ -123,7 +120,7 @@ bool UITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// bool UITiledImage::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -208,7 +205,7 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { _image = new BaseSubFrame(_gameRef); if (!_image || DID_FAIL(_image->setSurface((char *)params))) { delete _image; - _image = NULL; + _image = nullptr; cmd = PARSERR_GENERIC; } break; diff --git a/engines/wintermute/ui/ui_tiled_image.h b/engines/wintermute/ui/ui_tiled_image.h index c413e7f129..ded7a285dd 100644 --- a/engines/wintermute/ui/ui_tiled_image.h +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -44,8 +44,9 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); bool display(int x, int y, int width, int height); - UITiledImage(BaseGame *inGame = NULL); + UITiledImage(BaseGame *inGame = nullptr); virtual ~UITiledImage(); +private: BaseSubFrame *_image; Rect32 _upLeft; Rect32 _upMiddle; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 9606486efb..39bc1bdcfe 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -59,9 +59,9 @@ UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { _titleAlign = TAL_LEFT; _transparent = false; - _backInactive = NULL; - _fontInactive = NULL; - _imageInactive = NULL; + _backInactive = nullptr; + _fontInactive = nullptr; + _imageInactive = nullptr; _type = UI_WINDOW; _canFocus = true; @@ -70,8 +70,8 @@ UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { _dragFrom.x = _dragFrom.y = 0; _mode = WINDOW_NORMAL; - _shieldWindow = NULL; - _shieldButton = NULL; + _shieldWindow = nullptr; + _shieldButton = nullptr; _fadeColor = 0x00000000; _fadeBackground = false; @@ -81,7 +81,7 @@ UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { _inGame = false; _clipContents = false; - _viewport = NULL; + _viewport = nullptr; _pauseMusic = true; } @@ -99,9 +99,9 @@ void UIWindow::cleanup() { delete _shieldWindow; delete _shieldButton; delete _viewport; - _shieldWindow = NULL; - _shieldButton = NULL; - _viewport = NULL; + _shieldWindow = nullptr; + _shieldButton = nullptr; + _viewport = nullptr; delete _backInactive; if (!_sharedFonts && _fontInactive) { @@ -210,7 +210,7 @@ bool UIWindow::display(int offsetX, int offsetY) { back->display(_posX + offsetX, _posY + offsetY, _width, _height); } if (image) { - image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); + image->draw(_posX + offsetX, _posY + offsetY, _transparent ? nullptr : this); } if (!BasePlatform::isRectEmpty(&_titleRect) && font && _text) { @@ -218,7 +218,7 @@ bool UIWindow::display(int offsetX, int offsetY) { } if (!_transparent && !image) { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, nullptr, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); } for (uint32 i = 0; i < _widgets.size(); i++) { @@ -240,7 +240,7 @@ bool UIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -374,7 +374,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; - _back = NULL; + _back = nullptr; cmd = PARSERR_GENERIC; } break; @@ -384,7 +384,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _backInactive = new UITiledImage(_gameRef); if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { delete _backInactive; - _backInactive = NULL; + _backInactive = nullptr; cmd = PARSERR_GENERIC; } break; @@ -394,7 +394,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; - _image = NULL; + _image = nullptr; cmd = PARSERR_GENERIC; } break; @@ -404,7 +404,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _imageInactive = new BaseSprite(_gameRef); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { delete _imageInactive; - _imageInactive = NULL; + _imageInactive = nullptr; cmd = PARSERR_GENERIC; } break; @@ -473,7 +473,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -482,7 +482,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { UIButton *btn = new UIButton(_gameRef); if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { delete btn; - btn = NULL; + btn = nullptr; cmd = PARSERR_GENERIC; } else { btn->_parent = this; @@ -495,7 +495,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { UIText *text = new UIText(_gameRef); if (!text || DID_FAIL(text->loadBuffer(params, false))) { delete text; - text = NULL; + text = nullptr; cmd = PARSERR_GENERIC; } else { text->_parent = this; @@ -508,7 +508,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { UIEdit *edit = new UIEdit(_gameRef); if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { delete edit; - edit = NULL; + edit = nullptr; cmd = PARSERR_GENERIC; } else { edit->_parent = this; @@ -521,7 +521,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { UIWindow *win = new UIWindow(_gameRef); if (!win || DID_FAIL(win->loadBuffer(params, false))) { delete win; - win = NULL; + win = nullptr; cmd = PARSERR_GENERIC; } else { win->_parent = this; @@ -616,7 +616,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); } - _focusedWidget = NULL; + _focusedWidget = nullptr; return STATUS_OK; } @@ -795,7 +795,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->_fontStorage->removeFont(_fontInactive); } _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontInactive != NULL); + stack->pushBool(_fontInactive != nullptr); return STATUS_OK; } @@ -811,7 +811,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { delete _imageInactive; - _imageInactive = NULL; + _imageInactive = nullptr; stack->pushBool(false); } else { stack->pushBool(true); @@ -1294,7 +1294,7 @@ bool UIWindow::moveFocus(bool forward) { } } if (!found) { - _focusedWidget = NULL; + _focusedWidget = nullptr; } if (!_focusedWidget) { |