Browse Source

- spellbook fix (#1110)
- possible fix for kingdom overview (#1109)
- tweaks for recruit window (part of #1113)

Ivan Savenko 13 years ago
parent
commit
07f9cb16c5

+ 6 - 4
client/CKingdomInterface.cpp

@@ -83,12 +83,12 @@ void InfoBox::clickRight(tribool down, bool previousState)
 {
 	if (down)
 	{
-		CComponent *comp;
+		CComponent *comp = nullptr;
 		std::string text;
 		data->prepareMessage(text, &comp);
 		if (comp)
 			CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
-		else
+		else if (!text.empty())
 			adventureInt->handleRightClick(text, down);
 	}
 }
@@ -97,14 +97,16 @@ void InfoBox::clickLeft(tribool down, bool previousState)
 {
 	if((!down) && previousState)
 	{
-		CComponent *comp;
+		CComponent *comp = nullptr;
 		std::string text;
 		data->prepareMessage(text, &comp);
 
 		std::vector<CComponent*> compVector;
 		if (comp)
+		{
 			compVector.push_back(comp);
-		LOCPLINT->showInfoDialog(text, compVector);
+			LOCPLINT->showInfoDialog(text, compVector);
+		}
 	}
 }
 

+ 4 - 0
client/CKingdomInterface.h

@@ -202,6 +202,10 @@ private:
 		int imageID;
 		ui32 count;
 		std::string hoverText;
+		OwnedObjectInfo():
+		    imageID(0),
+		    count(0)
+		{}
 	};
 	std::vector<OwnedObjectInfo> objects;
 

+ 5 - 0
client/CSpellWindow.cpp

@@ -348,6 +348,11 @@ void CSpellWindow::showAll(SDL_Surface * to)
 	}
 }
 
+void CSpellWindow::show(SDL_Surface * to)
+{
+	statusBar->show(to);
+}
+
 class SpellbookSpellSorter
 {
 public:

+ 1 - 0
client/CSpellWindow.h

@@ -109,6 +109,7 @@ public:
 	void activate();
 	void deactivate();
 	void showAll(SDL_Surface * to);
+	void show(SDL_Surface * to);
 
 	void teleportTo(int town, const CGHeroInstance * hero);
 };

+ 10 - 7
client/GUIClasses.cpp

@@ -1377,10 +1377,10 @@ void CRecruitmentWindow::select(CCreatureCard *card)
 
 		slider->setAmount(maxAmount);
 
-		if(slider->value)
-			slider->moveTo(0);
+		if(slider->value != maxAmount)
+			slider->moveTo(maxAmount);
 		else // if slider already at 0 - emulate call to sliderMoved()
-			sliderMoved(0);
+			sliderMoved(maxAmount);
 
 		costPerTroopValue->createItems(card->creature->cost);
 		totalCostValue->createItems(card->creature->cost);
@@ -1533,10 +1533,10 @@ void CRecruitmentWindow::availableCreaturesChanged()
 	//restore selection
 	select(cards[selectedIndex]);
 
-	if(slider->value)
-		slider->moveTo(0);
+	if(slider->value == slider->amount)
+		slider->moveTo(slider->amount);
 	else // if slider already at 0 - emulate call to sliderMoved()
-		sliderMoved(0);
+		sliderMoved(slider->amount);
 }
 
 void CRecruitmentWindow::sliderMoved(int to)
@@ -3295,7 +3295,8 @@ void CSystemOptionsWindow::setMapScrollingSpeed( int newSpeed )
 }
 
 CSystemOptionsWindow::CSystemOptionsWindow():
-    CWindowObject(PLAYER_COLORED, "SysOpBck")
+    CWindowObject(PLAYER_COLORED, "SysOpBck"),
+    onFullscreenChanged(settings.listen["video"]["fullscreen"])
 {
 	//TODO: translation and\or config file
 	static const std::string fsLabel = "Fullscreen";
@@ -3402,6 +3403,8 @@ CSystemOptionsWindow::CSystemOptionsWindow():
 	newCreatureWin->select(settings["general"]["classicCreatureWindow"].Bool());
 	fullscreen->select(settings["video"]["fullscreen"].Bool());
 
+	onFullscreenChanged([&](const JsonNode &newState){ fullscreen->select(newState.Bool());});
+
 	gameResButton = new CAdventureMapButton("", rsHelp, boost::bind(&CSystemOptionsWindow::selectGameRes, this), 28, 275,"SYSOB12", SDLK_g);
 
 	std::string resText;

+ 3 - 0
client/GUIClasses.h

@@ -3,6 +3,7 @@
 #include "CAnimation.h"
 #include "FunctionList.h"
 #include "../lib/ResourceSet.h"
+#include "../lib/CConfigHandler.h"
 #include "../lib/GameConstants.h"
 #include "UIFramework/CIntObject.h"
 #include "UIFramework/CIntObjectClasses.h"
@@ -731,6 +732,8 @@ private:
 	CAdventureMapButton *gameResButton;
 	CLabel *gameResLabel;
 
+	SettingsListener onFullscreenChanged;
+
 	void setMusicVolume( int newVolume );
 	void setSoundVolume( int newVolume );
 	void setHeroMoveSpeed( int newSpeed );

+ 1 - 1
lib/CObjectHandler.cpp

@@ -6643,7 +6643,7 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
 		cb->setOwner(id, h->tempOwner);
 
 	auto s = state();
-	if(s == IBoatGenerator::GOOD)
+	if(s != IBoatGenerator::GOOD)
 	{
 		InfoWindow iw;
 		iw.player = tempOwner;