Browse Source

resizable battle window

Laserlicht 2 weeks ago
parent
commit
9cfe9e931c

+ 25 - 2
client/battle/BattleWindow.cpp

@@ -148,8 +148,9 @@ void BattleWindow::createQueue()
 		//re-center, taking into account stack queue position
 		//re-center, taking into account stack queue position
 		pos.y -= queue->pos.h;
 		pos.y -= queue->pos.h;
 		pos.h += queue->pos.h;
 		pos.h += queue->pos.h;
-		pos = center();
 	}
 	}
+	if(showQueue)
+		pos = center();
 
 
 	if (!showQueue)
 	if (!showQueue)
 		queue->disable();
 		queue->disable();
@@ -236,6 +237,9 @@ void BattleWindow::showStickyQuickSpellWindow()
 	quickSpellWindow->setEnabled(quickSpellWindowVisible);
 	quickSpellWindow->setEnabled(quickSpellWindowVisible);
 	unitActionWindow->setEnabled(unitActionWindowVisible);
 	unitActionWindow->setEnabled(unitActionWindowVisible);
 
 
+	if(owner.actionsController && unitActionWindowVisible) // needed after resize of window
+		owner.actionsController->activateStack();
+
 	createTimerInfoWindows();
 	createTimerInfoWindows();
 	setPositionInfoWindow();
 	setPositionInfoWindow();
 	ENGINE->windows().totalRedraw();
 	ENGINE->windows().totalRedraw();
@@ -317,8 +321,8 @@ void BattleWindow::hideQueue()
 		//re-center, taking into account stack queue position
 		//re-center, taking into account stack queue position
 		pos.y += queue->pos.h;
 		pos.y += queue->pos.h;
 		pos.h -= queue->pos.h;
 		pos.h -= queue->pos.h;
-		pos = center();
 	}
 	}
+	pos = center();
 	setPositionInfoWindow();
 	setPositionInfoWindow();
 	ENGINE->windows().totalRedraw();
 	ENGINE->windows().totalRedraw();
 }
 }
@@ -859,6 +863,25 @@ void BattleWindow::show(Canvas & to)
 	GAME->interface()->cingconsole->show(to);
 	GAME->interface()->cingconsole->show(to);
 }
 }
 
 
+void BattleWindow::onScreenResize()
+{
+	if(settings["battle"]["showQueue"].Bool())
+	{
+		hideQueue();
+		showQueue();
+	}
+	if(settings["battle"]["enableQuickSpellPanel"].Bool())
+	{
+		hideStickyQuickSpellWindow();
+		showStickyQuickSpellWindow();
+	}
+	if(settings["battle"]["stickyHeroInfoWindows"].Bool())
+	{
+		hideStickyHeroWindows();
+		showStickyHeroWindows();
+	}
+}
+
 void BattleWindow::close()
 void BattleWindow::close()
 {
 {
 	if(!ENGINE->windows().isTopWindow(this))
 	if(!ENGINE->windows().isTopWindow(this))

+ 1 - 0
client/battle/BattleWindow.h

@@ -133,6 +133,7 @@ public:
 	void clickPressed(const Point & cursorPosition) override;
 	void clickPressed(const Point & cursorPosition) override;
 	void show(Canvas & to) override;
 	void show(Canvas & to) override;
 	void showAll(Canvas & to) override;
 	void showAll(Canvas & to) override;
+	void onScreenResize() override;
 
 
 	/// Toggle UI to displaying tactics phase
 	/// Toggle UI to displaying tactics phase
 	void tacticPhaseStarted();
 	void tacticPhaseStarted();

+ 1 - 1
client/battle/UnitActionPanel.cpp

@@ -35,7 +35,7 @@ UnitActionPanel::UnitActionPanel(BattleInterface & owner)
 {
 {
 	OBJECT_CONSTRUCTION;
 	OBJECT_CONSTRUCTION;
 
 
-	addUsedEvents(LCLICK | SHOW_POPUP | MOVE | INPUT_MODE_CHANGE);
+	addUsedEvents(LCLICK | SHOW_POPUP | MOVE);
 
 
 	pos = Rect(0, 0, 52, 600);
 	pos = Rect(0, 0, 52, 600);
 	background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);
 	background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);

+ 15 - 15
client/gui/EventsReceiver.h

@@ -91,21 +91,21 @@ public:
 	/// These are the arguments that can be used to determine what kind of input UI element will receive
 	/// These are the arguments that can be used to determine what kind of input UI element will receive
 	enum
 	enum
 	{
 	{
-		LCLICK = 1,
-		SHOW_POPUP = 2,
-		HOVER = 4,
-		MOVE = 8,
-		KEYBOARD = 16,
-		TIME = 32,
-		GENERAL = 64,
-		WHEEL = 128,
-		DOUBLECLICK = 256,
-		TEXTINPUT = 512,
-		GESTURE = 1024,
-		DRAG = 2048,
-		INPUT_MODE_CHANGE = 4096,
-		DRAG_POPUP = 8192,
-		KEY_NAME = 16384
+		LCLICK              = 1 <<  0,
+		SHOW_POPUP          = 1 <<  1,
+		HOVER               = 1 <<  2,
+		MOVE                = 1 <<  3,
+		KEYBOARD            = 1 <<  4,
+		TIME                = 1 <<  5,
+		GENERAL             = 1 <<  6,
+		WHEEL               = 1 <<  7,
+		DOUBLECLICK         = 1 <<  8,
+		TEXTINPUT           = 1 <<  9,
+		GESTURE             = 1 << 10,
+		DRAG                = 1 << 11,
+		INPUT_MODE_CHANGE   = 1 << 12,
+		DRAG_POPUP          = 1 << 13,
+		KEY_NAME            = 1 << 14
 	};
 	};
 
 
 	/// Returns true if element is currently hovered by mouse
 	/// Returns true if element is currently hovered by mouse