浏览代码

vcmi: request pop all when hero is moved

This way new pickup will show immidately.
Konstantin 2 年之前
父节点
当前提交
3d33da0a9e
共有 3 个文件被更改,包括 19 次插入5 次删除
  1. 1 0
      client/CPlayerInterface.cpp
  2. 13 4
      client/adventureMap/CInfoBar.cpp
  3. 5 1
      client/adventureMap/CInfoBar.h

+ 1 - 0
client/CPlayerInterface.cpp

@@ -324,6 +324,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
 	if (!hero)
 		return;
 
+	adventureInt->infoBar->requestPopAll();
 	if (details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK)
 	{
 		if (hero->getRemovalSound())

+ 13 - 4
client/adventureMap/CInfoBar.cpp

@@ -268,7 +268,7 @@ void CInfoBar::tick()
 {
 	removeUsedEvents(TIME);
 	if(GH.topInt() == adventureInt)
-		popComponents();
+		popComponents(true);
 }
 
 void CInfoBar::clickLeft(tribool down, bool previousState)
@@ -280,7 +280,7 @@ void CInfoBar::clickLeft(tribool down, bool previousState)
 		else if(state == GAME)
 			showDate();
 		else
-			popComponents();
+			popComponents(true);
 	}
 }
 
@@ -334,6 +334,8 @@ void CInfoBar::pushComponents(const std::vector<Component> & components, std::st
 			vect.erase(vect.begin(), vect.begin() + std::min(vect.size(), max));
 		};
 	};
+	if(shouldPopAll)
+		popAll();
 	if(components.empty())
 		prepareComponents(components, message, timer);
 	else
@@ -421,20 +423,27 @@ void CInfoBar::prepareComponents(const std::vector<Component> & components, std:
 	return;
 }
 
+void CInfoBar::requestPopAll()
+{
+	shouldPopAll = true;
+}
+
 void CInfoBar::popAll()
 {
 	componentsQueue = {};
+	shouldPopAll = false;
 }
 
-void CInfoBar::popComponents()
+void CInfoBar::popComponents(bool remove)
 {
 	OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255-DISPOSE);
+	if(remove && !componentsQueue.empty())
+		componentsQueue.pop();
 	if(!componentsQueue.empty())
 	{
 		state = COMPONENT;
 		const auto & extracted = componentsQueue.front();
 		visibleInfo = std::make_shared<VisibleComponentInfo>(extracted.first);
-		componentsQueue.pop();
 		setTimer(extracted.second);
 		redraw();
 		return;

+ 5 - 1
client/adventureMap/CInfoBar.h

@@ -138,6 +138,7 @@ private:
 
 	std::shared_ptr<CVisibleInfo> visibleInfo;
 	EState state;
+	bool shouldPopAll = false;
 
 	std::queue<std::pair<VisibleComponentInfo::Cache, int>> componentsQueue;
 
@@ -145,7 +146,7 @@ private:
 	void showComponents(const std::vector<Component> & comps, std::string message, int textH, bool tiny, int timer);
 	void pushComponents(const std::vector<Component> & comps, std::string message, int textH, bool tiny, int timer);
 	void prepareComponents(const std::vector<Component> & comps, std::string message, int timer);
-	void popComponents();
+	void popComponents(bool remove = false);
 
 	//removes all information about current state, deactivates timer (if any)
 	void reset();
@@ -170,6 +171,9 @@ public:
 	/// Remove all queued components
 	void popAll();
 
+	/// Request infobar to pop all after next InfoWindow arrives.
+	void requestPopAll();
+
 	/// print enemy turn progress
 	void startEnemyTurn(PlayerColor color);