Răsfoiți Sursa

Moved all non-window GUI elements out from GUI classes file. TODO: reorganize source tree

Ivan Savenko 11 ani în urmă
părinte
comite
83099fdb78

+ 286 - 0
client/AdventureMapClasses.cpp

@@ -20,8 +20,14 @@
 #include "CMusicHandler.h"
 #include "Graphics.h"
 #include "GUIClasses.h"
+#include "StartInfo.h"
+#include "CPreGame.h"
 #include "gui/CGuiHandler.h"
 #include "gui/SDL_Pixels.h"
+#include "gui/MiscWidgets.h"
+#include "battle/CBattleInterface.h"
+#include "battle/CBattleInterfaceClasses.h"
+#include "gui/MiscWidgets.h"
 
 /*
  * CAdventureMapClasses.h, part of VCMI engine
@@ -950,3 +956,283 @@ void CInfoBar::showGameStatus()
 	setTimer(3000);
 	redraw();
 }
+
+void CInGameConsole::show(SDL_Surface * to)
+{
+	int number = 0;
+
+	std::vector<std::list< std::pair< std::string, int > >::iterator> toDel;
+
+	boost::unique_lock<boost::mutex> lock(texts_mx);
+	for(auto it = texts.begin(); it != texts.end(); ++it, ++number)
+	{
+		Point leftBottomCorner(0, screen->h);
+		if(LOCPLINT->battleInt)
+		{
+			leftBottomCorner = LOCPLINT->battleInt->pos.bottomLeft();
+		}
+		graphics->fonts[FONT_MEDIUM]->renderTextLeft(to, it->first, Colors::GREEN,
+			Point(leftBottomCorner.x + 50, leftBottomCorner.y - texts.size() * 20 - 80 + number*20));
+
+		if(SDL_GetTicks() - it->second > defaultTimeout)
+		{
+			toDel.push_back(it);
+		}
+	}
+
+	for(auto & elem : toDel)
+	{
+		texts.erase(elem);
+	}
+}
+
+void CInGameConsole::print(const std::string &txt)
+{
+	boost::unique_lock<boost::mutex> lock(texts_mx);
+	int lineLen = conf.go()->ac.outputLineLength;
+
+	if(txt.size() < lineLen)
+	{
+		texts.push_back(std::make_pair(txt, SDL_GetTicks()));
+		if(texts.size() > maxDisplayedTexts)
+		{
+			texts.pop_front();
+		}
+	}
+	else
+	{
+		assert(lineLen);
+		for(int g=0; g<txt.size() / lineLen + 1; ++g)
+		{
+			std::string part = txt.substr(g * lineLen, lineLen);
+			if(part.size() == 0)
+				break;
+
+			texts.push_back(std::make_pair(part, SDL_GetTicks()));
+			if(texts.size() > maxDisplayedTexts)
+			{
+				texts.pop_front();
+			}
+		}
+	}
+}
+
+void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
+{
+	if(key.type != SDL_KEYDOWN) return;
+
+	if(!captureAllKeys && key.keysym.sym != SDLK_TAB) return; //because user is not entering any text
+
+	switch(key.keysym.sym)
+	{
+	case SDLK_TAB:
+	case SDLK_ESCAPE:
+		{
+			if(captureAllKeys)
+			{
+				captureAllKeys = false;
+				endEnteringText(false);
+			}
+			else if(SDLK_TAB)
+			{
+				captureAllKeys = true;
+				startEnteringText();
+			}
+			break;
+		}
+	case SDLK_RETURN: //enter key
+		{
+			if(enteredText.size() > 0  &&  captureAllKeys)
+			{
+				captureAllKeys = false;
+				endEnteringText(true);
+				CCS->soundh->playSound("CHAT");
+			}
+			break;
+		}
+	case SDLK_BACKSPACE:
+		{
+			if(enteredText.size() > 1)
+			{
+				Unicode::trimRight(enteredText,2);
+				enteredText += '_';
+				refreshEnteredText();
+			}
+			break;
+		}
+	case SDLK_UP: //up arrow
+		{
+			if(previouslyEntered.size() == 0)
+				break;
+
+			if(prevEntDisp == -1)
+			{
+				prevEntDisp = previouslyEntered.size() - 1;
+				enteredText = previouslyEntered[prevEntDisp] + "_";
+				refreshEnteredText();
+			}
+			else if( prevEntDisp > 0)
+			{
+				--prevEntDisp;
+				enteredText = previouslyEntered[prevEntDisp] + "_";
+				refreshEnteredText();
+			}
+			break;
+		}
+	case SDLK_DOWN: //down arrow
+		{
+			if(prevEntDisp != -1 && prevEntDisp+1 < previouslyEntered.size())
+			{
+				++prevEntDisp;
+				enteredText = previouslyEntered[prevEntDisp] + "_";
+				refreshEnteredText();
+			}
+			else if(prevEntDisp+1 == previouslyEntered.size()) //useful feature
+			{
+				prevEntDisp = -1;
+				enteredText = "_";
+				refreshEnteredText();
+			}
+			break;
+		}
+	default:
+		{
+			#ifdef VCMI_SDL1
+			if(enteredText.size() > 0 && enteredText.size() < conf.go()->ac.inputLineLength)
+			{
+				if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 )
+				{
+					enteredText[enteredText.size()-1] = (char)key.keysym.unicode;
+					enteredText += "_";
+					refreshEnteredText();
+				}
+			}
+			#endif // VCMI_SDL1
+			break;
+		}
+	}
+}
+
+#ifndef VCMI_SDL1
+
+void CInGameConsole::textInputed(const SDL_TextInputEvent & event)
+{
+	if(!captureAllKeys || enteredText.size() == 0)
+		return;
+	enteredText.resize(enteredText.size()-1);
+
+	enteredText += event.text;
+	enteredText += "_";
+
+	refreshEnteredText();
+}
+
+void CInGameConsole::textEdited(const SDL_TextEditingEvent & event)
+{
+ //do nothing here
+}
+
+#endif // VCMI_SDL1
+
+void CInGameConsole::startEnteringText()
+{
+	CSDL_Ext::startTextInput(&pos);
+
+	enteredText = "_";
+	if(GH.topInt() == adventureInt)
+	{
+		GH.statusbar->alignment = TOPLEFT;
+		GH.statusbar->setText(enteredText);
+
+		//Prevent changes to the text from mouse interaction with the adventure map
+		GH.statusbar->lock(true);
+	}
+	else if(LOCPLINT->battleInt)
+	{
+		LOCPLINT->battleInt->console->ingcAlter = enteredText;
+	}
+}
+
+void CInGameConsole::endEnteringText(bool printEnteredText)
+{
+	CSDL_Ext::stopTextInput();
+
+	prevEntDisp = -1;
+	if(printEnteredText)
+	{
+		std::string txt = enteredText.substr(0, enteredText.size()-1);
+		LOCPLINT->cb->sendMessage(txt);
+		previouslyEntered.push_back(txt);
+		//print(txt);
+	}
+	enteredText = "";
+	if(GH.topInt() == adventureInt)
+	{
+		GH.statusbar->alignment = CENTER;
+		GH.statusbar->lock(false);
+		GH.statusbar->clear();
+	}
+	else if(LOCPLINT->battleInt)
+	{
+		LOCPLINT->battleInt->console->ingcAlter = "";
+	}
+}
+
+void CInGameConsole::refreshEnteredText()
+{
+	if(GH.topInt() == adventureInt)
+	{
+		GH.statusbar->lock(false);
+		GH.statusbar->clear();
+		GH.statusbar->setText(enteredText);
+		GH.statusbar->lock(true);
+	}
+	else if(LOCPLINT->battleInt)
+	{
+		LOCPLINT->battleInt->console->ingcAlter = enteredText;
+	}
+}
+
+CInGameConsole::CInGameConsole() : prevEntDisp(-1), defaultTimeout(10000), maxDisplayedTexts(10)
+{
+	#ifdef VCMI_SDL1
+	addUsedEvents(KEYBOARD);
+	#else
+	addUsedEvents(KEYBOARD | TEXTINPUT);
+	#endif
+}
+
+CAdventureOptions::CAdventureOptions():
+	CWindowObject(PLAYER_COLORED, "ADVOPTS")
+{
+	OBJ_CONSTRUCTION_CAPTURING_ALL;
+
+	exit = new CAdventureMapButton("","",boost::bind(&CAdventureOptions::close, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
+	exit->assignedKeys.insert(SDLK_ESCAPE);
+
+	scenInfo = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 198, "ADVINFO.DEF",SDLK_i);
+	scenInfo->callback += CAdventureOptions::showScenarioInfo;
+	//viewWorld = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
+
+	puzzle = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 81, "ADVPUZ.DEF");
+	puzzle->callback += boost::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
+
+	dig = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 139, "ADVDIG.DEF");
+	if(const CGHeroInstance *h = adventureInt->curHero())
+		dig->callback += boost::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
+	else
+		dig->block(true);
+}
+
+void CAdventureOptions::showScenarioInfo()
+{
+	auto campState = LOCPLINT->cb->getStartInfo()->campState;
+	if(campState)
+	{
+		GH.pushInt(new CBonusSelection(campState));
+	}
+	else
+	{
+		GH.pushInt(new CScenarioInfo(LOCPLINT->cb->getMapHeader(), LOCPLINT->cb->getStartInfo()));
+	}
+}

+ 37 - 1
client/AdventureMapClasses.h

@@ -1,6 +1,5 @@
 #pragma once
 
-#include "gui/CIntObject.h"
 #include "gui/CIntObjectClasses.h"
 
 class CArmedInstance;
@@ -313,3 +312,40 @@ public:
 	/// for 3 seconds shows amount of town halls and players status
 	void showGameStatus();
 };
+
+class CInGameConsole : public CIntObject
+{
+private:
+	std::list< std::pair< std::string, int > > texts; //list<text to show, time of add>
+	boost::mutex texts_mx;		// protects texts
+	std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
+	int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
+	int defaultTimeout; //timeout for new texts (in ms)
+	int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
+public:
+	std::string enteredText;
+	void show(SDL_Surface * to);
+	void print(const std::string &txt);
+	void keyPressed (const SDL_KeyboardEvent & key); //call-in
+
+#ifndef VCMI_SDL1
+	void textInputed(const SDL_TextInputEvent & event) override;
+	void textEdited(const SDL_TextEditingEvent & event) override;
+#endif // VCMI_SDL1
+
+	void startEnteringText();
+	void endEnteringText(bool printEnteredText);
+	void refreshEnteredText();
+
+	CInGameConsole(); //c-tor
+};
+
+/// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,...
+class CAdventureOptions : public CWindowObject
+{
+public:
+	CAdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
+
+	CAdventureOptions();
+	static void showScenarioInfo();
+};

+ 2 - 35
client/CAdvmapInterface.cpp

@@ -14,6 +14,7 @@
 #include "../lib/CConfigHandler.h"
 #include "CSpellWindow.h"
 #include "Graphics.h"
+#include "GUIClasses.h"
 #include "CDefHandler.h"
 #include "../lib/CGeneralTextHandler.h"
 #include "../lib/CHeroHandler.h"
@@ -31,6 +32,7 @@
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
 #include "gui/CTradeWindow.h"
+#include "gui/MiscWidgets.h"
 #include "../lib/UnlockGuard.h"
 
 #ifdef _MSC_VER
@@ -1524,38 +1526,3 @@ void CAdvMapInt::adjustActiveness(bool aiTurnStart)
 	if(wasActive) 
 		activate();
 }
-
-CAdventureOptions::CAdventureOptions():
-    CWindowObject(PLAYER_COLORED, "ADVOPTS")
-{
-	OBJ_CONSTRUCTION_CAPTURING_ALL;
-
-	exit = new CAdventureMapButton("","",boost::bind(&CAdventureOptions::close, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
-	exit->assignedKeys.insert(SDLK_ESCAPE);
-
-	scenInfo = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 198, "ADVINFO.DEF",SDLK_i);
-	scenInfo->callback += CAdventureOptions::showScenarioInfo;
-	//viewWorld = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
-
-	puzzle = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 81, "ADVPUZ.DEF");
-	puzzle->callback += boost::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
-
-	dig = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 139, "ADVDIG.DEF");
-	if(const CGHeroInstance *h = adventureInt->curHero())
-		dig->callback += boost::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
-	else
-		dig->block(true);
-}
-
-void CAdventureOptions::showScenarioInfo()
-{
-	auto campState = LOCPLINT->cb->getStartInfo()->campState;
-	if(campState)
-	{
-		GH.pushInt(new CBonusSelection(campState));
-	}
-	else
-	{
-		GH.pushInt(new CScenarioInfo(LOCPLINT->cb->getMapHeader(), LOCPLINT->cb->getStartInfo()));
-	}
-}

+ 1 - 15
client/CAdvmapInterface.h

@@ -1,10 +1,6 @@
 #pragma once
 
-#include <typeinfo>
-
-#include "SDL.h"
-#include "gui/CIntObjectClasses.h"
-#include "GUIClasses.h"
+#include "gui/CIntObject.h"
 #include "AdventureMapClasses.h"
 
 class CDefHandler;
@@ -29,16 +25,6 @@ class IShipyard;
  *
  */
 
-/// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,...
-class CAdventureOptions : public CWindowObject
-{
-public:
-	CAdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
-
-	CAdventureOptions();
-	static void showScenarioInfo();
-};
-
 /// Holds information about which tiles of the terrain are shown/not shown at the screen
 class CTerrainRect
 	:  public CIntObject

+ 2 - 0
client/CCastleInterface.cpp

@@ -25,6 +25,8 @@
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
 #include "gui/CTradeWindow.h"
+#include "gui/MiscWidgets.h"
+#include "GUIClasses.h"
 
 using namespace boost::assign;
 

+ 1 - 2
client/CCastleInterface.h

@@ -1,8 +1,7 @@
 #pragma once
 
-
 #include "CAnimation.h"
-#include "GUIClasses.h"
+#include "gui/CGarrisonInt.h"
 
 class CAdventureMapButton;
 class CBuilding;

+ 1 - 0
client/CCreatureWindow.cpp

@@ -26,6 +26,7 @@
 
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/MiscWidgets.h"
 
 using namespace CSDL_Ext;
 

+ 1 - 1
client/CCreatureWindow.h

@@ -2,7 +2,7 @@
 
 #include "gui/CIntObject.h"
 #include "../lib/HeroBonus.h"
-#include "GUIClasses.h"
+#include "gui/CArtifactHolder.h"
 
 /*
  * CCreatureWindow.h, part of VCMI engine

+ 2 - 0
client/CHeroWindow.cpp

@@ -25,6 +25,8 @@
 
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/MiscWidgets.h"
+#include "GUIClasses.h"
 #include "CMT.h"
 
 #undef min

+ 3 - 1
client/CHeroWindow.h

@@ -2,7 +2,8 @@
 
 #include "../lib/HeroBonus.h"
 #include "gui/CIntObjectClasses.h"
-#include "GUIClasses.h"
+#include "gui/CArtifactHolder.h"
+#include "gui/CGarrisonInt.h"
 
 /*
  * CHeroWindow.h, part of VCMI engine
@@ -24,6 +25,7 @@ class LClickableAreaHero;
 class LRClickableAreaWText;
 class LRClickableAreaWTextComp;
 class CArtifactsOfHero;
+class MoraleLuckBox;
 
 /// Button which switches hero selection
 class CHeroSwitcher : public CIntObject

+ 1 - 0
client/CKingdomInterface.cpp

@@ -16,6 +16,7 @@
 #include "CPlayerInterface.h" //LOCPLINT
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/MiscWidgets.h"
 #include "CMT.h"
 
 /*

+ 6 - 2
client/CKingdomInterface.h

@@ -1,7 +1,7 @@
 #pragma once
 
-
-#include "GUIClasses.h"
+#include "gui/CArtifactHolder.h"
+#include "gui/CGarrisonInt.h"
 
 class CAdventureMapButton;
 class CAnimImage;
@@ -11,6 +11,10 @@ class CSlider;
 class CTownInfo;
 class CCreaInfo;
 class HeroSlots;
+class LRClickableAreaOpenTown;
+class CComponent;
+class CHeroArea;
+class MoraleLuckBox;
 
 /*
  * CKingdomInterface.h, part of VCMI engine

+ 1 - 0
client/CMakeLists.txt

@@ -23,6 +23,7 @@ set(client_SRCS
 		gui/CTradeWindow.cpp
 		gui/Fonts.cpp
 		gui/Geometries.cpp
+		gui/MiscWidgets.cpp
 		gui/CCursorHandler.cpp
 		gui/SDL_Extensions.cpp
 

+ 1 - 0
client/CMessage.cpp

@@ -22,6 +22,7 @@
 #include "../lib/CConfigHandler.h"
 #include "CBitmapHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/MiscWidgets.h"
 
 const int BETWEEN_COMPS_ROWS = 10;
 const int BEFORE_COMPONENTS = 30;

+ 0 - 1
client/CMusicHandler.h

@@ -2,7 +2,6 @@
 
 #include "../lib/CConfigHandler.h"
 #include "../lib/CSoundBase.h"
-#include "../lib/CCreatureHandler.h"
 
 /*
  * CMusicHandler.h, part of VCMI engine

+ 2 - 0
client/CPlayerInterface.cpp

@@ -17,6 +17,7 @@
 #include "../lib/CConfigHandler.h"
 #include "battle/CCreatureAnimation.h"
 #include "Graphics.h"
+#include "GUIClasses.h"
 #include "../lib/CArtHandler.h"
 #include "../lib/CGeneralTextHandler.h"
 #include "../lib/CHeroHandler.h"
@@ -36,6 +37,7 @@
 #include "../lib/CGameState.h"
 #include "../lib/GameConstants.h"
 #include "gui/CGuiHandler.h"
+#include "gui/MiscWidgets.h"
 #include "../lib/UnlockGuard.h"
 
 #ifdef min

+ 1 - 0
client/CPreGame.cpp

@@ -39,6 +39,7 @@
 #include "../lib/GameConstants.h"
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/MiscWidgets.h"
 #include "../lib/mapping/CMapService.h"
 #include "../lib/mapping/CMap.h"
 #include "../lib/CRandomGenerator.h"

+ 1 - 2
client/CPreGame.h

@@ -1,12 +1,11 @@
 #pragma once
 
 #include "../lib/filesystem/Filesystem.h"
-#include <SDL.h>
 #include "../lib/StartInfo.h"
-#include "GUIClasses.h"
 #include "../lib/FunctionList.h"
 #include "../lib/mapping/CMapInfo.h"
 #include "../lib/rmg/CMapGenerator.h"
+#include "gui/CIntObjectClasses.h"
 
 /*
  * CPreGame.h, part of VCMI engine

+ 3 - 3
client/CQuestLog.cpp

@@ -5,20 +5,20 @@
 #include "../lib/CGeneralTextHandler.h"
 #include "../CCallback.h"
 
-#include <SDL.h>
-#include "gui/SDL_Extensions.h"
 #include "CBitmapHandler.h"
 #include "CDefHandler.h"
 #include "Graphics.h"
 #include "CPlayerInterface.h"
-#include "../lib/CConfigHandler.h"
+#include "CAdvmapInterface.h"
 
 #include "../lib/CGameState.h"
 #include "../lib/CArtHandler.h"
 #include "../lib/NetPacksBase.h"
+#include "../lib/CConfigHandler.h"
 
 #include "gui/CGuiHandler.h"
 #include "gui/CIntObjectClasses.h"
+#include "gui/SDL_Extensions.h"
 
 /*
  * CQuestLog.cpp, part of VCMI engine

+ 8 - 7
client/CQuestLog.h

@@ -1,9 +1,12 @@
-#include "gui/CIntObject.h"
+#pragma once
+
+#include "gui/CIntObjectClasses.h"
+#include "CAnimation.h"
 #include "AdventureMapClasses.h"
-#include "CAdvmapInterface.h"
-#include "GUIClasses.h"
+//#include "CAdvmapInterface.h"
+//
 
-#include "../lib/CGameState.h"
+//#include "../lib/CGameState.h"
 
 /*
  * CQuestLog.h, part of VCMI engine
@@ -29,8 +32,6 @@ class CSlider;
 class CLabel;
 struct QuestInfo;
 
-extern CAdvMapInt *adventureInt;
-
 const int QUEST_COUNT = 9;
 
 class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
@@ -101,4 +102,4 @@ public:
 	void sliderMoved (int newpos);
 	void recreateQuestList (int pos);
 	void showAll (SDL_Surface * to);
-};
+};

+ 3 - 0
client/CSpellWindow.cpp

@@ -3,6 +3,7 @@
 
 #include "Graphics.h"
 #include "CDefHandler.h"
+#include "../lib/CConfigHandler.h"
 #include "../lib/CSpellHandler.h"
 #include "../lib/CGeneralTextHandler.h"
 #include "CVideoHandler.h"
@@ -18,7 +19,9 @@
 #include "../lib/BattleState.h"
 #include "../lib/GameConstants.h"
 #include "gui/CGuiHandler.h"
+#include "gui/MiscWidgets.h"
 #include "CMT.h"
+#include "GUIClasses.h"
 
 /*
  * CSpellWindow.cpp, part of VCMI engine

Fișier diff suprimat deoarece este prea mare
+ 116 - 1063
client/GUIClasses.cpp


+ 7 - 230
client/GUIClasses.h

@@ -1,23 +1,11 @@
 #pragma once
 
-#include "CAnimation.h"
-#include "../lib/FunctionList.h"
+#include "../lib/GameConstants.h"
 #include "../lib/ResourceSet.h"
 #include "../lib/CConfigHandler.h"
-#include "../lib/GameConstants.h"
-#include "gui/CIntObject.h"
-#include "gui/CIntObjectClasses.h"
-#include "../lib/GameConstants.h"
 #include "gui/CArtifactHolder.h"
-#include "gui/CComponent.h"
 #include "gui/CGarrisonInt.h"
-
-#ifdef max
-#undef max
-#endif
-#ifdef min
-#undef min
-#endif
+#include "CAnimation.h"
 
 /*
  * GUIClasses.h, part of VCMI engine
@@ -82,150 +70,12 @@ struct InfoAboutArmy;
 struct InfoAboutHero;
 struct InfoAboutTown;
 
-/// text + comp. + ok button
-class CInfoWindow : public CSimpleWindow
-{ //window able to delete its components when closed
-	bool delComps; //whether comps will be deleted
-
-public:
-	typedef std::vector<std::pair<std::string,CFunctionList<void()> > > TButtonsInfo;
-	typedef std::vector<CComponent*> TCompsInfo;
-	QueryID ID; //for identification
-	CTextBox *text;
-	std::vector<CAdventureMapButton *> buttons;
-	std::vector<CComponent*> components;
-	CSlider *slider;
-
-	void setDelComps(bool DelComps);
-	virtual void close();
-
-	void show(SDL_Surface * to);
-	void showAll(SDL_Surface * to);
-	void sliderMoved(int to);
-
-	CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo &comps = TCompsInfo(), const TButtonsInfo &Buttons = TButtonsInfo(), bool delComps = true); //c-tor
-	CInfoWindow(); //c-tor
-	~CInfoWindow(); //d-tor
-
-	//use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
-	static void showInfoDialog( const std::string & text, const std::vector<CComponent*> *components, bool DelComps = true, PlayerColor player = PlayerColor(1));
-	static void showOkDialog(const std::string & text, const std::vector<CComponent*> *components, const boost::function<void()> & onOk, bool delComps = true, PlayerColor player = PlayerColor(1));
-	static void showYesNoDialog( const std::string & text, const std::vector<CComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, PlayerColor player = PlayerColor(1));
-	static CInfoWindow *create(const std::string &text, PlayerColor playerID = PlayerColor(1), const std::vector<CComponent*> *components = nullptr, bool DelComps = false);
-
-	/// create text from title and description: {title}\n\n description
-	static std::string genText(std::string title, std::string description);
-};
-
-/// popup displayed on R-click
-class CRClickPopup : public CIntObject
-{
-public:
-	virtual void close();
-	void clickRight(tribool down, bool previousState);
-
-	CRClickPopup();
-	virtual ~CRClickPopup(); //d-tor
-
-	static CIntObject* createInfoWin(Point position, const CGObjectInstance * specific);
-	static void createAndPush(const std::string &txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo());
-	static void createAndPush(const std::string &txt, CComponent * component);
-	static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT);
-};
-
-/// popup displayed on R-click
-class CRClickPopupInt : public CRClickPopup
-{
-public:
-	IShowActivatable *inner;
-	bool delInner;
-
-	void show(SDL_Surface * to);
-	void showAll(SDL_Surface * to);
-	CRClickPopupInt(IShowActivatable *our, bool deleteInt); //c-tor
-	virtual ~CRClickPopupInt(); //d-tor
-};
-
-class CInfoPopup : public CRClickPopup
-{
-public:
-	bool free; //TODO: comment me
-	SDL_Surface * bitmap; //popup background
-	void close();
-	void show(SDL_Surface * to);
-	CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
-	CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
-	CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false); //default c-tor
-
-	void init(int x, int y);
-	~CInfoPopup(); //d-tor
-};
-
-/// popup on adventure map for town\hero objects
-class CInfoBoxPopup : public CWindowObject
-{
-	Point toScreen(Point pos);
-public:
-	CInfoBoxPopup(Point position, const CGTownInstance * town);
-	CInfoBoxPopup(Point position, const CGHeroInstance * hero);
-	CInfoBoxPopup(Point position, const CGGarrison * garr);
-};
-
-/// component selection window
-class CSelWindow : public CInfoWindow
-{ //warning - this window deletes its components by closing!
-public:
-	void selectionChange(unsigned to);
-	void madeChoice(); //looks for selected component and calls callback
-	CSelWindow(const std::string& text, PlayerColor player, int charperline ,const std::vector<CSelectableComponent*> &comps, const std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, QueryID askID); //c-tor
-	CSelWindow(){}; //c-tor
-	//notification - this class inherits important destructor from CInfoWindow
-};
-
+class CCreaturePic;
+class MoraleLuckBox;
+class CHeroArea;
+class CMinorResDataBar;
 
-////////////////////////////////////////////////////////////////////////////////
-
-/// base class for hero/town/garrison tooltips
-class CArmyTooltip : public CIntObject
-{
-	void init(const InfoAboutArmy &army);
-public:
-	CArmyTooltip(Point pos, const InfoAboutArmy &army);
-	CArmyTooltip(Point pos, const CArmedInstance * army);
-};
-
-/// Class for hero tooltip. Does not have any background!
-/// background for infoBox: ADSTATHR
-/// background for tooltip: HEROQVBK
-class CHeroTooltip : public CArmyTooltip
-{
-	void init(const InfoAboutHero &hero);
-public:
-	CHeroTooltip(Point pos, const InfoAboutHero &hero);
-	CHeroTooltip(Point pos, const CGHeroInstance * hero);
-};
-
-/// Class for town tooltip. Does not have any background!
-/// background for infoBox: ADSTATCS
-/// background for tooltip: TOWNQVBK
-class CTownTooltip : public CArmyTooltip
-{
-	void init(const InfoAboutTown &town);
-public:
-	CTownTooltip(Point pos, const InfoAboutTown &town);
-	CTownTooltip(Point pos, const CGTownInstance * town);
-};
-
-/// draws picture with creature on background, use Animated=true to get animation
-class CCreaturePic : public CIntObject
-{
-private:
-	CPicture *bg;
-	CCreatureAnim *anim; //displayed animation
-
-public:
-	CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor
-};
+class CComponentBox;
 
 /// Recruitment window where you can recruit creatures
 class CRecruitmentWindow : public CWindowObject
@@ -333,17 +183,6 @@ public:
 
 };
 
-/// Resource bar like that at the bottom of the adventure map screen
-class CMinorResDataBar : public CIntObject
-{
-public:
-	SDL_Surface *bg; //background bitmap
-	void show(SDL_Surface * to);
-	void showAll(SDL_Surface * to);
-	CMinorResDataBar(); //c-tor
-	~CMinorResDataBar(); //d-tor
-};
-
 /// Town portal, castle gate window
 class CObjectListWindow : public CWindowObject
 {
@@ -474,68 +313,6 @@ public:
 	void show(SDL_Surface * to);
 };
 
-class CInGameConsole : public CIntObject
-{
-private:
-	std::list< std::pair< std::string, int > > texts; //list<text to show, time of add>
-	boost::mutex texts_mx;		// protects texts
-	std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
-	int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
-	int defaultTimeout; //timeout for new texts (in ms)
-	int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
-public:
-	std::string enteredText;
-	void show(SDL_Surface * to);
-	void print(const std::string &txt);
-	void keyPressed (const SDL_KeyboardEvent & key); //call-in
-
-#ifndef VCMI_SDL1
-	void textInputed(const SDL_TextInputEvent & event) override;
-	void textEdited(const SDL_TextEditingEvent & event) override;
-#endif // VCMI_SDL1
-
-	void startEnteringText();
-	void endEnteringText(bool printEnteredText);
-	void refreshEnteredText();
-
-	CInGameConsole(); //c-tor
-};
-
-class MoraleLuckBox : public LRClickableAreaWTextComp
-{
-	CAnimImage *image;
-public:
-	bool morale; //true if morale, false if luck
-	bool small;
-
-	void set(const IBonusBearer *node);
-
-	MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
-};
-
-/// Opens hero window by left-clicking on it
-class CHeroArea: public CIntObject
-{
-	const CGHeroInstance * hero;
-public:
-
-	CHeroArea(int x, int y, const CGHeroInstance * _hero);
-
-	void clickLeft(tribool down, bool previousState);
-	void clickRight(tribool down, bool previousState);
-	void hover(bool on);
-};
-
-/// Opens town screen by left-clicking on it
-class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
-{
-public:
-	const CGTownInstance * town;
-	void clickLeft(tribool down, bool previousState);
-	void clickRight(tribool down, bool previousState);
-	LRClickableAreaOpenTown();
-};
-
 class CExchangeWindow : public CWindowObject, public CWindowWithGarrison, public CWindowWithArtifacts
 {
 	CGStatusBar * ourBar; //internal statusbar

+ 2 - 0
client/NetPacksClient.cpp

@@ -26,6 +26,8 @@
 #include "../lib/BattleState.h"
 #include "../lib/GameConstants.h"
 #include "gui/CGuiHandler.h"
+#include "gui/MiscWidgets.h"
+#include "AdventureMapClasses.h"
 #include "CMT.h"
 
 //macros to avoid code duplication - calls given method with given arguments if interface for specific player is present

+ 1 - 0
client/gui/CGarrisonInt.cpp

@@ -7,6 +7,7 @@
 #include "../CCreatureWindow.h"
 #include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
+#include "../GUIClasses.h"
 
 #include "../../CCallback.h"
 

+ 12 - 8
client/gui/CIntObjectClasses.cpp

@@ -1,23 +1,27 @@
 #include "StdInc.h"
 #include "CIntObjectClasses.h"
 
-#include "../CBitmapHandler.h"
 #include "SDL_Pixels.h"
 #include "SDL_Extensions.h"
-#include "../Graphics.h"
-#include "../CAnimation.h"
+#include "CGuiHandler.h"
 #include "CCursorHandler.h"
-#include "../CGameInfo.h"
-#include "../../CCallback.h"
-#include "../../lib/CConfigHandler.h"
+#include "MiscWidgets.h"
+
 #include "../battle/CBattleInterface.h"
 #include "../battle/CBattleInterfaceClasses.h"
+
+#include "../CBitmapHandler.h"
+#include "../Graphics.h"
+#include "../CAnimation.h"
+#include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
 #include "../CMessage.h"
 #include "../CMusicHandler.h"
-#include "../GUIClasses.h"
-#include "CGuiHandler.h"
 #include "../CAdvmapInterface.h"
+
+#include "../../CCallback.h"
+
+#include "../../lib/CConfigHandler.h"
 #include "../../lib/CGeneralTextHandler.h" //for Unicode related stuff
 
 CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free )

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff