1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fixed auto-enabling of status bar on windows activations

This commit is contained in:
Ivan Savenko 2023-05-05 23:36:33 +03:00
parent 8e320d8454
commit c24ccf663b
4 changed files with 18 additions and 15 deletions

View File

@ -432,16 +432,18 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name, int maxw)
autoRedraw = false;
}
CGStatusBar::~CGStatusBar()
{
assert(GH.statusbar.get() != this || GH.statusbar == nullptr);
if (GH.statusbar.get() == this)
GH.statusbar = nullptr;
}
void CGStatusBar::show(SDL_Surface * to)
{
showAll(to);
}
void CGStatusBar::init()
{
GH.statusbar = shared_from_this();
}
void CGStatusBar::clickLeft(tribool down, bool previousState)
{
if(!down)
@ -451,8 +453,16 @@ void CGStatusBar::clickLeft(tribool down, bool previousState)
}
}
void CGStatusBar::activate()
{
GH.statusbar = shared_from_this();
CIntObject::deactivate();
}
void CGStatusBar::deactivate()
{
assert(GH.statusbar.get() == this);
if (enteringText)
LOCPLINT->cingconsole->endEnteringText(false);

View File

@ -125,8 +125,6 @@ class CGStatusBar : public CLabel, public std::enable_shared_from_this<CGStatusB
std::string consoleText;
bool enteringText;
void init();
CGStatusBar(std::shared_ptr<CIntObject> background_, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::CENTER, const SDL_Color & Color = Colors::WHITE);
CGStatusBar(int x, int y, std::string name, int maxw = -1);
@ -143,15 +141,17 @@ protected:
void clickLeft(tribool down, bool previousState) override;
public:
~CGStatusBar();
template<typename ...Args>
static std::shared_ptr<CGStatusBar> create(Args... args)
{
std::shared_ptr<CGStatusBar> ret{new CGStatusBar{args...}};
ret->init();
return ret;
}
void show(SDL_Surface * to) override;
void activate() override;
void deactivate() override;
// IStatusBar interface

View File

@ -248,9 +248,3 @@ CStatusbarWindow::CStatusbarWindow(int options, std::string imageName, Point cen
CStatusbarWindow::CStatusbarWindow(int options, std::string imageName) : CWindowObject(options, imageName)
{
}
void CStatusbarWindow::activate()
{
CIntObject::activate();
GH.statusbar = statusbar;
}

View File

@ -58,7 +58,6 @@ class CStatusbarWindow : public CWindowObject
public:
CStatusbarWindow(int options, std::string imageName, Point centerAt);
CStatusbarWindow(int options, std::string imageName = "");
void activate() override;
protected:
std::shared_ptr<CGStatusBar> statusbar;
};