mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Fixed auto-enabling of status bar on windows activations
This commit is contained in:
		| @@ -432,16 +432,18 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name, int maxw) | |||||||
| 	autoRedraw = false; | 	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) | void CGStatusBar::show(SDL_Surface * to) | ||||||
| { | { | ||||||
| 	showAll(to); | 	showAll(to); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CGStatusBar::init() |  | ||||||
| { |  | ||||||
| 	GH.statusbar = shared_from_this(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void CGStatusBar::clickLeft(tribool down, bool previousState) | void CGStatusBar::clickLeft(tribool down, bool previousState) | ||||||
| { | { | ||||||
| 	if(!down) | 	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() | void CGStatusBar::deactivate() | ||||||
| { | { | ||||||
|  | 	assert(GH.statusbar.get() == this); | ||||||
|  |  | ||||||
| 	if (enteringText) | 	if (enteringText) | ||||||
| 		LOCPLINT->cingconsole->endEnteringText(false); | 		LOCPLINT->cingconsole->endEnteringText(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -125,8 +125,6 @@ class CGStatusBar : public CLabel, public std::enable_shared_from_this<CGStatusB | |||||||
| 	std::string consoleText; | 	std::string consoleText; | ||||||
| 	bool enteringText; | 	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(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); | 	CGStatusBar(int x, int y, std::string name, int maxw = -1); | ||||||
|  |  | ||||||
| @@ -143,15 +141,17 @@ protected: | |||||||
| 	void clickLeft(tribool down, bool previousState) override; | 	void clickLeft(tribool down, bool previousState) override; | ||||||
|  |  | ||||||
| public: | public: | ||||||
|  | 	~CGStatusBar(); | ||||||
|  |  | ||||||
| 	template<typename ...Args> | 	template<typename ...Args> | ||||||
| 	static std::shared_ptr<CGStatusBar> create(Args... args) | 	static std::shared_ptr<CGStatusBar> create(Args... args) | ||||||
| 	{ | 	{ | ||||||
| 		std::shared_ptr<CGStatusBar> ret{new CGStatusBar{args...}}; | 		std::shared_ptr<CGStatusBar> ret{new CGStatusBar{args...}}; | ||||||
| 		ret->init(); |  | ||||||
| 		return ret; | 		return ret; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void show(SDL_Surface * to) override; | 	void show(SDL_Surface * to) override; | ||||||
|  | 	void activate() override; | ||||||
| 	void deactivate() override; | 	void deactivate() override; | ||||||
|  |  | ||||||
| 	// IStatusBar interface | 	// IStatusBar interface | ||||||
|   | |||||||
| @@ -248,9 +248,3 @@ CStatusbarWindow::CStatusbarWindow(int options, std::string imageName, Point cen | |||||||
| CStatusbarWindow::CStatusbarWindow(int options, std::string imageName) : CWindowObject(options, imageName) | CStatusbarWindow::CStatusbarWindow(int options, std::string imageName) : CWindowObject(options, imageName) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
| void CStatusbarWindow::activate() |  | ||||||
| { |  | ||||||
| 	CIntObject::activate(); |  | ||||||
| 	GH.statusbar = statusbar; |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -58,7 +58,6 @@ class CStatusbarWindow : public CWindowObject | |||||||
| public: | public: | ||||||
| 	CStatusbarWindow(int options, std::string imageName, Point centerAt); | 	CStatusbarWindow(int options, std::string imageName, Point centerAt); | ||||||
| 	CStatusbarWindow(int options, std::string imageName = ""); | 	CStatusbarWindow(int options, std::string imageName = ""); | ||||||
| 	void activate() override; |  | ||||||
| protected: | protected: | ||||||
| 	std::shared_ptr<CGStatusBar> statusbar; | 	std::shared_ptr<CGStatusBar> statusbar; | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user