diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index fecc485da..9d172d2a3 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -310,8 +310,6 @@ std::shared_ptr InterfaceObjectConfigurable::buildPicture(const JsonNo auto image = ImagePath::fromJson(config["image"]); auto position = readPosition(config["position"]); auto pic = std::make_shared(image, position.x, position.y); - if(!config["visible"].isNull()) - pic->visible = config["visible"].Bool(); if ( config["playerColored"].Bool() && LOCPLINT) pic->colorize(LOCPLINT->playerID); diff --git a/client/widgets/ComboBox.cpp b/client/widgets/ComboBox.cpp index 7b6ee4920..eca9fd458 100644 --- a/client/widgets/ComboBox.cpp +++ b/client/widgets/ComboBox.cpp @@ -22,10 +22,11 @@ ComboBox::DropDown::Item::Item(const JsonNode & config, ComboBox::DropDown & _dr { build(config); - if(auto w = widget("hoverImage")) + if(auto w = widget("hoverImage")) { pos.w = w->pos.w; pos.h = w->pos.h; + w->disable(); } setRedrawParent(true); } @@ -42,14 +43,14 @@ void ComboBox::DropDown::Item::updateItem(int idx, const void * _item) void ComboBox::DropDown::Item::hover(bool on) { - auto h = widget("hoverImage"); + auto h = widget("hoverImage"); auto w = widget("labelName"); if(h && w) { - if(w->getText().empty()) - h->visible = false; + if(w->getText().empty() || on == false) + h->disable(); else - h->visible = on; + h->enable(); } redraw(); } diff --git a/client/widgets/Images.cpp b/client/widgets/Images.cpp index 76ccd2838..8ae5795fb 100644 --- a/client/widgets/Images.cpp +++ b/client/widgets/Images.cpp @@ -35,7 +35,6 @@ CPicture::CPicture(std::shared_ptr image, const Point & position) : bg(image) - , visible(true) , needRefresh(false) { pos += position; @@ -53,7 +52,6 @@ CPicture::CPicture( const ImagePath & bmpname ) CPicture::CPicture( const ImagePath & bmpname, const Point & position ) : bg(GH.renderHandler().loadImage(bmpname)) - , visible(true) , needRefresh(false) { pos.x += position.x; @@ -81,13 +79,13 @@ CPicture::CPicture(std::shared_ptr image, const Rect &SrcRect, int x, in void CPicture::show(Canvas & to) { - if (visible && needRefresh) + if (needRefresh) showAll(to); } void CPicture::showAll(Canvas & to) { - if(bg && visible) + if(bg) { if (srcRect.has_value()) to.draw(bg, pos.topLeft(), *srcRect); diff --git a/client/widgets/Images.h b/client/widgets/Images.h index 2a9f3ae10..94fef0c1c 100644 --- a/client/widgets/Images.h +++ b/client/widgets/Images.h @@ -34,10 +34,6 @@ public: /// If set to true, iamge will be redrawn on each frame bool needRefresh; - /// If set to false, image will not be rendered - /// Deprecated, use CIntObject::disable()/enable() instead - bool visible; - std::shared_ptr getSurface() { return bg; diff --git a/client/windows/CSpellWindow.cpp b/client/windows/CSpellWindow.cpp index 43ad953c4..bbd104fd4 100644 --- a/client/windows/CSpellWindow.cpp +++ b/client/windows/CSpellWindow.cpp @@ -449,8 +449,16 @@ void CSpellWindow::setCurrentPage(int value) schoolPicture->visible = selectedTab!=4 && currentPage == 0; if(selectedTab != 4) schoolPicture->setFrame(selectedTab, 0); - leftCorner->visible = currentPage != 0; - rightCorner->visible = (currentPage+1) < pagesWithinCurrentTab(); + + if (currentPage != 0) + leftCorner->enable(); + else + leftCorner->disable(); + + if (currentPage + 1 < pagesWithinCurrentTab()) + rightCorner->enable(); + else + rightCorner->disable(); mana->setText(std::to_string(myHero->mana));//just in case, it will be possible to cast spell without closing book }