Merge branch 'refac'

Conflicts:
	engines/wintermute/graphics/transparent_surface.cpp
	engines/wintermute/graphics/transparent_surface.h
This commit is contained in:
Einar Johan Trøan Sømåen 2013-09-30 11:23:36 +02:00
commit 48ad18d266
17 changed files with 311 additions and 128 deletions

View File

@ -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();
}
@ -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);
}
}

View File

@ -121,12 +121,12 @@ void AdResponseBox::clearButtons() {
//////////////////////////////////////////////////////////////////////////
bool AdResponseBox::invalidateButtons() {
for (uint32 i = 0; i < _respButtons.size(); i++) {
_respButtons[i]->_image = nullptr;
_respButtons[i]->_cursor = nullptr;
_respButtons[i]->_font = nullptr;
_respButtons[i]->_fontHover = nullptr;
_respButtons[i]->_fontPress = nullptr;
_respButtons[i]->setImage(nullptr);
_respButtons[i]->setFont(nullptr);
_respButtons[i]->setText("");
_respButtons[i]->_cursor = nullptr;
_respButtons[i]->setFontHover(nullptr);
_respButtons[i]->setFontPress(nullptr);
}
return STATUS_OK;
}
@ -141,16 +141,17 @@ bool AdResponseBox::createButtons() {
UIButton *btn = new UIButton(_gameRef);
if (btn) {
btn->_parent = _window;
btn->_sharedFonts = btn->_sharedImages = true;
btn->setSharedFonts(true);
btn->setSharedImages(true);
btn->_sharedCursors = true;
// iconic
if (_responses[i]->getIcon()) {
btn->_image = _responses[i]->getIcon();
btn->setImage(_responses[i]->getIcon());
if (_responses[i]->getIconHover()) {
btn->_imageHover = _responses[i]->getIconHover();
btn->setImageHover(_responses[i]->getIconHover());
}
if (_responses[i]->getIconPressed()) {
btn->_imagePress = _responses[i]->getIconPressed();
btn->setImagePress(_responses[i]->getIconPressed());
}
btn->setCaption(_responses[i]->getText());
@ -163,23 +164,30 @@ bool AdResponseBox::createButtons() {
// textual
else {
btn->setText(_responses[i]->getText());
btn->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font;
btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover;
btn->_fontPress = btn->_fontHover;
btn->_align = _align;
if (_font == nullptr) {
btn->setFont(_gameRef->getSystemFont());
} else {
btn->setFont(_font);
}
btn->setFontHover((_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover);
btn->setFontPress(btn->getFontHover());
btn->setTextAlign(_align);
if (_gameRef->_touchInterface) {
btn->_fontHover = btn->_font;
btn->setFontHover(btn->getFont());
}
if (_responses[i]->getFont()) {
btn->_font = _responses[i]->getFont();
btn->setFont(_responses[i]->getFont());
}
btn->_width = _responseArea.right - _responseArea.left;
if (btn->_width <= 0) {
btn->_width = _gameRef->_renderer->getWidth();
int width = _responseArea.right - _responseArea.left;
if (width <= 0) {
btn->setWidth(_gameRef->_renderer->getWidth());
} else {
btn->setWidth(width);
}
}
btn->setName("response");
@ -187,17 +195,17 @@ bool AdResponseBox::createButtons() {
// make the responses touchable
if (_gameRef->_touchInterface) {
btn->_height = MAX<int32>(btn->_height, 50);
btn->setHeight(MAX<int32>(btn->getHeight(), 50));
}
//btn->SetListener(this, btn, _responses[i]->_iD);
btn->setListener(this, btn, i);
btn->_visible = false;
btn->setVisible(false);
_respButtons.add(btn);
if (_responseArea.bottom - _responseArea.top < btn->_height) {
if (_responseArea.bottom - _responseArea.top < btn->getHeight()) {
_gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->getText());
_responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top));
_responseArea.bottom += (btn->getHeight() - (_responseArea.bottom - _responseArea.top));
}
}
}
@ -368,7 +376,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) {
if (_window) {
for (uint32 i = 0; i < _window->_widgets.size(); i++) {
if (!_window->_widgets[i]->_listenerObject) {
if (!_window->_widgets[i]->getListener()) {
_window->_widgets[i]->setListener(this, _window->_widgets[i], 0);
}
}
@ -461,7 +469,7 @@ bool AdResponseBox::display() {
if (!_horizontal) {
int totalHeight = 0;
for (i = 0; i < _respButtons.size(); i++) {
totalHeight += (_respButtons[i]->_height + _spacing);
totalHeight += (_respButtons[i]->getHeight() + _spacing);
}
totalHeight -= _spacing;
@ -487,22 +495,22 @@ bool AdResponseBox::display() {
// prepare response buttons
bool scrollNeeded = false;
for (i = _scrollOffset; i < _respButtons.size(); i++) {
if ((_horizontal && xxx + _respButtons[i]->_width > rect.right)
|| (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) {
if ((_horizontal && xxx + _respButtons[i]->getWidth() > rect.right)
|| (!_horizontal && yyy + _respButtons[i]->getHeight() > rect.bottom)) {
scrollNeeded = true;
_respButtons[i]->_visible = false;
_respButtons[i]->setVisible(false);
break;
}
_respButtons[i]->_visible = true;
_respButtons[i]->setVisible(true);
_respButtons[i]->_posX = xxx;
_respButtons[i]->_posY = yyy;
if (_horizontal) {
xxx += (_respButtons[i]->_width + _spacing);
xxx += (_respButtons[i]->getWidth() + _spacing);
} else {
yyy += (_respButtons[i]->_height + _spacing);
yyy += (_respButtons[i]->getHeight() + _spacing);
}
}
@ -515,8 +523,8 @@ bool AdResponseBox::display() {
// go exclusive
if (_shieldWindow) {
_shieldWindow->_posX = _shieldWindow->_posY = 0;
_shieldWindow->_width = _gameRef->_renderer->getWidth();
_shieldWindow->_height = _gameRef->_renderer->getHeight();
_shieldWindow->setWidth(_gameRef->_renderer->getWidth());
_shieldWindow->setHeight(_gameRef->_renderer->getHeight());
_shieldWindow->display();
}

View File

@ -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();
}
}

View File

@ -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]->_inGame == inGame) {
if (_windows[i]->isVisible() && _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;

View File

@ -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(), _transform._blendMode);

View File

@ -758,4 +758,11 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool
}
}
TransparentSurface::AlphaType TransparentSurface::getAlphaMode() const {
return _alphaMode;
}
void TransparentSurface::setAlphaMode(TransparentSurface::AlphaType mode) {
_alphaMode = mode;
}
} // End of namespace Wintermute

View File

@ -101,8 +101,6 @@ struct TransparentSurface : public Graphics::Surface {
ALPHA_FULL = 2
};
AlphaType _alphaMode;
#ifdef SCUMM_LITTLE_ENDIAN
static const int kAIndex = 0;
static const int kBIndex = 1;
@ -180,6 +178,11 @@ struct TransparentSurface : public Graphics::Surface {
*
*/
TransparentSurface *rotoscale(const TransformStruct &transform) const;
AlphaType getAlphaMode() const;
void setAlphaMode(AlphaType);
private:
AlphaType _alphaMode;
};
/**

View File

@ -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();
}
@ -1206,4 +1206,28 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) {
return STATUS_OK;
}
void UIButton::setFontHover(BaseFont *font) {
_fontHover = font;
}
BaseFont *UIButton::getFontHover() {
return _fontHover;
}
void UIButton::setFontPress(BaseFont *font) {
_fontPress = font;
}
void UIButton::setImageHover(BaseSprite *sprite) {
_imageHover = sprite;
}
void UIButton::setImagePress(BaseSprite *sprite) {
_imagePress = sprite;
}
void UIButton::setTextAlign(TTextAlign align) {
_align = align;
}
} // End of namespace Wintermute

View File

@ -37,31 +37,14 @@ 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 +56,39 @@ public:
virtual bool scSetProperty(const char *name, ScValue *value) override;
virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
virtual const char *scToString() override;
void setFontHover(BaseFont *font);
BaseFont *getFontHover();
void setFontPress(BaseFont *font);
void setTextAlign(TTextAlign align);
void setImageHover(BaseSprite *sprite);
void setImagePress(BaseSprite *sprite);
private:
bool _pixelPerfect;
bool _stayPressed;
bool _centerImage;
bool _oneTimePress;
UITiledImage *_backPress;
UITiledImage *_backHover;
UITiledImage *_backDisable;
UITiledImage *_backFocus;
bool _press;
bool _hover;
BaseFont *_fontDisable;
BaseFont *_fontPress;
BaseFont *_fontHover;
BaseFont *_fontFocus;
BaseSprite *_imageHover;
BaseSprite *_imagePress;
BaseSprite *_imageDisable;
BaseSprite *_imageFocus;
uint32 _oneTimePressTime;
TTextAlign _align;
};
} // End of namespace Wintermute

View File

@ -627,9 +627,9 @@ bool UIEdit::display(int offsetX, int offsetY) {
curFirst = true;
} else {
while (font->getTextWidth((byte *)_text + _scrollOffset, MAX<int32>(0, _selStart - _scrollOffset)) +
sfont->getTextWidth((byte *)(_text + MAX<int32>(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart))
sfont->getTextWidth((byte *)(_text + MAX<int32>(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart))
> _width - cursorWidth - 2 * _frameWidth) {
> _width - cursorWidth - 2 * _frameWidth) {
_scrollOffset++;
if (_scrollOffset >= (int)strlen(_text)) {
break;

View File

@ -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

View File

@ -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

View File

@ -648,4 +648,79 @@ bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) {
return STATUS_FAILED;
}
int32 UIObject::getWidth() const {
return _width;
}
int32 UIObject::getHeight() const {
return _height;
}
void UIObject::setWidth(int32 width) {
assert(width >= 0);
_width = width;
}
void UIObject::setHeight(int32 height) {
assert(height >= 0);
_height = height;
}
bool UIObject::isDisabled() const {
return _disable;
}
bool UIObject::isVisible() const {
return _visible;
}
void UIObject::setVisible(bool visible) {
_visible = visible;
}
void UIObject::setDisabled(bool disable) {
_disable = disable;
}
bool UIObject::hasSharedFonts() const {
return _sharedFonts;
}
void UIObject::setSharedFonts(bool shared) {
_sharedFonts = shared;
}
bool UIObject::hasSharedImages() const {
return _sharedImages;
}
void UIObject::setSharedImages(bool shared) {
_sharedImages = shared;
}
BaseSprite *UIObject::getImage() const {
return _image;
}
void UIObject::setImage(BaseSprite *image) {
_image = image;
}
bool UIObject::canFocus() const {
return _canFocus;
}
void UIObject::setFont(BaseFont *font) {
_font = font;
}
BaseFont *UIObject::getFont() {
return _font;
}
BaseScriptHolder *UIObject::getListener() const {
return _listenerObject;
}
} // End of namespace Wintermute

View File

@ -41,35 +41,23 @@ class UIObject : public BaseObject {
public:
bool getTotalOffset(int *offsetX, int *offsetY);
bool _canFocus;
bool focus();
virtual bool handleMouse(TMouseEvent event, TMouseButton button);
bool isFocused();
bool _parentNotify;
DECLARE_PERSISTENT(UIObject, BaseObject)
UIObject *_parent;
virtual bool display() override { return display(0, 0); }
virtual bool display(int offsetX) { return display(offsetX, 0); }
virtual bool display(int offsetX, int offsetY);
virtual void correctSize();
bool _sharedFonts;
bool _sharedImages;
void setText(const char *text);
char *_text;
BaseFont *_font;
bool _visible;
UITiledImage *_back;
bool _disable;
UIObject(BaseGame *inGame = nullptr);
virtual ~UIObject();
int32 _width;
int32 _height;
TUIObjectType _type;
BaseSprite *_image;
void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam);
BaseScriptHolder *_listenerParamObject;
uint32 _listenerParamDWORD;
BaseScriptHolder *_listenerObject;
BaseScriptHolder *getListener() const;
UIObject *_focusedWidget;
virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
@ -78,6 +66,42 @@ public:
virtual bool scSetProperty(const char *name, ScValue *value) override;
virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
virtual const char *scToString() override;
TUIObjectType _type;
int32 getWidth() const;
int32 getHeight() const;
void setHeight(int32 height);
void setWidth(int32 width);
bool isDisabled() const;
void setDisabled(bool disable);
bool isVisible() const;
void setVisible(bool visible);
bool hasSharedFonts() const;
void setSharedFonts(bool shared);
bool hasSharedImages() const;
void setSharedImages(bool shared);
BaseSprite *getImage() const;
void setImage(BaseSprite *image);
void setFont(BaseFont *font);
BaseFont *getFont();
bool canFocus() const;
protected:
BaseScriptHolder *_listenerParamObject;
uint32 _listenerParamDWORD;
BaseScriptHolder *_listenerObject;
BaseSprite *_image;
BaseFont *_font;
bool _sharedFonts;
bool _sharedImages;
char *_text;
bool _visible;
bool _disable;
int32 _width;
int32 _height;
bool _canFocus;
bool _parentNotify;
UITiledImage *_back;
};
} // End of namespace Wintermute

View File

@ -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;

View File

@ -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();
}
@ -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;
@ -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;
}
@ -1442,4 +1442,14 @@ bool UIWindow::getWindowObjects(BaseArray<UIObject *> &objects, bool interactive
return STATUS_OK;
}
bool UIWindow::getInGame() const {
return _inGame;
}
TWindowMode UIWindow::getMode() const {
return _mode;
}
} // End of namespace Wintermute

View File

@ -38,47 +38,32 @@ namespace Wintermute {
class UIButton;
class BaseViewport;
class UIWindow : public UIObject {
uint32 _fadeColor;
public:
bool getWindowObjects(BaseArray<UIObject *> &Objects, bool InteractiveOnly);
bool _pauseMusic;
void cleanup();
virtual void makeFreezable(bool freezable);
BaseViewport *_viewport;
bool _clipContents;
bool _inGame;
bool _isMenu;
bool _fadeBackground;
virtual bool handleMouseWheel(int delta);
UIWindow *_shieldWindow;
UIButton *_shieldButton;
bool close();
bool goSystemExclusive();
bool goExclusive();
TWindowMode _mode;
bool moveFocus(bool forward = true);
virtual bool handleMouse(TMouseEvent Event, TMouseButton Button);
Point32 _dragFrom;
bool _dragging;
DECLARE_PERSISTENT(UIWindow, UIObject)
bool _transparent;
bool showWidget(const char *name, bool visible = true);
bool enableWidget(const char *name, bool enable = true);
Rect32 _titleRect;
Rect32 _dragRect;
virtual bool display(int offsetX = 0, int offsetY = 0) override;
UIWindow(BaseGame *inGame);
virtual ~UIWindow();
virtual bool handleKeypress(Common::Event *event, bool printable = false) override;
BaseArray<UIObject *> _widgets;
TTextAlign _titleAlign;
bool loadFile(const char *filename);
bool loadBuffer(byte *buffer, bool complete = true);
UITiledImage *_backInactive;
BaseFont *_fontInactive;
BaseSprite *_imageInactive;
virtual bool listen(BaseScriptHolder *param1, uint32 param2);
virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
@ -87,6 +72,30 @@ public:
virtual bool scSetProperty(const char *name, ScValue *value) override;
virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
virtual const char *scToString();
bool getInGame() const;
TWindowMode getMode() const;
private:
bool _pauseMusic;
BaseViewport *_viewport;
bool _clipContents;
bool _inGame;
bool _isMenu;
bool _fadeBackground;
TWindowMode _mode;
Point32 _dragFrom;
bool _dragging;
bool _transparent;
uint32 _fadeColor;
UIWindow *_shieldWindow;
UIButton *_shieldButton;
Rect32 _titleRect;
Rect32 _dragRect;
UITiledImage *_backInactive;
BaseFont *_fontInactive;
BaseSprite *_imageInactive;
TTextAlign _titleAlign;
};
} // End of namespace Wintermute