diff options
author | Tobia Tesan | 2013-09-20 13:42:53 +0200 |
---|---|---|
committer | Tobia Tesan | 2013-09-21 23:22:16 +0200 |
commit | 2e457d96e8095020bce006fd633382bde6c6ae26 (patch) | |
tree | 6a0355bd732100682b25caeb6cbe493edba1a848 /engines | |
parent | b033850e8a07595dee479a37d50e87a828be356c (diff) | |
download | scummvm-rg350-2e457d96e8095020bce006fd633382bde6c6ae26.tar.gz scummvm-rg350-2e457d96e8095020bce006fd633382bde6c6ae26.tar.bz2 scummvm-rg350-2e457d96e8095020bce006fd633382bde6c6ae26.zip |
WINTERMUTE: Make some members of UIObject private
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/ad/ad_inventory_box.cpp | 4 | ||||
-rw-r--r-- | engines/wintermute/ad/ad_response_box.cpp | 54 | ||||
-rw-r--r-- | engines/wintermute/ad/ad_scene.cpp | 4 | ||||
-rw-r--r-- | engines/wintermute/base/base_game.cpp | 8 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_object.cpp | 73 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_object.h | 44 | ||||
-rw-r--r-- | engines/wintermute/ui/ui_window.cpp | 14 |
7 files changed, 151 insertions, 50 deletions
diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index d703de1714..681d7311b7 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(); } diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 9d7c17ac74..24eaa77023 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -121,12 +121,12 @@ void AdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::invalidateButtons() { for (uint32 i = 0; i < _respButtons.size(); i++) { - _respButtons[i]->_image = nullptr; + _respButtons[i]->putImage(nullptr); + _respButtons[i]->putFont(nullptr); + _respButtons[i]->setText(""); _respButtons[i]->_cursor = nullptr; - _respButtons[i]->_font = nullptr; _respButtons[i]->_fontHover = nullptr; _respButtons[i]->_fontPress = nullptr; - _respButtons[i]->setText(""); } return STATUS_OK; } @@ -141,11 +141,12 @@ 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->putImage(_responses[i]->getIcon()); if (_responses[i]->getIconHover()) { btn->_imageHover = _responses[i]->getIconHover(); } @@ -163,23 +164,28 @@ bool AdResponseBox::createButtons() { // textual else { btn->setText(_responses[i]->getText()); - btn->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font; + if (_font == nullptr) { + btn->putFont(_gameRef->getSystemFont()); + } else { + btn->putFont(_font); + } btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; btn->_fontPress = btn->_fontHover; btn->_align = _align; if (_gameRef->_touchInterface) { - btn->_fontHover = btn->_font; + btn->_fontHover = btn->getFont(); } if (_responses[i]->getFont()) { - btn->_font = _responses[i]->getFont(); + btn->putFont(_responses[i]->getFont()); } - btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) { - btn->_width = _gameRef->_renderer->getWidth(); + btn->setWidth(_responseArea.right - _responseArea.left); + if (btn->getWidth() <= 0) { + // TODO: This is not very pretty. Should do it at setWidth level, heh? + btn->setWidth(_gameRef->_renderer->getWidth()); } } btn->setName("response"); @@ -187,17 +193,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)); } } } @@ -461,7 +467,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 +493,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 +521,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(); } diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 668b39853b..46badee92b 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1014,8 +1014,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(); } } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 62ce64b749..38fb668f8e 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -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; } @@ -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]->getInGame() == inGame) { + if (_windows[i]->isVisible() && _windows[i]->getInGame() == inGame) { res = _windows[i]->display(); if (DID_FAIL(res)) { diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index c32ae75c20..333bba80c4 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -648,4 +648,77 @@ bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_FAILED; } +int32 UIObject::getWidth() { + return _width; +} + +int32 UIObject::getHeight() { + return _height; +} + +void UIObject::setWidth(int32 width) { + // assert (width >= 0); + // This would be ideal, but ATM must be failing pretty much everywhere. + _width = width; +} + +void UIObject::setHeight(int32 height) { + // assert (height >= 0); + // This would be ideal, but ATM must be failing pretty much everywhere. + _height = height; +} + +bool UIObject::isDisabled() { + return _disable; +} + +bool UIObject::isVisible() { + return _visible; +} + +void UIObject::setVisible(bool visible) { + _visible = visible; +} + +void UIObject::setDisabled(bool disable) { + _disable = disable; +} + +bool UIObject::hasSharedFonts() { + return _sharedFonts; +} + +void UIObject::setSharedFonts(bool shared) { + _sharedFonts = shared; +} + +bool UIObject::hasSharedImages() { + return _sharedImages; +} + +void UIObject::setSharedImages(bool shared) { + _sharedImages = shared; +} + +BaseSprite *UIObject::getImage() { + return _image; +} + +void UIObject::putImage(BaseSprite *image) { + _image = image; +} + +bool UIObject::canFocus() { + return _canFocus; +} + +void UIObject::putFont(BaseFont *font) { + _font = font; +} + +BaseFont *UIObject::getFont() { + return _font; +} + + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 5d9508c2cf..bcd90082d1 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -41,7 +41,6 @@ class UIObject : public BaseObject { public: bool getTotalOffset(int *offsetX, int *offsetY); - bool _canFocus; bool focus(); virtual bool handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); @@ -52,20 +51,11 @@ public: 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; @@ -78,6 +68,38 @@ 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(); + int32 getHeight(); + void setHeight(int32 height); + void setWidth(int32 width); + bool isDisabled(); + void setDisabled(bool disable); + bool isVisible(); + void setVisible(bool visible); + bool hasSharedFonts(); + void setSharedFonts(bool shared); + bool hasSharedImages(); + void setSharedImages(bool shared); + BaseSprite *getImage(); + void putImage(BaseSprite *image); + void putFont(BaseFont *font); + BaseFont *getFont(); + bool canFocus(); + +protected: + BaseSprite *_image; + BaseFont *_font; + bool _sharedFonts; + bool _sharedImages; + char *_text; + bool _visible; + bool _disable; + int32 _width; + int32 _height; + bool _canFocus; + }; } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index e8acd11a2c..c098415367 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -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(); } @@ -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; @@ -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; } |