From efc4284b42678ebc55d901902dc7db20c7aa2ff6 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 19 Sep 2013 02:00:35 +0200 Subject: WINTERMUTE: Keep _alphaMode private in TransparentSurface --- engines/wintermute/base/gfx/osystem/render_ticket.cpp | 8 ++++---- engines/wintermute/graphics/transparent_surface.cpp | 7 +++++++ engines/wintermute/graphics/transparent_surface.h | 8 +++++--- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp index b1720c1b0b..a1538e9faf 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp +++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp @@ -107,9 +107,9 @@ 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()); } } src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height()); @@ -127,9 +127,9 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect if (_owner) { if (_transform._alphaDisable) { - src._alphaMode = TransparentSurface::ALPHA_OPAQUE; + src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE); } else { - src._alphaMode = _owner->getAlphaType(); + src.setAlphaMode(_owner->getAlphaType()); } } src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height()); diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index cd200354f7..200cffb237 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -612,4 +612,11 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool } } +TransparentSurface::AlphaType TransparentSurface::getAlphaMode() { + return _alphaMode; +} + +void TransparentSurface::setAlphaMode(TransparentSurface::AlphaType mode) { + _alphaMode = mode; +} } // End of namespace Wintermute diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 598aaa55d7..fe5dc08fc0 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -81,8 +81,6 @@ struct TransparentSurface : public Graphics::Surface { ALPHA_FULL = 2 }; - AlphaType _alphaMode; - /** @brief renders the surface to another surface @param pDest a pointer to the target image. In most cases this is the framebuffer. @@ -120,6 +118,11 @@ struct TransparentSurface : public Graphics::Surface { TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; TransparentSurface *rotoscale(const TransformStruct &transform) const; + AlphaType getAlphaMode(); + void setAlphaMode(AlphaType); +private: + AlphaType _alphaMode; + }; /** @@ -134,7 +137,6 @@ struct TransparentSurface : public Graphics::Surface { } };*/ - } // End of namespace Wintermute -- cgit v1.2.3 From 6e211118470f65173515a54ad72642101c6d6e2b Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 19 Sep 2013 02:02:16 +0200 Subject: WINTERMUTE: Make *_entity private in UIEntity --- engines/wintermute/ui/ui_entity.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index 1b6e8a10d6..e155ca2ce2 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -44,7 +44,6 @@ public: 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 -- cgit v1.2.3 From 38369687fe3c0876f7f428fc8eee0b37c9f45579 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 19 Sep 2013 02:03:06 +0200 Subject: WINTERMUTE: Make TextAlign private in UIText --- engines/wintermute/ui/ui_text.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index 29ed62a5ef..4470367fd5 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -37,13 +37,13 @@ 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); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; -- cgit v1.2.3 From b033850e8a07595dee479a37d50e87a828be356c Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 01:25:41 +0200 Subject: WINTERMUTE: Keep attributes in UIWindow private --- engines/wintermute/base/base_game.cpp | 4 +-- engines/wintermute/ui/ui_window.cpp | 10 ++++++++ engines/wintermute/ui/ui_window.h | 47 +++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 21 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b2c05d271d..62ce64b749 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -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]->_visible && _windows[i]->getInGame() == inGame) { res = _windows[i]->display(); if (DID_FAIL(res)) { @@ -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; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 9066ee9f5b..e8acd11a2c 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -1442,4 +1442,14 @@ bool UIWindow::getWindowObjects(BaseArray &objects, bool interactive return STATUS_OK; } +bool UIWindow::getInGame() { + return _inGame; +} + +TWindowMode UIWindow::getMode() { + return _mode; +} + + + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 8a726fdff8..9175e3cde8 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 &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 _widgets; - TTextAlign _titleAlign; + bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - UITiledImage *_backInactive; - BaseFont *_fontInactive; - BaseSprite *_imageInactive; + 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(); + TWindowMode getMode(); + +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 -- cgit v1.2.3 From 2e457d96e8095020bce006fd633382bde6c6ae26 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 13:42:53 +0200 Subject: WINTERMUTE: Make some members of UIObject private --- engines/wintermute/ad/ad_inventory_box.cpp | 4 +- engines/wintermute/ad/ad_response_box.cpp | 54 ++++++++++++---------- engines/wintermute/ad/ad_scene.cpp | 4 +- engines/wintermute/base/base_game.cpp | 8 ++-- engines/wintermute/ui/ui_object.cpp | 73 ++++++++++++++++++++++++++++++ engines/wintermute/ui/ui_object.h | 44 +++++++++++++----- engines/wintermute/ui/ui_window.cpp | 14 +++--- 7 files changed, 151 insertions(+), 50 deletions(-) (limited to 'engines/wintermute') 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(btn->_height, 50); + btn->setHeight(MAX(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 &objects, bool interactiveOnly) { for (uint32 i = 0; i < _widgets.size(); i++) { UIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) { + if (control->isDisabled() && interactiveOnly) { continue; } -- cgit v1.2.3 From aafe8c1f0d45aef7429331b5e00f74d2e42b0ce7 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 13:57:36 +0200 Subject: WINTERMUTE: Add getListener() --- engines/wintermute/ad/ad_inventory_box.cpp | 2 +- engines/wintermute/ad/ad_response_box.cpp | 2 +- engines/wintermute/ui/ui_object.cpp | 4 ++++ engines/wintermute/ui/ui_object.h | 8 +++++--- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 681d7311b7..313da99a28 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -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); } } diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 24eaa77023..6d513eb851 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -374,7 +374,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); } } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 333bba80c4..e4bcb2aa6b 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -720,5 +720,9 @@ BaseFont *UIObject::getFont() { return _font; } +BaseScriptHolder *UIObject::getListener() { + return _listenerObject; +} + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index bcd90082d1..6d1f6ae895 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -57,9 +57,8 @@ public: UIObject(BaseGame *inGame = nullptr); virtual ~UIObject(); void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); - BaseScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - BaseScriptHolder *_listenerObject; + BaseScriptHolder *getListener(); + UIObject *_focusedWidget; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; @@ -89,6 +88,9 @@ public: bool canFocus(); protected: + BaseScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + BaseScriptHolder *_listenerObject; BaseSprite *_image; BaseFont *_font; bool _sharedFonts; -- cgit v1.2.3 From 252e0c17ec711c13ac5ef3bd6af68646275d63d6 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 13:58:17 +0200 Subject: WINTERMUTE: Make _parentNotify private in UIObject --- engines/wintermute/ui/ui_object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 6d1f6ae895..4132d9576a 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -44,7 +44,7 @@ public: 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); } @@ -101,7 +101,7 @@ protected: int32 _width; int32 _height; bool _canFocus; - + bool _parentNotify; }; } // End of namespace Wintermute -- cgit v1.2.3 From 91ebad46d3adc4cf48a14f0f1bbfa9e41e28ecad Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 13:59:37 +0200 Subject: WINTERMUTE: Keep _back private in UIObject --- engines/wintermute/ui/ui_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 4132d9576a..6eaade4b4b 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -53,7 +53,6 @@ public: virtual void correctSize(); void setText(const char *text); - UITiledImage *_back; UIObject(BaseGame *inGame = nullptr); virtual ~UIObject(); void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); @@ -102,6 +101,7 @@ protected: int32 _height; bool _canFocus; bool _parentNotify; + UITiledImage *_back; }; } // End of namespace Wintermute -- cgit v1.2.3 From 1361fcde7c0cf0cecb6896288465551d1eb195f9 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 14:04:20 +0200 Subject: WINTERMUTE: Avoid feeding setWidth negative values --- engines/wintermute/ad/ad_response_box.cpp | 8 +++++--- engines/wintermute/ui/ui_object.cpp | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 6d513eb851..f9680e99df 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -182,10 +182,12 @@ bool AdResponseBox::createButtons() { btn->putFont(_responses[i]->getFont()); } - btn->setWidth(_responseArea.right - _responseArea.left); - if (btn->getWidth() <= 0) { - // TODO: This is not very pretty. Should do it at setWidth level, heh? + int width = _responseArea.right - _responseArea.left; + + if (width <= 0) { btn->setWidth(_gameRef->_renderer->getWidth()); + } else { + btn->setWidth(width); } } btn->setName("response"); diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index e4bcb2aa6b..0824f1f9bd 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -657,14 +657,12 @@ int32 UIObject::getHeight() { } void UIObject::setWidth(int32 width) { - // assert (width >= 0); - // This would be ideal, but ATM must be failing pretty much everywhere. + assert (width >= 0); _width = width; } void UIObject::setHeight(int32 height) { - // assert (height >= 0); - // This would be ideal, but ATM must be failing pretty much everywhere. + assert (height >= 0); _height = height; } -- cgit v1.2.3 From b22eaaa98a9620fae346b1bd1bf67311cb312ec0 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 17:07:01 +0200 Subject: WINTERMUTE: Keep attributes private in UIEdit --- engines/wintermute/ui/ui_edit.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index a057be9ead..7a379011fd 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -38,21 +38,15 @@ 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(); @@ -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 -- cgit v1.2.3 From 59f4a9e7ac519405a728b9d9a448114c05fe4776 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 17:10:20 +0200 Subject: WINTERMUTE: Keep some attributes private in UIButton --- engines/wintermute/ui/ui_button.h | 44 ++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index b5002f3166..846121e320 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -37,31 +37,15 @@ 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); @@ -73,6 +57,28 @@ 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; + BaseFont *_fontDisable; + BaseFont *_fontPress; + BaseFont *_fontHover; + BaseFont *_fontFocus; + BaseSprite *_imageHover; + BaseSprite *_imagePress; + BaseSprite *_imageDisable; + BaseSprite *_imageFocus; + TTextAlign _align; + +private: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + UITiledImage *_backPress; + UITiledImage *_backHover; + UITiledImage *_backDisable; + UITiledImage *_backFocus; + bool _press; + bool _hover; + }; } // End of namespace Wintermute -- cgit v1.2.3 From 1869481767b205b3475d9d79e69f69c8cc184b02 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 17:39:32 +0200 Subject: WINTERMUTE: Setters/getters for UIButton --- engines/wintermute/ad/ad_response_box.cpp | 10 +++++----- engines/wintermute/ui/ui_button.cpp | 12 ++++++++++++ engines/wintermute/ui/ui_button.h | 14 +++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index f9680e99df..229ba8152b 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -125,8 +125,8 @@ bool AdResponseBox::invalidateButtons() { _respButtons[i]->putFont(nullptr); _respButtons[i]->setText(""); _respButtons[i]->_cursor = nullptr; - _respButtons[i]->_fontHover = nullptr; - _respButtons[i]->_fontPress = nullptr; + _respButtons[i]->putFontHover(nullptr); + _respButtons[i]->putFontPress(nullptr); } return STATUS_OK; } @@ -169,12 +169,12 @@ bool AdResponseBox::createButtons() { } else { btn->putFont(_font); } - btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; - btn->_fontPress = btn->_fontHover; + btn->putFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover); + btn->putFontPress(btn->getFontHover()); btn->_align = _align; if (_gameRef->_touchInterface) { - btn->_fontHover = btn->getFont(); + btn->putFontHover(btn->getFont()); } diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index b2e6c3953b..eff1059e1f 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1206,4 +1206,16 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } +void UIButton::putFontHover(BaseFont *font) { + _fontHover = font; +} + +BaseFont *UIButton::getFontHover() { + return _fontHover; +} + +void UIButton::putFontPress(BaseFont *font) { + _fontPress = font; +} + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 846121e320..2d7cb012dd 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -57,15 +57,16 @@ 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; - BaseFont *_fontDisable; - BaseFont *_fontPress; - BaseFont *_fontHover; - BaseFont *_fontFocus; + BaseSprite *_imageHover; BaseSprite *_imagePress; BaseSprite *_imageDisable; BaseSprite *_imageFocus; TTextAlign _align; + + void putFontHover(BaseFont *font); + BaseFont *getFontHover(); + void putFontPress(BaseFont *font); private: bool _pixelPerfect; @@ -78,7 +79,10 @@ private: UITiledImage *_backFocus; bool _press; bool _hover; - + BaseFont *_fontDisable; + BaseFont *_fontPress; + BaseFont *_fontHover; + BaseFont *_fontFocus; }; } // End of namespace Wintermute -- cgit v1.2.3 From 417bf3db02ec3af8184d3de7d4ed87181342367f Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 17:49:35 +0200 Subject: WINTERMUTE: Make sprites private in UIButton --- engines/wintermute/ad/ad_response_box.cpp | 4 ++-- engines/wintermute/ui/ui_button.cpp | 8 ++++++++ engines/wintermute/ui/ui_button.h | 12 ++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 229ba8152b..8454f213b7 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -148,10 +148,10 @@ bool AdResponseBox::createButtons() { if (_responses[i]->getIcon()) { btn->putImage(_responses[i]->getIcon()); if (_responses[i]->getIconHover()) { - btn->_imageHover = _responses[i]->getIconHover(); + btn->putImageHover(_responses[i]->getIconHover()); } if (_responses[i]->getIconPressed()) { - btn->_imagePress = _responses[i]->getIconPressed(); + btn->putImagePress(_responses[i]->getIconPressed()); } btn->setCaption(_responses[i]->getText()); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index eff1059e1f..1d266740a1 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1218,4 +1218,12 @@ void UIButton::putFontPress(BaseFont *font) { _fontPress = font; } +void UIButton::putImageHover(BaseSprite *sprite) { + _imageHover = sprite; +} + +void UIButton::putImagePress(BaseSprite *sprite) { + _imagePress = sprite; +} + } // End of namespace Wintermute diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 2d7cb012dd..bf2144f18e 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -58,15 +58,14 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString() override; - BaseSprite *_imageHover; - BaseSprite *_imagePress; - BaseSprite *_imageDisable; - BaseSprite *_imageFocus; TTextAlign _align; void putFontHover(BaseFont *font); BaseFont *getFontHover(); void putFontPress(BaseFont *font); + + void putImageHover(BaseSprite *sprite); + void putImagePress(BaseSprite *sprite); private: bool _pixelPerfect; @@ -83,6 +82,11 @@ private: BaseFont *_fontPress; BaseFont *_fontHover; BaseFont *_fontFocus; + BaseSprite *_imageHover; + BaseSprite *_imagePress; + BaseSprite *_imageDisable; + BaseSprite *_imageFocus; + }; } // End of namespace Wintermute -- cgit v1.2.3 From 2a977dec8c180c297c000b3c09b068f76344c313 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 17:52:25 +0200 Subject: WINTERMUTE: add UIButton::setTextAlign --- engines/wintermute/ad/ad_response_box.cpp | 2 +- engines/wintermute/ui/ui_button.cpp | 6 ++++++ engines/wintermute/ui/ui_button.h | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 8454f213b7..267a207eaa 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -171,7 +171,7 @@ bool AdResponseBox::createButtons() { } btn->putFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover); btn->putFontPress(btn->getFontHover()); - btn->_align = _align; + btn->setTextAlign(_align); if (_gameRef->_touchInterface) { btn->putFontHover(btn->getFont()); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 1d266740a1..a299603b25 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1226,4 +1226,10 @@ void UIButton::putImagePress(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 bf2144f18e..ea41435a6b 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -38,7 +38,6 @@ namespace Wintermute { class UIButton : public UIObject { public: - uint32 _oneTimePressTime; DECLARE_PERSISTENT(UIButton, UIObject) void press(); virtual bool display() { return display(0, 0); } @@ -58,12 +57,13 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString() override; - TTextAlign _align; void putFontHover(BaseFont *font); BaseFont *getFontHover(); void putFontPress(BaseFont *font); + void setTextAlign(TTextAlign align); + void putImageHover(BaseSprite *sprite); void putImagePress(BaseSprite *sprite); @@ -86,6 +86,8 @@ private: BaseSprite *_imagePress; BaseSprite *_imageDisable; BaseSprite *_imageFocus; + uint32 _oneTimePressTime; + TTextAlign _align; }; -- cgit v1.2.3 From 5b8a6885c67fe2e1af3dab0e634da1938f8e544c Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 23:03:16 +0200 Subject: WINTERMUTE: s/put/set/ in setters --- engines/wintermute/ad/ad_response_box.cpp | 26 +++++++++++++------------- engines/wintermute/ui/ui_button.cpp | 8 ++++---- engines/wintermute/ui/ui_button.h | 8 ++++---- engines/wintermute/ui/ui_object.cpp | 4 ++-- engines/wintermute/ui/ui_object.h | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 267a207eaa..9fcc33e2d1 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]->putImage(nullptr); - _respButtons[i]->putFont(nullptr); + _respButtons[i]->setImage(nullptr); + _respButtons[i]->setFont(nullptr); _respButtons[i]->setText(""); _respButtons[i]->_cursor = nullptr; - _respButtons[i]->putFontHover(nullptr); - _respButtons[i]->putFontPress(nullptr); + _respButtons[i]->setFontHover(nullptr); + _respButtons[i]->setFontPress(nullptr); } return STATUS_OK; } @@ -146,12 +146,12 @@ bool AdResponseBox::createButtons() { btn->_sharedCursors = true; // iconic if (_responses[i]->getIcon()) { - btn->putImage(_responses[i]->getIcon()); + btn->setImage(_responses[i]->getIcon()); if (_responses[i]->getIconHover()) { - btn->putImageHover(_responses[i]->getIconHover()); + btn->setImageHover(_responses[i]->getIconHover()); } if (_responses[i]->getIconPressed()) { - btn->putImagePress(_responses[i]->getIconPressed()); + btn->setImagePress(_responses[i]->getIconPressed()); } btn->setCaption(_responses[i]->getText()); @@ -165,21 +165,21 @@ bool AdResponseBox::createButtons() { else { btn->setText(_responses[i]->getText()); if (_font == nullptr) { - btn->putFont(_gameRef->getSystemFont()); + btn->setFont(_gameRef->getSystemFont()); } else { - btn->putFont(_font); + btn->setFont(_font); } - btn->putFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover); - btn->putFontPress(btn->getFontHover()); + btn->setFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover); + btn->setFontPress(btn->getFontHover()); btn->setTextAlign(_align); if (_gameRef->_touchInterface) { - btn->putFontHover(btn->getFont()); + btn->setFontHover(btn->getFont()); } if (_responses[i]->getFont()) { - btn->putFont(_responses[i]->getFont()); + btn->setFont(_responses[i]->getFont()); } int width = _responseArea.right - _responseArea.left; diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index a299603b25..a3f0069541 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1206,7 +1206,7 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -void UIButton::putFontHover(BaseFont *font) { +void UIButton::setFontHover(BaseFont *font) { _fontHover = font; } @@ -1214,15 +1214,15 @@ BaseFont *UIButton::getFontHover() { return _fontHover; } -void UIButton::putFontPress(BaseFont *font) { +void UIButton::setFontPress(BaseFont *font) { _fontPress = font; } -void UIButton::putImageHover(BaseSprite *sprite) { +void UIButton::setImageHover(BaseSprite *sprite) { _imageHover = sprite; } -void UIButton::putImagePress(BaseSprite *sprite) { +void UIButton::setImagePress(BaseSprite *sprite) { _imagePress = sprite; } diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index ea41435a6b..e5dc25bdf0 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -58,14 +58,14 @@ public: virtual const char *scToString() override; - void putFontHover(BaseFont *font); + void setFontHover(BaseFont *font); BaseFont *getFontHover(); - void putFontPress(BaseFont *font); + void setFontPress(BaseFont *font); void setTextAlign(TTextAlign align); - void putImageHover(BaseSprite *sprite); - void putImagePress(BaseSprite *sprite); + void setImageHover(BaseSprite *sprite); + void setImagePress(BaseSprite *sprite); private: bool _pixelPerfect; diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 0824f1f9bd..73d7d0f2e6 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -702,7 +702,7 @@ BaseSprite *UIObject::getImage() { return _image; } -void UIObject::putImage(BaseSprite *image) { +void UIObject::setImage(BaseSprite *image) { _image = image; } @@ -710,7 +710,7 @@ bool UIObject::canFocus() { return _canFocus; } -void UIObject::putFont(BaseFont *font) { +void UIObject::setFont(BaseFont *font) { _font = font; } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 6eaade4b4b..8451479455 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -81,8 +81,8 @@ public: bool hasSharedImages(); void setSharedImages(bool shared); BaseSprite *getImage(); - void putImage(BaseSprite *image); - void putFont(BaseFont *font); + void setImage(BaseSprite *image); + void setFont(BaseFont *font); BaseFont *getFont(); bool canFocus(); -- cgit v1.2.3 From 1023ac4b33158905b900585c27dfa1f2e368d4f3 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 20 Sep 2013 23:32:56 +0200 Subject: WINTERMUTE: const'ify getters --- engines/wintermute/ui/ui_object.cpp | 10 +++++----- engines/wintermute/ui/ui_object.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 73d7d0f2e6..224e68add7 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -648,11 +648,11 @@ bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_FAILED; } -int32 UIObject::getWidth() { +int32 UIObject::getWidth() const { return _width; } -int32 UIObject::getHeight() { +int32 UIObject::getHeight() const { return _height; } @@ -698,7 +698,7 @@ void UIObject::setSharedImages(bool shared) { _sharedImages = shared; } -BaseSprite *UIObject::getImage() { +BaseSprite *UIObject::getImage() const { return _image; } @@ -714,11 +714,11 @@ void UIObject::setFont(BaseFont *font) { _font = font; } -BaseFont *UIObject::getFont() { +BaseFont *UIObject::getFont() const { return _font; } -BaseScriptHolder *UIObject::getListener() { +BaseScriptHolder *UIObject::getListener() const { return _listenerObject; } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 8451479455..d9be29ba9a 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -56,7 +56,7 @@ public: UIObject(BaseGame *inGame = nullptr); virtual ~UIObject(); void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); - BaseScriptHolder *getListener(); + BaseScriptHolder *getListener() const; UIObject *_focusedWidget; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; @@ -68,8 +68,8 @@ public: virtual const char *scToString() override; TUIObjectType _type; - int32 getWidth(); - int32 getHeight(); + int32 getWidth() const; + int32 getHeight() const; void setHeight(int32 height); void setWidth(int32 width); bool isDisabled(); @@ -80,10 +80,10 @@ public: void setSharedFonts(bool shared); bool hasSharedImages(); void setSharedImages(bool shared); - BaseSprite *getImage(); + BaseSprite *getImage() const; void setImage(BaseSprite *image); void setFont(BaseFont *font); - BaseFont *getFont(); + BaseFont *getFont() const; bool canFocus(); protected: -- cgit v1.2.3 From f7a9e921aee9371a9defe5acaf4a685ada76fcfb Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 21 Sep 2013 22:53:29 +0200 Subject: WINTERMUTE: Formatting --- engines/wintermute/ui/ui_button.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index a3f0069541..cc4f76c259 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1230,6 +1230,4 @@ void UIButton::setTextAlign(TTextAlign align) { _align = align; } - - } // End of namespace Wintermute -- cgit v1.2.3 From 5afb297e396fa3ad40559e552008741c6cd6ba66 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Sep 2013 11:12:25 +0200 Subject: WINTERMUTE: Constify some getters in TransparentSurface, UIObject and UIWindow --- engines/wintermute/graphics/transparent_surface.cpp | 2 +- engines/wintermute/graphics/transparent_surface.h | 2 +- engines/wintermute/ui/ui_object.cpp | 12 ++++++------ engines/wintermute/ui/ui_object.h | 12 ++++++------ engines/wintermute/ui/ui_window.cpp | 4 ++-- engines/wintermute/ui/ui_window.h | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 200cffb237..ca6f29791a 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -612,7 +612,7 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool } } -TransparentSurface::AlphaType TransparentSurface::getAlphaMode() { +TransparentSurface::AlphaType TransparentSurface::getAlphaMode() const { return _alphaMode; } diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index fe5dc08fc0..5a9c16d73f 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -118,7 +118,7 @@ struct TransparentSurface : public Graphics::Surface { TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; TransparentSurface *rotoscale(const TransformStruct &transform) const; - AlphaType getAlphaMode(); + AlphaType getAlphaMode() const; void setAlphaMode(AlphaType); private: AlphaType _alphaMode; diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 224e68add7..0962d83f8b 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -666,11 +666,11 @@ void UIObject::setHeight(int32 height) { _height = height; } -bool UIObject::isDisabled() { +bool UIObject::isDisabled() const { return _disable; } -bool UIObject::isVisible() { +bool UIObject::isVisible() const { return _visible; } @@ -682,7 +682,7 @@ void UIObject::setDisabled(bool disable) { _disable = disable; } -bool UIObject::hasSharedFonts() { +bool UIObject::hasSharedFonts() const { return _sharedFonts; } @@ -690,7 +690,7 @@ void UIObject::setSharedFonts(bool shared) { _sharedFonts = shared; } -bool UIObject::hasSharedImages() { +bool UIObject::hasSharedImages() const { return _sharedImages; } @@ -706,7 +706,7 @@ void UIObject::setImage(BaseSprite *image) { _image = image; } -bool UIObject::canFocus() { +bool UIObject::canFocus() const { return _canFocus; } @@ -714,7 +714,7 @@ void UIObject::setFont(BaseFont *font) { _font = font; } -BaseFont *UIObject::getFont() const { +BaseFont *UIObject::getFont() { return _font; } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index d9be29ba9a..56d22a0b18 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -72,19 +72,19 @@ public: int32 getHeight() const; void setHeight(int32 height); void setWidth(int32 width); - bool isDisabled(); + bool isDisabled() const; void setDisabled(bool disable); - bool isVisible(); + bool isVisible() const; void setVisible(bool visible); - bool hasSharedFonts(); + bool hasSharedFonts() const; void setSharedFonts(bool shared); - bool hasSharedImages(); + bool hasSharedImages() const; void setSharedImages(bool shared); BaseSprite *getImage() const; void setImage(BaseSprite *image); void setFont(BaseFont *font); - BaseFont *getFont() const; - bool canFocus(); + BaseFont *getFont(); + bool canFocus() const; protected: BaseScriptHolder *_listenerParamObject; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index c098415367..a54f7c5da1 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -1442,11 +1442,11 @@ bool UIWindow::getWindowObjects(BaseArray &objects, bool interactive return STATUS_OK; } -bool UIWindow::getInGame() { +bool UIWindow::getInGame() const { return _inGame; } -TWindowMode UIWindow::getMode() { +TWindowMode UIWindow::getMode() const { return _mode; } diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 9175e3cde8..d8dae8c0d3 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -73,8 +73,8 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; virtual const char *scToString(); - bool getInGame(); - TWindowMode getMode(); + bool getInGame() const; + TWindowMode getMode() const; private: bool _pauseMusic; -- cgit v1.2.3 From 15d98724d85b33d9918125999d6f654736ef10af Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Sep 2013 11:13:29 +0200 Subject: WINTERMUTE: Formatting (Clean up extra whitespace in UIObject). --- engines/wintermute/ui/ui_object.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 0962d83f8b..72a601a251 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -657,12 +657,12 @@ int32 UIObject::getHeight() const { } void UIObject::setWidth(int32 width) { - assert (width >= 0); + assert(width >= 0); _width = width; } void UIObject::setHeight(int32 height) { - assert (height >= 0); + assert(height >= 0); _height = height; } -- cgit v1.2.3 From 12e7cb401f80d8e1dee1af67817333d897508dfb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Sep 2013 11:18:54 +0200 Subject: WINTERMUTE: Formatting with Astyle (UIButton, UIEdit, UIObject, UIWindow, TransparentSurface) --- engines/wintermute/graphics/transparent_surface.cpp | 2 +- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_button.h | 4 ++-- engines/wintermute/ui/ui_edit.cpp | 4 ++-- engines/wintermute/ui/ui_object.cpp | 2 +- engines/wintermute/ui/ui_object.h | 2 +- engines/wintermute/ui/ui_window.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index ca6f29791a..470e2cc1cb 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -181,7 +181,7 @@ 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 diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index cc4f76c259..66cee8a50c 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -660,7 +660,7 @@ bool UIButton::display(int offsetX, int offsetY) { _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(); } diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index e5dc25bdf0..542a50d35a 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -57,11 +57,11 @@ public: 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); diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index caed157e0b..502685f0f1 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -627,9 +627,9 @@ bool UIEdit::display(int offsetX, int offsetY) { curFirst = true; } else { while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + - sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - > _width - cursorWidth - 2 * _frameWidth) { + > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= (int)strlen(_text)) { break; diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 72a601a251..a8da89b011 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -668,7 +668,7 @@ void UIObject::setHeight(int32 height) { bool UIObject::isDisabled() const { return _disable; -} +} bool UIObject::isVisible() const { return _visible; diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 56d22a0b18..8d14d8a6a4 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -89,7 +89,7 @@ public: protected: BaseScriptHolder *_listenerParamObject; uint32 _listenerParamDWORD; - BaseScriptHolder *_listenerObject; + BaseScriptHolder *_listenerObject; BaseSprite *_image; BaseFont *_font; bool _sharedFonts; diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index d8dae8c0d3..a603e0f7b9 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -72,7 +72,7 @@ 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; -- cgit v1.2.3 From ccd3258bdccaf7290137aea5b98889a9568547db Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Sep 2013 11:19:54 +0200 Subject: WINTERMUTE: Use ; and not , to separate delete and new. --- engines/wintermute/ui/ui_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index a54f7c5da1..da681b9153 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -400,8 +400,8 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IMAGE_INACTIVE: - delete _imageInactive, - _imageInactive = new BaseSprite(_gameRef); + delete _imageInactive; + _imageInactive = new BaseSprite(_gameRef); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { delete _imageInactive; _imageInactive = nullptr; -- cgit v1.2.3