From 2f5d6f2684a14fcf9ad941cc0d93e90192fef01f Mon Sep 17 00:00:00 2001 From: beegee1 Date: Sat, 17 Dec 2011 18:59:59 +0000 Subject: [PATCH] * CHexField renamed to CBattleHex * CHexFieldControl renamed to CClickableHex * CCreatureAnimation.cpp/.h moved to BattleInterface/CCreatureAnimation.cpp/.h * Removed unused project files * Added VCMI_client filters file for VS 2010 * Gathered common parts of StdInc.h in Global.h * Boost.Spirit has been included in PCH for ERM project * StopWatch renamed to CStopWatch * GuiBase.cpp split up in UIFramework/... --- AI/EmptyAI/StdInc.h | 324 +---- AI/GeniusAI/BattleLogic.cpp | 10 +- AI/GeniusAI/CGeniusAI.cpp | 4 +- AI/GeniusAI/CGeniusAI.h | 2 +- AI/GeniusAI/StdInc.h | 324 +---- AI/GeniusAI/bouml/GeniusAI/129161 | 107 -- AI/GeniusAI/bouml/GeniusAI/129161.diagram | 34 - AI/GeniusAI/bouml/GeniusAI/129289 | 106 -- AI/GeniusAI/bouml/GeniusAI/129289.diagram | 25 - AI/GeniusAI/bouml/GeniusAI/129417 | 87 -- AI/GeniusAI/bouml/GeniusAI/129417.diagram | 3 - AI/GeniusAI/bouml/GeniusAI/GeniusAI.prj | 46 - AI/GeniusAI/bouml/GeniusAI/cpp_includes | 13 - .../bouml/GeniusAI/generation_settings | 309 ----- AI/GeniusAI/bouml/GeniusAI/idl_includes | 1 - AI/GeniusAI/bouml/GeniusAI/java_imports | 1 - AI/GeniusAI/bouml/GeniusAI/python_imports | 1 - AI/GeniusAI/bouml/GeniusAI/stereotypes | 58 - AI/GeniusAI/bouml/GeniusAI/tools | 18 - AI/GeniusAI/genius.cbp | 77 -- AI/GeniusAI/genius.vcxproj | 1 + AI/StupidAI/StdInc.h | 324 +---- AI/StupidAI/StupidAI.cpp | 24 +- AI/StupidAI/StupidAI.h | 6 +- AI/StupidAI/StupidAI.vcxproj | 1 + Global.h | 330 +++++ Scripting/ERM/ERM.vcxproj | 1 + Scripting/ERM/ERMParser.cpp | 15 +- Scripting/ERM/ERMParser.h | 4 - Scripting/ERM/StdInc.h | 338 +----- client/AdventureMapButton.cpp | 13 +- client/AdventureMapButton.h | 5 +- client/BattleInterface/CAttackAnimation.cpp | 4 +- client/BattleInterface/CAttackAnimation.h | 6 +- client/BattleInterface/CBattleConsole.h | 2 +- client/BattleInterface/CBattleHero.cpp | 1 + client/BattleInterface/CBattleHero.h | 2 +- client/BattleInterface/CBattleInterface.cpp | 86 +- client/BattleInterface/CBattleInterface.h | 28 +- .../BattleInterface/CBattleOptionsWindow.cpp | 2 +- client/BattleInterface/CBattleOptionsWindow.h | 2 +- .../BattleInterface/CBattleResultWindow.cpp | 1 + client/BattleInterface/CBattleResultWindow.h | 2 +- .../BattleInterface/CBattleStackAnimation.cpp | 4 +- .../BattleInterface/CBattleStackAnimation.h | 6 +- ...CHexFieldControl.cpp => CClickableHex.cpp} | 21 +- .../{CHexFieldControl.h => CClickableHex.h} | 10 +- .../CCreatureAnimation.cpp | 8 +- .../CCreatureAnimation.h | 8 +- client/BattleInterface/CDefenceAnimation.cpp | 2 +- .../BattleInterface/CMeleeAttackAnimation.cpp | 12 +- .../BattleInterface/CMeleeAttackAnimation.h | 2 +- client/BattleInterface/CMovementAnimation.cpp | 14 +- client/BattleInterface/CMovementAnimation.h | 6 +- .../BattleInterface/CMovementEndAnimation.cpp | 4 +- .../BattleInterface/CMovementEndAnimation.h | 4 +- .../CMovementStartAnimation.cpp | 2 +- client/BattleInterface/CReverseAnimation.cpp | 8 +- client/BattleInterface/CReverseAnimation.h | 4 +- client/BattleInterface/CShootingAnimation.cpp | 14 +- client/BattleInterface/CShootingAnimation.h | 4 +- .../BattleInterface/CSpellEffectAnimation.cpp | 5 +- .../BattleInterface/CSpellEffectAnimation.h | 6 +- client/BattleInterface/CStackQueue.cpp | 1 + client/BattleInterface/CStackQueue.h | 2 +- client/CAdvmapInterface.cpp | 43 +- client/CAnimation.cpp | 34 +- client/CAnimation.h | 19 +- client/CCastleInterface.cpp | 71 +- client/CCastleInterface.h | 15 +- client/CCreatureWindow.cpp | 10 +- client/CCreatureWindow.h | 3 +- client/CHeroWindow.cpp | 26 +- client/CKingdomInterface.cpp | 47 +- client/CKingdomInterface.h | 3 +- client/CMT.cpp | 7 +- client/CMessage.cpp | 24 +- client/CPlayerInterface.cpp | 37 +- client/CPlayerInterface.h | 6 +- client/CPreGame.cpp | 53 +- client/CPreGame.h | 4 +- client/CSpellWindow.cpp | 5 +- client/CSpellWindow.h | 4 +- client/Client.cpp | 8 +- client/Client.h | 4 +- client/GUIBase.cpp | 1071 ----------------- client/GUIBase.h | 626 ---------- client/GUIClasses.cpp | 177 +-- client/GUIClasses.h | 73 +- client/Graphics.cpp | 5 +- client/Graphics.h | 5 +- client/Makefile.am | 20 +- client/NetPacksClient.cpp | 2 +- client/SDL_Extensions.cpp | 7 +- client/SDL_Extensions.h | 3 +- client/StdInc.h | 324 +---- client/UIFramework/CGuiHandler.cpp | 461 +++++++ client/UIFramework/CGuiHandler.h | 117 ++ client/UIFramework/CIntObject.cpp | 443 +++++++ client/UIFramework/CIntObject.h | 135 +++ client/UIFramework/CKeyShortcut.cpp | 20 + client/UIFramework/CKeyShortcut.h | 25 + client/UIFramework/CPicture.cpp | 133 ++ client/UIFramework/CPicture.h | 46 + client/UIFramework/CSimpleWindow.h | 23 + client/UIFramework/IActivatable.h | 20 + client/UIFramework/IShowActivatable.h | 24 + client/UIFramework/IShowable.h | 26 + client/UIFramework/IStatusBar.h | 24 + client/UIFramework/IUpdateable.h | 18 + client/UIFramework/SPoint.h | 87 ++ client/UIFramework/SRect.cpp | 19 + client/UIFramework/SRect.h | 187 +++ client/VCMI_client.cbp | 145 --- client/VCMI_client.vcxproj | 28 +- client/VCMI_client.vcxproj.filters | 258 ++++ client/mapHandler.cpp | 3 +- client/vcmi_client/.dep.inc | 5 - client/vcmi_client/Makefile | 92 -- .../vcmi_client/nbproject/Makefile-Debug.mk | 221 ---- .../vcmi_client/nbproject/Makefile-Release.mk | 217 ---- client/vcmi_client/nbproject/Makefile-impl.mk | 123 -- .../vcmi_client/nbproject/Package-Debug.bash | 72 -- .../nbproject/Package-Release.bash | 72 -- .../vcmi_client/nbproject/configurations.xml | 594 --------- .../nbproject/private/configurations.xml | 37 - .../nbproject/private/private.properties | 0 .../vcmi_client/nbproject/private/private.xml | 26 - .../vcmi_client/nbproject/project.properties | 0 client/vcmi_client/nbproject/project.xml | 17 - lib/BattleAction.cpp | 4 +- lib/BattleAction.h | 8 +- lib/BattleState.cpp | 210 ++-- lib/BattleState.h | 64 +- lib/CGameInterface.cpp | 2 +- lib/CGameInterface.h | 4 +- lib/CHeroHandler.cpp | 8 +- lib/CHeroHandler.h | 6 +- lib/{StopWatch.h => CStopWatch.h} | 4 +- lib/IGameCallback.cpp | 40 +- lib/IGameCallback.h | 26 +- lib/IGameEventsReceiver.h | 4 +- lib/Makefile.am | 4 +- lib/NetPacks.h | 4 +- lib/NetPacksLib.cpp | 4 +- lib/{SHexField.cpp => SBattleHex.cpp} | 22 +- lib/{SHexField.h => SBattleHex.h} | 24 +- lib/StdInc.h | 324 +---- lib/VCMI_Lib.cpp | 6 +- lib/VCMI_lib.cbp | 111 -- lib/VCMI_lib.vcxproj | 7 +- lib/map.cpp | 4 +- lib/vcmi_lib/Makefile-nb | 92 -- lib/vcmi_lib/nbproject/Makefile-Debug.mk | 142 --- lib/vcmi_lib/nbproject/Makefile-Release.mk | 142 --- lib/vcmi_lib/nbproject/Makefile-impl.mk | 123 -- lib/vcmi_lib/nbproject/Package-Debug.bash | 72 -- lib/vcmi_lib/nbproject/Package-Release.bash | 72 -- lib/vcmi_lib/nbproject/configurations.xml | 325 ----- lib/vcmi_lib/nbproject/project.properties | 0 lib/vcmi_lib/nbproject/project.xml | 15 - server/CGameHandler.cpp | 24 +- server/CGameHandler.h | 4 +- server/StdInc.h | 324 +---- server/VCMI_server.cbp | 71 -- server/VCMI_server.vcxproj | 1 + server/vcmi_server/Makefile | 92 -- .../vcmi_server/nbproject/Makefile-Debug.mk | 81 -- .../vcmi_server/nbproject/Makefile-Release.mk | 77 -- server/vcmi_server/nbproject/Makefile-impl.mk | 123 -- .../vcmi_server/nbproject/Package-Debug.bash | 72 -- .../nbproject/Package-Release.bash | 72 -- .../vcmi_server/nbproject/configurations.xml | 127 -- .../vcmi_server/nbproject/project.properties | 0 server/vcmi_server/nbproject/project.xml | 17 - vcmi.workspace | 9 - 176 files changed, 3257 insertions(+), 9059 deletions(-) delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129161 delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129161.diagram delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129289 delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129289.diagram delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129417 delete mode 100644 AI/GeniusAI/bouml/GeniusAI/129417.diagram delete mode 100644 AI/GeniusAI/bouml/GeniusAI/GeniusAI.prj delete mode 100644 AI/GeniusAI/bouml/GeniusAI/cpp_includes delete mode 100644 AI/GeniusAI/bouml/GeniusAI/generation_settings delete mode 100644 AI/GeniusAI/bouml/GeniusAI/idl_includes delete mode 100644 AI/GeniusAI/bouml/GeniusAI/java_imports delete mode 100644 AI/GeniusAI/bouml/GeniusAI/python_imports delete mode 100644 AI/GeniusAI/bouml/GeniusAI/stereotypes delete mode 100644 AI/GeniusAI/bouml/GeniusAI/tools delete mode 100644 AI/GeniusAI/genius.cbp create mode 100644 Global.h rename client/BattleInterface/{CHexFieldControl.cpp => CClickableHex.cpp} (78%) rename client/BattleInterface/{CHexFieldControl.h => CClickableHex.h} (74%) rename client/{ => BattleInterface}/CCreatureAnimation.cpp (94%) rename client/{ => BattleInterface}/CCreatureAnimation.h (93%) delete mode 100644 client/GUIBase.cpp delete mode 100644 client/GUIBase.h create mode 100644 client/UIFramework/CGuiHandler.cpp create mode 100644 client/UIFramework/CGuiHandler.h create mode 100644 client/UIFramework/CIntObject.cpp create mode 100644 client/UIFramework/CIntObject.h create mode 100644 client/UIFramework/CKeyShortcut.cpp create mode 100644 client/UIFramework/CKeyShortcut.h create mode 100644 client/UIFramework/CPicture.cpp create mode 100644 client/UIFramework/CPicture.h create mode 100644 client/UIFramework/CSimpleWindow.h create mode 100644 client/UIFramework/IActivatable.h create mode 100644 client/UIFramework/IShowActivatable.h create mode 100644 client/UIFramework/IShowable.h create mode 100644 client/UIFramework/IStatusBar.h create mode 100644 client/UIFramework/IUpdateable.h create mode 100644 client/UIFramework/SPoint.h create mode 100644 client/UIFramework/SRect.cpp create mode 100644 client/UIFramework/SRect.h delete mode 100644 client/VCMI_client.cbp create mode 100644 client/VCMI_client.vcxproj.filters delete mode 100644 client/vcmi_client/.dep.inc delete mode 100644 client/vcmi_client/Makefile delete mode 100644 client/vcmi_client/nbproject/Makefile-Debug.mk delete mode 100644 client/vcmi_client/nbproject/Makefile-Release.mk delete mode 100644 client/vcmi_client/nbproject/Makefile-impl.mk delete mode 100644 client/vcmi_client/nbproject/Package-Debug.bash delete mode 100644 client/vcmi_client/nbproject/Package-Release.bash delete mode 100644 client/vcmi_client/nbproject/configurations.xml delete mode 100644 client/vcmi_client/nbproject/private/configurations.xml delete mode 100644 client/vcmi_client/nbproject/private/private.properties delete mode 100644 client/vcmi_client/nbproject/private/private.xml delete mode 100644 client/vcmi_client/nbproject/project.properties delete mode 100644 client/vcmi_client/nbproject/project.xml rename lib/{StopWatch.h => CStopWatch.h} (91%) rename lib/{SHexField.cpp => SBattleHex.cpp} (71%) rename lib/{SHexField.h => SBattleHex.h} (71%) delete mode 100644 lib/VCMI_lib.cbp delete mode 100644 lib/vcmi_lib/Makefile-nb delete mode 100644 lib/vcmi_lib/nbproject/Makefile-Debug.mk delete mode 100644 lib/vcmi_lib/nbproject/Makefile-Release.mk delete mode 100644 lib/vcmi_lib/nbproject/Makefile-impl.mk delete mode 100644 lib/vcmi_lib/nbproject/Package-Debug.bash delete mode 100644 lib/vcmi_lib/nbproject/Package-Release.bash delete mode 100644 lib/vcmi_lib/nbproject/configurations.xml delete mode 100644 lib/vcmi_lib/nbproject/project.properties delete mode 100644 lib/vcmi_lib/nbproject/project.xml delete mode 100644 server/VCMI_server.cbp delete mode 100644 server/vcmi_server/Makefile delete mode 100644 server/vcmi_server/nbproject/Makefile-Debug.mk delete mode 100644 server/vcmi_server/nbproject/Makefile-Release.mk delete mode 100644 server/vcmi_server/nbproject/Makefile-impl.mk delete mode 100644 server/vcmi_server/nbproject/Package-Debug.bash delete mode 100644 server/vcmi_server/nbproject/Package-Release.bash delete mode 100644 server/vcmi_server/nbproject/configurations.xml delete mode 100644 server/vcmi_server/nbproject/project.properties delete mode 100644 server/vcmi_server/nbproject/project.xml delete mode 100644 vcmi.workspace diff --git a/AI/EmptyAI/StdInc.h b/AI/EmptyAI/StdInc.h index 5c3d9f243..81a6cb308 100644 --- a/AI/EmptyAI/StdInc.h +++ b/AI/EmptyAI/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/AI/GeniusAI/BattleLogic.cpp b/AI/GeniusAI/BattleLogic.cpp index 0579ae29e..3da277936 100644 --- a/AI/GeniusAI/BattleLogic.cpp +++ b/AI/GeniusAI/BattleLogic.cpp @@ -526,7 +526,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) } } - std::vector fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false); + std::vector fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false); if(fields.size() == 0) { @@ -540,11 +540,11 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) ba.destinationTile = static_cast(dest_tile); //simplified checking for possibility of attack (previous was too simplified) int destStackPos = m_cb->battleGetPos(destinationID); - if(SHexField::mutualPosition(dest_tile, destStackPos) != -1) + if(SBattleHex::mutualPosition(dest_tile, destStackPos) != -1) ba.additionalInfo = destStackPos; - else if(SHexField::mutualPosition(dest_tile, destStackPos+1) != -1) + else if(SBattleHex::mutualPosition(dest_tile, destStackPos+1) != -1) ba.additionalInfo = destStackPos+1; - else if(SHexField::mutualPosition(dest_tile, destStackPos-1) != -1) + else if(SBattleHex::mutualPosition(dest_tile, destStackPos-1) != -1) ba.additionalInfo = destStackPos-1; else return BattleAction::makeDefend(attackerStack); @@ -581,7 +581,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) } } - for (std::vector::const_iterator it = fields.begin(); it != fields.end(); ++it) + for (std::vector::const_iterator it = fields.begin(); it != fields.end(); ++it) { if (*it == dest_tile) { diff --git a/AI/GeniusAI/CGeniusAI.cpp b/AI/GeniusAI/CGeniusAI.cpp index de8d3551f..e15836b6f 100644 --- a/AI/GeniusAI/CGeniusAI.cpp +++ b/AI/GeniusAI/CGeniusAI.cpp @@ -1311,7 +1311,7 @@ void CGeniusAI::battleNewRound(int round) /** * */ -void CGeniusAI::battleStackMoved(int ID, std::vector dest, int distance) +void CGeniusAI::battleStackMoved(int ID, std::vector dest, int distance) { std::string message("\t\t\tCGeniusAI::battleStackMoved ID("); message += boost::lexical_cast(ID); @@ -1345,7 +1345,7 @@ void CGeniusAI::battleSpellCast(const BattleSpellCast *sc) * */ // void CGeniusAI::battleStackMoved(int ID, -// SHexField dest, +// SBattleHex dest, // bool startMoving, // bool endMoving) // { diff --git a/AI/GeniusAI/CGeniusAI.h b/AI/GeniusAI/CGeniusAI.h index 747ea024b..a5ebc7f2b 100644 --- a/AI/GeniusAI/CGeniusAI.h +++ b/AI/GeniusAI/CGeniusAI.h @@ -201,7 +201,7 @@ public: virtual void battleStacksAttacked(const std::set & bsa); //called when stack receives damage (after battleAttack()) virtual void battleEnd(const BattleResult *br); virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - virtual void battleStackMoved(int ID, std::vector dest, int distance); + virtual void battleStackMoved(int ID, std::vector dest, int distance); virtual void battleSpellCast(const BattleSpellCast *sc); virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right //virtual void battlefieldPrepared(int battlefieldType, std::vector obstacles); //called when battlefield is prepared, prior the battle beginning diff --git a/AI/GeniusAI/StdInc.h b/AI/GeniusAI/StdInc.h index 5c3d9f243..81a6cb308 100644 --- a/AI/GeniusAI/StdInc.h +++ b/AI/GeniusAI/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/AI/GeniusAI/bouml/GeniusAI/129161 b/AI/GeniusAI/bouml/GeniusAI/129161 deleted file mode 100644 index 34e04bdf5..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129161 +++ /dev/null @@ -1,107 +0,0 @@ -format 66 -"Battle AI" // Battle AI - revision 1 - modified_by 9 "rrowniak" - // class settings - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //use case diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default class_drawing_mode default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //component diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //deployment diagram settings - package_name_in_tab default show_context default write_horizontally default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - - classview 129161 "Diagrams" - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //class settings - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - classdiagram 129161 "Structure - class diagram" - draw_all_relations no hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - size A4 - end - end - - classview 129417 "Class view" - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //class settings - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - class 129417 "CBattleLogic" - visibility package - cpp_decl "" - java_decl "" - php_decl "" - python_2_2 python_decl "" - idl_decl "" - explicit_switch_type "" - - classrelation 130057 // - relation 129673 *--- - a role_name "" private - classrelation_ref 130057 // - b role_name "" private - classrelation_ref 130185 // - end - - classrelation 130441 // - relation_ref 129801 // - end - end - - class 129545 "CBattleHelper" - visibility package - cpp_decl "" - java_decl "" - php_decl "" - python_2_2 python_decl "" - idl_decl "" - explicit_switch_type "" - - classrelation 130313 // - relation 129801 *--- - a role_name "" private - classrelation_ref 130313 // - b role_name "" private - classrelation_ref 130441 // - end - end - end -end diff --git a/AI/GeniusAI/bouml/GeniusAI/129161.diagram b/AI/GeniusAI/bouml/GeniusAI/129161.diagram deleted file mode 100644 index 5748fa68d..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129161.diagram +++ /dev/null @@ -1,34 +0,0 @@ -format 66 - -classcanvas 128009 class_ref 129289 // CGlobalAI - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 119 38 2000 -end -classcanvas 128137 class_ref 129161 // CGeniusAI - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 123 153 2000 -end -classcanvas 128905 class_ref 129417 // CBattleLogic - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 279 152 2000 -end -classcanvas 129033 class_ref 129545 // CBattleHelper - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 435 153 2000 -end -relationcanvas 128265 relation_ref 129161 // - from ref 128137 z 2001 to ref 128009 - no_role_a no_role_b - no_multiplicity_a no_multiplicity_b -end -relationcanvas 129161 relation_ref 129673 // - from ref 128905 z 2001 to ref 128137 - no_role_a no_role_b - no_multiplicity_a no_multiplicity_b -end -relationcanvas 129289 relation_ref 129801 // - from ref 129033 z 2001 to ref 128905 - no_role_a no_role_b - no_multiplicity_a no_multiplicity_b -end -end diff --git a/AI/GeniusAI/bouml/GeniusAI/129289 b/AI/GeniusAI/bouml/GeniusAI/129289 deleted file mode 100644 index 09f002177..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129289 +++ /dev/null @@ -1,106 +0,0 @@ -format 66 -"General AI" // General AI - revision 1 - modified_by 9 "rrowniak" - // class settings - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //use case diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default class_drawing_mode default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //component diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //deployment diagram settings - package_name_in_tab default show_context default write_horizontally default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - - classview 129289 "Diagrams" - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //class settings - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - classdiagram 129289 "Structure - clas diagram" - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - size A4 - end - end - - classview 129545 "Class view" - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //class settings - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - class 129673 "CGeneralAI" - visibility package - cpp_decl "" - java_decl "" - php_decl "" - python_2_2 python_decl "" - idl_decl "" - explicit_switch_type "" - - classrelation 129801 // - relation 129545 *--- - a role_name "" private - classrelation_ref 129801 // - b role_name "" private - classrelation_ref 129929 // - end - end - end - - usecaseview 129161 "Use case diagrams" - //use case diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default class_drawing_mode default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - usecasediagram 129417 "Main requirements" - package_name_in_tab default show_context default auto_label_position default draw_all_relations default class_drawing_mode default shadow default show_stereotype_properties default - size A4 - end - end -end diff --git a/AI/GeniusAI/bouml/GeniusAI/129289.diagram b/AI/GeniusAI/bouml/GeniusAI/129289.diagram deleted file mode 100644 index 5263641d3..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129289.diagram +++ /dev/null @@ -1,25 +0,0 @@ -format 66 - -classcanvas 128009 class_ref 129161 // CGeniusAI - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 102 100 2000 -end -classcanvas 128137 class_ref 129289 // CGlobalAI - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 102 15 2006 -end -classcanvas 128393 class_ref 129673 // CGeneralAI - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - xyz 281 100 2006 -end -relationcanvas 128265 relation_ref 129161 // - from ref 128009 z 2001 to ref 128137 - no_role_a no_role_b - no_multiplicity_a no_multiplicity_b -end -relationcanvas 128521 relation_ref 129545 // - from ref 128393 z 2001 to ref 128009 - no_role_a no_role_b - no_multiplicity_a no_multiplicity_b -end -end diff --git a/AI/GeniusAI/bouml/GeniusAI/129417 b/AI/GeniusAI/bouml/GeniusAI/129417 deleted file mode 100644 index 8293aa7d1..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129417 +++ /dev/null @@ -1,87 +0,0 @@ -format 66 -"Common" // Common - revision 1 - modified_by 9 "rrowniak" - // class settings - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //use case diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default class_drawing_mode default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //component diagram settings - package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //deployment diagram settings - package_name_in_tab default show_context default write_horizontally default auto_label_position default draw_all_relations default shadow default - draw_component_as_icon default show_component_req_prov default show_component_rea default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - - classview 129673 "Class view" - //class diagram settings - draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_infonote default shadow default show_stereotype_properties default - //collaboration diagram settings - show_full_operations_definition default show_hierarchical_rank default write_horizontally default drawing_language default package_name_in_tab default show_context default draw_all_relations default shadow default show_stereotype_properties default - //object diagram settings - write_horizontally default package_name_in_tab default show_context default auto_label_position default draw_all_relations default shadow default show_stereotype_properties default - //sequence diagram settings - show_full_operations_definition default write_horizontally default class_drawing_mode default drawing_language default draw_all_relations default shadow default show_stereotype_properties default - //state diagram settings - package_name_in_tab default show_context default auto_label_position default write_trans_label_horizontally default show_trans_definition default draw_all_relations default shadow default - show_activities default region_horizontally default drawing_language default show_stereotype_properties default - //class settings - //activity diagram settings - package_name_in_tab default show_context default show_opaque_action_definition default auto_label_position default write_flow_label_horizontally default draw_all_relations default shadow default - show_infonote default drawing_language default show_stereotype_properties default - class 129161 "CGeniusAI" - visibility package - cpp_decl "" - java_decl "" - php_decl "" - python_2_2 python_decl "" - idl_decl "" - explicit_switch_type "" - - classrelation 129161 // - relation 129161 -_-|> - a public - classrelation_ref 129161 // - b parent class_ref 129289 // CGlobalAI - end - - classrelation 129929 // - relation_ref 129545 // - end - - classrelation 130185 // - relation_ref 129673 // - end - end - - class 129289 "CGlobalAI" - abstract visibility package stereotype "interface" - cpp_decl "" - java_decl "${comment}${@}${visibility}interface ${name}${extends} { -${members}} -" - php_decl "${comment}${visibility}interface ${name} { -${members}} -" - python_2_2 python_decl "" - idl_decl "${comment}${abstract}${local}interface ${name}${inherit} { -${members}}; -" - explicit_switch_type "" - - end - end -end diff --git a/AI/GeniusAI/bouml/GeniusAI/129417.diagram b/AI/GeniusAI/bouml/GeniusAI/129417.diagram deleted file mode 100644 index 789feb175..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/129417.diagram +++ /dev/null @@ -1,3 +0,0 @@ -format 66 - -end diff --git a/AI/GeniusAI/bouml/GeniusAI/GeniusAI.prj b/AI/GeniusAI/bouml/GeniusAI/GeniusAI.prj deleted file mode 100644 index d1053e5be..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/GeniusAI.prj +++ /dev/null @@ -1,46 +0,0 @@ -format 66 -"GeniusAI" - revision 2 - modified_by 9 "rrowniak" - - - - // class settings - default_attribute_visibility private default_relation_visibility private default_operation_visibility public - //class diagram settings - draw_all_relations yes hide_attributes no hide_operations no show_members_full_definition no show_members_visibility no show_members_stereotype no show_members_multiplicity no show_members_initialization no show_attribute_modifiers no member_max_width 127 show_parameter_dir yes show_parameter_name yes package_name_in_tab no class_drawing_mode natural drawing_language uml show_context_mode no auto_label_position yes show_relation_modifiers no show_infonote no shadow yes show_stereotype_properties no - //use case diagram settings - package_name_in_tab no show_context no auto_label_position yes draw_all_relations yes class_drawing_mode actor shadow yes show_stereotype_properties no - //sequence diagram settings - show_full_operations_definition no write_horizontally yes class_drawing_mode natural drawing_language uml draw_all_relations yes shadow yes show_stereotype_properties no - //collaboration diagram settings - show_full_operations_definition no show_hierarchical_rank no write_horizontally yes drawing_language uml package_name_in_tab no show_context no draw_all_relations yes shadow yes show_stereotype_properties no - //object diagram settings - write_horizontally yes package_name_in_tab no show_context no auto_label_position yes draw_all_relations yes shadow yes show_stereotype_properties no - //component diagram settings - package_name_in_tab no show_context no auto_label_position yes draw_all_relations yes shadow yes - draw_component_as_icon no show_component_req_prov no show_component_rea no show_stereotype_properties no - //deployment diagram settings - package_name_in_tab no show_context no write_horizontally yes auto_label_position yes draw_all_relations yes shadow yes - draw_component_as_icon no show_component_req_prov no show_component_rea no show_stereotype_properties no - //state diagram settings - package_name_in_tab no show_context no auto_label_position yes write_trans_label_horizontally yes show_trans_definition no draw_all_relations yes shadow yes - show_activities yes region_horizontally yes drawing_language uml show_stereotype_properties no - //activity diagram settings - package_name_in_tab no show_context no show_opaque_action_definition no auto_label_position yes write_flow_label_horizontally no draw_all_relations yes shadow yes - show_infonote yes drawing_language uml show_stereotype_properties no - - class_color yellow duration_color transparent continuation_color gray note_color blue fragment_color transparent subject_color transparent usecase_color yellow package_color transparent component_color green artifact_color green deploymentnode_color gray state_color yellow stateaction_color transparent activity_color transparent activityregion_color transparent activitypartition_color transparent activityaction_color transparent parameterpin_color white - font_size 8 - diagram_format A4 - - mark_for_import - - ncouples 1 - key "check-in-cmd" value "specify the command containing %file and %dir or %dironly" - package_ref 129161 // Battle AI - - package_ref 129289 // General AI - - package_ref 129417 // Common -end diff --git a/AI/GeniusAI/bouml/GeniusAI/cpp_includes b/AI/GeniusAI/bouml/GeniusAI/cpp_includes deleted file mode 100644 index 531b86f76..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/cpp_includes +++ /dev/null @@ -1,13 +0,0 @@ -// "a type" "needed cpp_includes" -"vector" "#include -using namespace std;" - -"list" "#include -using namespace std;" - -"map" "#include -using namespace std;" - -"string" "#include -using namespace std;" - diff --git a/AI/GeniusAI/bouml/GeniusAI/generation_settings b/AI/GeniusAI/bouml/GeniusAI/generation_settings deleted file mode 100644 index 1f32568c0..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/generation_settings +++ /dev/null @@ -1,309 +0,0 @@ - - - cpp_h_extension "h" cpp_src_extension "cpp" java_extension "java" php_extension "php" python_extension "py" idl_extension "idl" - - type_forms 15 // uml cpp java idl cpp_in cpp_out cpp_inout cpp_return - "void" "void" "void" "void" "${type}" "${type} &" "${type}" "${type}" - "any" "void *" "Object" "any" "const ${type}" "${type}" "${type} &" "${type}" - "bool" "bool" "boolean" "boolean" "${type}" "${type} &" "${type} &" "${type}" - "char" "char" "char" "char" "${type}" "${type} &" "${type} &" "${type}" - "uchar" "unsigned char" "char" "octet" "${type}" "${type} &" "${type} &" "${type}" - "byte" "unsigned char" "byte" "octet" "${type}" "${type} &" "${type} &" "${type}" - "short" "short" "short" "short" "${type}" "${type} &" "${type} &" "${type}" - "ushort" "unsigned short" "short" "unsigned short" "${type}" "${type} &" "${type} &" "${type}" - "int" "int" "int" "long" "${type}" "${type} &" "${type} &" "${type}" - "uint" "unsigned int" "int" "unsigned long" "${type}" "${type} &" "${type} &" "${type}" - "long" "long" "long" "long" "${type}" "${type} &" "${type} &" "${type}" - "ulong" "unsigned long" "long" "unsigned long" "${type}" "${type} &" "${type} &" "${type}" - "float" "float" "float" "float" "${type}" "${type} &" "${type} &" "${type}" - "double" "double" "double" "double" "${type}" "${type} &" "${type} &" "${type}" - "string" "string" "String" "string" "${type}" "${type} &" "${type} &" "${type}" - - relations_stereotypes 5 // uml cpp java pythonidl - "sequence" "vector" "Vector" "list" "sequence" - "vector" "vector" "Vector" "list" "sequence" - "list" "list" "List" "list" "sequence" - "set" "set" "Set" "set" "sequence" - "map" "map" "Map" "dict" "sequence" - - classes_stereotypes 14 // uml cpp java php python idl - "class" "class" "class" "class" "class" "valuetype" - "interface" "class" "interface" "interface" "class" "interface" - "exception" "class" "class" "class" "class" "exception" - "enum" "enum" "enum" "enum" "enum" "enum" - "enum_pattern" "enum" "enum_pattern" "enum" "enum" "enum" - "struct" "struct" "class" "class" "class" "struct" - "union" "union" "class" "class" "class" "union" - "typedef" "typedef" "ignored" "ignored" "ignored" "typedef" - "boundary" "class" "class" "class" "class" "interface" - "control" "class" "class" "class" "class" "valuetype" - "entity" "class" "class" "class" "class" "valuetype" - "actor" "ignored" "ignored" "ignored" "ignored" "ignored" - "@interface" "ignored" "@interface" "ignored" "ignored" "ignored" - "stereotype" "ignored" "ignored" "ignored" "ignored" "ignored" - - cpp_enum_default_type_forms "${type}" "${type} &" "${type} &" "${type}" // in out inout return - other_cpp_types_default_type_forms "const ${type} &" "${type} &" "${type} &" "${type}" // in out inout return - - cpp_default_h_content "#ifndef ${NAMESPACE}_${NAME}_H -#define ${NAMESPACE}_${NAME}_H - -${comment} -${includes} -${declarations} -${namespace_start} -${definition} -${namespace_end} -#endif -" - cpp_default_src_content "${comment} -${includes} -${namespace_start} -${members} -${namespace_end}" - cpp_default_class_decl "${comment}${template}class ${name}${inherit} { -${members}}; -${inlines} -" - cpp_default_external_class_decl "${name} -#include <${name}.h> -" - cpp_default_struct_decl "${comment}${template}struct ${name}${inherit} { -${members}}; -${inlines} -" - cpp_default_union_decl "${comment}${template}union ${name} { -${members}}; -${inlines} -" - cpp_default_enum_decl "${comment}enum ${name} { -${items} -}; -" - cpp_default_typedef_decl "${comment}typedef ${type} ${name}; -" - cpp_default_attribute_declaration " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${value}; -" // multiplicity 1 - " ${comment}${static}${mutable}${volatile}${const}${stereotype}<${type}> ${name}${value}; -" // multiplicity * a..b - " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${multiplicity}${value}; -" // multiplicity [..] - cpp_default_enum_item_declaration " ${name}${value},${comment}" - cpp_association_aggregation_declaration - " ${comment}${static}${mutable}${volatile}${const}${type} * ${name}${value}; -" // multiplicity 1 - " ${comment}${static}${mutable}${volatile}${const}${stereotype}<${type} *> ${name}${value}; -" // multiplicity * a..b - " ${comment}${static}${mutable}${volatile}${const}${type} * ${name}${multiplicity}${value}; -" // multiplicity [..] - cpp_aggregation_by_value_declaration - " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${value}; -" // multiplicity 1 - " ${comment}${static}${mutable}${volatile}${const}${stereotype}<${type}> ${name}${value}; -" // multiplicity * a..b - " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${multiplicity}${value}; -" // multiplicity [..] - cpp_get "get_${name}" inline const value_const public - cpp_set "set_${name}" public - cpp_default_operation_declaration " ${comment}${friend}${static}${inline}${virtual}${type} ${name}${(}${)}${const}${volatile}${throw}${abstract}; -" - cpp_default_operation_definition "${comment}${inline}${type} ${class}::${name}${(}${)}${const}${volatile}${throw}${staticnl}{ - ${body}} -" - java_default_src_content "${comment} -${package} -${imports} -${definition}" - java_default_class_decl "${comment}${@}${visibility}${final}${abstract}class ${name}${extends}${implements} { -${members}} -" - java_default_external_class_decl "${name}" - java_default_interface_decl "${comment}${@}${visibility}interface ${name}${extends} { -${members}} -" - java5_default_enum_decl "${comment}${@}${visibility}${final}${abstract}enum ${name}${implements} { -${items}; -${members}} -" - java_default_enum_decl "${comment}${@}${visibility}final class ${name} { -${members} - private final int value; - - public int value() { - return value; - } - - public static ${name} fromInt(int value) { - switch (value) { -${cases} default: throw new Error(); - } - - } - private ${name}(int v) { value = v; }; -} -" - java_default_attribute_declaration " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${type} ${name}${value}; -" // multiplicity 1 - " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${stereotype}<${type}> ${name}${value}; -" // multiplicity * a..b - " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${type}${multiplicity} ${name}${value}; -" // multiplicity N - java5_default_enum_item_declaration " ${@}${name}${value},${comment}" - java_default_enum_item_declaration " ${comment}${@}public static final int _${name}${value}; -public static final ${class} ${name} = new ${class}(_${name}); -" - java_default_enum_case " case _${name}: return ${name}; -" - java_association_aggregation_declaration - " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${type} ${name}${value}; -" // multiplicity 1 - " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${stereotype}<${type}> ${name}${value}; -" // multiplicity * a..b - " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${type}${multiplicity} ${name}${value}; -" // multiplicity N - java_get "get${Name}" final public - java_set "set${Name}" public - java_default_operation_definition " ${comment}${@}${visibility}${final}${static}${abstract}${synchronized}${type} ${name}${(}${)}${throws}${staticnl}{ - ${body}} -" - php_default_src_content " -" - php_default_class_decl "${comment}${final}${visibility}${abstract}class ${name}${extends}${implements} { -${members}} -" - php_default_enum_decl "${comment}${visibility}final class ${name} { -${items}} -" - php_default_external_class_decl "${name}" - php_default_interface_decl "${comment}${visibility}interface ${name} { -${members}} -" - php_default_attribute_declaration " ${comment}${visibility}${const}${static}${var}${name}${value}; -" - php_default_enum_item_decl " const ${name}${value};${comment} -" - php_default_relation_declaration" ${comment}${visibility}${const}${static}${var}${name}${value}; -" - php_get "get${Name}" final - php_set "set${Name}" - php_default_operation_definition " ${comment}${final}${visibility}${abstract}${static}function ${name}${(}${)} -{ - ${body}} -" - python_2_2 - python_indent_step " " - python_default_src_content "${comment} -${import} -${definition}" - python_default_class_decl "class ${name}${inherit}: -${docstring}${members} -" - python_default_enum_decl "class ${name}: -${docstring}${members} -" - python_default_external_class_decl "${name}" - python_default_attribute_declaration "${comment}${self}${name} = ${value} -" // multiplicity 1 - "${comment}${self}${name} = ${stereotype}() -" // multiplicity != 1 - python_default_enum_item_decl "${comment}${self}${name} = ${value} -" - python_default_relation_declaration"${comment}${self}${name} = ${value} -" // multiplicity 1 - "${comment}${self}${name} = ${stereotype}() -" // multiplicity != 1 - python_default_composition_declaration"${comment}${self}${name} = ${type}() -" // multiplicity 1 - "${comment}${self}${name} = ${stereotype}() -" // multiplicity != 1 - python_default_operation_definition "${@}${static}${abstract}def ${name}${(}${)}: -${docstring}${body} -" - python_default_initoperation_definition "${@}${static}${abstract}def ${name}${(}${p0}${v0}${)}: -${docstring}super(${class}, ${p0}).__init__() -${body} -" - python_get "get${Name}" - python_set "set${Name}" - idl_default_src_content "#ifndef ${MODULE}_${NAME}_H -#define ${MODULE}_${NAME}_H - -${comment} -${includes} -${module_start} -${definition} -${module_end} -#endif -" - idl_default_interface_decl "${comment}${abstract}${local}interface ${name}${inherit} { -${members}}; -" - idl_default_valuetype_decl "${comment}${abstract}${custom}valuetype ${name}${inherit} { -${members}}; -" - idl_default_struct_decl "${comment}struct ${name} { -${members}}; -" - idl_default_typedef_decl "${comment}typedef ${type} ${name}; -" - idl_default_exception_decl "${comment}exception ${name} { -${members}}; -" - idl_default_union_decl "${comment}union ${name} switch(${switch}) { -${members}}; -" - idl_default_enum_decl "${comment}enum ${name} { -${items}}; -" - idl_default_external_class_decl "${name} -#include \"${name}.idl\" -" - idl_default_attribute_declaration " ${comment}${readonly}${attribute}${type} ${name}; -" // multiplicity 1 - " ${comment}${readonly}${attribute}${stereotype}<${type}> ${name}; -" // multiplicity * a..b - " ${comment}${readonly}${attribute}${stereotype}<${type},${multiplicity}> ${name}; -" // multiplicity N - idl_default_valuetype_attribute_declaration " ${comment}${visibility}${type} ${name}; -" // multiplicity 1 - " ${comment}${visibility}${stereotype}<${type}> ${name}; -" // multiplicity * a..b - " ${comment}${visibility}${stereotype}<${type},${multiplicity}> ${name}; -" // multiplicity N - idl_default_const_declaration " ${comment}const ${type} ${name}${value}; -" // multiplicity 1 - " ${comment}const ${stereotype}<${type}> ${name}${value}; -" // multiplicity * a..b - " ${comment}const ${stereotype}<${type},${multiplicity}> ${name}${value}; -" // multiplicity N - idl_default_enum_item_declaration " ${name},${comment}" - idl_default_union_item_declaration " ${comment}case ${case} : ${readonly}${type} ${name};" // multiplicity 1 - " ${comment}case ${case} : ${readonly}${stereotype}<${type}> ${name};" // multiplicity * a..b - " ${comment}case ${case} : ${readonly}${stereotype}<${type},${multiplicity}> ${name};" // multiplicity N - idl_association_aggregation_declaration - " ${comment}${readonly}${attribute}${type} ${name}; -" // multiplicity 1 - " ${comment}${readonly}${attribute}${stereotype}<${type}> ${name}; -" // multiplicity * a..b - " ${comment}${readonly}${attribute}${stereotype}<${type},${multiplicity}> ${name}; -" // multiplicity N - idl_valuetype_association_aggregation_declaration - " ${comment}${visibility}${type} ${name}; -" // multiplicity 1 - " ${comment}${visibility}${stereotype}<${type}> ${name}; -" // multiplicity * a..b - " ${comment}${visibility}${stereotype}<${type},${multiplicity}> ${name}; -" // multiplicity N - idl_union_association_aggregation_declaration - " ${comment}case ${case} : ${readonly}${type} ${name};" // multiplicity 1 - " ${comment}case ${case} : ${readonly}${stereotype}<${type}> ${name};" // multiplicity * a..b - " ${comment}case ${case} : ${readonly}${stereotype}<${type},${multiplicity}> ${name};" // multiplicity N - idl_get "get_${name}" - idl_set "set_${name}" twoways - idl_default_operation_declaration " ${comment}${oneway}${type} ${name}${(}${)}${raisesnl}${raises}; -" - uml_get_name uml uml_set_name uml -end diff --git a/AI/GeniusAI/bouml/GeniusAI/idl_includes b/AI/GeniusAI/bouml/GeniusAI/idl_includes deleted file mode 100644 index fceab64b9..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/idl_includes +++ /dev/null @@ -1 +0,0 @@ -// "a type" "needed idl_includes" diff --git a/AI/GeniusAI/bouml/GeniusAI/java_imports b/AI/GeniusAI/bouml/GeniusAI/java_imports deleted file mode 100644 index bbd370acb..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/java_imports +++ /dev/null @@ -1 +0,0 @@ -// "a type" "needed java_imports" diff --git a/AI/GeniusAI/bouml/GeniusAI/python_imports b/AI/GeniusAI/bouml/GeniusAI/python_imports deleted file mode 100644 index 4a1bd3a85..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/python_imports +++ /dev/null @@ -1 +0,0 @@ -// "a type" "needed python_imports" diff --git a/AI/GeniusAI/bouml/GeniusAI/stereotypes b/AI/GeniusAI/bouml/GeniusAI/stereotypes deleted file mode 100644 index 0ac476cf9..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/stereotypes +++ /dev/null @@ -1,58 +0,0 @@ - - package_stereotypes 6 "facade" "framework" "model library" "stub" "toplevel" "profile" - -_-> 3 "access" "import" "from" - end - - class_stereotypes 19 "actor" "auxiliary" "boundary" "control" "entity" "enum" "enum_pattern" "exception" "focus" "implementationClass" "interface" "@interface" "metaclass" "stereotype" "struct" "type" "typedef" "union" "utility" - ---- 4 "list" "set" "vector" "map" - ---> 4 "list" "set" "vector" "map" - ---|> 4 "{complete,disjoint}" "{incomplete,disjoint}" "{complete,overlapping}" "{incomplete,overlapping}" - o--- 4 "list" "set" "vector" "map" - *--- 4 "list" "set" "vector" "map" - o--> 4 "list" "set" "vector" "map" - *--> 4 "list" "set" "vector" "map" - -_-> 4 "friend" "from" "import" "instantiate" - -_-|> 1 "bind" - end - - use_case_stereotypes 1 "realization" - - ---|> 4 "{complete,disjoint}" "{incomplete,disjoint}" "{complete,overlapping}" "{incomplete,overlapping}" - -_-> 2 "include" "extend" - end - - artifact_stereotypes 7 "document" "file" "script" "source" "text" "library" "executable" - -_-> 4 "deploy" "manifest" "import" "from" - end - - attribute_stereotypes 4 "list" "set" "vector" "map" - operation_stereotypes 0 - state_stereotypes 3 "machine" "submachine" "top" - activity_stereotypes 0 - flow_stereotypes 3 "interrupt" "multicast" "multireceive" - interruptibleactivityregion_stereotypes 0 - pseudostate_stereotypes 0 - stateaction_stereotypes 2 "send-signal" "receive-signal" - parameter_stereotypes 0 - parameterset_stereotypes 0 - activitynode_stereotypes 0 - activityaction_stereotypes 0 - activityobject_stereotypes 2 "datastore" "centralBuffer" - expansionregion_stereotypes 0 - activitypartition_stereotypes 0 - pin_stereotypes 0 - component_stereotypes 6 "buildComponent" "entity" "implement" "process" "service" "subsystem" - deploymentnode_stereotypes 3 "cpu" "device" "executionEnvironment" - classview_stereotypes 0 - usecaseview_stereotypes 0 - componentview_stereotypes 0 - deploymentview_stereotypes 0 - classdiagram_stereotypes 0 - seqdiagram_stereotypes 0 - coldiagram_stereotypes 0 - usecasediagram_stereotypes 0 - statediagram_stereotypes 0 - activitydiagram_stereotypes 0 - componentdiagram_stereotypes 0 - deploymentdiagram_stereotypes 0 -end diff --git a/AI/GeniusAI/bouml/GeniusAI/tools b/AI/GeniusAI/bouml/GeniusAI/tools deleted file mode 100644 index 3579028be..000000000 --- a/AI/GeniusAI/bouml/GeniusAI/tools +++ /dev/null @@ -1,18 +0,0 @@ -// 'tool' "the executable" "displayed string" {target}+ -tool "HTML documentation" "ghtml" Class Operation Attribute Generalisation Realize Dependency Association DirectionalAssociation Aggregation AggregationByValue DirectionalAggregation DirectionalAggregationByValue ExtraMember ClassInstance State Region StateAction Initial EntryPoint Final Terminate ExitPoint DeepHistory ShallowHistory Junction Choice Fork Join Transition Activity InterruptibleActivityRegion ExpansionRegion ActivityObject ActivityAction Parameter ParameterSet Pin ExpansionNode InitialActivityNode FinalActivityNode ExitPointActivityNode DecisionActivityNode MergeActivityNode ForkActivityNode JoinActivityNode Flow Project Package UseCaseView ClassView ComponentView DeploymentView UseCaseDiagram SeqDiagram ColDiagram ClassDiagram ObjectDiagram StateDiagram ActivityDiagram ComponentDiagram DeploymentDiagram UseCase Component Node Artifact Inherit DependOn -tool "HTML doc. (flat)" "ghtml -flat" Class Operation Attribute Generalisation Realize Dependency Association DirectionalAssociation Aggregation AggregationByValue DirectionalAggregation DirectionalAggregationByValue ExtraMember ClassInstance State Region StateAction Initial EntryPoint Final Terminate ExitPoint DeepHistory ShallowHistory Junction Choice Fork Join Transition Activity InterruptibleActivityRegion ExpansionRegion ActivityObject ActivityAction Parameter ParameterSet Pin ExpansionNode InitialActivityNode FinalActivityNode ExitPointActivityNode DecisionActivityNode MergeActivityNode ForkActivityNode JoinActivityNode Flow Project Package UseCaseView ClassView ComponentView DeploymentView UseCaseDiagram SeqDiagram ColDiagram ClassDiagram ObjectDiagram StateDiagram ActivityDiagram ComponentDiagram DeploymentDiagram UseCase Component Node Artifact Inherit DependOn -tool "HTML doc. (svg)" "ghtml -svg" Class Operation Attribute Generalisation Realize Dependency Association DirectionalAssociation Aggregation AggregationByValue DirectionalAggregation DirectionalAggregationByValue ExtraMember ClassInstance State Region StateAction Initial EntryPoint Final Terminate ExitPoint DeepHistory ShallowHistory Junction Choice Fork Join Transition Activity InterruptibleActivityRegion ExpansionRegion ActivityObject ActivityAction Parameter ParameterSet Pin ExpansionNode InitialActivityNode FinalActivityNode ExitPointActivityNode DecisionActivityNode MergeActivityNode ForkActivityNode JoinActivityNode Flow Project Package UseCaseView ClassView ComponentView DeploymentView UseCaseDiagram SeqDiagram ColDiagram ClassDiagram ObjectDiagram StateDiagram ActivityDiagram ComponentDiagram DeploymentDiagram UseCase Component Node Artifact Inherit DependOn -tool "HTML doc. (flat, svg)" "ghtml -flat -svg" Class Operation Attribute Generalisation Realize Dependency Association DirectionalAssociation Aggregation AggregationByValue DirectionalAggregation DirectionalAggregationByValue ExtraMember ClassInstance State Region StateAction Initial EntryPoint Final Terminate ExitPoint DeepHistory ShallowHistory Junction Choice Fork Join Transition Activity InterruptibleActivityRegion ExpansionRegion ActivityObject ActivityAction Parameter ParameterSet Pin ExpansionNode InitialActivityNode FinalActivityNode ExitPointActivityNode DecisionActivityNode MergeActivityNode ForkActivityNode JoinActivityNode Flow Project Package UseCaseView ClassView ComponentView DeploymentView UseCaseDiagram SeqDiagram ColDiagram ClassDiagram ObjectDiagram StateDiagram ActivityDiagram ComponentDiagram DeploymentDiagram UseCase Component Node Artifact Inherit DependOn -tool "Generate .pro" "gpro" Artifact -tool "Import Rose" "irose" Project Package -tool "C++ utilities" "cpp_util" Class -tool "Generate XMI 1.2" "gxmi" Project -tool "Generate XMI 2.1" "gxmi2" Project -tool "Import XMI 2.1" "ixmi2" Project Package -tool "C++ state machine" "stmgen" State -tool "Use case wizard" "usecasewizard" UseCase -tool "Check-in" "file_control ci" Project Package -tool "Check-out" "file_control co" Project Package -tool "Deploy classes" "deplcl" ClassView -tool "Global Change" "global_change" Class Project Package ClassView DeploymentView -tool "Uml projection" "uml_proj" Class Operation Attribute Generalisation Realize Dependency Association DirectionalAssociation Aggregation AggregationByValue DirectionalAggregation DirectionalAggregationByValue Project Package ClassView diff --git a/AI/GeniusAI/genius.cbp b/AI/GeniusAI/genius.cbp deleted file mode 100644 index 792be6722..000000000 --- a/AI/GeniusAI/genius.cbp +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - diff --git a/AI/GeniusAI/genius.vcxproj b/AI/GeniusAI/genius.vcxproj index d05f272d7..b1ef241b5 100644 --- a/AI/GeniusAI/genius.vcxproj +++ b/AI/GeniusAI/genius.vcxproj @@ -231,6 +231,7 @@ + diff --git a/AI/StupidAI/StdInc.h b/AI/StupidAI/StdInc.h index 5c3d9f243..81a6cb308 100644 --- a/AI/StupidAI/StdInc.h +++ b/AI/StupidAI/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/AI/StupidAI/StupidAI.cpp b/AI/StupidAI/StupidAI.cpp index 59a1a0c70..21ba21e4f 100644 --- a/AI/StupidAI/StupidAI.cpp +++ b/AI/StupidAI/StupidAI.cpp @@ -39,7 +39,7 @@ struct EnemyInfo { const CStack * s; int adi, adr; - std::vector attackFrom; //for melee fight + std::vector attackFrom; //for melee fight EnemyInfo(const CStack * _s) : s(_s) {} void calcDmg(const CStack * ourStack) @@ -60,10 +60,10 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2) return (ei1.adi-ei1.adr) < (ei2.adi - ei2.adr); } -int distToNearestNeighbour(SHexField hex, const std::vector & dists, SHexField *chosenHex = NULL) +int distToNearestNeighbour(SBattleHex hex, const std::vector & dists, SBattleHex *chosenHex = NULL) { int ret = 1000000; - BOOST_FOREACH(SHexField n, hex.neighbouringTiles()) + BOOST_FOREACH(SBattleHex n, hex.neighbouringTiles()) { if(dists[n] >= 0 && dists[n] < ret) { @@ -81,12 +81,12 @@ bool isCloser(const EnemyInfo & ei1, const EnemyInfo & ei2, const std::vectorposition, dists) < distToNearestNeighbour(ei2.s->position, dists); } -static bool willSecondHexBlockMoreEnemyShooters(const SHexField &h1, const SHexField &h2) +static bool willSecondHexBlockMoreEnemyShooters(const SBattleHex &h1, const SBattleHex &h2) { int shooters[2] = {0}; //count of shooters on hexes for(int i = 0; i < 2; i++) - BOOST_FOREACH(SHexField neighbour, (i ? h2 : h1).neighbouringTiles()) + BOOST_FOREACH(SBattleHex neighbour, (i ? h2 : h1).neighbouringTiles()) if(const CStack *s = cbc->battleGetStackByPos(neighbour)) if(s->getCreature()->isShooting()) shooters[i]++; @@ -98,7 +98,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) { //boost::this_thread::sleep(boost::posix_time::seconds(2)); print("activeStack called"); - std::vector avHexes = cb->battleGetAvailableHexes(stack, false); + std::vector avHexes = cb->battleGetAvailableHexes(stack, false); std::vector dists = cb->battleGetDistances(stack); std::vector enemiesShootable, enemiesReachable, enemiesUnreachable; @@ -110,7 +110,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) } else { - BOOST_FOREACH(SHexField hex, avHexes) + BOOST_FOREACH(SBattleHex hex, avHexes) { if(CStack::isMeleeAttackPossible(stack, s, hex)) { @@ -182,7 +182,7 @@ void CStupidAI::battleNewRound(int round) print("battleNewRound called"); } -void CStupidAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CStupidAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) { print("battleStackMoved called");; } @@ -233,10 +233,10 @@ void CStupidAI::print(const std::string &text) const tlog0 << "CStupidAI [" << this <<"]: " << text << std::endl; } -BattleAction CStupidAI::goTowards(const CStack * stack, SHexField hex) +BattleAction CStupidAI::goTowards(const CStack * stack, SBattleHex hex) { - SHexField realDest = hex; - SHexField predecessors[GameConstants::BFIELD_SIZE]; + SBattleHex realDest = hex; + SBattleHex predecessors[GameConstants::BFIELD_SIZE]; std::vector dists = cb->battleGetDistances(stack, hex); if(distToNearestNeighbour(hex, dists, &realDest) > GameConstants::BFIELD_SIZE) { @@ -245,7 +245,7 @@ BattleAction CStupidAI::goTowards(const CStack * stack, SHexField hex) } dists = cb->battleGetDistances(stack, realDest, predecessors); - std::vector avHexes = cb->battleGetAvailableHexes(stack, false); + std::vector avHexes = cb->battleGetAvailableHexes(stack, false); if(!avHexes.size()) { diff --git a/AI/StupidAI/StupidAI.h b/AI/StupidAI/StupidAI.h index 663c399e9..909135adc 100644 --- a/AI/StupidAI/StupidAI.h +++ b/AI/StupidAI/StupidAI.h @@ -1,6 +1,6 @@ #pragma once -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" class CStupidAI : public CBattleGameInterface { @@ -23,7 +23,7 @@ public: //void battleResultsApplied() OVERRIDE; //called when all effects of last battle are applied void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; void battleNewRound(int round) OVERRIDE; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; + void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; void battleSpellCast(const BattleSpellCast *sc) OVERRIDE; void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks //void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; @@ -34,6 +34,6 @@ public: void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield - BattleAction goTowards(const CStack * stack, SHexField hex ); + BattleAction goTowards(const CStack * stack, SBattleHex hex ); }; diff --git a/AI/StupidAI/StupidAI.vcxproj b/AI/StupidAI/StupidAI.vcxproj index 7ff466078..9d5da3b9b 100644 --- a/AI/StupidAI/StupidAI.vcxproj +++ b/AI/StupidAI/StupidAI.vcxproj @@ -166,6 +166,7 @@ + diff --git a/Global.h b/Global.h new file mode 100644 index 000000000..911581a34 --- /dev/null +++ b/Global.h @@ -0,0 +1,330 @@ +#pragma once + +// Standard include file +// Contents: +// Includes C/C++ libraries, STL libraries, IOStream and String libraries +// Includes the most important boost headers +// Defines the import + export, override and exception handling macros +// Defines the vstd library +// Includes the logger + +// This file shouldn't be changed, except if there is a important header file missing which is shared among several projects. + +/* + * Global.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#ifdef _WIN32 +#include +#else +#include "tchar_amigaos4.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +//filesystem version 3 causes problems (and it's default as of boost 1.46) +#define BOOST_FILESYSTEM_VERSION 2 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ANDROID +#include +#endif + +// Integral data types +typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) +typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) +typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) +typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) +typedef boost::int64_t si64; //signed int 64 bits (8 bytes) +typedef boost::int32_t si32; //signed int 32 bits (4 bytes) +typedef boost::int16_t si16; //signed int 16 bits (2 bytes) +typedef boost::int8_t si8; //signed int 8 bits (1 byte) + +// Import + Export macro declarations +#ifdef _WIN32 +#define DLL_EXPORT __declspec(dllexport) +#else +#if defined(__GNUC__) && __GNUC__ >= 4 +#define DLL_EXPORT __attribute__ ((visibility("default"))) +#else +#define DLL_EXPORT +#endif +#endif + +#ifdef _WIN32 +#define DLL_IMPORT __declspec(dllimport) +#else +#if defined(__GNUC__) && __GNUC__ >= 4 +#define DLL_IMPORT __attribute__ ((visibility("default"))) +#else +#define DLL_IMPORT +#endif +#endif + +#ifdef VCMI_DLL +#define DLL_LINKAGE DLL_EXPORT +#else +#define DLL_LINKAGE DLL_IMPORT +#endif + + +//a normal std::map with a const operator[] for sanity +template +class bmap : public std::map +{ +public: + const ValT & operator[](KeyT key) const + { + return find(key)->second; + } + ValT & operator[](KeyT key) + { + return static_cast &>(*this)[key]; + } + template void serialize(Handler &h, const int version) + { + h & static_cast &>(*this); + } +}; + +namespace vstd +{ + //returns true if container c contains item i + template + bool contains(const Container & c, const Item &i) + { + return std::find(c.begin(),c.end(),i) != c.end(); + } + + //returns true if map c contains item i + template + bool contains(const std::map & c, const Item2 &i) + { + return c.find(i)!=c.end(); + } + + //returns true if bmap c contains item i + template + bool contains(const bmap & c, const Item2 &i) + { + return c.find(i)!=c.end(); + } + + //returns true if unordered set c contains item i + template + bool contains(const boost::unordered_set & c, const Item &i) + { + return c.find(i)!=c.end(); + } + + //returns position of first element in vector c equal to s, if there is no such element, -1 is returned + template + int find_pos(const std::vector & c, const T2 &s) + { + for(size_t i=0; i < c.size(); ++i) + if(c[i] == s) + return i; + return -1; + } + + //Func(T1,T2) must say if these elements matches + template + int find_pos(const std::vector & c, const T2 &s, const Func &f) + { + for(size_t i=0; i < c.size(); ++i) + if(f(c[i],s)) + return i; + return -1; + } + + //returns iterator to the given element if present in container, end() if not + template + typename Container::iterator find(Container & c, const Item &i) + { + return std::find(c.begin(),c.end(),i); + } + + //returns const iterator to the given element if present in container, end() if not + template + typename Container::const_iterator find(const Container & c, const Item &i) + { + return std::find(c.begin(),c.end(),i); + } + + //removes element i from container c, returns false if c does not contain i + template + typename Container::size_type operator-=(Container &c, const Item &i) + { + typename Container::iterator itr = find(c,i); + if(itr == c.end()) + return false; + c.erase(itr); + return true; + } + + //assigns greater of (a, b) to a and returns maximum of (a, b) + template + t1 &amax(t1 &a, const t2 &b) + { + if(a >= b) + return a; + else + { + a = b; + return a; + } + } + + //assigns smaller of (a, b) to a and returns minimum of (a, b) + template + t1 &amin(t1 &a, const t2 &b) + { + if(a <= b) + return a; + else + { + a = b; + return a; + } + } + + //makes a to fit the range + template + t1 &abetween(t1 &a, const t2 &b, const t3 &c) + { + amax(a,b); + amin(a,c); + return a; + } + + //checks if a is between b and c + template + bool isbetween(const t1 &a, const t2 &b, const t3 &c) + { + return a > b && a < c; + } + + //checks if a is within b and c + template + bool iswithin(const t1 &a, const t2 &b, const t3 &c) + { + return a >= b && a <= c; + } + + template + struct assigner + { + public: + t1 &op1; + t2 op2; + assigner(t1 &a1, const t2 & a2) + :op1(a1), op2(a2) + {} + void operator()() + { + op1 = op2; + } + }; + + // Assigns value a2 to a1. The point of time of the real operation can be controlled + // with the () operator. + template + assigner assigno(t1 &a1, const t2 &a2) + { + return assigner(a1,a2); + } + + //deleted pointer and sets it to NULL + template + void clear_pointer(T* &ptr) + { + delete ptr; + ptr = NULL; + } +} +using vstd::operator-=; + +// can be used for counting arrays +template char (&_ArrayCountObj(const T (&)[N]))[N]; +#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) + +//for explicit overrides +#ifdef _MSC_VER +#define OVERRIDE override +#else +#define OVERRIDE //is there any working counterpart? +#endif + +//XXX pls dont - 'debug macros' are usually more trouble than it's worth +#define HANDLE_EXCEPTION \ + catch (const std::exception& e) { \ + tlog1 << e.what() << std::endl; \ + throw; \ +} \ + catch (const std::exception * e) \ +{ \ + tlog1 << e->what()<< std::endl; \ + throw; \ +} \ + catch (const std::string& e) { \ + tlog1 << e << std::endl; \ + throw; \ +} + +#define HANDLE_EXCEPTIONC(COMMAND) \ + catch (const std::exception& e) { \ + COMMAND; \ + tlog1 << e.what() << std::endl; \ + throw; \ +} \ + catch (const std::string &e) \ +{ \ + COMMAND; \ + tlog1 << e << std::endl; \ + throw; \ +} + + +#include "lib/CLogger.h" diff --git a/Scripting/ERM/ERM.vcxproj b/Scripting/ERM/ERM.vcxproj index b3fa4a53b..b931aabea 100644 --- a/Scripting/ERM/ERM.vcxproj +++ b/Scripting/ERM/ERM.vcxproj @@ -129,6 +129,7 @@ + diff --git a/Scripting/ERM/ERMParser.cpp b/Scripting/ERM/ERMParser.cpp index 1526e3a17..e1d84fc2b 100644 --- a/Scripting/ERM/ERMParser.cpp +++ b/Scripting/ERM/ERMParser.cpp @@ -1,24 +1,11 @@ #include "StdInc.h" #include "ERMParser.h" -#include + //To make compilation with older boost versions possible //Don't know exact version - 1.46 works while 1.42 not #if BOOST_VERSION >= 104600 -#include -#include -#include -#include -#include -#include -#include - -namespace spirit = boost::spirit; -namespace qi = boost::spirit::qi; -namespace ascii = spirit::ascii; -namespace phoenix = boost::phoenix; - /* * ERMParser.cpp, part of VCMI engine * diff --git a/Scripting/ERM/ERMParser.h b/Scripting/ERM/ERMParser.h index cde879b44..6e303da85 100644 --- a/Scripting/ERM/ERMParser.h +++ b/Scripting/ERM/ERMParser.h @@ -1,10 +1,6 @@ #pragma once -#include -#include -#include - /* * ERMParser.h, part of VCMI engine * diff --git a/Scripting/ERM/StdInc.h b/Scripting/ERM/StdInc.h index 5c3d9f243..4990e0910 100644 --- a/Scripting/ERM/StdInc.h +++ b/Scripting/ERM/StdInc.h @@ -1,325 +1,23 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../../tchar_amigaos4.h" -#endif +// Here you can add specific libraries and macros which are specific to this project. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../../lib/CLogger.h" +namespace spirit = boost::spirit; +namespace qi = boost::spirit::qi; +namespace ascii = spirit::ascii; +namespace phoenix = boost::phoenix; diff --git a/client/AdventureMapButton.cpp b/client/AdventureMapButton.cpp index da7b46ae6..fe4449959 100644 --- a/client/AdventureMapButton.cpp +++ b/client/AdventureMapButton.cpp @@ -12,6 +12,7 @@ #include "CMessage.h" #include "CMusicHandler.h" #include "GUIClasses.h" +#include "UIFramework/CGuiHandler.h" /* * AdventureMapButton.cpp, part of VCMI engine @@ -42,9 +43,9 @@ void CButtonBase::update() if (text) { if (state == PRESSED) - text->moveTo(Point(pos.x+pos.w/2+1, pos.y+pos.h/2+1)); + text->moveTo(SPoint(pos.x+pos.w/2+1, pos.y+pos.h/2+1)); else - text->moveTo(Point(pos.x+pos.w/2, pos.y+pos.h/2)); + text->moveTo(SPoint(pos.x+pos.w/2, pos.y+pos.h/2)); } int newPos = (int)state + bitmapOffset; @@ -500,10 +501,10 @@ void CSlider::moveTo(int to) double part = static_cast(to) / positions; part*=(pos.w-48); int newPos = part + pos.x + 16 - slider->pos.x; - slider->moveBy(Point(newPos, 0)); + slider->moveBy(SPoint(newPos, 0)); } else - slider->moveTo(Point(pos.x+16, pos.y)); + slider->moveTo(SPoint(pos.x+16, pos.y)); } else { @@ -512,10 +513,10 @@ void CSlider::moveTo(int to) double part = static_cast(to) / positions; part*=(pos.h-48); int newPos = part + pos.y + 16 - slider->pos.y; - slider->moveBy(Point(0, newPos)); + slider->moveBy(SPoint(0, newPos)); } else - slider->moveTo(Point(pos.x, pos.y+16)); + slider->moveTo(SPoint(pos.x, pos.y+16)); } if(moved) diff --git a/client/AdventureMapButton.h b/client/AdventureMapButton.h index 00146094e..aa0576d35 100644 --- a/client/AdventureMapButton.h +++ b/client/AdventureMapButton.h @@ -1,7 +1,8 @@ #pragma once #include "FunctionList.h" -#include "GUIBase.h" +#include "UIFramework/CKeyShortcut.h" +#include "UIFramework/SRect.h" /* * AdventureMapButton.h, part of VCMI engine @@ -22,7 +23,7 @@ class CLabel; namespace config{struct ButtonInfo;} /// Base class for buttons. -class CButtonBase : public KeyShortcut +class CButtonBase : public CKeyShortcut { public: enum ButtonState diff --git a/client/BattleInterface/CAttackAnimation.cpp b/client/BattleInterface/CAttackAnimation.cpp index 517dbff7d..f21d9f6ba 100644 --- a/client/BattleInterface/CAttackAnimation.cpp +++ b/client/BattleInterface/CAttackAnimation.cpp @@ -4,7 +4,7 @@ #include "../CMusicHandler.h" #include "../CGameInfo.h" #include "CBattleInterface.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../../lib/BattleState.h" #include "../CPlayerInterface.h" #include "../../CCallback.h" @@ -34,7 +34,7 @@ bool CAttackAnimation::checkInitialConditions() return isEarliest(false); } -CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *defender) +CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender) : CBattleStackAnimation(_owner, attacker), dest(_dest), attackedStack(defender), attackingStack(attacker) { diff --git a/client/BattleInterface/CAttackAnimation.h b/client/BattleInterface/CAttackAnimation.h index 7e4426744..9c63f46df 100644 --- a/client/BattleInterface/CAttackAnimation.h +++ b/client/BattleInterface/CAttackAnimation.h @@ -2,7 +2,7 @@ #include "CBattleStackAnimation.h" #include "../CAnimation.h" -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" class CBattleInterface; class CStack; @@ -21,7 +21,7 @@ class CStack; class CAttackAnimation : public CBattleStackAnimation { protected: - SHexField dest; //attacked hex + SBattleHex dest; //attacked hex bool shooting; CCreatureAnim::EAnimType group; //if shooting is true, print this animation group const CStack *attackedStack; @@ -31,5 +31,5 @@ public: void nextFrame(); bool checkInitialConditions(); - CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *defender); + CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender); }; \ No newline at end of file diff --git a/client/BattleInterface/CBattleConsole.h b/client/BattleInterface/CBattleConsole.h index dc4adad3f..9971b0ab9 100644 --- a/client/BattleInterface/CBattleConsole.h +++ b/client/BattleInterface/CBattleConsole.h @@ -1,6 +1,6 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" struct SDL_Surface; diff --git a/client/BattleInterface/CBattleHero.cpp b/client/BattleInterface/CBattleHero.cpp index a9b1d80b2..2b7093e0b 100644 --- a/client/BattleInterface/CBattleHero.cpp +++ b/client/BattleInterface/CBattleHero.cpp @@ -10,6 +10,7 @@ #include "../CSpellWindow.h" #include "../Graphics.h" #include "../CConfigHandler.h" +#include "../UIFramework/CGuiHandler.h" void CBattleHero::show(SDL_Surface *to) { diff --git a/client/BattleInterface/CBattleHero.h b/client/BattleInterface/CBattleHero.h index 3a34e4fe5..c207a0ce9 100644 --- a/client/BattleInterface/CBattleHero.h +++ b/client/BattleInterface/CBattleHero.h @@ -1,6 +1,6 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" class CBattleInterface; class CDefHandler; diff --git a/client/BattleInterface/CBattleInterface.cpp b/client/BattleInterface/CBattleInterface.cpp index 9995fdf89..b14c5a7e6 100644 --- a/client/BattleInterface/CBattleInterface.cpp +++ b/client/BattleInterface/CBattleInterface.cpp @@ -17,7 +17,7 @@ #include "../../CCallback.h" #include "../../lib/BattleState.h" #include "../../lib/CGeneralTextHandler.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../Graphics.h" #include "../CSpellWindow.h" #include "../CConfigHandler.h" @@ -29,7 +29,6 @@ #include "../../lib/CTownHandler.h" #include "../../lib/map.h" - #include "CBattleHero.h" #include "CStackQueue.h" #include "CBattleConsole.h" @@ -37,7 +36,7 @@ #include "CBattleAnimation.h" #include "CBattleOptionsWindow.h" #include "CDummyAnimation.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" #include "CShootingAnimation.h" #include "CSpellEffectAnimation.h" #include "CMeleeAttackAnimation.h" @@ -47,6 +46,7 @@ #include "CDefenceAnimation.h" #include "CMovementAnimation.h" +#include "../UIFramework/CGuiHandler.h" #ifndef __GNUC__ const double M_PI = 3.14159265358979323846; @@ -112,7 +112,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL) { - ObjectConstruction h__l__p(this); + OBJ_CONSTRUCTION; if(!curInt) curInt = LOCPLINT; //may happen when we are defending during network MP game @@ -136,7 +136,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe if(curInt->sysOpts.showQueue) pos.y += queue->pos.h / 2; //center whole window - queue->moveTo(Point(pos.x, pos.y - queue->pos.h)); + queue->moveTo(SPoint(pos.x, pos.y - queue->pos.h)); // queue->pos.x = pos.x; // queue->pos.y = pos.y - queue->pos.h; // pos.h += queue->pos.h; @@ -173,7 +173,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ), * mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) ); - Point moatPos = graphics->wallPositions[siegeH->town->town->typeID][12], + SPoint moatPos = graphics->wallPositions[siegeH->town->town->typeID][12], mlipPos = graphics->wallPositions[siegeH->town->town->typeID][13]; if(moat) //eg. tower has no moat @@ -603,8 +603,8 @@ void CBattleInterface::show(SDL_Surface * to) {//TODO: do not check it every frame if (activeStack) //highlight all attackable hexes { - std::set set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex); - BOOST_FOREACH(SHexField hex, set) + std::set set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex); + BOOST_FOREACH(SBattleHex hex, set) { int x = 14 + ((hex/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(hex%GameConstants::BFIELD_WIDTH) + pos.x; int y = 86 + 42 * (hex/GameConstants::BFIELD_WIDTH) + pos.y; @@ -630,10 +630,10 @@ void CBattleInterface::show(SDL_Surface * to) //preparing obstacles to be shown std::vector obstacles = curInt->cb->battleGetAllObstacles(); - std::multimap hexToObstacle; + std::multimap hexToObstacle; for(size_t b = 0; b < obstacles.size(); ++b) { - SHexField position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos); + SBattleHex position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos); hexToObstacle.insert(std::make_pair(position, b)); } @@ -845,7 +845,7 @@ void CBattleInterface::show(SDL_Surface * to) //showing in-game console LOCPLINT->cingconsole->show(to); - Rect posWithQueue = Rect(pos.x, pos.y, 800, 600); + SRect posWithQueue = SRect(pos.x, pos.y, 800, 600); if(curInt->sysOpts.showQueue) { @@ -891,12 +891,12 @@ void CBattleInterface::showAliveStacks(std::vector *aliveStacks, } } -void CBattleInterface::showObstacles(std::multimap *hexToObstacle, std::vector &obstacles, int hex, SDL_Surface *to) +void CBattleInterface::showObstacles(std::multimap *hexToObstacle, std::vector &obstacles, int hex, SDL_Surface *to) { - std::pair::const_iterator, std::multimap::const_iterator> obstRange = + std::pair::const_iterator, std::multimap::const_iterator> obstRange = hexToObstacle->equal_range(hex); - for(std::multimap::const_iterator it = obstRange.first; it != obstRange.second; ++it) + for(std::multimap::const_iterator it = obstRange.first; it != obstRange.second; ++it) { CObstacleInstance & curOb = obstacles[it->second]; std::pair shift = CGI->heroh->obstacles.find(curOb.ID)->second.posShift; @@ -963,7 +963,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel) { const CSpell * spell = CGI->spellh->spells[creatureSpellToCast]; - if (curInt->cb->battleCanCastThisSpell(spell, SHexField(myNumber)) == ESpellCastProblem::OK) + if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(myNumber)) == ESpellCastProblem::OK) { if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack)) { @@ -1210,7 +1210,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) void CBattleInterface::setBattleCursor(const int myNumber) { - const CHexFieldControl & hoveredHex = bfield[myNumber]; + const CClickableHex & hoveredHex = bfield[myNumber]; CCursorHandler *cursor = CCS->curh; const double subdividingAngle = 2.0*M_PI/6.0; // Divide a hex into six sectors. @@ -1368,7 +1368,7 @@ void CBattleInterface::setBattleCursor(const int myNumber) attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left break; } - SHexField hex(attackingHex); + SBattleHex hex(attackingHex); if (!hex.isValid()) attackingHex = -1; } @@ -1388,7 +1388,7 @@ void CBattleInterface::bOptionsf() CCS->curh->changeGraphic(0,0); - Rect tempRect = genRect(431, 481, 160, 84); + SRect tempRect = genRect(431, 481, 160, 84); tempRect += pos.topLeft(); CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(tempRect, this); GH.pushInt(optionsWin); @@ -1516,7 +1516,7 @@ void CBattleInterface::bConsoleDownf() void CBattleInterface::newStack(const CStack * stack) { - Point coords = CHexFieldControl::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);; + SPoint coords = CClickableHex::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);; if(stack->position < 0) //turret { @@ -1549,7 +1549,7 @@ void CBattleInterface::newStack(const CStack * stack) creAnims[stack->ID] = new CCreatureAnimation(stack->getCreature()->animDefName); } creAnims[stack->ID]->setType(CCreatureAnim::HOLDING); - creAnims[stack->ID]->pos = Rect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight); + creAnims[stack->ID]->pos = SRect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight); creDir[stack->ID] = stack->attackerOwned; } @@ -1568,7 +1568,7 @@ void CBattleInterface::stackActivated(const CStack * stack) //TODO: check it all activateStack(); } -void CBattleInterface::stackMoved(const CStack * stack, std::vector destHex, int distance) +void CBattleInterface::stackMoved(const CStack * stack, std::vector destHex, int distance) { addNewAnim(new CMovementAnimation(this, stack, destHex, distance)); waitForAnims(); @@ -1605,7 +1605,7 @@ void CBattleInterface::stacksAreAttacked(std::vector attacke } } -void CBattleInterface::stackAttacking( const CStack * attacker, SHexField dest, const CStack * attacked, bool shooting ) +void CBattleInterface::stackAttacking( const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting ) { if (shooting) { @@ -1639,7 +1639,7 @@ void CBattleInterface::newRound(int number) } -void CBattleInterface::giveCommand(ui8 action, SHexField tile, ui32 stack, si32 additional) +void CBattleInterface::giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional) { if(!curInt->cb->battleGetStackByID(stack) && action != 1 && action != 4 && action != 5) { @@ -1678,30 +1678,30 @@ void CBattleInterface::giveCommand(ui8 action, SHexField tile, ui32 stack, si32 } } -bool CBattleInterface::isTileAttackable(const SHexField & number) const +bool CBattleInterface::isTileAttackable(const SBattleHex & number) const { for(size_t b=0; b obstacles = curInt->cb->battleGetAllObstacles(); - std::set coveredHexes; + std::set coveredHexes; for(size_t b = 0; b < obstacles.size(); ++b) { - std::vector blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos); + std::vector blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos); for(size_t w = 0; w < blocked.size(); ++w) coveredHexes.insert(blocked[w]); } return vstd::contains(coveredHexes, hex); } -bool CBattleInterface::isCatapultAttackable(SHexField hex) const +bool CBattleInterface::isCatapultAttackable(SBattleHex hex) const { if(!siegeH) return false; @@ -1799,7 +1799,7 @@ void CBattleInterface::hexLclicked(int whichOne) if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel) { const CSpell * spell = CGI->spellh->spells[creatureSpellToCast]; - if (curInt->cb->battleCanCastThisSpell(spell, SHexField(whichOne)) == ESpellCastProblem::OK) + if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(whichOne)) == ESpellCastProblem::OK) { if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack)) { @@ -1880,7 +1880,7 @@ void CBattleInterface::hexLclicked(int whichOne) { if(actStack->doubleWide() && !actStack->attackerOwned) { - std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); + std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); if(vstd::contains(acc, whichOne)) attackFromHex = whichOne - 1; else @@ -1932,7 +1932,7 @@ void CBattleInterface::hexLclicked(int whichOne) { if(actStack->doubleWide() && actStack->attackerOwned) { - std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); + std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); if(vstd::contains(acc, whichOne)) attackFromHex = whichOne + 1; else @@ -2018,7 +2018,7 @@ void CBattleInterface::hexLclicked(int whichOne) CCS->curh->changeGraphic(1, 6); //cursor should be changed if(activeStack->doubleWide()) { - std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); + std::vector acc = curInt->cb->battleGetAvailableHexes(activeStack, false); int shiftedDest = whichOne + (activeStack->attackerOwned ? 1 : -1); if(vstd::contains(acc, whichOne)) giveCommand (BattleAction::WALK ,whichOne, activeStack->ID); @@ -2101,8 +2101,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) { //common ice bolt and magic arrow part //initial variables std::string animToDisplay; - Point srccoord = (sc->side ? Point(770, 60) : Point(30, 60)) + pos; - Point destcoord = CHexFieldControl::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow + SPoint srccoord = (sc->side ? SPoint(770, 60) : SPoint(30, 60)) + pos; + SPoint destcoord = CClickableHex::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow destcoord.x += 250; destcoord.y += 240; //animation angle @@ -2320,8 +2320,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) //mana absorption if (sc->manaGained) { - Point leftHero = Point(15, 30) + pos; - Point rightHero = Point(755, 30) + pos; + SPoint leftHero = SPoint(15, 30) + pos; + SPoint rightHero = SPoint(755, 30) + pos; addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero.x, leftHero.y, 0, 0, false)); addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero.x, rightHero.y, 0, 0, false)); } @@ -2632,7 +2632,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to) && !stack->hasBonusOfType(Bonus::SIEGE_WEAPON) //and not a war machine... ) { - const SHexField nextPos = stack->position + (stack->attackerOwned ? 1 : -1); + const SBattleHex nextPos = stack->position + (stack->attackerOwned ? 1 : -1); const bool edge = stack->position % GameConstants::BFIELD_WIDTH == (stack->attackerOwned ? GameConstants::BFIELD_WIDTH - 2 : 1); const bool moveInside = !edge && !stackCountOutsideHexes[nextPos]; int xAdd = (stack->attackerOwned ? 220 : 202) + @@ -2769,9 +2769,9 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack) if(curInt->sysOpts.printStackRange) { - std::vector hexesToShade = occupyableHexes; + std::vector hexesToShade = occupyableHexes; hexesToShade.insert(hexesToShade.end(), attackableHexes.begin(), attackableHexes.end()); - BOOST_FOREACH(SHexField hex, hexesToShade) + BOOST_FOREACH(SBattleHex hex, hexesToShade) { int i = hex.getY(); //row int j = hex.getX()-1; //column @@ -2937,7 +2937,7 @@ void CBattleInterface::hideQueue() if(!queue->embedded) { - moveBy(Point(0, -queue->pos.h / 2)); + moveBy(SPoint(0, -queue->pos.h / 2)); GH.totalRedraw(); } } @@ -2950,7 +2950,7 @@ void CBattleInterface::showQueue() if(!queue->embedded) { - moveBy(Point(0, +queue->pos.h / 2)); + moveBy(SPoint(0, +queue->pos.h / 2)); GH.totalRedraw(); } } @@ -3170,7 +3170,7 @@ std::string CBattleInterface::SiegeHelper::getSiegeName(ui16 what, ui16 additInf /// Positions are loaded from the config file: /config/wall_pos.txt void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what) { - Point pos = Point(-1, -1); + SPoint pos = SPoint(-1, -1); if (what >= 1 && what <= 17) { diff --git a/client/BattleInterface/CBattleInterface.h b/client/BattleInterface/CBattleInterface.h index ae233e276..2883b4c51 100644 --- a/client/BattleInterface/CBattleInterface.h +++ b/client/BattleInterface/CBattleInterface.h @@ -1,14 +1,13 @@ #pragma once -#include "../GUIBase.h" #include "../../lib/CCreatureSet.h" #include "../../lib/ConstTransitivePtr.h" //may be reundant #include "../CAnimation.h" #include "SStackAttackedInfo.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" #include "CShootingAnimation.h" -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" #include "../../lib/GameConstants.h" /* @@ -46,6 +45,7 @@ class CBattleHero; class CBattleConsole; class CBattleResultWindow; class CStackQueue; +class CPlayerInterface; /// Class which manages the locked hex fields that are blocked e.g. by obstacles class CBattleObstacle @@ -103,7 +103,7 @@ private: int mouseHoveredStack; //stack hovered by mouse; if -1 -> none time_t lastMouseHoveredStackAnimationTime; // time when last mouse hovered animation occurred static const time_t HOVER_ANIM_DELTA; - std::vector occupyableHexes, //hexes available for active stack + std::vector occupyableHexes, //hexes available for active stack attackableHexes; //hexes attackable by active stack bool stackCountOutsideHexes[GameConstants::BFIELD_SIZE]; // hexes that when in front of a unit cause it's amount box to move back int previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago @@ -112,7 +112,7 @@ private: double getAnimSpeedMultiplier() const; //returns multiplier for number of frames in a group std::map standingFrame; //number of frame in standing animation by stack ID, helps in showing 'random moves' - CPlayerInterface *tacticianInterface; //used during tactics mode, points to the interface of player with higher tactics (can be either attacker or defender in hot-seat), valid onloy for human players + CPlayerInterface * tacticianInterface; //used during tactics mode, points to the interface of player with higher tactics (can be either attacker or defender in hot-seat), valid onloy for human players bool tacticsMode; bool stackCanCastSpell; //if true, active stack could possibly cats some target spell bool spellDestSelectMode; //if true, player is choosing destination for his spell @@ -124,16 +124,16 @@ private: void showAliveStack(const CStack *stack, SDL_Surface * to); //helper function for function show void showAliveStacks(std::vector *aliveStacks, int hex, std::vector *flyingStacks, SDL_Surface *to); // loops through all stacks at a given hex position void showPieceOfWall(SDL_Surface * to, int hex, const std::vector & stacks); //helper function for show - void showObstacles(std::multimap *hexToObstacle, std::vector &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position + void showObstacles(std::multimap *hexToObstacle, std::vector &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position void redrawBackgroundWithHexes(const CStack * activeStack); void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker, bool Multiple); std::list projectiles; //projectiles flying on battlefield void projectileShowHelper(SDL_Surface * to); //prints projectiles present on the battlefield - void giveCommand(ui8 action, SHexField tile, ui32 stack, si32 additional=-1); - bool isTileAttackable(const SHexField & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles - bool blockedByObstacle(SHexField hex) const; - bool isCatapultAttackable(SHexField hex) const; //returns true if given tile can be attacked by catapult + void giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional=-1); + bool isTileAttackable(const SBattleHex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles + bool blockedByObstacle(SBattleHex hex) const; + bool isCatapultAttackable(SBattleHex hex) const; //returns true if given tile can be attacked by catapult std::list battleEffects; //different animations to display on the screen like spell effects @@ -177,7 +177,7 @@ public: void setAnimSpeed(int set); //speed of animation; 1 - slowest, 2 - medium, 4 - fastest int getAnimSpeed() const; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest - CHexFieldControl bfield[GameConstants::BFIELD_SIZE]; //11 lines, 17 hexes on each + CClickableHex bfield[GameConstants::BFIELD_SIZE]; //11 lines, 17 hexes on each //std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield SDL_Surface * cellBorder, * cellShade; CondSh *givenCommand; //data != NULL if we have i.e. moved current unit @@ -215,10 +215,10 @@ public: void newStack(const CStack * stack); //new stack appeared on battlefield void stackRemoved(int stackID); //stack disappeared from batlefiled void stackActivated(const CStack * stack); //active stack has been changed - void stackMoved(const CStack * stack, std::vector destHex, int distance); //stack with id number moved to destHex + void stackMoved(const CStack * stack, std::vector destHex, int distance); //stack with id number moved to destHex void waitForAnims(); void stacksAreAttacked(std::vector attackedInfos); //called when a certain amount of stacks has been attacked - void stackAttacking(const CStack * attacker, SHexField dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest + void stackAttacking(const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest void newRoundFirst( int round ); void newRound(int number); //caled when round is ended; number is the number of round void hexLclicked(int whichOne); //hex only call-in @@ -252,5 +252,5 @@ public: friend class CAttackAnimation; friend class CMeleeAttackAnimation; friend class CShootingAnimation; - friend class CHexFieldControl; + friend class CClickableHex; }; diff --git a/client/BattleInterface/CBattleOptionsWindow.cpp b/client/BattleInterface/CBattleOptionsWindow.cpp index fd09bc796..b0a429df7 100644 --- a/client/BattleInterface/CBattleOptionsWindow.cpp +++ b/client/BattleInterface/CBattleOptionsWindow.cpp @@ -2,12 +2,12 @@ #include "CBattleOptionsWindow.h" #include "CBattleInterface.h" -#include "../GUIBase.h" #include "../GUIClasses.h" #include "../AdventureMapButton.h" #include "../CGameInfo.h" #include "../CPlayerInterface.h" #include "../../lib/CGeneralTextHandler.h" +#include "../UIFramework/CGuiHandler.h" CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner) { diff --git a/client/BattleInterface/CBattleOptionsWindow.h b/client/BattleInterface/CBattleOptionsWindow.h index 4aecf6d75..91c89c624 100644 --- a/client/BattleInterface/CBattleOptionsWindow.h +++ b/client/BattleInterface/CBattleOptionsWindow.h @@ -1,6 +1,6 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" class CBattleInterface; class CPicture; diff --git a/client/BattleInterface/CBattleResultWindow.cpp b/client/BattleInterface/CBattleResultWindow.cpp index 566ce5455..44dd9de59 100644 --- a/client/BattleInterface/CBattleResultWindow.cpp +++ b/client/BattleInterface/CBattleResultWindow.cpp @@ -15,6 +15,7 @@ #include "../CVideoHandler.h" #include "../SDL_Extensions.h" #include "../CBitmapHandler.h" +#include "../UIFramework/CGuiHandler.h" CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner) : owner(_owner) diff --git a/client/BattleInterface/CBattleResultWindow.h b/client/BattleInterface/CBattleResultWindow.h index c49ee74d8..ecb97ff0f 100644 --- a/client/BattleInterface/CBattleResultWindow.h +++ b/client/BattleInterface/CBattleResultWindow.h @@ -1,6 +1,6 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" struct SDL_Surface; class AdventureMapButton; diff --git a/client/BattleInterface/CBattleStackAnimation.cpp b/client/BattleInterface/CBattleStackAnimation.cpp index 7a3eb11dd..f6dd972db 100644 --- a/client/BattleInterface/CBattleStackAnimation.cpp +++ b/client/BattleInterface/CBattleStackAnimation.cpp @@ -9,7 +9,7 @@ CBattleStackAnimation::CBattleStackAnimation(CBattleInterface * _owner, const CS { } -bool CBattleStackAnimation::isToReverseHlp(SHexField hexFrom, SHexField hexTo, bool curDir) +bool CBattleStackAnimation::isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir) { int fromMod = hexFrom % GameConstants::BFIELD_WIDTH; int fromDiv = hexFrom / GameConstants::BFIELD_WIDTH; @@ -35,7 +35,7 @@ bool CBattleStackAnimation::isToReverseHlp(SHexField hexFrom, SHexField hexTo, b return false; //should never happen } -bool CBattleStackAnimation::isToReverse(SHexField hexFrom, SHexField hexTo, bool curDir, bool toDoubleWide, bool toDir) +bool CBattleStackAnimation::isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir) { if(hexTo < 0) //turret return false; diff --git a/client/BattleInterface/CBattleStackAnimation.h b/client/BattleInterface/CBattleStackAnimation.h index 49eaa1a07..4e9ef9f62 100644 --- a/client/BattleInterface/CBattleStackAnimation.h +++ b/client/BattleInterface/CBattleStackAnimation.h @@ -1,7 +1,7 @@ #pragma once #include "CBattleAnimation.h" -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" class CStack; class CBattleInterface; @@ -24,8 +24,8 @@ public: const CStack * stack; //id of stack whose animation it is CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack); - static bool isToReverseHlp(SHexField hexFrom, SHexField hexTo, bool curDir); //helper for isToReverse - static bool isToReverse(SHexField hexFrom, SHexField hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo) + static bool isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir); //helper for isToReverse + static bool isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo) CCreatureAnimation *myAnim(); //animation for our stack }; \ No newline at end of file diff --git a/client/BattleInterface/CHexFieldControl.cpp b/client/BattleInterface/CClickableHex.cpp similarity index 78% rename from client/BattleInterface/CHexFieldControl.cpp rename to client/BattleInterface/CClickableHex.cpp index 9b58098cc..a2f6142cd 100644 --- a/client/BattleInterface/CHexFieldControl.cpp +++ b/client/BattleInterface/CClickableHex.cpp @@ -1,5 +1,5 @@ #include "StdInc.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" #include "CBattleInterface.h" #include "../../lib/BattleState.h" #include "../CGameInfo.h" @@ -11,10 +11,11 @@ #include "../SDL_Extensions.h" #include "../GUIClasses.h" #include "CBattleConsole.h" +#include "../UIFramework/CGuiHandler.h" -Point CHexFieldControl::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi) +SPoint CClickableHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi) { - Point ret(-500, -500); //returned value + SPoint ret(-500, -500); //returned value if(stack && stack->position < 0) //creatures in turrets { switch(stack->position) @@ -58,7 +59,7 @@ Point CHexFieldControl::getXYUnitAnim(const int & hexNum, const bool & attacker, //returning return ret +CPlayerInterface::battleInt->pos; } -void CHexFieldControl::activate() +void CClickableHex::activate() { activateHover(); activateMouseMove(); @@ -66,7 +67,7 @@ void CHexFieldControl::activate() activateRClick(); } -void CHexFieldControl::deactivate() +void CClickableHex::deactivate() { deactivateHover(); deactivateMouseMove(); @@ -74,7 +75,7 @@ void CHexFieldControl::deactivate() deactivateRClick(); } -void CHexFieldControl::hover(bool on) +void CClickableHex::hover(bool on) { hovered = on; //Hoverable::hover(on); @@ -85,11 +86,11 @@ void CHexFieldControl::hover(bool on) } } -CHexFieldControl::CHexFieldControl() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL) +CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL) { } -void CHexFieldControl::mouseMoved(const SDL_MouseMotionEvent &sEvent) +void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent) { if(myInterface->cellShade) { @@ -124,7 +125,7 @@ void CHexFieldControl::mouseMoved(const SDL_MouseMotionEvent &sEvent) } } -void CHexFieldControl::clickLeft(tribool down, bool previousState) +void CClickableHex::clickLeft(tribool down, bool previousState) { if(!down && hovered && strictHovered) //we've been really clicked! { @@ -132,7 +133,7 @@ void CHexFieldControl::clickLeft(tribool down, bool previousState) } } -void CHexFieldControl::clickRight(tribool down, bool previousState) +void CClickableHex::clickRight(tribool down, bool previousState) { const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info if(hovered && strictHovered && myst!=NULL) diff --git a/client/BattleInterface/CHexFieldControl.h b/client/BattleInterface/CClickableHex.h similarity index 74% rename from client/BattleInterface/CHexFieldControl.h rename to client/BattleInterface/CClickableHex.h index 9beacd6de..3ce60d28c 100644 --- a/client/BattleInterface/CHexFieldControl.h +++ b/client/BattleInterface/CClickableHex.h @@ -1,13 +1,13 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" class CBattleInterface; class CStack; struct SDL_MouseMotionEvent; /* - * CHexFieldControl.h, part of VCMI engine + * CClickableHex.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -17,7 +17,7 @@ struct SDL_MouseMotionEvent; */ /// Class which stands for a single hex field on a battlefield -class CHexFieldControl : public CIntObject +class CClickableHex : public CIntObject { private: bool setAlterText; //if true, this hex has set alternative text in console and will clean it @@ -27,7 +27,7 @@ public: //CStack * ourStack; bool hovered, strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering) CBattleInterface * myInterface; //interface that owns me - static Point getXYUnitAnim(const int &hexNum, const bool &attacker, const CStack *creature, const CBattleInterface *cbi); //returns (x, y) of left top corner of animation + static SPoint getXYUnitAnim(const int &hexNum, const bool &attacker, const CStack *creature, const CBattleInterface *cbi); //returns (x, y) of left top corner of animation //for user interactions void hover (bool on); @@ -36,5 +36,5 @@ public: void mouseMoved (const SDL_MouseMotionEvent &sEvent); void clickLeft(tribool down, bool previousState); void clickRight(tribool down, bool previousState); - CHexFieldControl(); + CClickableHex(); }; \ No newline at end of file diff --git a/client/CCreatureAnimation.cpp b/client/BattleInterface/CCreatureAnimation.cpp similarity index 94% rename from client/CCreatureAnimation.cpp rename to client/BattleInterface/CCreatureAnimation.cpp index 5b10a7e90..4658695ca 100644 --- a/client/CCreatureAnimation.cpp +++ b/client/BattleInterface/CCreatureAnimation.cpp @@ -1,10 +1,10 @@ #include "StdInc.h" #include "CCreatureAnimation.h" -#include "../lib/CLodHandler.h" -#include "../lib/VCMI_Lib.h" -#include "../lib/vcmi_endian.h" -#include "SDL_Extensions.h" +#include "../../lib/CLodHandler.h" +#include "../../lib/VCMI_Lib.h" +#include "../../lib/vcmi_endian.h" +#include "../SDL_Extensions.h" /* * CCreatureAnimation.cpp, part of VCMI engine diff --git a/client/CCreatureAnimation.h b/client/BattleInterface/CCreatureAnimation.h similarity index 93% rename from client/CCreatureAnimation.h rename to client/BattleInterface/CCreatureAnimation.h index dd8170afc..87ac66e9d 100644 --- a/client/CCreatureAnimation.h +++ b/client/BattleInterface/CCreatureAnimation.h @@ -1,10 +1,9 @@ #pragma once -#include "CDefHandler.h" -#include "GUIBase.h" -#include "../client/CBitmapHandler.h" -#include "CAnimation.h" +#include "../CDefHandler.h" +#include "../../client/CBitmapHandler.h" +#include "../CAnimation.h" /* * CCreatureAnimation.h, part of VCMI engine @@ -17,6 +16,7 @@ */ struct BMPPalette; +class CIntObject; /// Class which manages animations of creatures/units inside battles class CCreatureAnimation : public CIntObject diff --git a/client/BattleInterface/CDefenceAnimation.cpp b/client/BattleInterface/CDefenceAnimation.cpp index 4a342a2a1..0c32ec23c 100644 --- a/client/BattleInterface/CDefenceAnimation.cpp +++ b/client/BattleInterface/CDefenceAnimation.cpp @@ -3,7 +3,7 @@ #include "CBattleInterface.h" #include "../CGameInfo.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../CPlayerInterface.h" #include "../CMusicHandler.h" #include "../../lib/BattleState.h" diff --git a/client/BattleInterface/CMeleeAttackAnimation.cpp b/client/BattleInterface/CMeleeAttackAnimation.cpp index eb0717bf4..7116a6a63 100644 --- a/client/BattleInterface/CMeleeAttackAnimation.cpp +++ b/client/BattleInterface/CMeleeAttackAnimation.cpp @@ -2,7 +2,7 @@ #include "CMeleeAttackAnimation.h" #include "CBattleInterface.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../../lib/BattleState.h" #include "CReverseAnimation.h" @@ -40,18 +40,18 @@ bool CMeleeAttackAnimation::init() int revShiftattacker = (attackingStack->attackerOwned ? -1 : 1); - int mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn, dest); + int mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, dest); if(mutPos == -1 && attackingStack->doubleWide()) { - mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position); + mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position); } if (mutPos == -1 && attackedStack->doubleWide()) { - mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn, attackedStack->occupiedHex()); + mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, attackedStack->occupiedHex()); } if (mutPos == -1 && attackedStack->doubleWide() && attackingStack->doubleWide()) { - mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->occupiedHex()); + mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->occupiedHex()); } @@ -89,7 +89,7 @@ void CMeleeAttackAnimation::endAnim() delete this; } -CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, SHexField _dest, const CStack * _attacked) +CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked) : CAttackAnimation(_owner, attacker, _dest, _attacked) { } \ No newline at end of file diff --git a/client/BattleInterface/CMeleeAttackAnimation.h b/client/BattleInterface/CMeleeAttackAnimation.h index fe799aaae..3afd64872 100644 --- a/client/BattleInterface/CMeleeAttackAnimation.h +++ b/client/BattleInterface/CMeleeAttackAnimation.h @@ -24,5 +24,5 @@ public: void nextFrame(); void endAnim(); - CMeleeAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *_attacked); + CMeleeAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *_attacked); }; \ No newline at end of file diff --git a/client/BattleInterface/CMovementAnimation.cpp b/client/BattleInterface/CMovementAnimation.cpp index 636c15276..b86f0c503 100644 --- a/client/BattleInterface/CMovementAnimation.cpp +++ b/client/BattleInterface/CMovementAnimation.cpp @@ -2,13 +2,13 @@ #include "CMovementAnimation.h" #include "CBattleInterface.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../../lib/BattleState.h" #include "../CGameInfo.h" #include "../CMusicHandler.h" #include "CReverseAnimation.h" #include "CMovementEndAnimation.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" bool CMovementAnimation::init() { @@ -32,10 +32,10 @@ bool CMovementAnimation::init() } //bool twoTiles = movedStack->doubleWide(); - Point begPosition = CHexFieldControl::getXYUnitAnim(curStackPos, movedStack->attackerOwned, movedStack, owner); - Point endPosition = CHexFieldControl::getXYUnitAnim(nextHex, movedStack->attackerOwned, movedStack, owner); + SPoint begPosition = CClickableHex::getXYUnitAnim(curStackPos, movedStack->attackerOwned, movedStack, owner); + SPoint endPosition = CClickableHex::getXYUnitAnim(nextHex, movedStack->attackerOwned, movedStack, owner); - int mutPos = SHexField::mutualPosition(curStackPos, nextHex); + int mutPos = SBattleHex::mutualPosition(curStackPos, nextHex); //reverse unit if necessary if((begPosition.x > endPosition.x) && owner->creDir[stack->ID] == true) @@ -116,7 +116,7 @@ void CMovementAnimation::nextFrame() if(whichStep == steps) { // Sets the position of the creature animation sprites - Point coords = CHexFieldControl::getXYUnitAnim(nextHex, owner->creDir[stack->ID], stack, owner); + SPoint coords = CClickableHex::getXYUnitAnim(nextHex, owner->creDir[stack->ID], stack, owner); myAnim()->pos = coords; // true if creature haven't reached the final destination hex @@ -168,7 +168,7 @@ void CMovementAnimation::endAnim() delete this; } -CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector _destTiles, int _distance) +CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector _destTiles, int _distance) : CBattleStackAnimation(_owner, _stack), destTiles(_destTiles), nextPos(0), distance(_distance), stepX(0.0), stepY(0.0) { curStackPos = stack->position; diff --git a/client/BattleInterface/CMovementAnimation.h b/client/BattleInterface/CMovementAnimation.h index a288ff72f..3d7cba533 100644 --- a/client/BattleInterface/CMovementAnimation.h +++ b/client/BattleInterface/CMovementAnimation.h @@ -20,8 +20,8 @@ class CStack; class CMovementAnimation : public CBattleStackAnimation { private: - std::vector destTiles; //destination - SHexField nextHex; + std::vector destTiles; //destination + SBattleHex nextHex; ui32 nextPos; int distance; double stepX, stepY; //how far stack is moved in one frame @@ -33,5 +33,5 @@ public: void nextFrame(); void endAnim(); - CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector _destTiles, int _distance); + CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector _destTiles, int _distance); }; \ No newline at end of file diff --git a/client/BattleInterface/CMovementEndAnimation.cpp b/client/BattleInterface/CMovementEndAnimation.cpp index 4135a1dd7..fbc80ae2f 100644 --- a/client/BattleInterface/CMovementEndAnimation.cpp +++ b/client/BattleInterface/CMovementEndAnimation.cpp @@ -1,7 +1,7 @@ #include "StdInc.h" #include "CMovementEndAnimation.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../CMusicHandler.h" #include "../CGameInfo.h" #include "../../lib/BattleState.h" @@ -46,7 +46,7 @@ void CMovementEndAnimation::endAnim() delete this; } -CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SHexField destTile) +CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SBattleHex destTile) : CBattleStackAnimation(_owner, _stack), destinationTile(destTile) { } \ No newline at end of file diff --git a/client/BattleInterface/CMovementEndAnimation.h b/client/BattleInterface/CMovementEndAnimation.h index 0f90e4c6c..0db777d69 100644 --- a/client/BattleInterface/CMovementEndAnimation.h +++ b/client/BattleInterface/CMovementEndAnimation.h @@ -20,11 +20,11 @@ class CStack; class CMovementEndAnimation : public CBattleStackAnimation { private: - SHexField destinationTile; + SBattleHex destinationTile; public: bool init(); void nextFrame(); void endAnim(); - CMovementEndAnimation(CBattleInterface *_owner, const CStack *_stack, SHexField destTile); + CMovementEndAnimation(CBattleInterface *_owner, const CStack *_stack, SBattleHex destTile); }; \ No newline at end of file diff --git a/client/BattleInterface/CMovementStartAnimation.cpp b/client/BattleInterface/CMovementStartAnimation.cpp index 0785ef826..0a00db716 100644 --- a/client/BattleInterface/CMovementStartAnimation.cpp +++ b/client/BattleInterface/CMovementStartAnimation.cpp @@ -4,7 +4,7 @@ #include "../CMusicHandler.h" #include "CBattleInterface.h" #include "../CGameInfo.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../../lib/BattleState.h" #include "../CPlayerInterface.h" diff --git a/client/BattleInterface/CReverseAnimation.cpp b/client/BattleInterface/CReverseAnimation.cpp index 4486749af..951974e6e 100644 --- a/client/BattleInterface/CReverseAnimation.cpp +++ b/client/BattleInterface/CReverseAnimation.cpp @@ -1,10 +1,10 @@ #include "StdInc.h" #include "CReverseAnimation.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../../lib/BattleState.h" #include "CBattleInterface.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" bool CReverseAnimation::init() { @@ -58,7 +58,7 @@ void CReverseAnimation::endAnim() delete this; } -CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SHexField dest, bool _priority) +CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SBattleHex dest, bool _priority) : CBattleStackAnimation(_owner, stack), partOfAnim(1), secondPartSetup(false), hex(dest), priority(_priority) { } @@ -73,7 +73,7 @@ void CReverseAnimation::setupSecondPart() return; } - Point coords = CHexFieldControl::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner); + SPoint coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner); myAnim()->pos.x = coords.x; //creAnims[stackID]->pos.y = coords.second; diff --git a/client/BattleInterface/CReverseAnimation.h b/client/BattleInterface/CReverseAnimation.h index b786db0e1..dac230e0b 100644 --- a/client/BattleInterface/CReverseAnimation.h +++ b/client/BattleInterface/CReverseAnimation.h @@ -21,7 +21,7 @@ class CReverseAnimation : public CBattleStackAnimation private: int partOfAnim; //1 - first, 2 - second bool secondPartSetup; - SHexField hex; + SBattleHex hex; public: bool priority; //true - high, false - low bool init(); @@ -30,5 +30,5 @@ public: void setupSecondPart(); void endAnim(); - CReverseAnimation(CBattleInterface *_owner, const CStack *stack, SHexField dest, bool _priority); + CReverseAnimation(CBattleInterface *_owner, const CStack *stack, SBattleHex dest, bool _priority); }; \ No newline at end of file diff --git a/client/BattleInterface/CShootingAnimation.cpp b/client/BattleInterface/CShootingAnimation.cpp index b1fd22684..8f2f1c247 100644 --- a/client/BattleInterface/CShootingAnimation.cpp +++ b/client/BattleInterface/CShootingAnimation.cpp @@ -4,13 +4,13 @@ #include "../../lib/BattleState.h" #include "CBattleInterface.h" -#include "../CCreatureAnimation.h" +#include "CCreatureAnimation.h" #include "../CGameInfo.h" #include "../../lib/CTownHandler.h" #include "CMovementStartAnimation.h" #include "CReverseAnimation.h" #include "CSpellEffectAnimation.h" -#include "CHexFieldControl.h" +#include "CClickableHex.h" bool CShootingAnimation::init() { @@ -59,16 +59,16 @@ bool CShootingAnimation::init() spi.spin = false; } - Point xycoord = CHexFieldControl::getXYUnitAnim(shooter->position, true, shooter, owner); - Point destcoord; + SPoint xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner); + SPoint destcoord; // The "master" point where all projectile positions relate to. - static const Point projectileOrigin(181, 252); + static const SPoint projectileOrigin(181, 252); if (attackedStack) { - destcoord = CHexFieldControl::getXYUnitAnim(dest, false, attackedStack, owner); + destcoord = CClickableHex::getXYUnitAnim(dest, false, attackedStack, owner); destcoord.x += 250; destcoord.y += 210; //TODO: find a better place to shoot // Calculate projectile start position. Offsets are read out of the CRANIM.TXT. @@ -185,7 +185,7 @@ void CShootingAnimation::endAnim() delete this; } -CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, SHexField _dest, const CStack * _attacked, bool _catapult, int _catapultDmg) +CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked, bool _catapult, int _catapultDmg) : CAttackAnimation(_owner, attacker, _dest, _attacked), catapultDamage(_catapultDmg), catapult(_catapult) { diff --git a/client/BattleInterface/CShootingAnimation.h b/client/BattleInterface/CShootingAnimation.h index fa67563f3..a2f1890da 100644 --- a/client/BattleInterface/CShootingAnimation.h +++ b/client/BattleInterface/CShootingAnimation.h @@ -1,7 +1,7 @@ #pragma once #include "CAttackAnimation.h" -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" class CBattleInterface; class CStack; @@ -45,5 +45,5 @@ public: //last param only for catapult attacks CShootingAnimation(CBattleInterface *_owner, const CStack *attacker, - SHexField _dest, const CStack *_attacked, bool _catapult = false, int _catapultDmg = 0); + SBattleHex _dest, const CStack *_attacked, bool _catapult = false, int _catapultDmg = 0); }; \ No newline at end of file diff --git a/client/BattleInterface/CSpellEffectAnimation.cpp b/client/BattleInterface/CSpellEffectAnimation.cpp index f24e45d21..8e31b936d 100644 --- a/client/BattleInterface/CSpellEffectAnimation.cpp +++ b/client/BattleInterface/CSpellEffectAnimation.cpp @@ -8,6 +8,7 @@ #include "../../CCallback.h" #include "../../lib/BattleState.h" #include "../SDL_Extensions.h" +#include "../UIFramework/SRect.h" //effect animation bool CSpellEffectAnimation::init() @@ -67,7 +68,7 @@ bool CSpellEffectAnimation::init() if(effect == -1 || graphics->battleACToDef[effect].size() != 0) { const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false); - Rect &tilePos = owner->bfield[destTile].pos; + SRect &tilePos = owner->bfield[destTile].pos; SBattleEffect be; be.effectID = ID; if(customAnim.size()) @@ -170,7 +171,7 @@ void CSpellEffectAnimation::endAnim() delete this; } -CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, SHexField _destTile, int _dx, int _dy, bool _Vflip) +CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, SBattleHex _destTile, int _dx, int _dy, bool _Vflip) :CBattleAnimation(_owner), effect(_effect), destTile(_destTile), customAnim(""), dx(_dx), dy(_dy), Vflip(_Vflip) { } diff --git a/client/BattleInterface/CSpellEffectAnimation.h b/client/BattleInterface/CSpellEffectAnimation.h index 73af1a563..2528e5072 100644 --- a/client/BattleInterface/CSpellEffectAnimation.h +++ b/client/BattleInterface/CSpellEffectAnimation.h @@ -2,7 +2,7 @@ #include "CBattleAnimation.h" -#include "../../lib/SHexField.h" +#include "../../lib/SBattleHex.h" class CBattleInterface; @@ -21,7 +21,7 @@ class CSpellEffectAnimation : public CBattleAnimation { private: ui32 effect; - SHexField destTile; + SBattleHex destTile; std::string customAnim; int x, y, dx, dy; bool Vflip; @@ -30,6 +30,6 @@ public: void nextFrame(); void endAnim(); - CSpellEffectAnimation(CBattleInterface *_owner, ui32 _effect, SHexField _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false); + CSpellEffectAnimation(CBattleInterface *_owner, ui32 _effect, SBattleHex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false); CSpellEffectAnimation(CBattleInterface *_owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false); }; \ No newline at end of file diff --git a/client/BattleInterface/CStackQueue.cpp b/client/BattleInterface/CStackQueue.cpp index 6cda55472..4a6b07eeb 100644 --- a/client/BattleInterface/CStackQueue.cpp +++ b/client/BattleInterface/CStackQueue.cpp @@ -8,6 +8,7 @@ #include "../CPlayerInterface.h" #include "../CBitmapHandler.h" #include "../../CCallback.h" +#include "../UIFramework/CGuiHandler.h" void CStackQueue::update() { diff --git a/client/BattleInterface/CStackQueue.h b/client/BattleInterface/CStackQueue.h index 24f248a06..b4ff8ccae 100644 --- a/client/BattleInterface/CStackQueue.h +++ b/client/BattleInterface/CStackQueue.h @@ -1,6 +1,6 @@ #pragma once -#include "../GUIBase.h" +#include "../UIFramework/CIntObject.h" struct SDL_Surface; class CStack; diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 66e44e760..a2e562292 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -29,6 +29,7 @@ #include "CSoundBase.h" #include "../lib/CGameState.h" #include "CMusicHandler.h" +#include "UIFramework/CGuiHandler.h" #ifdef _MSC_VER #pragma warning (disable : 4355) @@ -142,7 +143,7 @@ void CMinimap::draw(SDL_Surface * to) rx = static_cast((tilesw / static_cast(mapSizes.x)) * pos.w), //width ry = static_cast((tilesh / static_cast(mapSizes.y)) * pos.h); //height - CSDL_Ext::drawDashedBorder(temps, Rect(bx, by, rx, ry), int3(255,75,125)); + CSDL_Ext::drawDashedBorder(temps, SRect(bx, by, rx, ry), int3(255,75,125)); //blitAt(radar,bx,by,temps); blitAt(temps,pos.x,pos.y,to); @@ -180,7 +181,7 @@ void CMinimapSurfacesRef::initMap(int level) SDL_FreeSurface(map[g]); } map.clear();*/ - const Rect &minimap_pos = adventureInt->minimap.pos; + const SRect &minimap_pos = adventureInt->minimap.pos; std::map &colors = adventureInt->minimap.colors; std::map &colorsBlocked = adventureInt->minimap.colorsBlocked; int3 mapSizes = LOCPLINT->cb->getMapSize(); @@ -220,7 +221,7 @@ void CMinimapSurfacesRef::initFoW(int level) } FoW.clear();*/ - const Rect &minimap_pos = adventureInt->minimap.pos; + const SRect &minimap_pos = adventureInt->minimap.pos; int3 mapSizes = LOCPLINT->cb->getMapSize(); int mw = map_[0]->w, mh = map_[0]->h;//, //wo = mw/mapSizes.x, ho = mh/mapSizes.y; //TODO use me @@ -252,7 +253,7 @@ void CMinimapSurfacesRef::initFlaggableObjs(int level) } flObjs.clear();*/ - const Rect &minimap_pos = adventureInt->minimap.pos; + const SRect &minimap_pos = adventureInt->minimap.pos; int3 mapSizes = LOCPLINT->cb->getMapSize(); int mw = map_[0]->w, mh = map_[0]->h; for(int d=0; dmh->map->twoLevel+1; ++d) @@ -629,25 +630,25 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to) { if (hvx<0 && hvy<0) { - Rect dstRect = genRect(32, 32, x + moveX, y + moveY); + SRect dstRect = genRect(32, 32, x + moveX, y + moveY); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect); } else if(hvx<0) { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } else if (hvy<0) { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } else { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } } @@ -655,25 +656,25 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to) { if (hvx<0 && hvy<0) { - Rect dstRect = genRect(32, 32, x, y); + SRect dstRect = genRect(32, 32, x, y); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect); } else if(hvx<0) { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } else if (hvy<0) { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } else { - Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); - Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y); + SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0); + SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y); CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect); } } @@ -1129,7 +1130,7 @@ void CAdvMapInt::fadventureOPtions() void CAdvMapInt::fsystemOptions() { - CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(Rect::createCentered(487, 481), LOCPLINT); + CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(SRect::createCentered(487, 481), LOCPLINT); GH.pushInt(sysopWindow); } @@ -1491,7 +1492,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key) int3(-1, -1, 0), int3(0, -1, 0), int3(+1, -1, 0) }; //numpad arrow - if(isArrowKey(SDLKey(k))) + if(CGuiHandler::isArrowKey(SDLKey(k))) { switch(k) { @@ -1509,7 +1510,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key) break; } - k = arrowToNum(SDLKey(k)); + k = CGuiHandler::arrowToNum(SDLKey(k)); } if(!isActive() || LOCPLINT->ctrlPressed())//ctrl makes arrow move screen, not hero diff --git a/client/CAnimation.cpp b/client/CAnimation.cpp index c5077c4cd..d36a444e5 100644 --- a/client/CAnimation.cpp +++ b/client/CAnimation.cpp @@ -39,7 +39,7 @@ public: inline void Load(size_t size, ui8 color=0); inline void EndLine(); //init image with these sizes and palette - inline void init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal); + inline void init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal); SDLImageLoader(SDLImage * Img); ~SDLImageLoader(); @@ -63,7 +63,7 @@ public: inline void Load(size_t size, ui8 color=0); inline void EndLine(); //init image with these sizes and palette - inline void init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal); + inline void init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal); CompImageLoader(CompImage * Img); ~CompImageLoader(); @@ -158,9 +158,9 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const ui32 currentOffset = sizeof(SSpriteDef); ui32 BaseOffset = sizeof(SSpriteDef); - loader.init(Point(sprite.width, sprite.height), - Point(sprite.leftMargin, sprite.topMargin), - Point(sprite.fullWidth, sprite.fullHeight), palette); + loader.init(SPoint(sprite.width, sprite.height), + SPoint(sprite.leftMargin, sprite.topMargin), + SPoint(sprite.fullWidth, sprite.fullHeight), palette); switch (sprite.format) { @@ -297,7 +297,7 @@ SDLImageLoader::SDLImageLoader(SDLImage * Img): { } -void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal) +void SDLImageLoader::init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal) { //Init image image->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SpriteSize.x, SpriteSize.y, 8, 0, 0, 0, 0); @@ -353,9 +353,9 @@ CompImageLoader::CompImageLoader(CompImage * Img): } -void CompImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal) +void CompImageLoader::init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal) { - image->sprite = Rect(Margins, SpriteSize); + image->sprite = SRect(Margins, SpriteSize); image->fullSize = FullSize; if (SpriteSize.x && SpriteSize.y) { @@ -588,17 +588,17 @@ SDLImage::SDLImage(std::string filename, bool compressed): } } -void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotation) const +void SDLImage::draw(SDL_Surface *where, int posX, int posY, SRect *src, ui8 rotation) const { if (!surf) return; - Rect sourceRect(margins.x, margins.y, surf->w, surf->h); + SRect sourceRect(margins.x, margins.y, surf->w, surf->h); //TODO: rotation and scaling if (src) { sourceRect = sourceRect & *src; } - Rect destRect(posX, posY, surf->w, surf->h); + SRect destRect(posX, posY, surf->w, surf->h); destRect += sourceRect.topLeft(); sourceRect -= margins; CSDL_Ext::blitSurface(surf, &sourceRect, where, &destRect); @@ -640,22 +640,22 @@ CompImage::CompImage(SDL_Surface * surf) assert(0); } -void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha) const +void CompImage::draw(SDL_Surface *where, int posX, int posY, SRect *src, ui8 alpha) const { int rotation = 0; //TODO //rotation & 2 = horizontal rotation //rotation & 4 = vertical rotation if (!surf) return; - Rect sourceRect(sprite); + SRect sourceRect(sprite); //TODO: rotation and scaling if (src) sourceRect = sourceRect & *src; //Limit source rect to sizes of surface - sourceRect = sourceRect & Rect(0, 0, where->w, where->h); + sourceRect = sourceRect & SRect(0, 0, where->w, where->h); //Starting point on SDL surface - Point dest(posX+sourceRect.x, posY+sourceRect.y); + SPoint dest(posX+sourceRect.x, posY+sourceRect.y); if (rotation & 2) dest.y += sourceRect.h; if (rotation & 4) @@ -1309,7 +1309,7 @@ void CShowableAnim::showAll(SDL_Surface *to) void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to) { assert(to); - Rect src( xOffset, yOffset, pos.w, pos.h); + SRect src( xOffset, yOffset, pos.w, pos.h); IImage * img = anim.getImage(frame, group); if (img) img->draw(to, pos.x-xOffset, pos.y-yOffset, &src, alpha); @@ -1324,7 +1324,7 @@ void CShowableAnim::rotate(bool on, bool vertical) flags &= ~flag; } -CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, ui8 flags, EAnimType type): +CCreatureAnim::CCreatureAnim(int x, int y, std::string name, SRect picPos, ui8 flags, EAnimType type): CShowableAnim(x,y,name,flags,3,type) { xOffset = picPos.x; diff --git a/client/CAnimation.h b/client/CAnimation.h index e17291137..86002fa65 100644 --- a/client/CAnimation.h +++ b/client/CAnimation.h @@ -1,7 +1,6 @@ #pragma once - -#include "GUIBase.h" +#include "UIFramework/CIntObject.h" /* * CAnimation.h, part of VCMI engine @@ -61,7 +60,7 @@ class IImage public: //draws image on surface "where" at position - virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const=0; + virtual void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const=0; //decrease ref count, returns true if image can be deleted (refCount <= 0) bool decreaseRef(); @@ -84,9 +83,9 @@ public: //Surface without empty borders SDL_Surface * surf; //size of left and top borders - Point margins; + SPoint margins; //total size including borders - Point fullSize; + SPoint fullSize; public: //Load image from def file @@ -97,7 +96,7 @@ public: SDLImage(SDL_Surface * from, bool extraRef); ~SDLImage(); - void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const; + void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const; void playerColored(int player); int width() const; int height() const; @@ -120,9 +119,9 @@ public: class CompImage : public IImage { //x,y - margins, w,h - sprite size - Rect sprite; + SRect sprite; //total size including borders - Point fullSize; + SPoint fullSize; //RLE-d data ui8 * surf; @@ -143,7 +142,7 @@ public: CompImage(SDL_Surface * surf); ~CompImage(); - void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const; + void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const; void playerColored(int player); int width() const; int height() const; @@ -367,7 +366,7 @@ public: //clear queue and set animation to this sequence void clearAndSet(EAnimType type); - CCreatureAnim(int x, int y, std::string name, Rect picPos, + CCreatureAnim(int x, int y, std::string name, SRect picPos, ui8 flags= USE_RLE, EAnimType = HOLDING ); }; diff --git a/client/CCastleInterface.cpp b/client/CCastleInterface.cpp index 8ae467671..cd865bd1e 100644 --- a/client/CCastleInterface.cpp +++ b/client/CCastleInterface.cpp @@ -22,6 +22,7 @@ #include "Graphics.h" #include "SDL_Extensions.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" using namespace boost::assign; @@ -255,7 +256,7 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc background->colorize(LOCPLINT->playerID); pos.w = background->pos.w; pos.h = background->pos.h; - moveTo(Point(centerX - pos.w/2, centerY - pos.h/2)); + moveTo(SPoint(centerX - pos.w/2, centerY - pos.h/2)); const CCreature * creature = CGI->creh->creatures[Town->creatures[level].second.back()]; @@ -279,8 +280,8 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc int posX = pos.w/2 - resAmount.size() * 25 + 5; for (size_t i=0; imoveBy(Point(posX, posY)); - resAmount[i]->moveBy(Point(posX+16, posY+43)); + resPicture[i]->moveBy(SPoint(posX, posY)); + resAmount[i]->moveBy(SPoint(posX+16, posY+43)); posX += 50; } } @@ -927,8 +928,8 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos): pos.h = builds->pos.h + panel->pos.h; center(); - garr = new CGarrisonInt(305, 387, 4, Point(0,96), panel->bg, Point(62,374), town->getUpperArmy(), town->visitingHero); - heroes = new HeroSlots(town, Point(241, 387), Point(241, 483), garr, true); + garr = new CGarrisonInt(305, 387, 4, SPoint(0,96), panel->bg, SPoint(62,374), town->getUpperArmy(), town->visitingHero); + heroes = new HeroSlots(town, SPoint(241, 387), SPoint(241, 483), garr, true); title = new CLabel(85, 387, FONT_MEDIUM, TOPLEFT, zwykly, town->name); income = new CLabel(195, 443, FONT_SMALL, CENTER); icon = new CAnimImage("ITPT", 0, 0, 15, 387); @@ -942,7 +943,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos): removeChild(split); garr->addSplitBtn(split); - Rect barRect(9, 182, 732, 18); + SRect barRect(9, 182, 732, 18); statusbar = new CGStatusBar(new CPicture(*panel, barRect, 9, 555, false)); resdatabar = new CResDataBar("ZRESBAR", 3, 575, 32, 2, 85, 85); @@ -1044,13 +1045,13 @@ void CCastleInterface::recreateIcons() creainfo.clear(); for (size_t i=0; i<4; i++) - creainfo.push_back(new CCreaInfo(Point(14+55*i, 459), town, i)); + creainfo.push_back(new CCreaInfo(SPoint(14+55*i, 459), town, i)); for (size_t i=0; i<4; i++) - creainfo.push_back(new CCreaInfo(Point(14+55*i, 507), town, i+4)); + creainfo.push_back(new CCreaInfo(SPoint(14+55*i, 507), town, i+4)); } -CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool compact, bool ShowAvailable): +CCreaInfo::CCreaInfo(SPoint position, const CGTownInstance *Town, int Level, bool compact, bool ShowAvailable): town(Town), level(Level), showAvailable(ShowAvailable) @@ -1262,7 +1263,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key ) } } -HeroSlots::HeroSlots(const CGTownInstance * Town, Point garrPos, Point visitPos, CGarrisonInt *Garrison, bool ShowEmpty): +HeroSlots::HeroSlots(const CGTownInstance * Town, SPoint garrPos, SPoint visitPos, CGarrisonInt *Garrison, bool ShowEmpty): showEmpty(ShowEmpty), town(Town), garr(Garrison) @@ -1350,7 +1351,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town): resdatabar = new CMinorResDataBar; resdatabar->pos.x += pos.x; resdatabar->pos.y += pos.y; - Rect barRect(5, 556, 740, 18); + SRect barRect(5, 556, 740, 18); statusBar = new CGStatusBar(new CPicture(*background, barRect, 5, 556, false)); title = new CLabel(399, 12, FONT_MEDIUM, CENTER, zwykly, CGI->buildh->buildings[town->subID][town->hallLevel()+EBuilding::VILLAGE_HALL]->Name()); @@ -1453,13 +1454,13 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin background->colorize(LOCPLINT->playerID); buildingPic = new CAnimImage(graphics->buildingPics[town->subID], building->bid, 0, 125, 50); - Rect barRect(9, 494, 380, 18); + SRect barRect(9, 494, 380, 18); statusBar = new CGStatusBar(new CPicture(*background, barRect, 9, 494, false)); title = new CLabel(197, 30, FONT_MEDIUM, CENTER, zwykly, boost::str(boost::format(CGI->generaltexth->hcommands[7]) % building->Name())); - buildingDescr = new CTextBox(building->Description(), Rect(33, 135, 329, 67), 0, FONT_MEDIUM, CENTER); - buildingState = new CTextBox(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, CENTER); + buildingDescr = new CTextBox(building->Description(), SRect(33, 135, 329, 67), 0, FONT_MEDIUM, CENTER); + buildingState = new CTextBox(getTextForState(state), SRect(33, 216, 329, 67), 0, FONT_SMALL, CENTER); //Create objects for all required resources for(int i = 0; imoveBy(Point(posX, posY)); - resAmount[index]->moveBy(Point(posX+16, posY+48)); + resPicture[index]->moveBy(SPoint(posX, posY)); + resAmount[index]->moveBy(SPoint(posX+16, posY+48)); posX += 80; index++; } @@ -1543,15 +1544,15 @@ CFortScreen::CFortScreen(const CGTownInstance * town) std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name()); exit = new AdventureMapButton(text, "", boost::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN); - std::vector positions; - positions += Point(10, 22), Point(404, 22), - Point(10, 155), Point(404,155), - Point(10, 288), Point(404,288); + std::vector positions; + positions += SPoint(10, 22), SPoint(404, 22), + SPoint(10, 155), SPoint(404,155), + SPoint(10, 288), SPoint(404,288); if (fortSize == GameConstants::CREATURES_PER_TOWN) - positions += Point(206,421); + positions += SPoint(206,421); else - positions += Point(10, 421), Point(404,421); + positions += SPoint(10, 421), SPoint(404,421); for (ui32 i=0; ipos.x += pos.x; resdatabar->pos.y += pos.y; - Rect barRect(4, 554, 740, 18); + SRect barRect(4, 554, 740, 18); statusBar = new CGStatusBar(new CPicture(*background, barRect, 4, 554, false)); } @@ -1582,7 +1583,7 @@ void CFortScreen::creaturesChanged() recAreas[i]->creaturesChanged(); } -LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int min, int max) +LabeledValue::LabeledValue(SRect size, std::string name, std::string descr, int min, int max) { pos.x+=size.x; pos.y+=size.y; @@ -1591,7 +1592,7 @@ LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int m init(name, descr, min, max); } -LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int val) +LabeledValue::LabeledValue(SRect size, std::string name, std::string descr, int val) { pos.x+=size.x; pos.y+=size.y; @@ -1654,7 +1655,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance * hoverText = boost::str(boost::format(CGI->generaltexth->tcommands[21]) % creature->namePl); creatureAnim = new CCreaturePic(159, 4, creature, false); - Rect sizes(287, 4, 96, 18); + SRect sizes(287, 4, 96, 18); values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], creature->attack)); sizes.y+=20; values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[191], CGI->generaltexth->fcommands[1], creature->defence)); @@ -1718,20 +1719,20 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner) resdatabar = new CMinorResDataBar; resdatabar->pos.x += pos.x; resdatabar->pos.y += pos.y; - Rect barRect(7, 556, 737, 18); + SRect barRect(7, 556, 737, 18); statusBar = new CGStatusBar(new CPicture(*background, barRect, 7, 556, false)); exit = new AdventureMapButton(CGI->generaltexth->allTexts[593],"",boost::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN); exit->assignedKeys.insert(SDLK_ESCAPE); - std::vector > positions; + std::vector > positions; positions.resize(5); - positions[0] += Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445); - positions[1] += Point(48,53), Point(48,147), Point(48,241), Point(48,335), Point(48,429); - positions[2] += Point(570,82), Point(672,82), Point(570,157), Point(672,157); - positions[3] += Point(183,42), Point(183,148), Point(183,253); - positions[4] += Point(491,325), Point(591,325); + positions[0] += SPoint(222,445), SPoint(312,445), SPoint(402,445), SPoint(520,445), SPoint(610,445), SPoint(700,445); + positions[1] += SPoint(48,53), SPoint(48,147), SPoint(48,241), SPoint(48,335), SPoint(48,429); + positions[2] += SPoint(570,82), SPoint(672,82), SPoint(570,157), SPoint(672,157); + positions[3] += SPoint(183,42), SPoint(183,148), SPoint(183,253); + positions[4] += SPoint(491,325), SPoint(591,325); for(size_t i=0; itown->town->mageLevel; i++) { @@ -1751,7 +1752,7 @@ void CMageGuildScreen::close() GH.popIntTotally(this); } -CMageGuildScreen::Scroll::Scroll(Point position, const CSpell *Spell) +CMageGuildScreen::Scroll::Scroll(SPoint position, const CSpell *Spell) :spell(Spell) { OBJ_CONSTRUCTION_CAPTURING_ALL; @@ -1810,7 +1811,7 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, int aid, i animBG->needRefresh = true; const CCreature *creature = CGI->creh->creatures[creMachineID]; - anim = new CCreatureAnim(64, 50, creature->animDefName, Rect()); + anim = new CCreatureAnim(64, 50, creature->animDefName, SRect()); anim->clipRect(113,125,200,150); title = new CLabel(165, 28, FONT_BIG, CENTER, tytulowy, diff --git a/client/CCastleInterface.h b/client/CCastleInterface.h index e5a80045c..f9d71d7d4 100644 --- a/client/CCastleInterface.h +++ b/client/CCastleInterface.h @@ -2,7 +2,7 @@ #include "CAnimation.h" -#include "GUIBase.h" +#include "GUIClasses.h" class AdventureMapButton; class CBuilding; @@ -19,6 +19,9 @@ class CStatusBar; class CTextBox; class CTownList; struct Structure; +class CGHeroInstance; +class CGarrisonInt; +class CCreature; /* * CCastleInterface.h, part of VCMI engine @@ -101,7 +104,7 @@ public: CHeroGSlot * garrisonedHero; CHeroGSlot * visitingHero; - HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, CGarrisonInt *Garrison, bool ShowEmpty); + HeroSlots(const CGTownInstance * town, SPoint garrPos, SPoint visitPos, CGarrisonInt *Garrison, bool ShowEmpty); void splitClicked(); //for hero meeting only (splitting stacks is handled by garrison int) void update(); @@ -162,7 +165,7 @@ class CCreaInfo : public CIntObject std::string genGrowthText(); public: - CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool compact=false, bool showAvailable=false); + CCreaInfo(SPoint position, const CGTownInstance *Town, int Level, bool compact=false, bool showAvailable=false); void update(); void hover(bool on); @@ -301,8 +304,8 @@ class LabeledValue : public CIntObject void init(std::string name, std::string descr, int min, int max); public: - LabeledValue(Rect size, std::string name, std::string descr, int min, int max); - LabeledValue(Rect size, std::string name, std::string descr, int val); + LabeledValue(SRect size, std::string name, std::string descr, int min, int max); + LabeledValue(SRect size, std::string name, std::string descr, int val); void hover(bool on); }; @@ -356,7 +359,7 @@ class CMageGuildScreen : public CIntObject CAnimImage *image; public: - Scroll(Point position, const CSpell *Spell); + Scroll(SPoint position, const CSpell *Spell); void clickLeft(tribool down, bool previousState); void clickRight(tribool down, bool previousState); void hover(bool on); diff --git a/client/CCreatureWindow.cpp b/client/CCreatureWindow.cpp index 7a83b02bc..fd4308814 100644 --- a/client/CCreatureWindow.cpp +++ b/client/CCreatureWindow.cpp @@ -20,6 +20,8 @@ #include "../lib/BattleState.h" #include "../lib/CSpellHandler.h" +#include "UIFramework/CGuiHandler.h" + using namespace CSDL_Ext; class CBonusItem; @@ -242,7 +244,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * number = (stack->count * (expmax - expmin)) / expmin; boost::replace_first (expText, "%i", boost::lexical_cast(number)); //Maximum New Recruits to remain at Rank 10 if at Maximum Experience - expArea = new LRClickableAreaWTextComp(Rect(334, 49, 160, 44),SComponent::experience); + expArea = new LRClickableAreaWTextComp(SRect(334, 49, 160, 44),SComponent::experience); expArea->text = expText; expArea->bonusValue = 0; //TDO: some specific value or no number at all } @@ -276,7 +278,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * int duration = battleStack->getBonus(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain; boost::replace_first (spellText, "%d", boost::lexical_cast(duration)); blitAt(graphics->spellEffectsPics->ourImages[effect + 1].bitmap, 20 + 52 * printed, 184, *bitmap); - spellEffects.push_back(new LRClickableAreaWText(Rect(20 + 52 * printed, 184, 50, 38), spellText, spellText)); + spellEffects.push_back(new LRClickableAreaWText(SRect(20 + 52 * printed, 184, 50, 38), spellText, spellText)); if (++printed >= 10) //we can fit only 10 effects break; } @@ -327,7 +329,7 @@ void CCreatureWindow::recreateSkillList(int Pos) int offsetx = 257*j - (bonusRows == 4 ? 1 : 0); int offsety = 60*i + (bonusRows > 1 ? 1 : 0); //lack of precision :/ - bonusItems[n]->moveTo (Point(pos.x + offsetx + 10, pos.y + offsety + 230), true); + bonusItems[n]->moveTo (SPoint(pos.x + offsetx + 10, pos.y + offsety + 230), true); bonusItems[n]->visible = true; if (++j > 1) //next line @@ -426,7 +428,7 @@ CBonusItem::CBonusItem() } -CBonusItem::CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName) +CBonusItem::CBonusItem(const SRect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName) { OBJ_CONSTRUCTION; visible = false; diff --git a/client/CCreatureWindow.h b/client/CCreatureWindow.h index 9358d79b0..3c752f53c 100644 --- a/client/CCreatureWindow.h +++ b/client/CCreatureWindow.h @@ -1,7 +1,6 @@ #pragma once -#include "GUIBase.h" #include "GUIClasses.h" #include "../lib/HeroBonus.h" @@ -79,7 +78,7 @@ public: bool visible; CBonusItem(); - CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName); + CBonusItem(const SRect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName); ~CBonusItem(); void setBonus (const Bonus &bonus); diff --git a/client/CHeroWindow.cpp b/client/CHeroWindow.cpp index 778acfefe..4ddda141c 100644 --- a/client/CHeroWindow.cpp +++ b/client/CHeroWindow.cpp @@ -22,6 +22,8 @@ #include "../lib/CLodHandler.h" #include "../lib/CObjectHandler.h" +#include "UIFramework/CGuiHandler.h" + #undef min /* @@ -82,7 +84,7 @@ CHeroWindow * CHeroSwitcher::getOwner() CHeroSwitcher::CHeroSwitcher(int serial) { - pos = Rect(612, 87 + serial * 54, 48, 32) + pos; + pos = SRect(612, 87 + serial * 54, 48, 32) + pos; id = serial; used = LCLICK; } @@ -122,26 +124,26 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero) flags = CDefHandler::giveDefEss("CREST58.DEF"); //areas - portraitArea = new LRClickableAreaWText(Rect(18, 18, 58, 64)); + portraitArea = new LRClickableAreaWText(SRect(18, 18, 58, 64)); for(int v=0; vtext = CGI->generaltexth->arraytxt[2+v]; area->type = v; area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]); primSkillAreas.push_back(area); } - specArea = new LRClickableAreaWText(Rect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]); - expArea = new LRClickableAreaWText(Rect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]); - morale = new MoraleLuckBox(true, Rect(175,179,53,45)); - luck = new MoraleLuckBox(false, Rect(233,179,53,45)); - spellPointsArea = new LRClickableAreaWText(Rect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]); + specArea = new LRClickableAreaWText(SRect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]); + expArea = new LRClickableAreaWText(SRect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]); + morale = new MoraleLuckBox(true, SRect(175,179,53,45)); + luck = new MoraleLuckBox(false, SRect(233,179,53,45)); + spellPointsArea = new LRClickableAreaWText(SRect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]); for(int i = 0; i < std::min(hero->secSkills.size(), 8u); ++i) { - Rect r = Rect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42); + SRect r = SRect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42); secSkillAreas.push_back(new LRClickableAreaWTextComp(r, SComponent::secskill)); } @@ -195,7 +197,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals OBJ_CONSTRUCTION_CAPTURING_ALL; if(!garr) { - garr = new CGarrisonInt(15, 485, 8, Point(), background->bg, Point(15,485), curHero); + garr = new CGarrisonInt(15, 485, 8, SPoint(), background->bg, SPoint(15,485), curHero); { BLOCK_CAPTURING; split = new AdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::bind(&CGarrisonInt::splitClick,garr), pos.x + 539, pos.y + 519, "hsbtns9.def", false, NULL, false); //deleted by garrison destructor @@ -205,7 +207,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals } if(!artSets.size()) { - CArtifactsOfHero *arts = new CArtifactsOfHero(Point(-65, -8), true); + CArtifactsOfHero *arts = new CArtifactsOfHero(SPoint(-65, -8), true); arts->setHero(curHero); artSets.push_back(arts); } @@ -243,7 +245,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals //if we have exchange window with this curHero open bool noDismiss=false; - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { if(CExchangeWindow * cew = dynamic_cast(isa)) for(int g=0; g < ARRAY_COUNT(cew->heroInst); ++g) diff --git a/client/CKingdomInterface.cpp b/client/CKingdomInterface.cpp index d9f21225b..d088d3171 100644 --- a/client/CKingdomInterface.cpp +++ b/client/CKingdomInterface.cpp @@ -13,6 +13,7 @@ #include "CConfigHandler.h" #include "CGameInfo.h" #include "CPlayerInterface.h" //LOCPLINT +#include "UIFramework/CGuiHandler.h" /* * CKingdomInterface.cpp, part of VCMI engine @@ -26,7 +27,7 @@ extern SDL_Surface *screenBuf; -InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data): +InfoBox::InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data): size(Size), infoPos(Pos), data(Data), @@ -469,7 +470,7 @@ CKingdomInterface::CKingdomInterface() pos = background->center(); ui32 footerPos = conf.go()->ac.overviewSize * 116; - tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4)); + tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), SPoint(4,4)); std::vector ownedObjects = LOCPLINT->cb->getMyObjects(); generateObjectsList(ownedObjects); @@ -530,7 +531,7 @@ void CKingdomInterface::generateObjectsList(const std::vector(obj.count); - return new InfoBox(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL, + return new InfoBox(SPoint(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL, new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText)); } return NULL; @@ -593,11 +594,11 @@ void CKingdomInterface::generateMinesList(const std::vector(minesCount[i]); - minesBox[i] = new InfoBox(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL, + minesBox[i] = new InfoBox(SPoint(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL, new InfoBoxCustom(value, "", "OVMINES", i, CGI->generaltexth->mines[i].first)); } incomeArea = new HoverableArea; - incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68); + incomeArea->pos = SRect(pos.x+580, pos.y+31+footerPos, 136, 68); incomeArea->hoverText = CGI->generaltexth->allTexts[255]; incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, zwykly, boost::lexical_cast(totalIncome)); } @@ -690,7 +691,7 @@ CKingdHeroList::CKingdHeroList(size_t maxSize) ui32 townCount = LOCPLINT->cb->howManyHeroes(false); ui32 size = conf.go()->ac.overviewSize*116 + 19; heroes = new CListBox(boost::bind(&CKingdHeroList::createHeroItem, this, _1), boost::bind(&CKingdHeroList::destroyHeroItem, this, _1), - Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) ); + SPoint(19,21), SPoint(0,116), maxSize, townCount, 0, 1, SRect(-19, -21, size, size) ); } void CKingdHeroList::updateGarrisons() @@ -743,7 +744,7 @@ CKingdTownList::CKingdTownList(size_t maxSize) ui32 townCount = LOCPLINT->cb->howManyTowns(); ui32 size = conf.go()->ac.overviewSize*116 + 19; towns = new CListBox(boost::bind(&CKingdTownList::createTownItem, this, _1), CListBox::DestroyFunc(), - Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) ); + SPoint(19,21), SPoint(0,116), maxSize, townCount, 0, 1, SRect(-19, -21, size, size) ); } void CKingdTownList::townChanged(const CGTownInstance *town) @@ -789,8 +790,8 @@ CTownItem::CTownItem(const CGTownInstance* Town): hall = new CTownInfo( 69, 31, town, true); fort = new CTownInfo(111, 31, town, false); - garr = new CGarrisonInt(313, 3, 4, Point(232,0), NULL, Point(313,2), town->getUpperArmy(), town->visitingHero, true, true, true); - heroes = new HeroSlots(town, Point(244,6), Point(475,6), garr, false); + garr = new CGarrisonInt(313, 3, 4, SPoint(232,0), NULL, SPoint(313,2), town->getUpperArmy(), town->visitingHero, true, true, true); + heroes = new HeroSlots(town, SPoint(244,6), SPoint(475,6), garr, false); size_t iconIndex = town->subID*2; if (!town->hasFort()) @@ -801,13 +802,13 @@ CTownItem::CTownItem(const CGTownInstance* Town): picture = new CAnimImage("ITPT", iconIndex, 0, 5, 6); townArea = new LRClickableAreaOpenTown; - townArea->pos = Rect(pos.x+5, pos.y+6, 58, 64); + townArea->pos = SRect(pos.x+5, pos.y+6, 58, 64); townArea->town = town; for (size_t i=0; icreatures.size(); i++) { - growth.push_back(new CCreaInfo(Point(401+37*i, 78), town, i, true, true)); - available.push_back(new CCreaInfo(Point(48+37*i, 78), town, i, true, false)); + growth.push_back(new CCreaInfo(SPoint(401+37*i, 78), town, i, true, true)); + available.push_back(new CCreaInfo(SPoint(48+37*i, 78), town, i, true, false)); } } @@ -846,7 +847,7 @@ public: background = new CAnimImage("OVSLOT", 4); pos = background->pos; for (size_t i=0; i<9; i++) - arts.push_back(new CArtPlace(Point(270+i*48, 65))); + arts.push_back(new CArtPlace(SPoint(270+i*48, 65))); } }; @@ -866,7 +867,7 @@ public: btnLeft = new AdventureMapButton(std::string(), std::string(), CFunctionList(), 269, 66, "HSBTNS3"); btnRight = new AdventureMapButton(std::string(), std::string(), CFunctionList(), 675, 66, "HSBTNS5"); for (size_t i=0; i<8; i++) - arts.push_back(new CArtPlace(Point(295+i*48, 65))); + arts.push_back(new CArtPlace(SPoint(295+i*48, 65))); } }; @@ -916,7 +917,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart * artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1); artButtons->select(0,0); - garr = new CGarrisonInt(6, 78, 4, Point(), NULL, Point(), hero, NULL, true, true); + garr = new CGarrisonInt(6, 78, 4, SPoint(), NULL, SPoint(), hero, NULL, true, true); portrait = new CAnimImage("PortraitsLarge", hero->subID, 0, 5, 6); heroArea = new CHeroArea(5, 6, hero); @@ -925,24 +926,24 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart * artsText = new CLabel(320, 55, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->overview[2]); for (size_t i=0; iset(hero); luck->set(hero); diff --git a/client/CKingdomInterface.h b/client/CKingdomInterface.h index 178673d31..5f689d690 100644 --- a/client/CKingdomInterface.h +++ b/client/CKingdomInterface.h @@ -1,7 +1,6 @@ #pragma once -#include "GUIBase.h" #include "GUIClasses.h" class AdventureMapButton; @@ -65,7 +64,7 @@ private: HoverableArea *hover; public: - InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data); + InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data); ~InfoBox(); void clickRight(tribool down, bool previousState); diff --git a/client/CMT.cpp b/client/CMT.cpp index 5f4a9871c..6b4a361ae 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -38,6 +38,7 @@ #include "../lib/CArtHandler.h" #include "../lib/CScriptingModule.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" #ifdef _WIN32 #include "SDL_syswm.h" @@ -95,7 +96,7 @@ void startGame(StartInfo * options, CConnection *serv = NULL); void init() { - StopWatch tmh, pomtime; + CStopWatch tmh, pomtime; #if SDL_BYTEORDER == SDL_BIG_ENDIAN int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff; #else @@ -220,7 +221,7 @@ int main(int argc, char** argv) putenv((char*)"SDL_VIDEO_WINDOW_POS"); putenv((char*)"SDL_VIDEO_CENTERED=1"); - StopWatch total, pomtime; + CStopWatch total, pomtime; std::cout.flags(std::ios::unitbuf); logfile = new std::ofstream((GVCMIDirs.UserPath + "/VCMI_Client_log.txt").c_str()); console = new CConsoleHandler; @@ -479,7 +480,7 @@ void processCommand(const std::string &message) } else if(cn == "gui") { - BOOST_FOREACH(const IShowActivable *child, GH.listInt) + BOOST_FOREACH(const IShowActivatable *child, GH.listInt) { if(const CIntObject *obj = dynamic_cast(child)) printInfoAboutIntObject(obj, 0); diff --git a/client/CMessage.cpp b/client/CMessage.cpp index e479fc02c..24e3a9863 100644 --- a/client/CMessage.cpp +++ b/client/CMessage.cpp @@ -106,8 +106,8 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for { for (int j=0; jh) { - Rect srcR(0,0,background->w, background->h); - Rect dstR(i,j,w,h); + SRect srcR(0,0,background->w, background->h); + SRect dstR(i,j,w,h); CSDL_Ext::blitSurface(background, &srcR, ret, &dstR); } } @@ -446,7 +446,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player) curh = (ret->bitmap->h - ret->text->pos.h)/2; } - ret->text->moveBy(Point(xOffset, curh)); + ret->text->moveBy(SPoint(xOffset, curh)); curh += ret->text->pos.h; @@ -463,7 +463,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player) for(size_t i=0; ibuttons.size(); i++) { - ret->buttons[i]->moveBy(Point(bw, curh)); + ret->buttons[i]->moveBy(SPoint(bw, curh)); bw += ret->buttons[i]->pos.w + 20; } } @@ -493,8 +493,8 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int cur_w = box[6]->w; // Top border - Rect srcR(0, 0, cur_w, box[6]->h); - Rect dstR(start_x, y, 0, 0); + SRect srcR(0, 0, cur_w, box[6]->h); + SRect dstR(start_x, y, 0, 0); CSDL_Ext::blitSurface(box[6], &srcR, ret, &dstR); // Bottom border @@ -514,8 +514,8 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int cur_h = box[4]->h; // Left border - Rect srcR(0, 0, box[4]->w, cur_h); - Rect dstR(x, start_y, 0, 0); + SRect srcR(0, 0, box[4]->w, cur_h); + SRect dstR(x, start_y, 0, 0); CSDL_Ext::blitSurface(box[4], &srcR, ret, &dstR); // Right border @@ -526,16 +526,16 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int } //corners - Rect dstR(x, y, box[0]->w, box[0]->h); + SRect dstR(x, y, box[0]->w, box[0]->h); CSDL_Ext::blitSurface(box[0], NULL, ret, &dstR); - dstR=Rect(x+w-box[1]->w, y, box[1]->w, box[1]->h); + dstR=SRect(x+w-box[1]->w, y, box[1]->w, box[1]->h); CSDL_Ext::blitSurface(box[1], NULL, ret, &dstR); - dstR=Rect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h); + dstR=SRect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h); CSDL_Ext::blitSurface(box[2], NULL, ret, &dstR); - dstR=Rect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h); + dstR=SRect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h); CSDL_Ext::blitSurface(box[3], NULL, ret, &dstR); } diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index b34c91c99..31630cc94 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -15,7 +15,7 @@ #include "SDL_Extensions.h" #include "SDL_framerate.h" #include "CConfigHandler.h" -#include "CCreatureAnimation.h" +#include "BattleInterface/CCreatureAnimation.h" #include "Graphics.h" #include "../lib/CArtHandler.h" #include "../lib/CGeneralTextHandler.h" @@ -32,10 +32,11 @@ #include "../lib/map.h" #include "../lib/VCMIDirs.h" #include "mapHandler.h" -#include "../lib/StopWatch.h" +#include "../lib/CStopWatch.h" #include "../lib/StartInfo.h" #include "../lib/CGameState.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" #ifdef min #undef min @@ -482,7 +483,7 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town) c->garr->recreateSlots(); c->heroes->update(); } - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { CKingdomInterface *ki = dynamic_cast(isa); if (ki) @@ -508,9 +509,9 @@ void CPlayerInterface::garrisonChanged( const CGObjectInstance * obj, bool updat if(updateInfobox) updateInfo(obj); - for(std::list::iterator i = GH.listInt.begin(); i != GH.listInt.end(); i++) + for(std::list::iterator i = GH.listInt.begin(); i != GH.listInt.end(); i++) { - if((*i)->type & IShowActivable::WITH_GARRISON) + if((*i)->type & IShowActivatable::WITH_GARRISON) { CGarrisonHolder *cgh = dynamic_cast(*i); cgh->updateGarrisons(); @@ -755,7 +756,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br) battleInt->battleFinished(*br); } -void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector dest, int distance) { if(LOCPLINT != this) { //another local interface should do this @@ -873,10 +874,10 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba) else { int shift = 0; - if(ba->counter() && SHexField::mutualPosition(curAction->destinationTile, attacker->position) < 0) + if(ba->counter() && SBattleHex::mutualPosition(curAction->destinationTile, attacker->position) < 0) { - int distp = SHexField::getDistance(curAction->destinationTile + 1, attacker->position); - int distm = SHexField::getDistance(curAction->destinationTile - 1, attacker->position); + int distp = SBattleHex::getDistance(curAction->destinationTile + 1, attacker->position); + int distm = SBattleHex::getDistance(curAction->destinationTile - 1, attacker->position); if( distp < distm ) shift = 1; @@ -1052,7 +1053,7 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town ) if(fs) fs->creaturesChanged(); - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { CKingdomInterface *ki = dynamic_cast(isa); if (ki && townObj) @@ -2339,9 +2340,9 @@ void CPlayerInterface::artifactPut(const ArtifactLocation &al) void CPlayerInterface::artifactRemoved(const ArtifactLocation &al) { boost::unique_lock un(*pim); - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { - if(isa->type & IShowActivable::WITH_ARTIFACTS) + if(isa->type & IShowActivatable::WITH_ARTIFACTS) { (dynamic_cast(isa))->artifactRemoved(al); } @@ -2351,9 +2352,9 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al) void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) { boost::unique_lock un(*pim); - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { - if(isa->type & IShowActivable::WITH_ARTIFACTS) + if(isa->type & IShowActivatable::WITH_ARTIFACTS) { (dynamic_cast(isa))->artifactMoved(src, dst); } @@ -2363,9 +2364,9 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) { boost::unique_lock un(*pim); - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { - if(isa->type & IShowActivable::WITH_ARTIFACTS) + if(isa->type & IShowActivatable::WITH_ARTIFACTS) { (dynamic_cast(isa))->artifactAssembled(al); } @@ -2375,9 +2376,9 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al) { boost::unique_lock un(*pim); - BOOST_FOREACH(IShowActivable *isa, GH.listInt) + BOOST_FOREACH(IShowActivatable *isa, GH.listInt) { - if(isa->type & IShowActivable::WITH_ARTIFACTS) + if(isa->type & IShowActivatable::WITH_ARTIFACTS) { (dynamic_cast(isa))->artifactDisassembled(al); } diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index 933bbf2a7..34d689ee2 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -2,9 +2,9 @@ #include "../lib/CondSh.h" -#include "GUIBase.h" #include "FunctionList.h" #include "../lib/CGameInterface.h" +#include "UIFramework/IUpdateable.h" #ifdef __GNUC__ #define sprintf_s snprintf @@ -55,7 +55,7 @@ class CInGameConsole; union SDL_Event; class IStatusBar; class CInfoWindow; -class IShowActivable; +class IShowActivatable; class ClickableL; class ClickableR; class Hoverable; @@ -218,7 +218,7 @@ public: void battleEnd(const BattleResult *br) OVERRIDE; //end of battle void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; used for HP regen handling void battleNewRound(int round) OVERRIDE; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; + void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; void battleSpellCast(const BattleSpellCast *sc) OVERRIDE; void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE; //called when a specific effect is set to stacks void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; //various one-shot effect diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index f6c9e0d4c..b02af4996 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -2,7 +2,7 @@ #include "CPreGame.h" #include -#include "../lib/StopWatch.h" +#include "../lib/CStopWatch.h" #include "SDL_Extensions.h" #include "CGameInfo.h" #include "CCursorHandler.h" @@ -39,6 +39,7 @@ #include "CConfigHandler.h" #include "../lib/CFileUtility.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" /* * CPreGame.cpp, part of VCMI engine @@ -360,7 +361,7 @@ CreditsScreen::CreditsScreen() std::string text = bitmaph->getTextFile("CREDITS"); size_t firstQuote = text.find('\"')+1; text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote ); - credits = new CTextBox(text, Rect(450, 600, 350, 32000), 0, FONT_CREDITS, CENTER, zwykly); + credits = new CTextBox(text, SRect(450, 600, 350, 32000), 0, FONT_CREDITS, CENTER, zwykly); credits->pos.h = credits->maxH; } @@ -493,7 +494,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti sh->startServer(); } - IShowActivable::type = BLOCK_ADV_HOTKEYS; + IShowActivatable::type = BLOCK_ADV_HOTKEYS; pos.w = 762; pos.h = 584; if(Type == CMenuScreen::saveGame) @@ -1088,7 +1089,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::functionbutton.x, GH.current->button.y); + SPoint clickPos(GH.current->button.x, GH.current->button.y); clickPos = clickPos - pos.topLeft(); if (clickPos.y > 115 && clickPos.y < 564 && clickPos.x > 22 && clickPos.x < 371) @@ -1474,7 +1475,7 @@ void SelectionTab::selectFName( const std::string &fname ) -CChatBox::CChatBox(const Rect &rect) +CChatBox::CChatBox(const SRect &rect) { OBJ_CONSTRUCTION; pos += rect; @@ -1482,9 +1483,9 @@ CChatBox::CChatBox(const Rect &rect) captureAllKeys = true; const int height = graphics->fonts[FONT_SMALL]->height; - inputBox = new CTextInput(Rect(0, rect.h - height, rect.w, height)); + inputBox = new CTextInput(SRect(0, rect.h - height, rect.w, height)); inputBox->used &= ~KEYBOARD; - chatHistory = new CTextBox("", Rect(0, 0, rect.w, rect.h - height), 1); + chatHistory = new CTextBox("", SRect(0, 0, rect.w, rect.h - height), 1); SDL_Color green = {0,252,0}; chatHistory->color = green; @@ -1517,18 +1518,18 @@ InfoCard::InfoCard( bool Network ) used = RCLICK; mapDescription = NULL; - Rect descriptionRect(26, 149, 320, 115); + SRect descriptionRect(26, 149, 320, 115); mapDescription = new CTextBox("", descriptionRect, 1); if(SEL->screenType == CMenuScreen::campaignList) { CSelectionScreen *ss = static_cast(parent); - moveChild(new CPicture(*ss->bg, descriptionRect + Point(-393, 0)), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child) + CGuiHandler::moveChild(new CPicture(*ss->bg, descriptionRect + SPoint(-393, 0)), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child) } else { bg = new CPicture(BitmapHandler::loadBitmap("GSELPOP1.bmp"), 0, 0, true); - moveChild(bg, this, parent); + CGuiHandler::moveChild(bg, this, parent); parent->children.insert(parent->children.begin()+1, bg); parent->children.pop_back(); pos.w = bg->pos.w; @@ -1549,13 +1550,13 @@ InfoCard::InfoCard( bool Network ) difficulty->block(true); //description needs bg - moveChild(new CPicture(*bg, descriptionRect), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child) + CGuiHandler::moveChild(new CPicture(*bg, descriptionRect), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child) if(network) { playerListBg = new CPicture("CHATPLUG.bmp", 16, 276); chat = new CChatBox(descriptionRect); - moveChild(new CPicture(*bg, chat->chatHistory->pos - pos), this, chat->chatHistory, true); //move subpicture bg to our description control (by default it's our (Infocard) child) + CGuiHandler::moveChild(new CPicture(*bg, chat->chatHistory->pos - pos), this, chat->chatHistory, true); //move subpicture bg to our description control (by default it's our (Infocard) child) chatOn = true; mapDescription->disable(); @@ -1752,7 +1753,7 @@ void InfoCard::changeSelection( const CMapInfo *to ) void InfoCard::clickRight( tribool down, bool previousState ) { - static const Rect flagArea(19, 397, 335, 23); + static const SRect flagArea(19, 397, 335, 23); if(down && SEL->current && isItInLoc(flagArea, GH.current->motion.x, GH.current->motion.y)) showTeamsPopup(); } @@ -2128,7 +2129,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet serial++; } - pos = parent->pos + Point(54, 122 + serial*50); + pos = parent->pos + SPoint(54, 122 + serial*50); static const char *flags[] = {"AOFLGBR.DEF", "AOFLGBB.DEF", "AOFLGBY.DEF", "AOFLGBG.DEF", "AOFLGBO.DEF", "AOFLGBP.DEF", "AOFLGBT.DEF", "AOFLGBS.DEF"}; @@ -2173,11 +2174,11 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet defActions &= ~SHARE_POS; town = new SelectedBox(TOWN, s.color); - town->pos += pos + Point(119, 2); + town->pos += pos + SPoint(119, 2); hero = new SelectedBox(HERO, s.color); - hero->pos += pos + Point(195, 2); + hero->pos += pos + SPoint(195, 2); bonus = new SelectedBox(BONUS, s.color); - bonus->pos += pos + Point(271, 2); + bonus->pos += pos + SPoint(271, 2); } void OptionsTab::PlayerOptionsEntry::showAll( SDL_Surface * to ) @@ -2615,8 +2616,8 @@ CMultiMode::CMultiMode() blitAt(CPicture("MUMAP.bmp"), 16, 77, *bg); //blit img pos = bg->center(); //center, window has size of bg graphic - bar = new CGStatusBar(new CPicture(Rect(7, 465, 440, 18), 0));//226, 472 - txt = new CTextInput(Rect(19, 436, 334, 16), *bg); + bar = new CGStatusBar(new CPicture(SRect(7, 465, 440, 18), 0));//226, 472 + txt = new CTextInput(SRect(19, 436, 334, 16), *bg); txt->setText(GDefaultOptions.playerName); //Player btns[0] = new AdventureMapButton(CGI->generaltexth->zelp[266], bind(&CMultiMode::openHotseat, this), 373, 78, "MUBHOT.DEF"); @@ -2652,18 +2653,18 @@ CHotSeatPlayers::CHotSeatPlayers(const std::string &firstPlayer) std::string text = CGI->generaltexth->allTexts[446]; boost::replace_all(text, "\t","\n"); - Rect boxRect(25, 20, 315, 50); + SRect boxRect(25, 20, 315, 50); title = new CTextBox(text, boxRect, 0, FONT_BIG, CENTER, zwykly);//HOTSEAT Please enter names for(int i = 0; i < ARRAY_COUNT(txt); i++) { - txt[i] = new CTextInput(Rect(60, 85 + i*30, 280, 16), *bg); + txt[i] = new CTextInput(SRect(60, 85 + i*30, 280, 16), *bg); txt[i]->cb += boost::bind(&CHotSeatPlayers::onChange, this, _1); } ok = new AdventureMapButton(CGI->generaltexth->zelp[560], bind(&CHotSeatPlayers::enterSelectionScreen, this), 95, 338, "MUBCHCK.DEF", SDLK_RETURN); cancel = new AdventureMapButton(CGI->generaltexth->zelp[561], bind(&CGuiHandler::popIntTotally, ref(GH), this), 205, 338, "MUBCANC.DEF", SDLK_ESCAPE); - bar = new CGStatusBar(new CPicture(Rect(7, 381, 348, 18), 0));//226, 472 + bar = new CGStatusBar(new CPicture(SRect(7, 381, 348, 18), 0));//226, 472 txt[0]->setText(firstPlayer, true); txt[0]->giveFocus(); @@ -2727,11 +2728,11 @@ CBonusSelection::CBonusSelection( CCampaignState * _ourCampaign ) //campaign description printAtLoc(CGI->generaltexth->allTexts[38], 481, 63, FONT_SMALL, tytulowy, background); - cmpgDesc = new CTextBox(ourCampaign->camp->header.description, Rect(480, 86, 286, 117), 1); + cmpgDesc = new CTextBox(ourCampaign->camp->header.description, SRect(480, 86, 286, 117), 1); cmpgDesc->showAll(background); //map description - mapDesc = new CTextBox("", Rect(480, 280, 286, 117), 1); + mapDesc = new CTextBox("", SRect(480, 280, 286, 117), 1); //bonus choosing printAtLoc(CGI->generaltexth->allTexts[71], 511, 432, FONT_MEDIUM, zwykly, background); //Choose a bonus: @@ -3495,7 +3496,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode &config ) image = new CPicture(config["image"].String()); hoverLabel = new CLabel(pos.w / 2, pos.h + 20, FONT_MEDIUM, CENTER, tytulowy, ""); - moveChild(hoverLabel, this, parent); + CGuiHandler::moveChild(hoverLabel, this, parent); } if (status == CCampaignScreen::COMPLETED) diff --git a/client/CPreGame.h b/client/CPreGame.h index fa5a8676b..a2281b76e 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -3,10 +3,10 @@ #include #include "../lib/StartInfo.h" -#include "GUIBase.h" #include "GUIClasses.h" #include "FunctionList.h" #include "../lib/CMapInfo.h" +#include "UIFramework/IUpdateable.h" /* * CPreGame.h, part of VCMI engine @@ -103,7 +103,7 @@ public: CTextBox *chatHistory; CTextInput *inputBox; - CChatBox(const Rect &rect); + CChatBox(const SRect &rect); void keyPressed(const SDL_KeyboardEvent & key); diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index cb8453351..b292d88d3 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -18,6 +18,7 @@ #include "../lib/CHeroHandler.h" #include "../lib/BattleState.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" /* * CSpellWindow.cpp, part of VCMI engine @@ -550,12 +551,12 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key) if(LOCPLINT->altPressed()) { SDLKey hlpKey = key.keysym.sym; - if(isNumKey(hlpKey, false)) + if(CGuiHandler::isNumKey(hlpKey, false)) { if(hlpKey == SDLK_KP_PLUS) hlpKey = SDLK_EQUALS; else - hlpKey = numToDigit(hlpKey); + hlpKey = CGuiHandler::numToDigit(hlpKey); } static const SDLKey spellSelectors[] = {SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS}; diff --git a/client/CSpellWindow.h b/client/CSpellWindow.h index d5325b192..93d9d23f0 100644 --- a/client/CSpellWindow.h +++ b/client/CSpellWindow.h @@ -1,7 +1,6 @@ #pragma once - -#include "GUIBase.h" +#include "UIFramework/CIntObject.h" /* * CSpellWindow.h, part of VCMI engine @@ -18,6 +17,7 @@ class CDefHandler; struct SDL_Rect; class CGHeroInstance; class CStatusBar; +class CPlayerInterface; /// Spellbook button is used by the spell window class class SpellbookInteractiveArea : public CIntObject diff --git a/client/Client.cpp b/client/Client.cpp index c6b66a0af..ce0fa55b8 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -27,13 +27,13 @@ #include "mapHandler.h" #include "CConfigHandler.h" #include "Client.h" -#include "GUIBase.h" #include "CPreGame.h" #include "BattleInterface/CBattleInterface.h" #include "../lib/CThreadHelper.h" #include "../lib/CScriptingModule.h" #include "../lib/CFileUtility.h" #include "../lib/RegisterTypes.h" +#include "UIFramework/CGuiHandler.h" extern std::string NAME; namespace intpr = boost::interprocess; @@ -222,7 +222,7 @@ void CClient::loadGame( const std::string & fname ) CServerHandler sh; sh.startServer(); - StopWatch tmh; + CStopWatch tmh; { char sig[8]; CMapHeader dum; @@ -306,7 +306,7 @@ void CClient::newGame( CConnection *con, StartInfo *si ) - StopWatch tmh; + CStopWatch tmh; const_cast(CGI)->state = new CGameState(); tlog0 <<"\tGamestate: "<scenarioOps->mode == StartInfo::DUEL) - new CBattleInterface(info->belligerents[0], info->belligerents[1], info->heroes[0], info->heroes[1], Rect((conf.cc.resx - 800)/2, (conf.cc.resy - 600)/2, 800, 600), att, def); + new CBattleInterface(info->belligerents[0], info->belligerents[1], info->heroes[0], info->heroes[1], SRect((conf.cc.resx - 800)/2, (conf.cc.resy - 600)/2, 800, 600), att, def); if(vstd::contains(battleints,info->sides[0])) battleints[info->sides[0]]->battleStart(info->belligerents[0], info->belligerents[1], info->tile, info->heroes[0], info->heroes[1], 0); diff --git a/client/Client.h b/client/Client.h index a26593800..279e6a3b9 100644 --- a/client/Client.h +++ b/client/Client.h @@ -3,7 +3,7 @@ #include "../lib/IGameCallback.h" #include "../lib/CondSh.h" -#include "../lib/StopWatch.h" +#include "../lib/CStopWatch.h" /* * Client.h, part of VCMI engine @@ -38,7 +38,7 @@ class CServerHandler private: void callServer(); //calls server via system(), should be called as thread public: - StopWatch th; + CStopWatch th; boost::thread *serverThread; //thread that called system to run server SharedMem *shared; //interprocess memory (for waiting for server) bool verbose; //whether to print log msgs diff --git a/client/GUIBase.cpp b/client/GUIBase.cpp deleted file mode 100644 index cffb9e8ca..000000000 --- a/client/GUIBase.cpp +++ /dev/null @@ -1,1071 +0,0 @@ -#include "StdInc.h" -#include "SDL_Extensions.h" -#include "GUIBase.h" - -#include "CGameInfo.h" -#include "CCursorHandler.h" -#include "CBitmapHandler.h" -#include "Graphics.h" -#include "../lib/CThreadHelper.h" -#include "CConfigHandler.h" - -/* - * GUIBase.cpp, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ - -extern std::queue events; -extern boost::mutex eventsM; - - -SDL_Color Colors::MetallicGold = createColor(173, 142, 66); -SDL_Color Colors::Yellow = createColor(242, 226, 110); - -SDL_Color Colors::createColor(int r, int g, int b) -{ - SDL_Color temp = {r, g, b, 0}; - return temp; -} - -void KeyShortcut::keyPressed(const SDL_KeyboardEvent & key) -{ - if(vstd::contains(assignedKeys,key.keysym.sym)) - { - bool prev = pressedL; - if(key.state == SDL_PRESSED) - { - pressedL = true; - clickLeft(true, prev); - } - else - { - pressedL = false; - clickLeft(false, prev); - } - } -} - - -void CGuiHandler::popInt( IShowActivable *top ) -{ - assert(listInt.front() == top); - top->deactivate(); - listInt.pop_front(); - objsToBlit -= top; - if(listInt.size()) - listInt.front()->activate(); - totalRedraw(); -} - -void CGuiHandler::popIntTotally( IShowActivable *top ) -{ - assert(listInt.front() == top); - popInt(top); - delete top; - fakeMouseMove(); -} - -void CGuiHandler::pushInt( IShowActivable *newInt ) -{ - //a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway) - screenBuf = screen2; - - if(listInt.size()) - listInt.front()->deactivate(); - listInt.push_front(newInt); - newInt->activate(); - objsToBlit.push_back(newInt); - totalRedraw(); -} - -void CGuiHandler::popInts( int howMany ) -{ - if(!howMany) return; //senseless but who knows... - - assert(listInt.size() >= howMany); - listInt.front()->deactivate(); - for(int i=0; i < howMany; i++) - { - objsToBlit -= listInt.front(); - delete listInt.front(); - listInt.pop_front(); - } - - if(listInt.size()) - { - listInt.front()->activate(); - totalRedraw(); - } - fakeMouseMove(); -} - -IShowActivable * CGuiHandler::topInt() -{ - if(!listInt.size()) - return NULL; - else - return listInt.front(); -} - -void CGuiHandler::totalRedraw() -{ - for(int i=0;ishowAll(screen2); - - blitAt(screen2,0,0,screen); -} - -void CGuiHandler::updateTime() -{ - int tv = th.getDiff(); - std::list hlp = timeinterested; - for (std::list::iterator i=hlp.begin(); i != hlp.end();i++) - { - if(!vstd::contains(timeinterested,*i)) continue; - if ((*i)->toNextTick>=0) - (*i)->toNextTick-=tv; - if ((*i)->toNextTick<0) - (*i)->tick(); - } -} - -void CGuiHandler::handleEvents() -{ - while(true) - { - SDL_Event *ev = NULL; - boost::unique_lock lock(eventsM); - if(!events.size()) - { - return; - } - else - { - ev = events.front(); - events.pop(); - } - handleEvent(ev); - delete ev; - } -} - -void CGuiHandler::handleEvent(SDL_Event *sEvent) -{ - current = sEvent; - bool prev; - - if (sEvent->type==SDL_KEYDOWN || sEvent->type==SDL_KEYUP) - { - SDL_KeyboardEvent key = sEvent->key; - - //translate numpad keys - if(key.keysym.sym == SDLK_KP_ENTER) - { - key.keysym.sym = (SDLKey)SDLK_RETURN; - } - - bool keysCaptured = false; - for(std::list::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++) - { - if((*i)->captureAllKeys) - { - keysCaptured = true; - break; - } - } - - std::list miCopy = keyinterested; - for(std::list::iterator i=miCopy.begin(); i != miCopy.end() && current; i++) - if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureAllKeys)) - (**i).keyPressed(key); - } - else if(sEvent->type==SDL_MOUSEMOTION) - { - CCS->curh->cursorMove(sEvent->motion.x, sEvent->motion.y); - handleMouseMotion(sEvent); - } - else if (sEvent->type==SDL_MOUSEBUTTONDOWN) - { - if(sEvent->button.button == SDL_BUTTON_LEFT) - { - - if(lastClick == sEvent->motion && (SDL_GetTicks() - lastClickTime) < 300) - { - std::list hlp = doubleClickInterested; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(doubleClickInterested,*i)) continue; - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - (*i)->onDoubleClick(); - } - } - - } - - lastClick = sEvent->motion; - lastClickTime = SDL_GetTicks(); - - std::list hlp = lclickable; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(lclickable,*i)) continue; - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - prev = (*i)->pressedL; - (*i)->pressedL = true; - (*i)->clickLeft(true, prev); - } - } - } - else if (sEvent->button.button == SDL_BUTTON_RIGHT) - { - std::list hlp = rclickable; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(rclickable,*i)) continue; - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - prev = (*i)->pressedR; - (*i)->pressedR = true; - (*i)->clickRight(true, prev); - } - } - } - else if(sEvent->button.button == SDL_BUTTON_WHEELDOWN || sEvent->button.button == SDL_BUTTON_WHEELUP) - { - std::list hlp = wheelInterested; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(wheelInterested,*i)) continue; - (*i)->wheelScrolled(sEvent->button.button == SDL_BUTTON_WHEELDOWN, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)); - } - } - } - else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT)) - { - std::list hlp = lclickable; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(lclickable,*i)) continue; - prev = (*i)->pressedL; - (*i)->pressedL = false; - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - (*i)->clickLeft(false, prev); - } - else - (*i)->clickLeft(boost::logic::indeterminate, prev); - } - } - else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_RIGHT)) - { - std::list hlp = rclickable; - for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) - { - if(!vstd::contains(rclickable,*i)) continue; - prev = (*i)->pressedR; - (*i)->pressedR = false; - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - (*i)->clickRight(false, prev); - } - else - (*i)->clickRight(boost::logic::indeterminate, prev); - } - } - current = NULL; - -} //event end - -void CGuiHandler::handleMouseMotion(SDL_Event *sEvent) -{ - //sending active, hovered hoverable objects hover() call - std::vector hlp; - for(std::list::iterator i=hoverable.begin(); i != hoverable.end();i++) - { - if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) - { - if (!(*i)->hovered) - hlp.push_back((*i)); - } - else if ((*i)->hovered) - { - (*i)->hover(false); - (*i)->hovered = false; - } - } - for(int i=0; ihover(true); - hlp[i]->hovered = true; - } - - handleMoveInterested(sEvent->motion); -} - -void CGuiHandler::simpleRedraw() -{ - //update only top interface and draw background - if(objsToBlit.size() > 1) - blitAt(screen2,0,0,screen); //blit background - objsToBlit.back()->show(screen); //blit active interface/window -} - -void CGuiHandler::handleMoveInterested( const SDL_MouseMotionEvent & motion ) -{ - //sending active, MotionInterested objects mouseMoved() call - std::list miCopy = motioninterested; - for(std::list::iterator i=miCopy.begin(); i != miCopy.end();i++) - { - if ((*i)->strongInterest || isItIn(&(*i)->pos, motion.x, motion.y)) - { - (*i)->mouseMoved(motion); - } - } -} - -void CGuiHandler::fakeMouseMove() -{ - SDL_Event evnt; - - SDL_MouseMotionEvent sme = {SDL_MOUSEMOTION, 0, 0, 0, 0, 0, 0}; - int x, y; - sme.state = SDL_GetMouseState(&x, &y); - sme.x = x; - sme.y = y; - - evnt.motion = sme; - current = &evnt; - handleMouseMotion(&evnt); -} - -void CGuiHandler::run() -{ - setThreadName(-1, "CGuiHandler::run"); - try - { - if (conf.cc.fullscreen) - CCS->curh->centerCursor(); - - mainFPSmng->init(); // resets internal clock, needed for FPS manager - while(!terminate) - { - if(curInt) - curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment - - mainFPSmng->framerateDelay(); // holds a constant FPS - } - } HANDLE_EXCEPTION -} - -CGuiHandler::CGuiHandler() -:lastClick(-500, -500) -{ - curInt = NULL; - current = NULL; - terminate = false; - statusbar = NULL; - - // Creates the FPS manager and sets the framerate to 48 which is doubled the value of the original Heroes 3 FPS rate - mainFPSmng = new FPSManager(48); - mainFPSmng->init(); // resets internal clock, needed for FPS manager -} - -CGuiHandler::~CGuiHandler() -{ - delete mainFPSmng; -} - -void CGuiHandler::breakEventHandling() -{ - current = NULL; -} - -void CGuiHandler::drawFPSCounter() -{ - const static SDL_Color yellow = {255, 255, 0, 0}; - static SDL_Rect overlay = { 0, 0, 64, 32}; - Uint32 black = SDL_MapRGB(screen->format, 10, 10, 10); - SDL_FillRect(screen, &overlay, black); - std::string fps = boost::lexical_cast(mainFPSmng->fps); - CSDL_Ext::printAt(fps, 10, 10, FONT_BIG, yellow, screen); -} - - -void CIntObject::activateLClick() -{ - GH.lclickable.push_front(this); - active |= LCLICK; -} - -void CIntObject::deactivateLClick() -{ - std::list::iterator hlp = std::find(GH.lclickable.begin(),GH.lclickable.end(),this); - assert(hlp != GH.lclickable.end()); - GH.lclickable.erase(hlp); - active &= ~LCLICK; -} - -void CIntObject::clickLeft(tribool down, bool previousState) -{ -} - -void CIntObject::activateRClick() -{ - GH.rclickable.push_front(this); - active |= RCLICK; -} - -void CIntObject::deactivateRClick() -{ - std::list::iterator hlp = std::find(GH.rclickable.begin(),GH.rclickable.end(),this); - assert(hlp != GH.rclickable.end()); - GH.rclickable.erase(hlp); - active &= ~RCLICK; -} - -void CIntObject::clickRight(tribool down, bool previousState) -{ -} - -void CIntObject::activateHover() -{ - GH.hoverable.push_front(this); - active |= HOVER; -} - -void CIntObject::deactivateHover() -{ - std::list::iterator hlp = std::find(GH.hoverable.begin(),GH.hoverable.end(),this); - assert(hlp != GH.hoverable.end()); - GH.hoverable.erase(hlp); - active &= ~HOVER; -} - -void CIntObject::hover( bool on ) -{ -} - -void CIntObject::activateKeys() -{ - GH.keyinterested.push_front(this); - active |= KEYBOARD; -} - -void CIntObject::deactivateKeys() -{ - std::list::iterator hlp = std::find(GH.keyinterested.begin(),GH.keyinterested.end(),this); - assert(hlp != GH.keyinterested.end()); - GH.keyinterested.erase(hlp); - active &= ~KEYBOARD; -} - -void CIntObject::keyPressed( const SDL_KeyboardEvent & key ) -{ -} - -void CIntObject::activateMouseMove() -{ - GH.motioninterested.push_front(this); - active |= MOVE; -} - -void CIntObject::deactivateMouseMove() -{ - std::list::iterator hlp = std::find(GH.motioninterested.begin(),GH.motioninterested.end(),this); - assert(hlp != GH.motioninterested.end()); - GH.motioninterested.erase(hlp); - active &= ~MOVE; -} - -void CIntObject::mouseMoved( const SDL_MouseMotionEvent & sEvent ) -{ -} - -void CIntObject::activateTimer() -{ - GH.timeinterested.push_back(this); - active |= TIME; -} - -void CIntObject::deactivateTimer() -{ - std::list::iterator hlp = std::find(GH.timeinterested.begin(),GH.timeinterested.end(),this); - assert(hlp != GH.timeinterested.end()); - GH.timeinterested.erase(hlp); - active &= ~TIME; -} - -void CIntObject::tick() -{ -} - -CIntObject::CIntObject() -{ - pressedL = pressedR = hovered = captureAllKeys = strongInterest = false; - toNextTick = active = used = 0; - - recActions = defActions = GH.defActionsDef; - - pos.x = 0; - pos.y = 0; - pos.w = 0; - pos.h = 0; - - if(GH.captureChildren) - { - assert(GH.createdObj.size()); - parent = GH.createdObj.front(); - parent->children.push_back(this); - - if(parent->defActions & SHARE_POS) - { - pos.x = parent->pos.x; - pos.y = parent->pos.y; - } - } - else - parent = NULL; -} - -void CIntObject::show( SDL_Surface * to ) -{ - if(defActions & UPDATE) - for(size_t i = 0; i < children.size(); i++) - if(children[i]->recActions & UPDATE) - children[i]->show(to); -} - -void CIntObject::showAll( SDL_Surface * to ) -{ - if(defActions & SHOWALL) - { - for(size_t i = 0; i < children.size(); i++) - if(children[i]->recActions & SHOWALL) - children[i]->showAll(to); - - } - else - show(to); -} - -void CIntObject::activate() -{ - assert(!active); - active |= GENERAL; - activate(used); - - if(defActions & ACTIVATE) - for(size_t i = 0; i < children.size(); i++) - if(children[i]->recActions & ACTIVATE) - children[i]->activate(); -} - -void CIntObject::activate(ui16 what) -{ - if(what & LCLICK) - activateLClick(); - if(what & RCLICK) - activateRClick(); - if(what & HOVER) - activateHover(); - if(what & MOVE) - activateMouseMove(); - if(what & KEYBOARD) - activateKeys(); - if(what & TIME) - activateTimer(); - if(what & WHEEL) - activateWheel(); - if(what & DOUBLECLICK) - activateDClick(); -} - -void CIntObject::deactivate() -{ - assert(active); - active &= ~ GENERAL; - deactivate(used); - - assert(!active); - - if(defActions & DEACTIVATE) - for(size_t i = 0; i < children.size(); i++) - if(children[i]->recActions & DEACTIVATE) - children[i]->deactivate(); -} - -void CIntObject::deactivate(ui16 what) -{ - if(what & LCLICK) - deactivateLClick(); - if(what & RCLICK) - deactivateRClick(); - if(what & HOVER) - deactivateHover(); - if(what & MOVE) - deactivateMouseMove(); - if(what & KEYBOARD) - deactivateKeys(); - if(what & TIME) // TIME is special - deactivateTimer(); - if(what & WHEEL) - deactivateWheel(); - if(what & DOUBLECLICK) - deactivateDClick(); -} - -CIntObject::~CIntObject() -{ - assert(!active); //do not delete active obj - - if(defActions & DISPOSE) - for(size_t i = 0; i < children.size(); i++) - if(children[i]->recActions & DISPOSE) - delete children[i]; - - if(parent && GH.createdObj.size()) //temporary object destroyed - parent->children -= this; -} - -void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ ) -{ - CSDL_Ext::printAt(text, pos.x + x, pos.y + y, font, kolor, dst); -} - -void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ ) -{ - CSDL_Ext::printAtMiddle(text, pos.x + x, pos.y + y, font, kolor, dst); -} - -void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst) -{ - printAtMiddleLoc(text, p.x, p.y, font, kolor, dst); -} - -void CIntObject::blitAtLoc( SDL_Surface * src, int x, int y, SDL_Surface * dst ) -{ - blitAt(src, pos.x + x, pos.y + y, dst); -} - -void CIntObject::blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst) -{ - blitAtLoc(src, p.x, p.y, dst); -} - -void CIntObject::printAtMiddleWBLoc( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst) -{ - CSDL_Ext::printAtMiddleWB(text, pos.x + x, pos.y + y, font, charpr, kolor, dst); -} - -void CIntObject::printToLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst ) -{ - CSDL_Ext::printTo(text, pos.x + x, pos.y + y, font, kolor, dst); -} - -void CIntObject::disable() -{ - if(active) - deactivate(); - - recActions = DISPOSE; -} - -void CIntObject::enable(bool activation) -{ - if(!active && activation) - activate(); - - recActions = 255; -} - -bool CIntObject::isItInLoc( const SDL_Rect &rect, int x, int y ) -{ - return isItIn(&rect, x - pos.x, y - pos.y); -} - -bool CIntObject::isItInLoc( const SDL_Rect &rect, const Point &p ) -{ - return isItIn(&rect, p.x - pos.x, p.y - pos.y); -} - -void CIntObject::activateWheel() -{ - GH.wheelInterested.push_front(this); - active |= WHEEL; -} - -void CIntObject::deactivateWheel() -{ - std::list::iterator hlp = std::find(GH.wheelInterested.begin(),GH.wheelInterested.end(),this); - assert(hlp != GH.wheelInterested.end()); - GH.wheelInterested.erase(hlp); - active &= ~WHEEL; -} - -void CIntObject::wheelScrolled(bool down, bool in) -{ -} - -void CIntObject::activateDClick() -{ - GH.doubleClickInterested.push_front(this); - active |= DOUBLECLICK; -} - -void CIntObject::deactivateDClick() -{ - std::list::iterator hlp = std::find(GH.doubleClickInterested.begin(),GH.doubleClickInterested.end(),this); - assert(hlp != GH.doubleClickInterested.end()); - GH.doubleClickInterested.erase(hlp); - active &= ~DOUBLECLICK; -} - -void CIntObject::onDoubleClick() -{ -} - -const Rect & CIntObject::center( const Rect &r, bool propagate ) -{ - pos.w = r.w; - pos.h = r.h; - return center(Point(screen->w/2, screen->h/2), propagate); -} - -const Rect & CIntObject::center( bool propagate ) -{ - return center(pos, propagate); -} - -const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/) -{ - moveBy(Point(p.x - pos.w/2 - pos.x, - p.y - pos.h/2 - pos.y), - propagate); - return pos; -} - -void CIntObject::fitToScreen(int borderWidth, bool propagate) -{ - Point newPos = pos.topLeft(); - vstd::amax(newPos.x, borderWidth); - vstd::amax(newPos.y, borderWidth); - vstd::amin(newPos.x, screen->w - borderWidth - pos.w); - vstd::amin(newPos.y, screen->h - borderWidth - pos.h); - if (newPos != pos.topLeft()) - moveTo(newPos, propagate); -} - -void CIntObject::moveBy( const Point &p, bool propagate /*= true*/ ) -{ - pos.x += p.x; - pos.y += p.y; - if(propagate) - for(size_t i = 0; i < children.size(); i++) - children[i]->moveBy(p, propagate); -} - -void CIntObject::moveTo( const Point &p, bool propagate /*= true*/ ) -{ - moveBy(Point(p.x - pos.x, p.y - pos.y), propagate); -} - -void CIntObject::delChild(CIntObject *child) -{ - children -= child; - delete child; -} - -void CIntObject::addChild(CIntObject *child, bool adjustPosition /*= false*/) -{ - assert(!vstd::contains(children, child)); - assert(child->parent == NULL); - children.push_back(child); - child->parent = this; - if(adjustPosition) - child->pos += pos; -} - -void CIntObject::removeChild(CIntObject *child, bool adjustPosition /*= false*/) -{ - assert(vstd::contains(children, child)); - assert(child->parent == this); - children -= child; - child->parent = NULL; - if(adjustPosition) - child->pos -= pos; -} - -void CIntObject::changeUsedEvents(ui16 what, bool enable, bool adjust /*= true*/) -{ - if(enable) - { - used |= what; - if(adjust && active) - activate(what); - } - else - { - used &= ~what; - if(adjust && active) - deactivate(what); - } -} - -void CIntObject::drawBorderLoc(SDL_Surface * sur, const Rect &r, const int3 &color) -{ - CSDL_Ext::drawBorder(sur, r + pos, color); -} - -CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free ) -{ - init(); - bg = BG; - freeSurf = Free; - pos.x += x; - pos.y += y; - pos.w = BG->w; - pos.h = BG->h; -} - -CPicture::CPicture( const std::string &bmpname, int x, int y ) -{ - init(); - bg = BitmapHandler::loadBitmap(bmpname); - freeSurf = true;; - pos.x += x; - pos.y += y; - if(bg) - { - pos.w = bg->w; - pos.h = bg->h; - } - else - { - pos.w = pos.h = 0; - } -} - -CPicture::CPicture(const Rect &r, const SDL_Color &color, bool screenFormat /*= false*/) -{ - init(); - createSimpleRect(r, screenFormat, SDL_MapRGB(bg->format, color.r, color.g,color.b)); -} - -CPicture::CPicture(const Rect &r, ui32 color, bool screenFormat /*= false*/) -{ - init(); - createSimpleRect(r, screenFormat, color); -} - -CPicture::CPicture(SDL_Surface *BG, const Rect &SrcRect, int x /*= 0*/, int y /*= 0*/, bool free /*= false*/) -{ - needRefresh = false; - srcRect = new Rect(SrcRect); - pos.x += x; - pos.y += y; - pos.w = srcRect->w; - pos.h = srcRect->h; - bg = BG; - freeSurf = free; -} - -CPicture::~CPicture() -{ - if(freeSurf) - SDL_FreeSurface(bg); - delete srcRect; -} - -void CPicture::init() -{ - needRefresh = false; - srcRect = NULL; -} - -void CPicture::show( SDL_Surface * to ) -{ - if (needRefresh) - showAll(to); -} - -void CPicture::showAll( SDL_Surface * to ) -{ - if(bg) - { - if(srcRect) - { - SDL_Rect srcRectCpy = *srcRect; - SDL_Rect dstRect = srcRectCpy; - dstRect.x = pos.x; - dstRect.y = pos.y; - - CSDL_Ext::blitSurface(bg, &srcRectCpy, to, &dstRect); - } - else - blitAt(bg, pos, to); - } -} - -void CPicture::convertToScreenBPP() -{ - SDL_Surface *hlp = bg; - bg = SDL_ConvertSurface(hlp,screen->format,0); - SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255)); - SDL_FreeSurface(hlp); -} - -void CPicture::createSimpleRect(const Rect &r, bool screenFormat, ui32 color) -{ - pos += r; - pos.w = r.w; - pos.h = r.h; - if(screenFormat) - bg = CSDL_Ext::newSurface(r.w, r.h); - else - bg = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 8, 0, 0, 0, 0); - - SDL_FillRect(bg, NULL, color); - freeSurf = true; -} - -void CPicture::colorizeAndConvert(int player) -{ - assert(bg); - colorize(player); - convertToScreenBPP(); -} - -void CPicture::colorize(int player) -{ - assert(bg); - assert(bg->format->BitsPerPixel == 8); - graphics->blueToPlayersAdv(bg, player); -} - -ObjectConstruction::ObjectConstruction( CIntObject *obj ) - :myObj(obj) -{ - GH.createdObj.push_front(obj); - GH.captureChildren = true; -} - -ObjectConstruction::~ObjectConstruction() -{ - assert(GH.createdObj.size()); - assert(GH.createdObj.front() == myObj); - GH.createdObj.pop_front(); - GH.captureChildren = GH.createdObj.size(); -} - -SetCaptureState::SetCaptureState(bool allow, ui8 actions) -{ - previousCapture = GH.captureChildren; - GH.captureChildren = false; - prevActions = GH.defActionsDef; - GH.defActionsDef = actions; -} - -SetCaptureState::~SetCaptureState() -{ - GH.captureChildren = previousCapture; - GH.defActionsDef = prevActions; -} - -void CIntObject::redraw() -{ - if (parent && (type & REDRAW_PARENT)) - { - parent->redraw(); - } - else - { - showAll(screenBuf); - if(screenBuf != screen) - showAll(screen); - } -} - -SDLKey arrowToNum( SDLKey key ) -{ - switch(key) - { - case SDLK_DOWN: - return SDLK_KP2; - case SDLK_UP: - return SDLK_KP8; - case SDLK_LEFT: - return SDLK_KP4; - case SDLK_RIGHT: - return SDLK_KP6; - default: - assert(0); - } - throw std::string("Wrong key!"); -} - -SDLKey numToDigit( SDLKey key ) -{ - if(key >= SDLK_KP0 && key <= SDLK_KP9) - return SDLKey(key - SDLK_KP0 + SDLK_0); - -#define REMOVE_KP(keyName) case SDLK_KP_ ## keyName : return SDLK_ ## keyName; - switch(key) - { - REMOVE_KP(PERIOD) - REMOVE_KP(MINUS) - REMOVE_KP(PLUS) - REMOVE_KP(EQUALS) - - case SDLK_KP_MULTIPLY: - return SDLK_ASTERISK; - case SDLK_KP_DIVIDE: - return SDLK_SLASH; - case SDLK_KP_ENTER: - return SDLK_RETURN; - default: - tlog3 << "Illegal numkey conversion!" << std::endl; - return SDLK_UNKNOWN; - } -#undef REMOVE_KP -} - -bool isNumKey( SDLKey key, bool number ) -{ - if(number) - return key >= SDLK_KP0 && key <= SDLK_KP9; - else - return key >= SDLK_KP0 && key <= SDLK_KP_EQUALS; -} - -bool isArrowKey( SDLKey key ) -{ - return key >= SDLK_UP && key <= SDLK_LEFT; -} - -CIntObject * moveChild(CIntObject *obj, CIntObject *from, CIntObject *to, bool adjustPos) -{ - from->removeChild(obj, adjustPos); - to->addChild(obj, adjustPos); - return obj; -} -Rect Rect::createCentered( int w, int h ) -{ - return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h); -} - -Rect Rect::around(const Rect &r, int width /*= 1*/) /*creates rect around another */ -{ - return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2); -} - -Rect Rect::centerIn(const Rect &r) -{ - return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h); -} diff --git a/client/GUIBase.h b/client/GUIBase.h deleted file mode 100644 index 764c51ca1..000000000 --- a/client/GUIBase.h +++ /dev/null @@ -1,626 +0,0 @@ -#pragma once - - -#include "../lib/int3.h" -#include "SDL.h" -#include "../lib/StopWatch.h" -#include "FontBase.h" -#include "SDL_framerate.h" - -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif - -/* - * GUIBase.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ - -class CDefEssential; -class AdventureMapButton; -class CHighlightableButtonsGroup; -class CDefHandler; -struct HeroMoveDetails; -class CDefEssential; -class CGHeroInstance; -class CAdvMapInt; -class CCastleInterface; -class CBattleInterface; -class CStack; -class SComponent; -class CCreature; -struct SDL_Surface; -struct CPath; -class CCreatureAnimation; -class CSelectableComponent; -class CCreatureSet; -class CGObjectInstance; -class CSlider; -struct UpgradeInfo; -template struct CondSh; -class CInGameConsole; -class CGarrisonInt; -class CInGameConsole; -struct Component; -class CArmedInstance; -class CGTownInstance; -class StackState; -class CPlayerInterface; - -using boost::logic::tribool; - -/// A point with x/y coordinate, used mostly for graphic rendering -struct Point -{ - int x, y; - - //constructors - Point() - { - x = y = 0; - }; - Point(int X, int Y) - :x(X),y(Y) - {}; - Point(const int3 &a) - :x(a.x),y(a.y) - {} - Point(const SDL_MouseMotionEvent &a) - :x(a.x),y(a.y) - {} - - template - Point operator+(const T &b) const - { - return Point(x+b.x,y+b.y); - } - - template - Point operator*(const T &mul) const - { - return Point(x*mul, y*mul); - } - - template - Point& operator+=(const T &b) - { - x += b.x; - y += b.y; - return *this; - } - - template - Point operator-(const T &b) const - { - return Point(x - b.x, y - b.y); - } - - template - Point& operator-=(const T &b) - { - x -= b.x; - y -= b.y; - return *this; - } - bool operator<(const Point &b) const //product order - { - return x < b.x && y < b.y; - } - template Point& operator=(const T &t) - { - x = t.x; - y = t.y; - return *this; - } - template bool operator==(const T &t) const - { - return x == t.x && y == t.y; - } - template bool operator!=(const T &t) const - { - return !(*this == t); - } -}; - -/// Rectangle class, which have a position and a size -struct Rect : public SDL_Rect -{ - Rect()//default c-tor - { - x = y = w = h = -1; - } - Rect(int X, int Y, int W, int H) //c-tor - { - x = X; - y = Y; - w = W; - h = H; - } - Rect(const Point &position, const Point &size) //c-tor - { - x = position.x; - y = position.y; - w = size.x; - h = size.y; - } - Rect(const SDL_Rect & r) //c-tor - { - x = r.x; - y = r.y; - w = r.w; - h = r.h; - } - explicit Rect(const SDL_Surface * const &surf) - { - x = y = 0; - w = surf->w; - h = surf->h; - } - - Rect centerIn(const Rect &r); - static Rect createCentered(int w, int h); - static Rect around(const Rect &r, int width = 1); //creates rect around another - - bool isIn(int qx, int qy) const //determines if given point lies inside rect - { - if (qx > x && qxy && qy Rect operator-(const T &t) - { - return Rect(x - t.x, y - t.y, w, h); - } - Rect operator&(const Rect &p) const //rect intersection - { - bool intersect = true; - - if(p.topLeft().y < y && p.bottomLeft().y < y) //rect p is above *this - { - intersect = false; - } - else if(p.topLeft().y > y+h && p.bottomLeft().y > y+h) //rect p is below *this - { - intersect = false; - } - else if(p.topLeft().x > x+w && p.topRight().x > x+w) //rect p is on the right hand side of this - { - intersect = false; - } - else if(p.topLeft().x < x && p.topRight().x < x) //rect p is on the left hand side of this - { - intersect = false; - } - - if(intersect) - { - Rect ret; - ret.x = std::max(this->x, p.x); - ret.y = std::max(this->y, p.y); - Point bR; //bottomRight point of returned rect - bR.x = std::min(this->w+this->x, p.w+p.x); - bR.y = std::min(this->h+this->y, p.h+p.y); - ret.w = bR.x - ret.x; - ret.h = bR.y - ret.y; - return ret; - } - else - { - return Rect(); - } - } - Rect operator|(const Rect &p) const //union of two rects - { - Rect ret; - ret.x = std::min(p.x, this->x); - ret.y = std::min(p.y, this->y); - int x2 = std::max(p.x+p.w, this->x+this->w); - int y2 = std::max(p.y+p.h, this->y+this->h); - ret.w = x2 -ret.x; - ret.h = y2 -ret.y; - return ret; - } -}; - -/// Defines a show method -class IShowable -{ -public: - virtual void redraw()=0; - virtual void show(SDL_Surface * to)=0; - virtual void showAll(SDL_Surface * to) - { - show(to); - } - virtual ~IShowable(){}; //d-tor -}; - -/// Status bar interface -class IStatusBar -{ -public: - virtual ~IStatusBar(){}; //d-tor - virtual void print(const std::string & text)=0; //prints text and refreshes statusbar - virtual void clear()=0;//clears statusbar and refreshes - virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text) - virtual std::string getCurrent()=0; //returns currently displayed text -}; - -/// Defines a activate/deactive method -class IActivable -{ -public: - virtual void activate()=0; - virtual void deactivate()=0; - virtual ~IActivable(){}; //d-tor -}; - - -class IShowActivable : public IShowable, public IActivable -{ -public: - //redraw parent flag - this int may be semi-transparent and require redraw of parent window - enum {WITH_GARRISON = 1, BLOCK_ADV_HOTKEYS = 2, WITH_ARTIFACTS = 4, REDRAW_PARENT=8}; - int type; //bin flags using etype - IShowActivable(); - virtual ~IShowActivable(){}; //d-tor -}; - - -class IUpdateable -{ -public: - virtual void update()=0; - virtual ~IUpdateable(){}; //d-tor -}; - -/// Base UI element -class CIntObject : public IShowActivable //interface object -{ -public: - CIntObject *parent; //parent object - std::vector children; - - Rect pos, //position of object on the screen - posRelative; //position of object in the parent (not used if no parent) - - CIntObject(); - virtual ~CIntObject(); //d-tor - - //l-clicks handling - bool pressedL; //for determining if object is L-pressed - void activateLClick(); - void deactivateLClick(); - virtual void clickLeft(tribool down, bool previousState); - - //r-clicks handling - bool pressedR; //for determining if object is R-pressed - void activateRClick(); - void deactivateRClick(); - virtual void clickRight(tribool down, bool previousState); - - //hover handling - bool hovered; //for determining if object is hovered - void activateHover(); - void deactivateHover(); - virtual void hover (bool on); - - //keyboard handling - bool captureAllKeys; //if true, only this object should get info about pressed keys - void activateKeys(); - void deactivateKeys(); - virtual void keyPressed(const SDL_KeyboardEvent & key); - - //mouse movement handling - bool strongInterest; //if true - report all mouse movements, if not - only when hovered - void activateMouseMove(); - void deactivateMouseMove(); - virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent); - - //time handling - int toNextTick; - void activateTimer(); - void deactivateTimer(); - virtual void tick(); - - //mouse wheel - void activateWheel(); - void deactivateWheel(); - virtual void wheelScrolled(bool down, bool in); - - //double click - void activateDClick(); - void deactivateDClick(); - virtual void onDoubleClick(); - - enum {LCLICK=1, RCLICK=2, HOVER=4, MOVE=8, KEYBOARD=16, TIME=32, GENERAL=64, WHEEL=128, DOUBLECLICK=256, ALL=0xffff}; - ui16 active; - ui16 used; - - enum {ACTIVATE=1, DEACTIVATE=2, UPDATE=4, SHOWALL=8, DISPOSE=16, SHARE_POS=32}; - ui8 defActions; //which calls will be tried to be redirected to children - ui8 recActions; //which calls we allow te receive from parent - - enum EAlignment {TOPLEFT, CENTER, BOTTOMRIGHT}; - - void disable(); //deactivates if needed, blocks all automatic activity, allows only disposal - void enable(bool activation = true); //activates if needed, all activity enabled (Warning: may not be symetric with disable if recActions was limited!) - void defActivate(); - void defDeactivate(); - void activate(); - void deactivate(); - void activate(ui16 what); - void deactivate(ui16 what); - void show(SDL_Surface * to); - void showAll(SDL_Surface * to); - void redraw(); - - void drawBorderLoc(SDL_Surface * sur, const Rect &r, const int3 &color); - void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); - void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); - void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); - void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst); - void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst); - void blitAtLoc(SDL_Surface * src, int x, int y, SDL_Surface * dst); - void blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst); - bool isItInLoc(const SDL_Rect &rect, int x, int y); - bool isItInLoc(const SDL_Rect &rect, const Point &p); - const Rect & center(const Rect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position - const Rect & center(const Point &p, bool propagate = true); //moves object so that point p will be in its center - const Rect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position - void fitToScreen(int borderWidth, bool propagate = true); //moves window to fit into screen - void moveBy(const Point &p, bool propagate = true); - void moveTo(const Point &p, bool propagate = true); - void changeUsedEvents(ui16 what, bool enable, bool adjust = true); - - void addChild(CIntObject *child, bool adjustPosition = false); - void removeChild(CIntObject *child, bool adjustPosition = false); - void delChild(CIntObject *child); //removes from children list, deletes - template void delChildNUll(T *&child, bool deactivateIfNeeded = false) //removes from children list, deletes and sets pointer to NULL - { - if(!child) - return; - - if(deactivateIfNeeded && child->active) - child->deactivate(); - - delChild(child); - child = NULL; - } -}; - -/// Class for binding keys to left mouse button clicks -/// Classes wanting use it should have it as one of their base classes -class KeyShortcut : public virtual CIntObject -{ -public: - std::set assignedKeys; - KeyShortcut(){}; //c-tor - KeyShortcut(int key){assignedKeys.insert(key);}; //c-tor - KeyShortcut(std::set Keys):assignedKeys(Keys){}; //c-tor - virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in -}; - -/// to unify updating garrisons via PlayerInterface -class CGarrisonHolder : public virtual CIntObject -{ -public: - CGarrisonHolder(); - virtual void updateGarrisons(){}; -}; - -class CWindowWithGarrison : public CGarrisonHolder -{ -public: - CGarrisonInt *garr; - virtual void updateGarrisons(); -}; -/// Window GUI class -class CSimpleWindow : public CIntObject -{ -public: - SDL_Surface * bitmap; //background - virtual void show(SDL_Surface * to); - CSimpleWindow():bitmap(NULL){}; //c-tor - virtual ~CSimpleWindow(); //d-tor -}; -/// Image class -class CPicture : public CIntObject -{ -public: - SDL_Surface *bg; - Rect *srcRect; //if NULL then whole surface will be used - bool freeSurf; //whether surface will be freed upon CPicture destruction - bool needRefresh;//Surface needs to be displayed each frame - - operator SDL_Surface*() - { - return bg; - } - - CPicture(const Rect &r, const SDL_Color &color, bool screenFormat = false); //rect filled with given color - CPicture(const Rect &r, ui32 color, bool screenFormat = false); //rect filled with given color - CPicture(SDL_Surface *BG, int x=0, int y=0, bool Free = true); //wrap existing SDL_Surface - CPicture(const std::string &bmpname, int x=0, int y=0); - CPicture(SDL_Surface *BG, const Rect &SrcRext, int x = 0, int y = 0, bool free = false); //wrap subrect of given surface - void init(); - - void createSimpleRect(const Rect &r, bool screenFormat, ui32 color); - ~CPicture(); - void show(SDL_Surface * to); - void showAll(SDL_Surface * to); - void convertToScreenBPP(); - void colorizeAndConvert(int player); - void colorize(int player); -}; - -/// Handles GUI logic and drawing -class CGuiHandler -{ -public: - FPSManager *mainFPSmng; //to keep const framerate - StopWatch th; - std::list listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on) - IStatusBar * statusbar; - - //active GUI elements (listening for events - std::list lclickable; - std::list rclickable; - std::list hoverable; - std::list keyinterested; - std::list motioninterested; - std::list timeinterested; - std::list wheelInterested; - std::list doubleClickInterested; - - //objs to blit - std::vector objsToBlit; - - SDL_Event * current; //current event - can be set to NULL to stop handling event - IUpdateable *curInt; - - Point lastClick; - unsigned lastClickTime; - bool terminate; - - CGuiHandler(); - ~CGuiHandler(); - void run(); // holds the main loop for the whole program after initialization and manages the update/rendering system - - void totalRedraw(); //forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering - void simpleRedraw(); //update only top interface and draw background from buffer, sets a flag, method gets called at the end of the rendering - - void popInt(IShowActivable *top); //removes given interface from the top and activates next - void popIntTotally(IShowActivable *top); //deactivates, deletes, removes given interface from the top and activates next - void pushInt(IShowActivable *newInt); //deactivate old top interface, activates this one and pushes to the top - void popInts(int howMany); //pops one or more interfaces - deactivates top, deletes and removes given number of interfaces, activates new front - IShowActivable *topInt(); //returns top interface - - void updateTime(); //handles timeInterested - void handleEvents(); //takes events from queue and calls interested objects - void handleEvent(SDL_Event *sEvent); - void handleMouseMotion(SDL_Event *sEvent); - void handleMoveInterested( const SDL_MouseMotionEvent & motion ); - void fakeMouseMove(); - void breakEventHandling(); //current event won't be propagated anymore - void drawFPSCounter(); // draws the FPS to the upper left corner of the screen - ui8 defActionsDef; //default auto actions - ui8 captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list - std::list createdObj; //stack of objs being created -}; - -extern CGuiHandler GH; //global gui handler - -SDLKey arrowToNum(SDLKey key); //converts arrow key to according numpad key -SDLKey numToDigit(SDLKey key);//converts numpad digit key to normal digit key -bool isNumKey(SDLKey key, bool number = true); //checks if key is on numpad (numbers - check only for numpad digits) -bool isArrowKey(SDLKey key); -CIntObject * moveChild(CIntObject *obj, CIntObject *from, CIntObject *to, bool adjustPos = false); - -template void pushIntT() -{ - GH.pushInt(new T()); -} - -struct ObjectConstruction -{ - CIntObject *myObj; - ObjectConstruction(CIntObject *obj); - ~ObjectConstruction(); -}; - -struct SetCaptureState -{ - bool previousCapture; - ui8 prevActions; - SetCaptureState(bool allow, ui8 actions); - ~SetCaptureState(); -}; - -class Colors -{ -public: - static SDL_Color MetallicGold; - static SDL_Color Yellow; - - static SDL_Color createColor(int r, int g, int b); -}; - -#define OBJ_CONSTRUCTION ObjectConstruction obj__i(this) -#define OBJ_CONSTRUCTION_CAPTURING_ALL defActions = 255; SetCaptureState obj__i1(true, 255); ObjectConstruction obj__i(this) -#define BLOCK_CAPTURING SetCaptureState obj__i(false, 0) -#define BLOCK_CAPTURING_DONT_TOUCH_REC_ACTIONS SetCaptureState obj__i(false, GH.defActionsDef) diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 7e082772c..37f7726b8 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -15,7 +15,7 @@ #include "CConfigHandler.h" #include "SDL_framerate.h" #include "CConfigHandler.h" -#include "CCreatureAnimation.h" +#include "BattleInterface/CCreatureAnimation.h" #include "CPlayerInterface.h" #include "Graphics.h" #include "CAnimation.h" @@ -30,7 +30,7 @@ #include "../lib/CondSh.h" #include "../lib/map.h" #include "mapHandler.h" -#include "../lib/StopWatch.h" +#include "../lib/CStopWatch.h" #include "../lib/NetPacks.h" #include "CSpellWindow.h" #include "CHeroWindow.h" @@ -43,6 +43,7 @@ #include "../lib/BattleState.h" #include "../lib/CGameState.h" #include "../lib/GameConstants.h" +#include "UIFramework/CGuiHandler.h" /* * GUIClasses.cpp, part of VCMI engine @@ -437,8 +438,8 @@ void CGarrisonInt::splitStacks(int am2) LOCPLINT->cb->splitStack(armedObjs[highlighted->upg], armedObjs[pb], highlighted->ID, p2, am2); } -CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point &garsOffset, - SDL_Surface *pomsur, const Point& SurOffset, +CGarrisonInt::CGarrisonInt(int x, int y, int inx, const SPoint &garsOffset, + SDL_Surface *pomsur, const SPoint& SurOffset, const CArmedInstance *s1, const CArmedInstance *s2, bool _removableUnits, bool smallImgs, bool _twoRows ) : interx(inx), garOffset(garsOffset), highlighted(NULL), splitting(false), @@ -481,7 +482,7 @@ CInfoWindow::CInfoWindow(std::string Text, int player, const TCompsInfo &comps, buttons.push_back(button); } - text = new CTextBox(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, zwykly); + text = new CTextBox(Text, SRect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, zwykly); if(!text->slider) { text->pos.w = text->maxW; @@ -602,13 +603,13 @@ void CRClickPopup::createAndPush(const std::string &txt, const CInfoWindow::TCom int player = LOCPLINT ? LOCPLINT->playerID : 1; //if no player, then use blue CSimpleWindow * temp = new CInfoWindow(txt, player, comps); - temp->center(Point(GH.current->motion)); //center on mouse + temp->center(SPoint(GH.current->motion)); //center on mouse temp->fitToScreen(10); CRClickPopupInt *rcpi = new CRClickPopupInt(temp,true); GH.pushInt(rcpi); } -void CRClickPopup::createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment /*= BOTTOMRIGHT*/) +void CRClickPopup::createAndPush(const CGObjectInstance *obj, const SPoint &p, EAlignment alignment /*= BOTTOMRIGHT*/) { SDL_Surface *iWin = LOCPLINT->infoWin(obj); //try get custom infowindow for this obj if(iWin) @@ -632,7 +633,7 @@ CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free) } -CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free/*=false*/) +CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, const SPoint &p, EAlignment alignment, bool Free/*=false*/) : free(Free),bitmap(Bitmap) { switch(alignment) @@ -934,7 +935,7 @@ void CSelectableComponent::show(SDL_Surface * to) blitAt(getImg(),pos.x,pos.y,to); if(selected) { - CSDL_Ext::drawBorder(to, Rect::around(Rect(pos.x, pos.y, getImg()->w, getImg()->h)), int3(239,215,123)); + CSDL_Ext::drawBorder(to, SRect::around(SRect(pos.x, pos.y, getImg()->w, getImg()->h)), int3(239,215,123)); } printAtMiddleWB(subtitle,pos.x+pos.w/2,pos.y+pos.h+25,FONT_SMALL,12,zwykly,to); @@ -976,7 +977,7 @@ CIntObject* CObjectList::createItem(size_t index) if(item->parent != this) { if (item->parent) - moveChild(item, item->parent, this); + CGuiHandler::moveChild(item, item->parent, this); else addChild(item); } @@ -986,7 +987,7 @@ CIntObject* CObjectList::createItem(size_t index) return item; } -CTabbedInt::CTabbedInt(CreateFunc create, DestroyFunc destroy, Point position, size_t ActiveID): +CTabbedInt::CTabbedInt(CreateFunc create, DestroyFunc destroy, SPoint position, size_t ActiveID): CObjectList(create, destroy), activeTab(NULL), activeID(ActiveID) @@ -1019,8 +1020,8 @@ CIntObject * CTabbedInt::getItem() return activeTab; } -CListBox::CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point ItemOffset, size_t VisibleSize, - size_t TotalSize, size_t InitialPos, int Slider, Rect SliderPos): +CListBox::CListBox(CreateFunc create, DestroyFunc destroy, SPoint Pos, SPoint ItemOffset, size_t VisibleSize, + size_t TotalSize, size_t InitialPos, int Slider, SRect SliderPos): CObjectList(create, destroy), first(InitialPos), totalSize(TotalSize), @@ -1041,7 +1042,7 @@ CListBox::CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point Item // Used to move active items after changing list position void CListBox::updatePositions() { - Point itemPos = pos.topLeft(); + SPoint itemPos = pos.topLeft(); for (std::list::iterator it = items.begin(); it!=items.end(); it++) { (*it)->moveTo(itemPos); @@ -1157,7 +1158,7 @@ CSelWindow::CSelWindow(const std::string &Text, int player, int charperline, con buttons[i]->callback += boost::bind(&CInfoWindow::close,this); //each button will close the window apart from call-defined actions } - text = new CTextBox(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, zwykly); + text = new CTextBox(Text, SRect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, zwykly); text->redrawParentOnScrolling = true; buttons.front()->assignedKeys.insert(SDLK_RETURN); //first button - reacts on enter @@ -1322,8 +1323,8 @@ void CHeroList::init() { int w = pos.w+1, h = pos.h+4; bg = CSDL_Ext::newSurface(w,h,screen); - Rect srcRect = genRect(w, h, pos.x, pos.y); - Rect dstRect = genRect(w, h, 0, 0); + SRect srcRect = genRect(w, h, pos.x, pos.y); + SRect dstRect = genRect(w, h, 0, 0); CSDL_Ext::blitSurface(adventureInt->bg, &srcRect, bg, &dstRect); } @@ -1845,7 +1846,7 @@ CCreaturePic::CCreaturePic(int x, int y, const CCreature *cre, bool Big, bool An else bg = new CPicture(graphics->backgroundsm[cre->faction],0,0,false); bg->needRefresh = true; - anim = new CCreatureAnim(0, 0, cre->animDefName, Rect()); + anim = new CCreatureAnim(0, 0, cre->animDefName, SRect()); anim->clipRect(cre->doubleWide?170:150, 155, bg->pos.w, bg->pos.h); anim->startPreview(); } @@ -1905,7 +1906,7 @@ void CRecruitmentWindow::clickLeft(tribool down, bool previousState) { for(int i=0;imotion.x, GH.current->motion.y)) { which = i; @@ -1930,7 +1931,7 @@ void CRecruitmentWindow::clickRight(tribool down, bool previousState) for(int i=0;imotion.x, GH.current->motion.y)) { CIntObject *popup = createCreWindow(creatures[i].ID, 0, 0); @@ -1985,7 +1986,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling *Dwelling, int Level, co bitmap = new CPicture("TPRCRT.bmp"); bitmap->colorizeAndConvert(LOCPLINT->playerID); bitmap->center(); - pos = (bitmap->pos += Point(0, y_offset)); + pos = (bitmap->pos += SPoint(0, y_offset)); bar = new CGStatusBar(8, 370, "APHLFTRT.bmp", 471); max = new AdventureMapButton(CGI->generaltexth->zelp[553],boost::bind(&CRecruitmentWindow::Max,this),134,313,"IRCBTNS.DEF",SDLK_m); @@ -2158,8 +2159,8 @@ void CSplitWindow::show(SDL_Surface * to) void CSplitWindow::keyPressed (const SDL_KeyboardEvent & key) { SDLKey k = key.keysym.sym; - if (isNumKey(k)) //convert numpad number to normal digit - k = numToDigit(k); + if (CGuiHandler::isNumKey(k)) //convert numpad number to normal digit + k = CGuiHandler::numToDigit(k); if(key.state != SDL_PRESSED) return; @@ -2205,11 +2206,11 @@ void CSplitWindow::clickLeft(tribool down, bool previousState) { if(down) { - Point click(GH.current->motion.x,GH.current->motion.y); + SPoint click(GH.current->motion.x,GH.current->motion.y); click = click - pos.topLeft(); - if(Rect(19,216,105,40).isIn(click)) //left picture + if(SRect(19,216,105,40).isIn(click)) //left picture which = 0; - else if(Rect(175,216,105,40).isIn(click)) //right picture + else if(SRect(175,216,105,40).isIn(click)) //right picture which = 1; } } @@ -2680,32 +2681,32 @@ CTradeWindow::CTradeableItem::CTradeableItem( EType Type, int ID, bool Left, int void CTradeWindow::CTradeableItem::showAll(SDL_Surface * to) { - Point posToBitmap; - Point posToSubCenter; + SPoint posToBitmap; + SPoint posToSubCenter; switch(type) { case RESOURCE: - posToBitmap = Point(19,9); - posToSubCenter = Point(36, 59); + posToBitmap = SPoint(19,9); + posToSubCenter = SPoint(36, 59); break; case CREATURE_PLACEHOLDER: case CREATURE: - posToSubCenter = Point(29, 76); + posToSubCenter = SPoint(29, 76); if(downSelection) posToSubCenter.y += 5; break; case PLAYER: - posToSubCenter = Point(31, 76); + posToSubCenter = SPoint(31, 76); break; case ARTIFACT_PLACEHOLDER: case ARTIFACT_INSTANCE: - posToSubCenter = Point(19, 55); + posToSubCenter = SPoint(19, 55); if(downSelection) posToSubCenter.y += 8; break; case ARTIFACT_TYPE: - posToSubCenter = Point(19, 58); + posToSubCenter = SPoint(19, 58); break; } @@ -2785,9 +2786,9 @@ SDL_Surface * CTradeWindow::CTradeableItem::getSurface() } } -void CTradeWindow::CTradeableItem::showAllAt(const Point &dstPos, const std::string &customSub, SDL_Surface * to) +void CTradeWindow::CTradeableItem::showAllAt(const SPoint &dstPos, const std::string &customSub, SDL_Surface * to) { - Rect oldPos = pos; + SRect oldPos = pos; std::string oldSub = subtitle; downSelection = true; @@ -2940,7 +2941,7 @@ void CTradeWindow::initItems(bool Left) CTradeableItem *hlp = new CTradeableItem(itemsType[Left], -1, 1, 0); hlp->recActions &= ~(UPDATE | SHOWALL); - hlp->pos += Rect(137, 469, 42, 42); + hlp->pos += SRect(137, 469, 42, 42); items[Left].push_back(hlp); } else //ARTIFACT_EXP @@ -2950,7 +2951,7 @@ void CTradeWindow::initItems(bool Left) } BLOCK_CAPTURING; - arts = new CArtifactsOfHero(Point(pos.x+xOffset, pos.y+yOffset)); + arts = new CArtifactsOfHero(SPoint(pos.x+xOffset, pos.y+yOffset)); arts->commonInfo = new CArtifactsOfHero::SCommonPart; arts->commonInfo->participants.insert(arts); arts->recActions = 255; @@ -2965,7 +2966,7 @@ void CTradeWindow::initItems(bool Left) } std::vector *ids = getItemsIds(Left); - std::vector pos; + std::vector pos; int amount = -1; getPositionsFor(pos, Left, itemsType[Left]); @@ -3035,7 +3036,7 @@ std::vector *CTradeWindow::getItemsIds(bool Left) return ids; } -void CTradeWindow::getPositionsFor(std::vector &poss, bool Left, EType type) const +void CTradeWindow::getPositionsFor(std::vector &poss, bool Left, EType type) const { if(mode == EMarketMode::ARTIFACT_EXP && !Left) { @@ -3048,10 +3049,10 @@ void CTradeWindow::getPositionsFor(std::vector &poss, bool Left, EType typ dy = 70; for (int i = 0; i < 4 ; i++) for (int j = 0; j < 5 ; j++) - poss += Rect(x + dx*j, y + dy*i, w, h); + poss += SRect(x + dx*j, y + dy*i, w, h); - poss += Rect(x + dx*1.5, y + dy*4, w, h); - poss += Rect(x + dx*2.5, y + dy*4, w, h); + poss += SRect(x + dx*1.5, y + dy*4, w, h); + poss += SRect(x + dx*2.5, y + dy*4, w, h); } else { @@ -3069,7 +3070,7 @@ void CTradeWindow::getPositionsFor(std::vector &poss, bool Left, EType typ if(!Left) { - BOOST_FOREACH(Rect &r, poss) + BOOST_FOREACH(SRect &r, poss) r.x += leftToRightOffset; } } @@ -3283,10 +3284,10 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan { slider = NULL; max = NULL; - deal->moveBy(Point(-30, 0)); + deal->moveBy(SPoint(-30, 0)); } - Rect traderTextRect; + SRect traderTextRect; //left side switch(Mode) @@ -3312,11 +3313,11 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan case EMarketMode::RESOURCE_ARTIFACT: case EMarketMode::ARTIFACT_RESOURCE: printAtMiddle(CGI->generaltexth->allTexts[168],445,148,FONT_SMALL,zwykly,*bg); //available for trade - traderTextRect = Rect(316, 48, 260, 75); + traderTextRect = SRect(316, 48, 260, 75); break; case EMarketMode::RESOURCE_PLAYER: printAtMiddle(CGI->generaltexth->allTexts[169],445,55,FONT_SMALL,zwykly,*bg); //players - traderTextRect = Rect(28, 48, 260, 75); + traderTextRect = SRect(28, 48, 260, 75); break; } @@ -3524,18 +3525,18 @@ std::string CMarketplaceWindow::selectionSubtitle(bool Left) const return "???"; } -Point CMarketplaceWindow::selectionOffset(bool Left) const +SPoint CMarketplaceWindow::selectionOffset(bool Left) const { if(Left) { switch(itemsType[1]) { case RESOURCE: - return Point(122, 446); + return SPoint(122, 446); case CREATURE: - return Point(128, 450); + return SPoint(128, 450); case ARTIFACT_INSTANCE: - return Point(134, 466); + return SPoint(134, 466); } } else @@ -3544,18 +3545,18 @@ Point CMarketplaceWindow::selectionOffset(bool Left) const { case RESOURCE: if(mode == EMarketMode::ARTIFACT_RESOURCE) - return Point(410, 469); + return SPoint(410, 469); else - return Point(410, 446); + return SPoint(410, 446); case ARTIFACT_TYPE: - return Point(425, 447); + return SPoint(425, 447); case PLAYER: - return Point(417, 451); + return SPoint(417, 451); } } assert(0); - return Point(0,0); + return SPoint(0,0); } void CMarketplaceWindow::resourceChanged(int type, int val) @@ -3854,7 +3855,7 @@ void CAltarWindow::selectionChanged(bool side) void CAltarWindow::mimicCres() { - std::vector positions; + std::vector positions; getPositionsFor(positions, false, CREATURE); BOOST_FOREACH(CTradeableItem *t, items[1]) @@ -3865,12 +3866,12 @@ void CAltarWindow::mimicCres() } } -Point CAltarWindow::selectionOffset(bool Left) const +SPoint CAltarWindow::selectionOffset(bool Left) const { if(Left) - return Point(150, 421); + return SPoint(150, 421); else - return Point(396, 421); + return SPoint(396, 421); } std::string CAltarWindow::selectionSubtitle(bool Left) const @@ -4369,7 +4370,7 @@ void CInGameConsole::show(SDL_Surface * to) for(std::list< std::pair< std::string, int > >::iterator it = texts.begin(); it != texts.end(); ++it, ++number) { SDL_Color green = {0,0xff,0,0}; - Point leftBottomCorner(0, screen->h); + SPoint leftBottomCorner(0, screen->h); if(LOCPLINT->battleInt) { leftBottomCorner = LOCPLINT->battleInt->pos.bottomLeft(); @@ -4578,7 +4579,7 @@ CGarrisonWindow::CGarrisonWindow( const CArmedInstance *up, const CGHeroInstance bg->colorizeAndConvert(LOCPLINT->playerID); pos = bg->center(); - garr = new CGarrisonInt(92, 127, 4, Point(0,96), bg->bg, Point(93,127), up, down, removableUnits); + garr = new CGarrisonInt(92, 127, 4, SPoint(0,96), bg->bg, SPoint(93,127), up, down, removableUnits); { AdventureMapButton *split = new AdventureMapButton(CGI->generaltexth->tcommands[3],"",boost::bind(&CGarrisonInt::splitClick,garr),88,314,"IDV6432.DEF"); removeChild(split); @@ -4609,7 +4610,7 @@ void CGarrisonWindow::showAll(SDL_Surface * to) blitAtLoc(graphics->portraitLarge[static_cast(garr->armedObjs[1])->portrait],29,222,to); } -IShowActivable::IShowActivable() +IShowActivatable::IShowActivatable() { type = 0; } @@ -4629,7 +4630,7 @@ void CRClickPopupInt::show(SDL_Surface * to) inner->show(to); } -CRClickPopupInt::CRClickPopupInt( IShowActivable *our, bool deleteInt ) +CRClickPopupInt::CRClickPopupInt( IShowActivatable *our, bool deleteInt ) { CCS->curh->hide(); inner = our; @@ -4659,7 +4660,7 @@ CArtPlace::CArtPlace(const CArtifactInstance* Art) { } -CArtPlace::CArtPlace(Point position, const CArtifactInstance * Art): +CArtPlace::CArtPlace(SPoint position, const CArtifactInstance * Art): picked(false), marked(false), locked(false), ourArt(Art) { pos += position; @@ -5024,7 +5025,7 @@ LRClickableAreaWText::LRClickableAreaWText() init(); } -LRClickableAreaWText::LRClickableAreaWText(const Rect &Pos, const std::string &HoverText /*= ""*/, const std::string &ClickText /*= ""*/) +LRClickableAreaWText::LRClickableAreaWText(const SRect &Pos, const std::string &HoverText /*= ""*/, const std::string &ClickText /*= ""*/) { init(); pos = Pos + pos; @@ -5050,7 +5051,7 @@ void LRClickableAreaWTextComp::clickLeft(tribool down, bool previousState) } } -LRClickableAreaWTextComp::LRClickableAreaWTextComp(const Rect &Pos, int BaseType) +LRClickableAreaWTextComp::LRClickableAreaWTextComp(const SRect &Pos, int BaseType) : LRClickableAreaWText(Pos), baseType(BaseType), bonusValue(-1) { } @@ -5129,7 +5130,7 @@ void LRClickableAreaOpenTown::clickRight(tribool down, bool previousState) } LRClickableAreaOpenTown::LRClickableAreaOpenTown() - : LRClickableAreaWTextComp(Rect(0,0,0,0), -1) + : LRClickableAreaWTextComp(SRect(0,0,0,0), -1) { } @@ -5388,7 +5389,7 @@ CArtifactsOfHero::CArtifactsOfHero(std::vector ArtWorn, std::vector rightArtRoll->callback += boost::bind(&CArtifactsOfHero::scrollBackpack,this,+1); } -CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart /*= false*/) +CArtifactsOfHero::CArtifactsOfHero(const SPoint& position, bool createCommonPart /*= false*/) : curHero(NULL), backpackPos(0), commonInfo(NULL), updateState(false), allowedAssembling(true), highlightModeCallback(0) { if(createCommonPart) @@ -5401,7 +5402,7 @@ CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart pos += position; artWorn.resize(19); - std::vector slotPos; + std::vector slotPos; slotPos += genRect(44,44,509,30), genRect(44,44,567,240), genRect(44,44,509,80), genRect(44,44,383,68), genRect(44,44,564,183), genRect(44,44,509,130), genRect(44,44,431,68), genRect(44,44,610,183), genRect(44,44,515,295), @@ -5741,11 +5742,11 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL) pos.h = screen->h; - artifs[0] = new CArtifactsOfHero(Point(pos.x + -334, pos.y + 150)); + artifs[0] = new CArtifactsOfHero(SPoint(pos.x + -334, pos.y + 150)); artifs[0]->commonInfo = new CArtifactsOfHero::SCommonPart; artifs[0]->commonInfo->participants.insert(artifs[0]); artifs[0]->setHero(heroInst[0]); - artifs[1] = new CArtifactsOfHero(Point(pos.x + 96, pos.y + 150)); + artifs[1] = new CArtifactsOfHero(SPoint(pos.x + 96, pos.y + 150)); artifs[1]->commonInfo = artifs[0]->commonInfo; artifs[1]->commonInfo->participants.insert(artifs[1]); artifs[1]->setHero(heroInst[1]); @@ -5826,7 +5827,7 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL) ourBar = new CGStatusBar(pos.x + 3, pos.y + 577, "KSTATBAR"); //garrison interface - garr = new CGarrisonInt(pos.x + 69, pos.y + 131, 4, Point(418,0), bg, Point(69,131), heroInst[0],heroInst[1], true, true); + garr = new CGarrisonInt(pos.x + 69, pos.y + 131, 4, SPoint(418,0), bg, SPoint(69,131), heroInst[0],heroInst[1], true, true); { BLOCK_CAPTURING; @@ -5855,7 +5856,7 @@ CShipyardWindow::CShipyardWindow(const std::vector &cost, int state, int b std::string boatFilenames[3] = {"AB01_", "AB02_", "AB03_"}; - Point waterCenter = Point(bgWater->pos.x+bgWater->pos.w/2, bgWater->pos.y+bgWater->pos.h/2); + SPoint waterCenter = SPoint(bgWater->pos.x+bgWater->pos.w/2, bgWater->pos.y+bgWater->pos.h/2); bgShip = new CAnimImage(boatFilenames[boatType], 0, 7, 120, 96, CShowableAnim::USE_RLE); bgShip->center(waterCenter); @@ -5909,7 +5910,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, double discoveredRatio) //printing necessary things to background int3 moveInt = int3(8, 9, 0); - Rect mapRect = genRect(544, 591, 8, 8); + SRect mapRect = genRect(544, 591, 8, 8); CGI->mh->terrainRect (grailPos - moveInt, adventureInt->anim, &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, @@ -6292,7 +6293,7 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance *visitor, const CGObjectIn quit = new AdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 294, 275, "IOKAY.DEF", SDLK_RETURN); bar = new CGStatusBar(327, 332); - garr = new CGarrisonInt(108, 60, 18, Point(),bg->bg,Point(108,60),hero,NULL); + garr = new CGarrisonInt(108, 60, 18, SPoint(),bg->bg,SPoint(108,60),hero,NULL); updateGarrisons(); } @@ -6485,7 +6486,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner) SThievesGuildInfo tgi; //info to be displayed LOCPLINT->cb->getThievesGuildInfo(tgi, owner); - pos = center(Rect(0,0,800,600));// Rect( (conf.cc.resx - 800) / 2, (conf.cc.resy - 600) / 2, 800, 600 ); + pos = center(SRect(0,0,800,600));// SRect( (conf.cc.resx - 800) / 2, (conf.cc.resy - 600) / 2, 800, 600 ); //loading backround and converting to more bpp form SDL_Surface * bg = background = BitmapHandler::loadBitmap("TpRank.bmp", false); @@ -6685,10 +6686,10 @@ void MoraleLuckBox::showAll(SDL_Surface * to) def = morale ? graphics->morale42 : graphics->luck42; SDL_Surface *img = def->ourImages[bonusValue + 3].bitmap; - blitAt(img, Rect(img).centerIn(pos), to); //put img in the center of our pos + blitAt(img, SRect(img).centerIn(pos), to); //put img in the center of our pos } -MoraleLuckBox::MoraleLuckBox(bool Morale, const Rect &r, bool Small) +MoraleLuckBox::MoraleLuckBox(bool Morale, const SRect &r, bool Small) :morale(Morale), small(Small) { @@ -6742,7 +6743,7 @@ void CLabel::setTxt(const std::string &Txt) } } -CTextBox::CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= zwykly*/) +CTextBox::CTextBox(std::string Text, const SRect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= zwykly*/) :CLabel(rect.x, rect.y, Font, Align, Color, Text), sliderStyle(SliderStyle), slider(NULL) { redrawParentOnScrolling = false; @@ -6862,7 +6863,7 @@ CGStatusBar::CGStatusBar(CPicture *BG, EFonts Font /*= FONT_SMALL*/, EAlignment { init(); bg = BG; - moveChild(bg, bg->parent, this); + CGuiHandler::moveChild(bg, bg->parent, this); pos = bg->pos; calcOffset(); } @@ -6877,7 +6878,7 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int if(maxw < pos.w) { vstd::amin(pos.w, maxw); - bg->srcRect = new Rect(0, 0, maxw, pos.h); + bg->srcRect = new SRect(0, 0, maxw, pos.h); } calcOffset(); } @@ -6903,15 +6904,15 @@ void CGStatusBar::calcOffset() switch(alignment) { case CENTER: - textOffset = Point(pos.w/2, pos.h/2); + textOffset = SPoint(pos.w/2, pos.h/2); break; case BOTTOMRIGHT: - textOffset = Point(pos.w, pos.h); + textOffset = SPoint(pos.w, pos.h); break; } } -CTextInput::CTextInput( const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList &CB ) +CTextInput::CTextInput( const SRect &Pos, const SPoint &bgOffset, const std::string &bgName, const CFunctionList &CB ) :cb(CB) { focus = false; @@ -6923,14 +6924,14 @@ CTextInput::CTextInput( const Rect &Pos, const Point &bgOffset, const std::strin giveFocus(); } -CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf) +CTextInput::CTextInput(const SRect &Pos, SDL_Surface *srf) { focus = false; pos += Pos; captureAllKeys = true; OBJ_CONSTRUCTION; bg = new CPicture(Pos, 0, true); - Rect hlp = Pos; + SRect hlp = Pos; if(srf) CSDL_Ext::blitSurface(srf, &hlp, *bg, NULL); else diff --git a/client/GUIClasses.h b/client/GUIClasses.h index ff1d8989e..d7c435adf 100644 --- a/client/GUIClasses.h +++ b/client/GUIClasses.h @@ -1,10 +1,13 @@ #pragma once -#include "GUIBase.h" #include "FunctionList.h" #include "../lib/ResourceSet.h" #include "../lib/GameConstants.h" +#include "UIFramework/CSimpleWindow.h" +#include "UIFramework/IStatusBar.h" +#include "UIFramework/CPicture.h" +#include "UIFramework/CKeyShortcut.h" #ifdef max #undef max @@ -127,19 +130,19 @@ public: virtual ~CRClickPopup(); //d-tor static void createAndPush(const std::string &txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo()); - static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT); + static void createAndPush(const CGObjectInstance *obj, const SPoint &p, EAlignment alignment = BOTTOMRIGHT); }; /// popup displayed on R-click class CRClickPopupInt : public CRClickPopup { public: - IShowActivable *inner; + IShowActivatable *inner; bool delInner; void show(SDL_Surface * to); void showAll(SDL_Surface * to); - CRClickPopupInt(IShowActivable *our, bool deleteInt); //c-tor + CRClickPopupInt(IShowActivatable *our, bool deleteInt); //c-tor virtual ~CRClickPopupInt(); //d-tor }; @@ -151,7 +154,7 @@ public: 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, const SPoint &p, EAlignment alignment, bool Free=false); //c-tor CInfoPopup(SDL_Surface *Bitmap = NULL, bool Free = false); //default c-tor void init(int x, int y); @@ -190,7 +193,7 @@ public: virtual void deactivate(); }; -class CSelectableComponent : public SComponent, public KeyShortcut +class CSelectableComponent : public SComponent, public CKeyShortcut { public: bool selected; //if true, this component is selected @@ -239,7 +242,7 @@ public: //CreateFunc, DestroyFunc - see CObjectList //Pos - position of object, all tabs will be moved to this position //ActiveID - ID of initially active tab - CTabbedInt(CreateFunc create, DestroyFunc destroy = DestroyFunc(), Point position=Point(), size_t ActiveID=0); + CTabbedInt(CreateFunc create, DestroyFunc destroy = DestroyFunc(), SPoint position=SPoint(), size_t ActiveID=0); void setActive(size_t which); //recreate active tab @@ -257,7 +260,7 @@ private: size_t first; size_t totalSize; - Point itemOffset; + SPoint itemOffset; CSlider * slider; void updatePositions(); @@ -269,8 +272,8 @@ public: //TotalSize //Slider - slider style, bit field: 1 = present(disabled), 2=horisontal(vertical), 4=blue(brown) //SliderPos - position of slider, if present - CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point ItemOffset, size_t VisibleSize, - size_t TotalSize, size_t InitialPos=0, int Slider=0, Rect SliderPos=Rect() ); + CListBox(CreateFunc create, DestroyFunc destroy, SPoint Pos, SPoint ItemOffset, size_t VisibleSize, + size_t TotalSize, size_t InitialPos=0, int Slider=0, SRect SliderPos=SRect() ); //recreate all visible items void reset(); @@ -318,7 +321,7 @@ class CGarrisonInt :public CIntObject { public: int interx; //space between slots - Point garOffset; //offset between garrisons (not used if only one hero) + SPoint garOffset; //offset between garrisons (not used if only one hero) CGarrisonSlot *highlighted; //chosen slot std::vector splitButtons; //may be empty if no buttons @@ -355,7 +358,7 @@ public: //removableUnits - you can take units from top; //smallImgs - units images size 64x58 or 32x32; //twoRows - display slots in 2 row (1st row = 4, 2nd = 3) - CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor + CGarrisonInt(int x, int y, int inx, const SPoint &garsOffset, SDL_Surface *pomsur, const SPoint &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor ~CGarrisonInt(); //d-tor }; @@ -387,7 +390,7 @@ public: std::string text; CPicture *bg; bool autoRedraw; //whether control will redraw itself on setTxt - Point textOffset; //text will be blitted at pos + textOffset with appropriate alignment + SPoint textOffset; //text will be blitted at pos + textOffset with appropriate alignment bool ignoreLeadingWhitespace; virtual void setTxt(const std::string &Txt); @@ -410,8 +413,8 @@ public: std::vector effects; CSlider *slider; - //CTextBox( std::string Text, const Point &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly); - CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly); + //CTextBox( std::string Text, const SPoint &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly); + CTextBox(std::string Text, const SRect &rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly); void showAll(SDL_Surface * to); //shows statusbar (with current text) void setTxt(const std::string &Txt); void setBounds(int limitW, int limitH); @@ -467,8 +470,8 @@ public: void setText(const std::string &nText, bool callCb = false); - CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList &CB); - CTextInput(const Rect &Pos, SDL_Surface *srf = NULL); + CTextInput(const SRect &Pos, const SPoint &bgOffset, const std::string &bgName, const CFunctionList &CB); + CTextInput(const SRect &Pos, SDL_Surface *srf = NULL); ~CTextInput(); void showAll(SDL_Surface * to); void clickLeft(tribool down, bool previousState); @@ -671,7 +674,7 @@ public: CPicture *titleImage;//title image (castle gate\town portal picture) AdventureMapButton *ok, *exit; - std::vector areas;//areas for each visible item + std::vector areas;//areas for each visible item std::vector items;//id of all items present in list int selected;//currently selected item int length;//size of list (=9) @@ -737,7 +740,7 @@ public: CFunctionList callback; bool downSelection; - void showAllAt(const Point &dstPos, const std::string &customSub, SDL_Surface * to); + void showAllAt(const SPoint &dstPos, const std::string &customSub, SDL_Surface * to); void clickRight(tribool down, bool previousState); void hover (bool on); @@ -771,7 +774,7 @@ public: void initTypes(); void initItems(bool Left); std::vector *getItemsIds(bool Left); //NULL if default - void getPositionsFor(std::vector &poss, bool Left, EType type) const; + void getPositionsFor(std::vector &poss, bool Left, EType type) const; void removeItems(const std::set &toRemove); void removeItem(CTradeableItem * t); void getEmptySlots(std::set &toRemove); @@ -781,7 +784,7 @@ public: virtual void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const = 0; virtual void selectionChanged(bool side) = 0; //true == left - virtual Point selectionOffset(bool Left) const = 0; + virtual SPoint selectionOffset(bool Left) const = 0; virtual std::string selectionSubtitle(bool Left) const = 0; virtual void garrisonChanged() = 0; virtual void artifactsChanged(bool left) = 0; @@ -802,7 +805,7 @@ public: CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); //c-tor ~CMarketplaceWindow(); //d-tor - Point selectionOffset(bool Left) const; + SPoint selectionOffset(bool Left) const; std::string selectionSubtitle(bool Left) const; @@ -843,7 +846,7 @@ public: void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const; void mimicCres(); - Point selectionOffset(bool Left) const; + SPoint selectionOffset(bool Left) const; std::string selectionSubtitle(bool Left) const; void garrisonChanged(); void artifactsChanged(bool left); @@ -961,7 +964,7 @@ public: std::string text; LRClickableAreaWText(); - LRClickableAreaWText(const Rect &Pos, const std::string &HoverText = "", const std::string &ClickText = ""); + LRClickableAreaWText(const SRect &Pos, const std::string &HoverText = "", const std::string &ClickText = ""); virtual ~LRClickableAreaWText(); void init(); @@ -978,7 +981,7 @@ public: virtual void clickLeft(tribool down, bool previousState); virtual void clickRight(tribool down, bool previousState); - LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1); + LRClickableAreaWTextComp(const SRect &Pos = SRect(0,0,0,0), int BaseType = -1); SComponent * createComponent() const; }; @@ -991,7 +994,7 @@ public: void set(const IBonusBearer *node); void showAll(SDL_Surface * to); - MoraleLuckBox(bool Morale, const Rect &r, bool Small=false); + MoraleLuckBox(bool Morale, const SRect &r, bool Small=false); ~MoraleLuckBox(); }; @@ -1063,7 +1066,7 @@ public: const CArtifactInstance * ourArt; CArtPlace(const CArtifactInstance * Art); //c-tor - CArtPlace(Point position, const CArtifactInstance * Art = NULL); //c-tor + CArtPlace(SPoint position, const CArtifactInstance * Art = NULL); //c-tor void clickLeft(tribool down, bool previousState); void clickRight(tribool down, bool previousState); void select (); @@ -1138,7 +1141,7 @@ public: void updateSlot(int i); void eraseSlotData (CArtPlace* artPlace, int slotID); - CArtifactsOfHero(const Point& position, bool createCommonPart = false); + CArtifactsOfHero(const SPoint& position, bool createCommonPart = false); //Alternative constructor, used if custom artifacts positioning required (Kingdom interface) CArtifactsOfHero(std::vector ArtWorn, std::vector Backpack, AdventureMapButton *leftScroll, AdventureMapButton *rightScroll, bool createCommonPart = false); @@ -1147,6 +1150,20 @@ public: friend class CArtPlace; }; +class CGarrisonHolder : public virtual CIntObject +{ +public: + CGarrisonHolder(); + virtual void updateGarrisons(){}; +}; + +class CWindowWithGarrison : public CGarrisonHolder +{ +public: + CGarrisonInt *garr; + virtual void updateGarrisons(); +}; + /// Garrison window where you can take creatures out of the hero to place it on the garrison class CGarrisonWindow : public CWindowWithGarrison { diff --git a/client/Graphics.cpp b/client/Graphics.cpp index e58d979e7..b3ff49ddb 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -20,6 +20,7 @@ #include "../lib/JsonNode.h" #include "../lib/vcmi_endian.h" #include "../lib/GameConstants.h" +#include "../lib/CStopWatch.h" using namespace boost::assign; using namespace CSDL_Ext; @@ -364,7 +365,7 @@ void Graphics::loadWallPositions() int townID = town["id"].Float(); BOOST_FOREACH(const JsonNode &coords, town["pos"].Vector()) { - Point pt(coords["x"].Float(), coords["y"].Float()); + SPoint pt(coords["x"].Float(), coords["y"].Float()); wallPositions[townID].push_back(pt); } @@ -484,7 +485,7 @@ void Graphics::loadHeroFlags(std::pair Graphics::*, void Graphics::loadHeroFlags() { using namespace boost::assign; - StopWatch th; + CStopWatch th; std::pair Graphics::*, std::vector > pr[4]; pr[0].first = &Graphics::flags1; pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"), diff --git a/client/Graphics.h b/client/Graphics.h index 1f3561b2c..286d3bb6a 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -2,8 +2,9 @@ #include "FontBase.h" -#include "GUIBase.h" #include "../lib/GameConstants.h" +#include "UIFramework/SPoint.h" +#include "UIFramework/SRect.h" /* * Graphics.h, part of VCMI engine @@ -86,7 +87,7 @@ public: std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names CDefEssential * spellEffectsPics; //bitmaps representing spells affecting a stack in battle - std::vector< Point > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall + std::vector< SPoint > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall //abilities CDefEssential * abils32, * abils44, * abils82; //spells diff --git a/client/Makefile.am b/client/Makefile.am index 84158f3b9..262c553ec 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -25,12 +25,14 @@ vcmiclient_SOURCES = \ ./BattleInterface/CBattleResultWindow.h \ ./BattleInterface/CBattleStackAnimation.cpp \ ./BattleInterface/CBattleStackAnimation.h \ + ./BattleInterface/CCreatureAnimation.h \ + ./BattleInterface/CCreatureAnimation.cpp \ ./BattleInterface/CDefenceAnimation.cpp \ ./BattleInterface/CDefenceAnimation.h \ ./BattleInterface/CDummyAnimation.cpp \ ./BattleInterface/CDummyAnimation.h \ - ./BattleInterface/CHexFieldControl.cpp \ - ./BattleInterface/CHexFieldControl.h \ + ./BattleInterface/CClickableHex.cpp \ + ./BattleInterface/CClickableHex.h \ ./BattleInterface/CMeleeAttackAnimation.cpp \ ./BattleInterface/CMeleeAttackAnimation.h \ ./BattleInterface/CMovementAnimation.cpp \ @@ -48,6 +50,16 @@ vcmiclient_SOURCES = \ ./BattleInterface/CStackQueue.cpp \ ./BattleInterface/CStackQueue.h \ ./BattleInterface/SStackAttackedInfo.h \ + ./UIFramework/CGuiHandler.cpp \ + ./UIFramework/CGuiHandler.h \ + ./UIFramework/CIntObject.cpp \ + ./UIFramework/CIntObject.h \ + ./UIFramework/CKeyShortcut.cpp \ + ./UIFramework/CKeyShortcut.h \ + ./UIFramework/CPicture.cpp \ + ./UIFramework/CPicture.h \ + ./UIFramework/SRect.cpp \ + ./UIFramework/SRect.h \ AdventureMapButton.cpp \ AdventureMapButton.h \ CAdvmapInterface.cpp \ @@ -60,8 +72,6 @@ vcmiclient_SOURCES = \ CCastleInterface.h \ CConfigHandler.cpp \ CConfigHandler.h \ - CCreatureAnimation.cpp \ - CCreatureAnimation.h \ CCreatureWindow.cpp \ CCreatureWindow.h \ CCursorHandler.cpp \ @@ -97,8 +107,6 @@ vcmiclient_SOURCES = \ FunctionList.h \ Graphics.cpp \ Graphics.h \ - GUIBase.cpp \ - GUIBase.h \ GUIClasses.cpp \ GUIClasses.h \ mapHandler.cpp \ diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index e8f271f8b..33b735010 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -24,7 +24,7 @@ #include "../lib/CGameState.h" #include "../lib/BattleState.h" #include "../lib/GameConstants.h" - +#include "UIFramework/CGuiHandler.h" //macros to avoid code duplication - calls given method with given arguments if interface for specific player is present //awaiting variadic templates... diff --git a/client/SDL_Extensions.cpp b/client/SDL_Extensions.cpp index b44885291..92d8e87b6 100644 --- a/client/SDL_Extensions.cpp +++ b/client/SDL_Extensions.cpp @@ -6,7 +6,6 @@ #include "CMessage.h" #include "CDefHandler.h" #include "Graphics.h" -#include "GUIBase.h" /* * SDL_Extensions.cpp, part of VCMI engine @@ -1020,7 +1019,7 @@ void CSDL_Ext::drawBorder( SDL_Surface * sur, const SDL_Rect &r, const int3 &col drawBorder(sur, r.x, r.y, r.w, r.h, color); } -void CSDL_Ext::drawDashedBorder(SDL_Surface * sur, const Rect &r, const int3 &color) +void CSDL_Ext::drawDashedBorder(SDL_Surface * sur, const SRect &r, const int3 &color) { const int y1 = r.y, y2 = r.y + r.h-1; for (int i=0; iw, dst->h); + betterDst = SRect(0, 0, dst->w, dst->h); } SDL_BlitSurface(src, srcRect, dst, &betterDst); @@ -1286,7 +1285,7 @@ void CSDL_Ext::fillRect( SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color ) } else { - newRect = Rect(0, 0, dst->w, dst->h); + newRect = SRect(0, 0, dst->w, dst->h); } SDL_FillRect(dst, &newRect, color); } diff --git a/client/SDL_Extensions.h b/client/SDL_Extensions.h index 466e0492f..c42be8008 100644 --- a/client/SDL_Extensions.h +++ b/client/SDL_Extensions.h @@ -5,6 +5,7 @@ #include "SDL_video.h" #include "SDL_ttf.h" #include "FontBase.h" +#include "UIFramework/SRect.h" /* * SDL_Extensions.h, part of VCMI engine @@ -170,7 +171,7 @@ namespace CSDL_Ext void update(SDL_Surface * what = screen); //updates whole surface (default - main screen) void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color); void drawBorder(SDL_Surface * sur, const SDL_Rect &r, const int3 &color); - void drawDashedBorder(SDL_Surface * sur, const Rect &r, const int3 &color); + void drawDashedBorder(SDL_Surface * sur, const SRect &r, const int3 &color); void setPlayerColor(SDL_Surface * sur, ui8 player); //sets correct color of flags; -1 for neutral std::string processStr(std::string str, std::vector & tor); //replaces %s in string SDL_Surface * newSurface(int w, int h, SDL_Surface * mod=screen); //creates new surface, with flags/format same as in surface given diff --git a/client/StdInc.h b/client/StdInc.h index 18659d5ee..76e828312 100644 --- a/client/StdInc.h +++ b/client/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/client/UIFramework/CGuiHandler.cpp b/client/UIFramework/CGuiHandler.cpp new file mode 100644 index 000000000..60414ab55 --- /dev/null +++ b/client/UIFramework/CGuiHandler.cpp @@ -0,0 +1,461 @@ +#include "StdInc.h" +#include "CGuiHandler.h" + +#include "IShowActivatable.h" +#include "../SDL_Extensions.h" +#include "CIntObject.h" +#include "../CGameInfo.h" +#include "../CCursorHandler.h" +#include "../../lib/CThreadHelper.h" +#include "../CConfigHandler.h" +#include "../SDL_framerate.h" +#include "IUpdateable.h" + +extern SDL_Surface * screenBuf, * screen2, * screen; +extern std::queue events; +extern boost::mutex eventsM; + +SDL_Color Colors::createColor(int r, int g, int b) +{ + SDL_Color temp = {r, g, b, 0}; + return temp; +} + +SObjectConstruction::SObjectConstruction( CIntObject *obj ) +:myObj(obj) +{ + GH.createdObj.push_front(obj); + GH.captureChildren = true; +} + +SObjectConstruction::~SObjectConstruction() +{ + assert(GH.createdObj.size()); + assert(GH.createdObj.front() == myObj); + GH.createdObj.pop_front(); + GH.captureChildren = GH.createdObj.size(); +} + +SSetCaptureState::SSetCaptureState(bool allow, ui8 actions) +{ + previousCapture = GH.captureChildren; + GH.captureChildren = false; + prevActions = GH.defActionsDef; + GH.defActionsDef = actions; +} + +SSetCaptureState::~SSetCaptureState() +{ + GH.captureChildren = previousCapture; + GH.defActionsDef = prevActions; +} + +void CGuiHandler::popInt( IShowActivatable *top ) +{ + assert(listInt.front() == top); + top->deactivate(); + listInt.pop_front(); + objsToBlit -= top; + if(listInt.size()) + listInt.front()->activate(); + totalRedraw(); +} + +void CGuiHandler::popIntTotally( IShowActivatable *top ) +{ + assert(listInt.front() == top); + popInt(top); + delete top; + fakeMouseMove(); +} + +void CGuiHandler::pushInt( IShowActivatable *newInt ) +{ + //a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway) + screenBuf = screen2; + + if(listInt.size()) + listInt.front()->deactivate(); + listInt.push_front(newInt); + newInt->activate(); + objsToBlit.push_back(newInt); + totalRedraw(); +} + +void CGuiHandler::popInts( int howMany ) +{ + if(!howMany) return; //senseless but who knows... + + assert(listInt.size() >= howMany); + listInt.front()->deactivate(); + for(int i=0; i < howMany; i++) + { + objsToBlit -= listInt.front(); + delete listInt.front(); + listInt.pop_front(); + } + + if(listInt.size()) + { + listInt.front()->activate(); + totalRedraw(); + } + fakeMouseMove(); +} + +IShowActivatable * CGuiHandler::topInt() +{ + if(!listInt.size()) + return NULL; + else + return listInt.front(); +} + +void CGuiHandler::totalRedraw() +{ + for(int i=0;ishowAll(screen2); + + blitAt(screen2,0,0,screen); +} + +void CGuiHandler::updateTime() +{ + int tv = th.getDiff(); + std::list hlp = timeinterested; + for (std::list::iterator i=hlp.begin(); i != hlp.end();i++) + { + if(!vstd::contains(timeinterested,*i)) continue; + if ((*i)->toNextTick>=0) + (*i)->toNextTick-=tv; + if ((*i)->toNextTick<0) + (*i)->tick(); + } +} + +void CGuiHandler::handleEvents() +{ + while(true) + { + SDL_Event *ev = NULL; + boost::unique_lock lock(eventsM); + if(!events.size()) + { + return; + } + else + { + ev = events.front(); + events.pop(); + } + handleEvent(ev); + delete ev; + } +} + +void CGuiHandler::handleEvent(SDL_Event *sEvent) +{ + current = sEvent; + bool prev; + + if (sEvent->type==SDL_KEYDOWN || sEvent->type==SDL_KEYUP) + { + SDL_KeyboardEvent key = sEvent->key; + + //translate numpad keys + if(key.keysym.sym == SDLK_KP_ENTER) + { + key.keysym.sym = (SDLKey)SDLK_RETURN; + } + + bool keysCaptured = false; + for(std::list::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++) + { + if((*i)->captureAllKeys) + { + keysCaptured = true; + break; + } + } + + std::list miCopy = keyinterested; + for(std::list::iterator i=miCopy.begin(); i != miCopy.end() && current; i++) + if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureAllKeys)) + (**i).keyPressed(key); + } + else if(sEvent->type==SDL_MOUSEMOTION) + { + CCS->curh->cursorMove(sEvent->motion.x, sEvent->motion.y); + handleMouseMotion(sEvent); + } + else if (sEvent->type==SDL_MOUSEBUTTONDOWN) + { + if(sEvent->button.button == SDL_BUTTON_LEFT) + { + + if(lastClick == sEvent->motion && (SDL_GetTicks() - lastClickTime) < 300) + { + std::list hlp = doubleClickInterested; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(doubleClickInterested,*i)) continue; + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + (*i)->onDoubleClick(); + } + } + + } + + lastClick = sEvent->motion; + lastClickTime = SDL_GetTicks(); + + std::list hlp = lclickable; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(lclickable,*i)) continue; + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + prev = (*i)->pressedL; + (*i)->pressedL = true; + (*i)->clickLeft(true, prev); + } + } + } + else if (sEvent->button.button == SDL_BUTTON_RIGHT) + { + std::list hlp = rclickable; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(rclickable,*i)) continue; + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + prev = (*i)->pressedR; + (*i)->pressedR = true; + (*i)->clickRight(true, prev); + } + } + } + else if(sEvent->button.button == SDL_BUTTON_WHEELDOWN || sEvent->button.button == SDL_BUTTON_WHEELUP) + { + std::list hlp = wheelInterested; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(wheelInterested,*i)) continue; + (*i)->wheelScrolled(sEvent->button.button == SDL_BUTTON_WHEELDOWN, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)); + } + } + } + else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT)) + { + std::list hlp = lclickable; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(lclickable,*i)) continue; + prev = (*i)->pressedL; + (*i)->pressedL = false; + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + (*i)->clickLeft(false, prev); + } + else + (*i)->clickLeft(boost::logic::indeterminate, prev); + } + } + else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_RIGHT)) + { + std::list hlp = rclickable; + for(std::list::iterator i=hlp.begin(); i != hlp.end() && current; i++) + { + if(!vstd::contains(rclickable,*i)) continue; + prev = (*i)->pressedR; + (*i)->pressedR = false; + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + (*i)->clickRight(false, prev); + } + else + (*i)->clickRight(boost::logic::indeterminate, prev); + } + } + current = NULL; + +} //event end + +void CGuiHandler::handleMouseMotion(SDL_Event *sEvent) +{ + //sending active, hovered hoverable objects hover() call + std::vector hlp; + for(std::list::iterator i=hoverable.begin(); i != hoverable.end();i++) + { + if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) + { + if (!(*i)->hovered) + hlp.push_back((*i)); + } + else if ((*i)->hovered) + { + (*i)->hover(false); + (*i)->hovered = false; + } + } + for(int i=0; ihover(true); + hlp[i]->hovered = true; + } + + handleMoveInterested(sEvent->motion); +} + +void CGuiHandler::simpleRedraw() +{ + //update only top interface and draw background + if(objsToBlit.size() > 1) + blitAt(screen2,0,0,screen); //blit background + objsToBlit.back()->show(screen); //blit active interface/window +} + +void CGuiHandler::handleMoveInterested( const SDL_MouseMotionEvent & motion ) +{ + //sending active, MotionInterested objects mouseMoved() call + std::list miCopy = motioninterested; + for(std::list::iterator i=miCopy.begin(); i != miCopy.end();i++) + { + if ((*i)->strongInterest || isItIn(&(*i)->pos, motion.x, motion.y)) + { + (*i)->mouseMoved(motion); + } + } +} + +void CGuiHandler::fakeMouseMove() +{ + SDL_Event evnt; + + SDL_MouseMotionEvent sme = {SDL_MOUSEMOTION, 0, 0, 0, 0, 0, 0}; + int x, y; + sme.state = SDL_GetMouseState(&x, &y); + sme.x = x; + sme.y = y; + + evnt.motion = sme; + current = &evnt; + handleMouseMotion(&evnt); +} + +void CGuiHandler::run() +{ + setThreadName(-1, "CGuiHandler::run"); + try + { + if (conf.cc.fullscreen) + CCS->curh->centerCursor(); + + mainFPSmng->init(); // resets internal clock, needed for FPS manager + while(!terminate) + { + if(curInt) + curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment + + mainFPSmng->framerateDelay(); // holds a constant FPS + } + } HANDLE_EXCEPTION +} + +CGuiHandler::CGuiHandler() +:lastClick(-500, -500) +{ + curInt = NULL; + current = NULL; + terminate = false; + statusbar = NULL; + + // Creates the FPS manager and sets the framerate to 48 which is doubled the value of the original Heroes 3 FPS rate + mainFPSmng = new FPSManager(48); + mainFPSmng->init(); // resets internal clock, needed for FPS manager +} + +CGuiHandler::~CGuiHandler() +{ + delete mainFPSmng; +} + +void CGuiHandler::breakEventHandling() +{ + current = NULL; +} + +CIntObject * CGuiHandler::moveChild(CIntObject *obj, CIntObject *from, CIntObject *to, bool adjustPos) +{ + from->removeChild(obj, adjustPos); + to->addChild(obj, adjustPos); + return obj; +} + +void CGuiHandler::drawFPSCounter() +{ + const static SDL_Color yellow = {255, 255, 0, 0}; + static SDL_Rect overlay = { 0, 0, 64, 32}; + Uint32 black = SDL_MapRGB(screen->format, 10, 10, 10); + SDL_FillRect(screen, &overlay, black); + std::string fps = boost::lexical_cast(mainFPSmng->fps); + CSDL_Ext::printAt(fps, 10, 10, FONT_BIG, yellow, screen); +} + +SDLKey CGuiHandler::arrowToNum( SDLKey key ) +{ + switch(key) + { + case SDLK_DOWN: + return SDLK_KP2; + case SDLK_UP: + return SDLK_KP8; + case SDLK_LEFT: + return SDLK_KP4; + case SDLK_RIGHT: + return SDLK_KP6; + default: + assert(0); + } + throw std::string("Wrong key!"); +} + +SDLKey CGuiHandler::numToDigit( SDLKey key ) +{ + if(key >= SDLK_KP0 && key <= SDLK_KP9) + return SDLKey(key - SDLK_KP0 + SDLK_0); + +#define REMOVE_KP(keyName) case SDLK_KP_ ## keyName : return SDLK_ ## keyName; + switch(key) + { + REMOVE_KP(PERIOD) + REMOVE_KP(MINUS) + REMOVE_KP(PLUS) + REMOVE_KP(EQUALS) + + case SDLK_KP_MULTIPLY: + return SDLK_ASTERISK; + case SDLK_KP_DIVIDE: + return SDLK_SLASH; + case SDLK_KP_ENTER: + return SDLK_RETURN; + default: + tlog3 << "Illegal numkey conversion!" << std::endl; + return SDLK_UNKNOWN; + } +#undef REMOVE_KP +} + +bool CGuiHandler::isNumKey( SDLKey key, bool number ) +{ + if(number) + return key >= SDLK_KP0 && key <= SDLK_KP9; + else + return key >= SDLK_KP0 && key <= SDLK_KP_EQUALS; +} + +bool CGuiHandler::isArrowKey( SDLKey key ) +{ + return key >= SDLK_UP && key <= SDLK_LEFT; +} \ No newline at end of file diff --git a/client/UIFramework/CGuiHandler.h b/client/UIFramework/CGuiHandler.h new file mode 100644 index 000000000..448f82e3e --- /dev/null +++ b/client/UIFramework/CGuiHandler.h @@ -0,0 +1,117 @@ +#pragma once + +#include "../../lib/CStopWatch.h" +#include "SPoint.h" + +class FPSManager; +class IStatusBar; +class CIntObject; +class IUpdateable; +class IShowActivatable; +class IShowable; + +/* + * CGuiHandler.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Handles GUI logic and drawing +class CGuiHandler +{ +public: + FPSManager * mainFPSmng; //to keep const framerate + CStopWatch th; + std::list listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on) + IStatusBar * statusbar; + + //active GUI elements (listening for events + std::list lclickable; + std::list rclickable; + std::list hoverable; + std::list keyinterested; + std::list motioninterested; + std::list timeinterested; + std::list wheelInterested; + std::list doubleClickInterested; + + //objs to blit + std::vector objsToBlit; + + SDL_Event * current; //current event - can be set to NULL to stop handling event + IUpdateable *curInt; + + SPoint lastClick; + unsigned lastClickTime; + bool terminate; + + CGuiHandler(); + ~CGuiHandler(); + void run(); // holds the main loop for the whole program after initialization and manages the update/rendering system + + void totalRedraw(); //forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering + void simpleRedraw(); //update only top interface and draw background from buffer, sets a flag, method gets called at the end of the rendering + + void popInt(IShowActivatable *top); //removes given interface from the top and activates next + void popIntTotally(IShowActivatable *top); //deactivates, deletes, removes given interface from the top and activates next + void pushInt(IShowActivatable *newInt); //deactivate old top interface, activates this one and pushes to the top + void popInts(int howMany); //pops one or more interfaces - deactivates top, deletes and removes given number of interfaces, activates new front + IShowActivatable *topInt(); //returns top interface + + void updateTime(); //handles timeInterested + void handleEvents(); //takes events from queue and calls interested objects + void handleEvent(SDL_Event *sEvent); + void handleMouseMotion(SDL_Event *sEvent); + void handleMoveInterested( const SDL_MouseMotionEvent & motion ); + void fakeMouseMove(); + void breakEventHandling(); //current event won't be propagated anymore + void drawFPSCounter(); // draws the FPS to the upper left corner of the screen + ui8 defActionsDef; //default auto actions + ui8 captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list + std::list createdObj; //stack of objs being created + + static CIntObject * moveChild(CIntObject *obj, CIntObject *from, CIntObject *to, bool adjustPos = false); + static SDLKey arrowToNum(SDLKey key); //converts arrow key to according numpad key + static SDLKey numToDigit(SDLKey key);//converts numpad digit key to normal digit key + static bool isNumKey(SDLKey key, bool number = true); //checks if key is on numpad (numbers - check only for numpad digits) + static bool isArrowKey(SDLKey key); +}; + +extern CGuiHandler GH; //global gui handler + +template void pushIntT() +{ + GH.pushInt(new T()); +} + +struct SObjectConstruction +{ + CIntObject *myObj; + SObjectConstruction(CIntObject *obj); + ~SObjectConstruction(); +}; + +struct SSetCaptureState +{ + bool previousCapture; + ui8 prevActions; + SSetCaptureState(bool allow, ui8 actions); + ~SSetCaptureState(); +}; + +namespace Colors +{ + SDL_Color createColor(int r, int g, int b); + + const SDL_Color MetallicGold = createColor(173, 142, 66); + const SDL_Color Yellow = createColor(242, 226, 110); +}; + +#define OBJ_CONSTRUCTION SObjectConstruction obj__i(this) +#define OBJ_CONSTRUCTION_CAPTURING_ALL defActions = 255; SSetCaptureState obj__i1(true, 255); SObjectConstruction obj__i(this) +#define BLOCK_CAPTURING SSetCaptureState obj__i(false, 0) +#define BLOCK_CAPTURING_DONT_TOUCH_REC_ACTIONS SSetCaptureState obj__i(false, GH.defActionsDef) diff --git a/client/UIFramework/CIntObject.cpp b/client/UIFramework/CIntObject.cpp new file mode 100644 index 000000000..3f30244d4 --- /dev/null +++ b/client/UIFramework/CIntObject.cpp @@ -0,0 +1,443 @@ +#include "StdInc.h" +#include "CIntObject.h" +#include "CGuiHandler.h" +#include "../SDL_Extensions.h" + +void CIntObject::activateLClick() +{ + GH.lclickable.push_front(this); + active |= LCLICK; +} + +void CIntObject::deactivateLClick() +{ + std::list::iterator hlp = std::find(GH.lclickable.begin(),GH.lclickable.end(),this); + assert(hlp != GH.lclickable.end()); + GH.lclickable.erase(hlp); + active &= ~LCLICK; +} + +void CIntObject::clickLeft(tribool down, bool previousState) +{ +} + +void CIntObject::activateRClick() +{ + GH.rclickable.push_front(this); + active |= RCLICK; +} + +void CIntObject::deactivateRClick() +{ + std::list::iterator hlp = std::find(GH.rclickable.begin(),GH.rclickable.end(),this); + assert(hlp != GH.rclickable.end()); + GH.rclickable.erase(hlp); + active &= ~RCLICK; +} + +void CIntObject::clickRight(tribool down, bool previousState) +{ +} + +void CIntObject::activateHover() +{ + GH.hoverable.push_front(this); + active |= HOVER; +} + +void CIntObject::deactivateHover() +{ + std::list::iterator hlp = std::find(GH.hoverable.begin(),GH.hoverable.end(),this); + assert(hlp != GH.hoverable.end()); + GH.hoverable.erase(hlp); + active &= ~HOVER; +} + +void CIntObject::hover( bool on ) +{ +} + +void CIntObject::activateKeys() +{ + GH.keyinterested.push_front(this); + active |= KEYBOARD; +} + +void CIntObject::deactivateKeys() +{ + std::list::iterator hlp = std::find(GH.keyinterested.begin(),GH.keyinterested.end(),this); + assert(hlp != GH.keyinterested.end()); + GH.keyinterested.erase(hlp); + active &= ~KEYBOARD; +} + +void CIntObject::keyPressed( const SDL_KeyboardEvent & key ) +{ +} + +void CIntObject::activateMouseMove() +{ + GH.motioninterested.push_front(this); + active |= MOVE; +} + +void CIntObject::deactivateMouseMove() +{ + std::list::iterator hlp = std::find(GH.motioninterested.begin(),GH.motioninterested.end(),this); + assert(hlp != GH.motioninterested.end()); + GH.motioninterested.erase(hlp); + active &= ~MOVE; +} + +void CIntObject::mouseMoved( const SDL_MouseMotionEvent & sEvent ) +{ +} + +void CIntObject::activateTimer() +{ + GH.timeinterested.push_back(this); + active |= TIME; +} + +void CIntObject::deactivateTimer() +{ + std::list::iterator hlp = std::find(GH.timeinterested.begin(),GH.timeinterested.end(),this); + assert(hlp != GH.timeinterested.end()); + GH.timeinterested.erase(hlp); + active &= ~TIME; +} + +void CIntObject::tick() +{ +} + +CIntObject::CIntObject() +{ + pressedL = pressedR = hovered = captureAllKeys = strongInterest = false; + toNextTick = active = used = 0; + + recActions = defActions = GH.defActionsDef; + + pos.x = 0; + pos.y = 0; + pos.w = 0; + pos.h = 0; + + if(GH.captureChildren) + { + assert(GH.createdObj.size()); + parent = GH.createdObj.front(); + parent->children.push_back(this); + + if(parent->defActions & SHARE_POS) + { + pos.x = parent->pos.x; + pos.y = parent->pos.y; + } + } + else + parent = NULL; +} + +void CIntObject::show( SDL_Surface * to ) +{ + if(defActions & UPDATE) + for(size_t i = 0; i < children.size(); i++) + if(children[i]->recActions & UPDATE) + children[i]->show(to); +} + +void CIntObject::showAll( SDL_Surface * to ) +{ + if(defActions & SHOWALL) + { + for(size_t i = 0; i < children.size(); i++) + if(children[i]->recActions & SHOWALL) + children[i]->showAll(to); + + } + else + show(to); +} + +void CIntObject::activate() +{ + assert(!active); + active |= GENERAL; + activate(used); + + if(defActions & ACTIVATE) + for(size_t i = 0; i < children.size(); i++) + if(children[i]->recActions & ACTIVATE) + children[i]->activate(); +} + +void CIntObject::activate(ui16 what) +{ + if(what & LCLICK) + activateLClick(); + if(what & RCLICK) + activateRClick(); + if(what & HOVER) + activateHover(); + if(what & MOVE) + activateMouseMove(); + if(what & KEYBOARD) + activateKeys(); + if(what & TIME) + activateTimer(); + if(what & WHEEL) + activateWheel(); + if(what & DOUBLECLICK) + activateDClick(); +} + +void CIntObject::deactivate() +{ + assert(active); + active &= ~ GENERAL; + deactivate(used); + + assert(!active); + + if(defActions & DEACTIVATE) + for(size_t i = 0; i < children.size(); i++) + if(children[i]->recActions & DEACTIVATE) + children[i]->deactivate(); +} + +void CIntObject::deactivate(ui16 what) +{ + if(what & LCLICK) + deactivateLClick(); + if(what & RCLICK) + deactivateRClick(); + if(what & HOVER) + deactivateHover(); + if(what & MOVE) + deactivateMouseMove(); + if(what & KEYBOARD) + deactivateKeys(); + if(what & TIME) // TIME is special + deactivateTimer(); + if(what & WHEEL) + deactivateWheel(); + if(what & DOUBLECLICK) + deactivateDClick(); +} + +CIntObject::~CIntObject() +{ + assert(!active); //do not delete active obj + + if(defActions & DISPOSE) + for(size_t i = 0; i < children.size(); i++) + if(children[i]->recActions & DISPOSE) + delete children[i]; + + if(parent && GH.createdObj.size()) //temporary object destroyed + parent->children -= this; +} + +void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ ) +{ + CSDL_Ext::printAt(text, pos.x + x, pos.y + y, font, kolor, dst); +} + +void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ ) +{ + CSDL_Ext::printAtMiddle(text, pos.x + x, pos.y + y, font, kolor, dst); +} + +void CIntObject::printAtMiddleLoc(const std::string & text, const SPoint &p, EFonts font, SDL_Color kolor, SDL_Surface * dst) +{ + printAtMiddleLoc(text, p.x, p.y, font, kolor, dst); +} + +void CIntObject::blitAtLoc( SDL_Surface * src, int x, int y, SDL_Surface * dst ) +{ + blitAt(src, pos.x + x, pos.y + y, dst); +} + +void CIntObject::blitAtLoc(SDL_Surface * src, const SPoint &p, SDL_Surface * dst) +{ + blitAtLoc(src, p.x, p.y, dst); +} + +void CIntObject::printAtMiddleWBLoc( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst) +{ + CSDL_Ext::printAtMiddleWB(text, pos.x + x, pos.y + y, font, charpr, kolor, dst); +} + +void CIntObject::printToLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst ) +{ + CSDL_Ext::printTo(text, pos.x + x, pos.y + y, font, kolor, dst); +} + +void CIntObject::disable() +{ + if(active) + deactivate(); + + recActions = DISPOSE; +} + +void CIntObject::enable(bool activation) +{ + if(!active && activation) + activate(); + + recActions = 255; +} + +bool CIntObject::isItInLoc( const SDL_Rect &rect, int x, int y ) +{ + return isItIn(&rect, x - pos.x, y - pos.y); +} + +bool CIntObject::isItInLoc( const SDL_Rect &rect, const SPoint &p ) +{ + return isItIn(&rect, p.x - pos.x, p.y - pos.y); +} + +void CIntObject::activateWheel() +{ + GH.wheelInterested.push_front(this); + active |= WHEEL; +} + +void CIntObject::deactivateWheel() +{ + std::list::iterator hlp = std::find(GH.wheelInterested.begin(),GH.wheelInterested.end(),this); + assert(hlp != GH.wheelInterested.end()); + GH.wheelInterested.erase(hlp); + active &= ~WHEEL; +} + +void CIntObject::wheelScrolled(bool down, bool in) +{ +} + +void CIntObject::activateDClick() +{ + GH.doubleClickInterested.push_front(this); + active |= DOUBLECLICK; +} + +void CIntObject::deactivateDClick() +{ + std::list::iterator hlp = std::find(GH.doubleClickInterested.begin(),GH.doubleClickInterested.end(),this); + assert(hlp != GH.doubleClickInterested.end()); + GH.doubleClickInterested.erase(hlp); + active &= ~DOUBLECLICK; +} + +void CIntObject::onDoubleClick() +{ +} + +void CIntObject::fitToScreen(int borderWidth, bool propagate) +{ + SPoint newPos = pos.topLeft(); + vstd::amax(newPos.x, borderWidth); + vstd::amax(newPos.y, borderWidth); + vstd::amin(newPos.x, screen->w - borderWidth - pos.w); + vstd::amin(newPos.y, screen->h - borderWidth - pos.h); + if (newPos != pos.topLeft()) + moveTo(newPos, propagate); +} + +void CIntObject::moveBy( const SPoint &p, bool propagate /*= true*/ ) +{ + pos.x += p.x; + pos.y += p.y; + if(propagate) + for(size_t i = 0; i < children.size(); i++) + children[i]->moveBy(p, propagate); +} + +void CIntObject::moveTo( const SPoint &p, bool propagate /*= true*/ ) +{ + moveBy(SPoint(p.x - pos.x, p.y - pos.y), propagate); +} + +void CIntObject::delChild(CIntObject *child) +{ + children -= child; + delete child; +} + +void CIntObject::addChild(CIntObject *child, bool adjustPosition /*= false*/) +{ + assert(!vstd::contains(children, child)); + assert(child->parent == NULL); + children.push_back(child); + child->parent = this; + if(adjustPosition) + child->pos += pos; +} + +void CIntObject::removeChild(CIntObject *child, bool adjustPosition /*= false*/) +{ + assert(vstd::contains(children, child)); + assert(child->parent == this); + children -= child; + child->parent = NULL; + if(adjustPosition) + child->pos -= pos; +} + +void CIntObject::changeUsedEvents(ui16 what, bool enable, bool adjust /*= true*/) +{ + if(enable) + { + used |= what; + if(adjust && active) + activate(what); + } + else + { + used &= ~what; + if(adjust && active) + deactivate(what); + } +} + +void CIntObject::drawBorderLoc(SDL_Surface * sur, const SRect &r, const int3 &color) +{ + CSDL_Ext::drawBorder(sur, r + pos, color); +} + +void CIntObject::redraw() +{ + if (parent && (type & REDRAW_PARENT)) + { + parent->redraw(); + } + else + { + showAll(screenBuf); + if(screenBuf != screen) + showAll(screen); + } +} + +const SRect & CIntObject::center( const SRect &r, bool propagate ) +{ + pos.w = r.w; + pos.h = r.h; + return center(SPoint(screen->w/2, screen->h/2), propagate); +} + +const SRect & CIntObject::center( bool propagate ) +{ + return center(pos, propagate); +} + +const SRect & CIntObject::center(const SPoint &p, bool propagate /*= true*/) +{ + moveBy(SPoint(p.x - pos.w/2 - pos.x, + p.y - pos.h/2 - pos.y), + propagate); + return pos; +} \ No newline at end of file diff --git a/client/UIFramework/CIntObject.h b/client/UIFramework/CIntObject.h new file mode 100644 index 000000000..e28c28d50 --- /dev/null +++ b/client/UIFramework/CIntObject.h @@ -0,0 +1,135 @@ +#pragma once + +#include +#include "IShowActivatable.h" +#include "SRect.h" +#include "../FontBase.h" + +struct SDL_Surface; + +/* + * CIntObject.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +using boost::logic::tribool; + +// Base UI element +class CIntObject : public IShowActivatable //interface object +{ +public: + CIntObject *parent; //parent object + std::vector children; + + SRect pos, //position of object on the screen + posRelative; //position of object in the parent (not used if no parent) + + CIntObject(); + virtual ~CIntObject(); //d-tor + + //l-clicks handling + bool pressedL; //for determining if object is L-pressed + void activateLClick(); + void deactivateLClick(); + virtual void clickLeft(tribool down, bool previousState); + + //r-clicks handling + bool pressedR; //for determining if object is R-pressed + void activateRClick(); + void deactivateRClick(); + virtual void clickRight(tribool down, bool previousState); + + //hover handling + bool hovered; //for determining if object is hovered + void activateHover(); + void deactivateHover(); + virtual void hover (bool on); + + //keyboard handling + bool captureAllKeys; //if true, only this object should get info about pressed keys + void activateKeys(); + void deactivateKeys(); + virtual void keyPressed(const SDL_KeyboardEvent & key); + + //mouse movement handling + bool strongInterest; //if true - report all mouse movements, if not - only when hovered + void activateMouseMove(); + void deactivateMouseMove(); + virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent); + + //time handling + int toNextTick; + void activateTimer(); + void deactivateTimer(); + virtual void tick(); + + //mouse wheel + void activateWheel(); + void deactivateWheel(); + virtual void wheelScrolled(bool down, bool in); + + //double click + void activateDClick(); + void deactivateDClick(); + virtual void onDoubleClick(); + + enum {LCLICK=1, RCLICK=2, HOVER=4, MOVE=8, KEYBOARD=16, TIME=32, GENERAL=64, WHEEL=128, DOUBLECLICK=256, ALL=0xffff}; + ui16 active; + ui16 used; + + enum {ACTIVATE=1, DEACTIVATE=2, UPDATE=4, SHOWALL=8, DISPOSE=16, SHARE_POS=32}; + ui8 defActions; //which calls will be tried to be redirected to children + ui8 recActions; //which calls we allow te receive from parent + + enum EAlignment {TOPLEFT, CENTER, BOTTOMRIGHT}; + + void disable(); //deactivates if needed, blocks all automatic activity, allows only disposal + void enable(bool activation = true); //activates if needed, all activity enabled (Warning: may not be symetric with disable if recActions was limited!) + void defActivate(); + void defDeactivate(); + void activate(); + void deactivate(); + void activate(ui16 what); + void deactivate(ui16 what); + void show(SDL_Surface * to); + void showAll(SDL_Surface * to); + void redraw(); + + void drawBorderLoc(SDL_Surface * sur, const SRect &r, const int3 &color); + void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); + void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); + void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst); + void printAtMiddleLoc(const std::string & text, const SPoint &p, EFonts font, SDL_Color kolor, SDL_Surface * dst); + void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst); + void blitAtLoc(SDL_Surface * src, int x, int y, SDL_Surface * dst); + void blitAtLoc(SDL_Surface * src, const SPoint &p, SDL_Surface * dst); + bool isItInLoc(const SDL_Rect &rect, int x, int y); + bool isItInLoc(const SDL_Rect &rect, const SPoint &p); + const SRect & center(const SRect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position + const SRect & center(const SPoint &p, bool propagate = true); //moves object so that point p will be in its center + const SRect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position + void fitToScreen(int borderWidth, bool propagate = true); //moves window to fit into screen + void moveBy(const SPoint &p, bool propagate = true); + void moveTo(const SPoint &p, bool propagate = true); + void changeUsedEvents(ui16 what, bool enable, bool adjust = true); + + void addChild(CIntObject *child, bool adjustPosition = false); + void removeChild(CIntObject *child, bool adjustPosition = false); + void delChild(CIntObject *child); //removes from children list, deletes + template void delChildNUll(T *&child, bool deactivateIfNeeded = false) //removes from children list, deletes and sets pointer to NULL + { + if(!child) + return; + + if(deactivateIfNeeded && child->active) + child->deactivate(); + + delChild(child); + child = NULL; + } +}; \ No newline at end of file diff --git a/client/UIFramework/CKeyShortcut.cpp b/client/UIFramework/CKeyShortcut.cpp new file mode 100644 index 000000000..e807fedce --- /dev/null +++ b/client/UIFramework/CKeyShortcut.cpp @@ -0,0 +1,20 @@ +#include "StdInc.h" +#include "CKeyShortcut.h" + +void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key) +{ + if(vstd::contains(assignedKeys,key.keysym.sym)) + { + bool prev = pressedL; + if(key.state == SDL_PRESSED) + { + pressedL = true; + clickLeft(true, prev); + } + else + { + pressedL = false; + clickLeft(false, prev); + } + } +} \ No newline at end of file diff --git a/client/UIFramework/CKeyShortcut.h b/client/UIFramework/CKeyShortcut.h new file mode 100644 index 000000000..ce1d685c7 --- /dev/null +++ b/client/UIFramework/CKeyShortcut.h @@ -0,0 +1,25 @@ +#pragma once + +#include "CIntObject.h" + +/* + * CKeyShortcut.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +/// Class for binding keys to left mouse button clicks +/// Classes wanting use it should have it as one of their base classes +class CKeyShortcut : public virtual CIntObject +{ +public: + std::set assignedKeys; + CKeyShortcut(){}; //c-tor + CKeyShortcut(int key){assignedKeys.insert(key);}; //c-tor + CKeyShortcut(std::set Keys):assignedKeys(Keys){}; //c-tor + virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in +}; \ No newline at end of file diff --git a/client/UIFramework/CPicture.cpp b/client/UIFramework/CPicture.cpp new file mode 100644 index 000000000..e9bb738c4 --- /dev/null +++ b/client/UIFramework/CPicture.cpp @@ -0,0 +1,133 @@ +#include "StdInc.h" +#include "CPicture.h" + +#include "../CBitmapHandler.h" +#include "../SDL_Extensions.h" +#include "../Graphics.h" + + +CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free ) +{ + init(); + bg = BG; + freeSurf = Free; + pos.x += x; + pos.y += y; + pos.w = BG->w; + pos.h = BG->h; +} + +CPicture::CPicture( const std::string &bmpname, int x, int y ) +{ + init(); + bg = BitmapHandler::loadBitmap(bmpname); + freeSurf = true;; + pos.x += x; + pos.y += y; + if(bg) + { + pos.w = bg->w; + pos.h = bg->h; + } + else + { + pos.w = pos.h = 0; + } +} + +CPicture::CPicture(const SRect &r, const SDL_Color &color, bool screenFormat /*= false*/) +{ + init(); + createSimpleRect(r, screenFormat, SDL_MapRGB(bg->format, color.r, color.g,color.b)); +} + +CPicture::CPicture(const SRect &r, ui32 color, bool screenFormat /*= false*/) +{ + init(); + createSimpleRect(r, screenFormat, color); +} + +CPicture::CPicture(SDL_Surface *BG, const SRect &SrcRect, int x /*= 0*/, int y /*= 0*/, bool free /*= false*/) +{ + needRefresh = false; + srcRect = new SRect(SrcRect); + pos.x += x; + pos.y += y; + pos.w = srcRect->w; + pos.h = srcRect->h; + bg = BG; + freeSurf = free; +} + +CPicture::~CPicture() +{ + if(freeSurf) + SDL_FreeSurface(bg); + delete srcRect; +} + +void CPicture::init() +{ + needRefresh = false; + srcRect = NULL; +} + +void CPicture::show( SDL_Surface * to ) +{ + if (needRefresh) + showAll(to); +} + +void CPicture::showAll( SDL_Surface * to ) +{ + if(bg) + { + if(srcRect) + { + SDL_Rect srcRectCpy = *srcRect; + SDL_Rect dstRect = srcRectCpy; + dstRect.x = pos.x; + dstRect.y = pos.y; + + CSDL_Ext::blitSurface(bg, &srcRectCpy, to, &dstRect); + } + else + blitAt(bg, pos, to); + } +} + +void CPicture::convertToScreenBPP() +{ + SDL_Surface *hlp = bg; + bg = SDL_ConvertSurface(hlp,screen->format,0); + SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255)); + SDL_FreeSurface(hlp); +} + +void CPicture::createSimpleRect(const SRect &r, bool screenFormat, ui32 color) +{ + pos += r; + pos.w = r.w; + pos.h = r.h; + if(screenFormat) + bg = CSDL_Ext::newSurface(r.w, r.h); + else + bg = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 8, 0, 0, 0, 0); + + SDL_FillRect(bg, NULL, color); + freeSurf = true; +} + +void CPicture::colorizeAndConvert(int player) +{ + assert(bg); + colorize(player); + convertToScreenBPP(); +} + +void CPicture::colorize(int player) +{ + assert(bg); + assert(bg->format->BitsPerPixel == 8); + graphics->blueToPlayersAdv(bg, player); +} \ No newline at end of file diff --git a/client/UIFramework/CPicture.h b/client/UIFramework/CPicture.h new file mode 100644 index 000000000..581100187 --- /dev/null +++ b/client/UIFramework/CPicture.h @@ -0,0 +1,46 @@ +#pragma once + +#include "CIntObject.h" + +struct SDL_Surface; +struct SRect; + +/* + * CPicture.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Image class +class CPicture : public CIntObject +{ +public: + SDL_Surface * bg; + SRect * srcRect; //if NULL then whole surface will be used + bool freeSurf; //whether surface will be freed upon CPicture destruction + bool needRefresh;//Surface needs to be displayed each frame + + operator SDL_Surface*() + { + return bg; + } + + CPicture(const SRect & r, const SDL_Color & color, bool screenFormat = false); //rect filled with given color + CPicture(const SRect & r, ui32 color, bool screenFormat = false); //rect filled with given color + CPicture(SDL_Surface * BG, int x = 0, int y=0, bool Free = true); //wrap existing SDL_Surface + CPicture(const std::string &bmpname, int x=0, int y=0); + CPicture(SDL_Surface *BG, const SRect &SrcRext, int x = 0, int y = 0, bool free = false); //wrap subrect of given surface + ~CPicture(); + void init(); + + void createSimpleRect(const SRect &r, bool screenFormat, ui32 color); + void show(SDL_Surface * to); + void showAll(SDL_Surface * to); + void convertToScreenBPP(); + void colorizeAndConvert(int player); + void colorize(int player); +}; \ No newline at end of file diff --git a/client/UIFramework/CSimpleWindow.h b/client/UIFramework/CSimpleWindow.h new file mode 100644 index 000000000..d2649a602 --- /dev/null +++ b/client/UIFramework/CSimpleWindow.h @@ -0,0 +1,23 @@ +#pragma once + +#include "UIFramework/CIntObject.h" + +/* + * CSimpleWindow.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Window GUI class +class CSimpleWindow : public CIntObject +{ +public: + SDL_Surface * bitmap; //background + virtual void show(SDL_Surface * to); + CSimpleWindow():bitmap(NULL){}; //c-tor + virtual ~CSimpleWindow(); //d-tor +}; \ No newline at end of file diff --git a/client/UIFramework/IActivatable.h b/client/UIFramework/IActivatable.h new file mode 100644 index 000000000..8608290ec --- /dev/null +++ b/client/UIFramework/IActivatable.h @@ -0,0 +1,20 @@ +#pragma once + +/* + * IActivatable.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Defines a activate/deactive method +class IActivatable +{ +public: + virtual void activate()=0; + virtual void deactivate()=0; + virtual ~IActivatable(){}; //d-tor +}; \ No newline at end of file diff --git a/client/UIFramework/IShowActivatable.h b/client/UIFramework/IShowActivatable.h new file mode 100644 index 000000000..a448b9aeb --- /dev/null +++ b/client/UIFramework/IShowActivatable.h @@ -0,0 +1,24 @@ +#pragma once + +#include "IShowable.h" +#include "IActivatable.h" + +/* + * IShowActivatable.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +class IShowActivatable : public IShowable, public IActivatable +{ +public: + //redraw parent flag - this int may be semi-transparent and require redraw of parent window + enum {WITH_GARRISON = 1, BLOCK_ADV_HOTKEYS = 2, WITH_ARTIFACTS = 4, REDRAW_PARENT=8}; + int type; //bin flags using etype + IShowActivatable(); + virtual ~IShowActivatable(){}; //d-tor +}; \ No newline at end of file diff --git a/client/UIFramework/IShowable.h b/client/UIFramework/IShowable.h new file mode 100644 index 000000000..cb503fa3d --- /dev/null +++ b/client/UIFramework/IShowable.h @@ -0,0 +1,26 @@ +#pragma once + +struct SDL_Surface; + +/* + * IShowable.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Defines a show method +class IShowable +{ +public: + virtual void redraw()=0; + virtual void show(SDL_Surface * to)=0; + virtual void showAll(SDL_Surface * to) + { + show(to); + } + virtual ~IShowable(){}; //d-tor +}; \ No newline at end of file diff --git a/client/UIFramework/IStatusBar.h b/client/UIFramework/IStatusBar.h new file mode 100644 index 000000000..97973820d --- /dev/null +++ b/client/UIFramework/IStatusBar.h @@ -0,0 +1,24 @@ +#pragma once + +struct SDL_Surface; + +/* + * IStatusBar.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// Status bar interface +class IStatusBar +{ +public: + virtual ~IStatusBar(){}; //d-tor + virtual void print(const std::string & text)=0; //prints text and refreshes statusbar + virtual void clear()=0;//clears statusbar and refreshes + virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text) + virtual std::string getCurrent()=0; //returns currently displayed text +}; \ No newline at end of file diff --git a/client/UIFramework/IUpdateable.h b/client/UIFramework/IUpdateable.h new file mode 100644 index 000000000..abec612fa --- /dev/null +++ b/client/UIFramework/IUpdateable.h @@ -0,0 +1,18 @@ +#pragma once + +/* + * IUpdateable.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +class IUpdateable +{ +public: + virtual void update()=0; + virtual ~IUpdateable(){}; //d-tor +}; \ No newline at end of file diff --git a/client/UIFramework/SPoint.h b/client/UIFramework/SPoint.h new file mode 100644 index 000000000..f722780d5 --- /dev/null +++ b/client/UIFramework/SPoint.h @@ -0,0 +1,87 @@ +#pragma once + +#include "../../lib/int3.h" +#include + +/* + * SPoint.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +// A point with x/y coordinate, used mostly for graphic rendering +struct SPoint +{ + int x, y; + + //constructors + SPoint() + { + x = y = 0; + }; + SPoint(int X, int Y) + :x(X),y(Y) + {}; + SPoint(const int3 &a) + :x(a.x),y(a.y) + {} + SPoint(const SDL_MouseMotionEvent &a) + :x(a.x),y(a.y) + {} + + template + SPoint operator+(const T &b) const + { + return SPoint(x+b.x,y+b.y); + } + + template + SPoint operator*(const T &mul) const + { + return SPoint(x*mul, y*mul); + } + + template + SPoint& operator+=(const T &b) + { + x += b.x; + y += b.y; + return *this; + } + + template + SPoint operator-(const T &b) const + { + return SPoint(x - b.x, y - b.y); + } + + template + SPoint& operator-=(const T &b) + { + x -= b.x; + y -= b.y; + return *this; + } + bool operator<(const SPoint &b) const //product order + { + return x < b.x && y < b.y; + } + template SPoint& operator=(const T &t) + { + x = t.x; + y = t.y; + return *this; + } + template bool operator==(const T &t) const + { + return x == t.x && y == t.y; + } + template bool operator!=(const T &t) const + { + return !(*this == t); + } +}; \ No newline at end of file diff --git a/client/UIFramework/SRect.cpp b/client/UIFramework/SRect.cpp new file mode 100644 index 000000000..b4f016dd1 --- /dev/null +++ b/client/UIFramework/SRect.cpp @@ -0,0 +1,19 @@ +#include "StdInc.h" +#include "SRect.h" + +extern SDL_Surface * screen; + +SRect SRect::createCentered( int w, int h ) +{ + return SRect(screen->w/2 - w/2, screen->h/2 - h/2, w, h); +} + +SRect SRect::around(const SRect &r, int width /*= 1*/) /*creates rect around another */ +{ + return SRect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2); +} + +SRect SRect::centerIn(const SRect &r) +{ + return SRect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h); +} \ No newline at end of file diff --git a/client/UIFramework/SRect.h b/client/UIFramework/SRect.h new file mode 100644 index 000000000..bcb005460 --- /dev/null +++ b/client/UIFramework/SRect.h @@ -0,0 +1,187 @@ +#pragma once + +#include +#include "SPoint.h" + +/* + * SRect.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#ifdef max +#undef max +#endif +#ifdef min +#undef min +#endif + +/// Rectangle class, which have a position and a size +struct SRect : public SDL_Rect +{ + SRect()//default c-tor + { + x = y = w = h = -1; + } + SRect(int X, int Y, int W, int H) //c-tor + { + x = X; + y = Y; + w = W; + h = H; + } + SRect(const SPoint & position, const SPoint & size) //c-tor + { + x = position.x; + y = position.y; + w = size.x; + h = size.y; + } + SRect(const SDL_Rect & r) //c-tor + { + x = r.x; + y = r.y; + w = r.w; + h = r.h; + } + explicit SRect(const SDL_Surface * const &surf) + { + x = y = 0; + w = surf->w; + h = surf->h; + } + + SRect centerIn(const SRect &r); + static SRect createCentered(int w, int h); + static SRect around(const SRect &r, int width = 1); //creates rect around another + + bool isIn(int qx, int qy) const //determines if given point lies inside rect + { + if (qx > x && qxy && qy SRect operator-(const T &t) + { + return SRect(x - t.x, y - t.y, w, h); + } + SRect operator&(const SRect &p) const //rect intersection + { + bool intersect = true; + + if(p.topLeft().y < y && p.bottomLeft().y < y) //rect p is above *this + { + intersect = false; + } + else if(p.topLeft().y > y+h && p.bottomLeft().y > y+h) //rect p is below *this + { + intersect = false; + } + else if(p.topLeft().x > x+w && p.topRight().x > x+w) //rect p is on the right hand side of this + { + intersect = false; + } + else if(p.topLeft().x < x && p.topRight().x < x) //rect p is on the left hand side of this + { + intersect = false; + } + + if(intersect) + { + SRect ret; + ret.x = std::max(this->x, p.x); + ret.y = std::max(this->y, p.y); + SPoint bR; //bottomRight point of returned rect + bR.x = std::min(this->w+this->x, p.w+p.x); + bR.y = std::min(this->h+this->y, p.h+p.y); + ret.w = bR.x - ret.x; + ret.h = bR.y - ret.y; + return ret; + } + else + { + return SRect(); + } + } + SRect operator|(const SRect &p) const //union of two rects + { + SRect ret; + ret.x = std::min(p.x, this->x); + ret.y = std::min(p.y, this->y); + int x2 = std::max(p.x+p.w, this->x+this->w); + int y2 = std::max(p.y+p.h, this->y+this->h); + ret.w = x2 -ret.x; + ret.h = y2 -ret.y; + return ret; + } +}; \ No newline at end of file diff --git a/client/VCMI_client.cbp b/client/VCMI_client.cbp deleted file mode 100644 index 97d7f9bc1..000000000 --- a/client/VCMI_client.cbp +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - diff --git a/client/VCMI_client.vcxproj b/client/VCMI_client.vcxproj index 8c6dc0515..4dc7d49cf 100644 --- a/client/VCMI_client.vcxproj +++ b/client/VCMI_client.vcxproj @@ -231,9 +231,10 @@ + + - @@ -248,7 +249,6 @@ - @@ -265,7 +265,6 @@ - @@ -275,8 +274,14 @@ Create StdInc.h + + + + + + @@ -286,9 +291,10 @@ + + - @@ -304,7 +310,6 @@ - @@ -324,13 +329,24 @@ - + + + + + + + + + + + + diff --git a/client/VCMI_client.vcxproj.filters b/client/VCMI_client.vcxproj.filters new file mode 100644 index 000000000..fe0c4514f --- /dev/null +++ b/client/VCMI_client.vcxproj.filters @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + BattleInterface + + + BattleInterface + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + BattleInterface + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + UIFramework + + + + BattleInterface + + + BattleInterface + + + + + + + + + + + + {3b4624b5-80f2-4bd8-b4c0-af29d3be4b58} + + + {918a73d4-7386-4d29-9515-a3579051d4ac} + + + \ No newline at end of file diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index 3b96ddad6..3ad0ac222 100644 --- a/client/mapHandler.cpp +++ b/client/mapHandler.cpp @@ -15,6 +15,7 @@ #include "CConfigHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/GameConstants.h" +#include "../lib/CStopWatch.h" /* * mapHandler.cpp, part of VCMI engine @@ -335,7 +336,7 @@ void CMapHandler::initHeroDef(const CGHeroInstance * h) } void CMapHandler::init() { - StopWatch th; + CStopWatch th; th.getDiff(); graphics->advmapobjGraphics[8][0]["AB01_.DEF"] = graphics->boatAnims[0]; diff --git a/client/vcmi_client/.dep.inc b/client/vcmi_client/.dep.inc deleted file mode 100644 index 4560e55af..000000000 --- a/client/vcmi_client/.dep.inc +++ /dev/null @@ -1,5 +0,0 @@ -# This code depends on make tool being used -DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES})) -ifneq (${DEPFILES},) -include ${DEPFILES} -endif diff --git a/client/vcmi_client/Makefile b/client/vcmi_client/Makefile deleted file mode 100644 index 30bc67837..000000000 --- a/client/vcmi_client/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# -# NOCDDL - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: .build-impl -# Add your post 'build' code here... - - -# clean -clean: .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: .clean-impl -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: .clobber-impl -# Add your post 'clobber' code here... - - -# all -all: .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: .all-impl -# Add your post 'all' code here... - - -# help -help: .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: .help-impl -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/client/vcmi_client/nbproject/Makefile-Debug.mk b/client/vcmi_client/nbproject/Makefile-Debug.mk deleted file mode 100644 index fe68952be..000000000 --- a/client/vcmi_client/nbproject/Makefile-Debug.mk +++ /dev/null @@ -1,221 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran - -# Macros -PLATFORM=GNU-Linux-x86 - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=build/Debug/${PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS=-D_GNU_SOURCE=1 -D_REENTRANT -CXXFLAGS=-D_GNU_SOURCE=1 -D_REENTRANT - -# Fortran Compiler Flags -FFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS=-L../../../../boost/lib -Wl,-rpath ../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86 -L../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86 -lvcmi_lib - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - ${MAKE} -f nbproject/Makefile-Debug.mk dist/Debug/${PLATFORM}/vcmi_client - -dist/Debug/${PLATFORM}/vcmi_client: ../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86/libvcmi_lib.so - -dist/Debug/${PLATFORM}/vcmi_client: ${OBJECTFILES} - ${MKDIR} -p dist/Debug/${PLATFORM} - ${LINK.cc} -lboost_system-mt -lboost_thread-mt -lboost_filesystem-mt -lSDL -lSDL_ttf -lSDL_image -lSDL_mixer -o dist/Debug/${PLATFORM}/vcmi_client ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o: ../../hch/CSpellHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o ../../hch/CSpellHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o: ../../CLuaHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o ../../CLuaHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o: ../CSpellWindow.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o ../CSpellWindow.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o: ../../CCastleInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o ../../CCastleInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o: ../../CCursorHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o ../../CCursorHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o: ../../hch/CObjectHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o ../../hch/CObjectHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o: ../CCreatureAnimation.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o ../CCreatureAnimation.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o: ../Client.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o ../Client.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o: ../../CGameInfo.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o ../../CGameInfo.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o: ../../CHeroWindow.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o ../../CHeroWindow.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o: ../../CMessage.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o ../../CMessage.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o: ../../CPlayerInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o ../../CPlayerInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o: ../../hch/CAbilityHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o ../../hch/CAbilityHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o: ../../hch/CSndHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o ../../hch/CSndHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o: ../../CBattleInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o ../../CBattleInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o: ../../mapHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o ../../mapHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o: ../../CPathfinder.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o ../../CPathfinder.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o: ../../CGameInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o ../../CGameInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o: ../../CPreGame.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o ../../CPreGame.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o: ../CBitmapHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o ../CBitmapHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o: ../Graphics.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o ../Graphics.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o: ../../hch/CDefHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o ../../hch/CDefHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o: ../../AdventureMapButton.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o ../../AdventureMapButton.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o: ../../SDL_Extensions.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o ../../SDL_Extensions.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o: ../CConfigHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o ../CConfigHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o: ../../CAdvmapInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o ../../CAdvmapInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o: ../../CThreadHelper.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o ../../CThreadHelper.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o: ../../hch/CMusicHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o ../../hch/CMusicHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o: ../../SDL_framerate.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o ../../SDL_framerate.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o: ../../CCallback.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o ../../CCallback.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o: ../../CMT.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -g -I/usr/include/SDL -I../../../../boost/include/boost-1_37 -I.. -I../../hch -I/usr/include/lua5.1 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o ../../CMT.cpp - -# Subprojects -.build-subprojects: - cd ../../lib/vcmi_lib && ${MAKE} -f Makefile-nb CONF=Debug - -# Clean Targets -.clean-conf: ${CLEAN_SUBPROJECTS} - ${RM} -r build/Debug - ${RM} dist/Debug/${PLATFORM}/vcmi_client - -# Subprojects -.clean-subprojects: - cd ../../lib/vcmi_lib && ${MAKE} -f Makefile-nb CONF=Debug clean diff --git a/client/vcmi_client/nbproject/Makefile-Release.mk b/client/vcmi_client/nbproject/Makefile-Release.mk deleted file mode 100644 index 521abcda1..000000000 --- a/client/vcmi_client/nbproject/Makefile-Release.mk +++ /dev/null @@ -1,217 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran - -# Macros -PLATFORM=GNU-Linux-x86 - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=build/Release/${PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS= -CXXFLAGS= - -# Fortran Compiler Flags -FFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS= - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - ${MAKE} -f nbproject/Makefile-Release.mk dist/Release/${PLATFORM}/vcmi_client - -dist/Release/${PLATFORM}/vcmi_client: ${OBJECTFILES} - ${MKDIR} -p dist/Release/${PLATFORM} - ${LINK.cc} -o dist/Release/${PLATFORM}/vcmi_client ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o: ../../hch/CSpellHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSpellHandler.o ../../hch/CSpellHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o: ../../CLuaHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CLuaHandler.o ../../CLuaHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o: ../CSpellWindow.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.o ../CSpellWindow.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o: ../../CCastleInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCastleInterface.o ../../CCastleInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o: ../../CCursorHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCursorHandler.o ../../CCursorHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o: ../../hch/CObjectHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CObjectHandler.o ../../hch/CObjectHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o: ../CCreatureAnimation.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CCreatureAnimation.o ../CCreatureAnimation.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o: ../Client.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Client.o ../Client.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o: ../../CGameInfo.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInfo.o ../../CGameInfo.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o: ../../CHeroWindow.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CHeroWindow.o ../../CHeroWindow.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o: ../../CMessage.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMessage.o ../../CMessage.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o: ../../CPlayerInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPlayerInterface.o ../../CPlayerInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o: ../../hch/CAbilityHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CAbilityHandler.o ../../hch/CAbilityHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o: ../../hch/CSndHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CSndHandler.o ../../hch/CSndHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o: ../../CBattleInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.o ../../CBattleInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o: ../../mapHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../mapHandler.o ../../mapHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o: ../../CPathfinder.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPathfinder.o ../../CPathfinder.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o: ../../CGameInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CGameInterface.o ../../CGameInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o: ../../CPreGame.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CPreGame.o ../../CPreGame.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o: ../CBitmapHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CBitmapHandler.o ../CBitmapHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o: ../Graphics.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../Graphics.o ../Graphics.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o: ../../hch/CDefHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CDefHandler.o ../../hch/CDefHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o: ../../AdventureMapButton.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../AdventureMapButton.o ../../AdventureMapButton.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o: ../../SDL_Extensions.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_Extensions.o ../../SDL_Extensions.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o: ../CConfigHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../CConfigHandler.o ../CConfigHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o: ../../CAdvmapInterface.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CAdvmapInterface.o ../../CAdvmapInterface.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o: ../../CThreadHelper.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CThreadHelper.o ../../CThreadHelper.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o: ../../hch/CMusicHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.o ../../hch/CMusicHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o: ../../SDL_framerate.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../SDL_framerate.o ../../SDL_framerate.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o: ../../CCallback.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CCallback.o ../../CCallback.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o: ../../CMT.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/client/vcmi_client/../../CMT.o ../../CMT.cpp - -# Subprojects -.build-subprojects: - -# Clean Targets -.clean-conf: - ${RM} -r build/Release - ${RM} dist/Release/${PLATFORM}/vcmi_client - -# Subprojects -.clean-subprojects: diff --git a/client/vcmi_client/nbproject/Makefile-impl.mk b/client/vcmi_client/nbproject/Makefile-impl.mk deleted file mode 100644 index 7f2bda8a1..000000000 --- a/client/vcmi_client/nbproject/Makefile-impl.mk +++ /dev/null @@ -1,123 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a pre- and a post- target defined where you can add customization code. -# -# This makefile implements macros and targets common to all configurations. -# -# NOCDDL - - -# Building and Cleaning subprojects are done by default, but can be controlled with the SUB -# macro. If SUB=no, subprojects will not be built or cleaned. The following macro -# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf -# and .clean-reqprojects-conf unless SUB has the value 'no' -SUB_no=NO -SUBPROJECTS=${SUB_${SUB}} -BUILD_SUBPROJECTS_=.build-subprojects -BUILD_SUBPROJECTS_NO= -BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} -CLEAN_SUBPROJECTS_=.clean-subprojects -CLEAN_SUBPROJECTS_NO= -CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} - - -# Project Name -PROJECTNAME=vcmi_client - -# Active Configuration -DEFAULTCONF=Debug -CONF=${DEFAULTCONF} - -# All Configurations -ALLCONFS=Debug Release - - -# build -.build-impl: .build-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf - - -# clean -.clean-impl: .clean-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf - - -# clobber -.clobber-impl: .clobber-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ - done - -# all -.all-impl: .all-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf; \ - done - -# dependency checking support -.depcheck-impl: - @echo "# This code depends on make tool being used" >.dep.inc - @if [ -n "${MAKE_VERSION}" ]; then \ - echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ - echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ - echo "include \$${DEPFILES}" >>.dep.inc; \ - echo "endif" >>.dep.inc; \ - else \ - echo ".KEEP_STATE:" >>.dep.inc; \ - echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ - fi - -# configuration validation -.validate-impl: - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - echo ""; \ - echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ - echo "See 'make help' for details."; \ - echo "Current directory: " `pwd`; \ - echo ""; \ - fi - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - exit 1; \ - fi - - -# help -.help-impl: .help-pre - @echo "This makefile supports the following configurations:" - @echo " ${ALLCONFS}" - @echo "" - @echo "and the following targets:" - @echo " build (default target)" - @echo " clean" - @echo " clobber" - @echo " all" - @echo " help" - @echo "" - @echo "Makefile Usage:" - @echo " make [CONF=] [SUB=no] build" - @echo " make [CONF=] [SUB=no] clean" - @echo " make [SUB=no] clobber" - @echo " make [SUB=no] all" - @echo " make help" - @echo "" - @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," - @echo " also clean subprojects." - @echo "Target 'clobber' will remove all built files from all configurations and," - @echo " unless 'SUB=no', also from subprojects." - @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'help' prints this message." - @echo "" - diff --git a/client/vcmi_client/nbproject/Package-Debug.bash b/client/vcmi_client/nbproject/Package-Debug.bash deleted file mode 100644 index dc9e4c6f1..000000000 --- a/client/vcmi_client/nbproject/Package-Debug.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Debug/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Debug/${PLATFORM}/vcmi_client -OUTPUT_BASENAME=vcmi_client -PACKAGE_TOP_DIR=vcmiclient/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Debug/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/vcmiclient/bin -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Debug/${PLATFORM}/package/vcmiclient.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Debug/${PLATFORM}/package/vcmiclient.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/client/vcmi_client/nbproject/Package-Release.bash b/client/vcmi_client/nbproject/Package-Release.bash deleted file mode 100644 index 8e0f3b406..000000000 --- a/client/vcmi_client/nbproject/Package-Release.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Release/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Release/${PLATFORM}/vcmi_client -OUTPUT_BASENAME=vcmi_client -PACKAGE_TOP_DIR=vcmiclient/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Release/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/vcmiclient/bin -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Release/${PLATFORM}/package/vcmiclient.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Release/${PLATFORM}/package/vcmiclient.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/client/vcmi_client/nbproject/configurations.xml b/client/vcmi_client/nbproject/configurations.xml deleted file mode 100644 index 478288b70..000000000 --- a/client/vcmi_client/nbproject/configurations.xml +++ /dev/null @@ -1,594 +0,0 @@ - - - - - ../../AdventureMapButton.h - ../../AI_Base.h - ../../hch/CAbilityHandler.h - ../../CAdvmapInterface.h - ../../hch/CAmbarCendamo.h - ../../hch/CArtHandler.h - ../../CBattleInterface.h - ../CBitmapHandler.h - ../../hch/CBuildingHandler.h - ../../CCallback.h - ../../CCastleInterface.h - ../CConfigHandler.h - ../CCreatureAnimation.h - ../../CCursorHandler.h - ../../hch/CDefHandler.h - ../../CGameInfo.h - ../../CGameInterface.h - ../../hch/CHeroHandler.h - ../../CHeroWindow.h - ../Client.h - ../../CLuaHandler.h - ../../CMessage.h - ../../hch/CMusicHandler.h - ../../hch/CObjectHandler.h - ../../CPathfinder.h - ../../CPlayerInterface.h - ../../CPreGame.h - ../../hch/CSndHandler.h - ../CSpellWindow.h - ../../CThreadHelper.h - ../FunctionList.h - ../../global.h - ../Graphics.h - ../../int3.h - ../../map.h - ../../mapHandler.h - ../../nodrze.h - ../../SDL_framerate.h - ../../StartInfo.h - ../../stdafx.h - ../../timeHandler.h - - - - - ../../AdventureMapButton.cpp - ../../hch/CAbilityHandler.cpp - ../../CAdvmapInterface.cpp - ../../CBattleInterface.cpp - ../CBitmapHandler.cpp - ../../CCallback.cpp - ../../CCastleInterface.cpp - ../CConfigHandler.cpp - ../CCreatureAnimation.cpp - ../../CCursorHandler.cpp - ../../hch/CDefHandler.cpp - ../../CGameInfo.cpp - ../../CGameInterface.cpp - ../../CHeroWindow.cpp - ../Client.cpp - ../../CLuaHandler.cpp - ../../CMessage.cpp - ../../CMT.cpp - ../../hch/CMusicHandler.cpp - ../../hch/CObjectHandler.cpp - ../../CPathfinder.cpp - ../../CPlayerInterface.cpp - ../../CPreGame.cpp - ../../hch/CSndHandler.cpp - ../../hch/CSpellHandler.cpp - ../CSpellWindow.cpp - ../../CThreadHelper.cpp - ../Graphics.cpp - ../../mapHandler.cpp - ../../SDL_Extensions.cpp - ../../SDL_framerate.cpp - - - Makefile - - - - .. - - Makefile - - - - localhost - GNU|GNU - 2 - - - - - /usr/include/SDL - ../../../../boost/include/boost-1_37 - .. - ../../hch - /usr/include/lua5.1 - - -D_GNU_SOURCE=1 -D_REENTRANT - - - dist/Debug/${PLATFORM}/vcmi_client - - ../../../../boost/lib - - - - - - - - -lboost_system-mt -lboost_thread-mt -lboost_filesystem-mt -lSDL -lSDL_ttf -lSDL_image -lSDL_mixer - - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - - - localhost - GNU|GNU - 2 - - - - 5 - - - 5 - - - 5 - - - - - - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 1 - - - 3 - - - - diff --git a/client/vcmi_client/nbproject/private/configurations.xml b/client/vcmi_client/nbproject/private/configurations.xml deleted file mode 100644 index 554a2aa96..000000000 --- a/client/vcmi_client/nbproject/private/configurations.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - Makefile - 0 - - - - gdb - 10 - - - - - true - 0 - 0 - - - - - - - gdb - 10 - - - - - true - 0 - 0 - - - - - - diff --git a/client/vcmi_client/nbproject/private/private.properties b/client/vcmi_client/nbproject/private/private.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/vcmi_client/nbproject/private/private.xml b/client/vcmi_client/nbproject/private/private.xml deleted file mode 100644 index a764863ba..000000000 --- a/client/vcmi_client/nbproject/private/private.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - file:/home/t0/vcmi/trunk/client/vcmi_client/../../hch/CMusicHandler.cpp - 67 - - - file:/home/t0/vcmi/trunk/client/vcmi_client/../CSpellWindow.cpp - 638 - - - file:/home/t0/vcmi/trunk/CPreGame.h - 272 - - - file:/home/t0/vcmi/trunk/client/vcmi_client/../../CBattleInterface.cpp - 1754 - 2257 - - - file:/home/t0/vcmi/trunk/CMessage.cpp - 103 - - - diff --git a/client/vcmi_client/nbproject/project.properties b/client/vcmi_client/nbproject/project.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/vcmi_client/nbproject/project.xml b/client/vcmi_client/nbproject/project.xml deleted file mode 100644 index ae8f80dbe..000000000 --- a/client/vcmi_client/nbproject/project.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - vcmi_client - 0 - - cpp - h - UTF-8 - - ../../lib/vcmi_lib - - - - diff --git a/lib/BattleAction.cpp b/lib/BattleAction.cpp index cf7d54c33..00f6b23e7 100644 --- a/lib/BattleAction.cpp +++ b/lib/BattleAction.cpp @@ -32,7 +32,7 @@ BattleAction BattleAction::makeDefend(const CStack *stack) } -BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, SHexField attackFrom /*= SHexField::INVALID*/) +BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, SBattleHex attackFrom /*= SBattleHex::INVALID*/) { BattleAction ba; ba.side = !stack->attackerOwned; @@ -62,7 +62,7 @@ BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *t return ba; } -BattleAction BattleAction::makeMove(const CStack *stack, SHexField dest) +BattleAction BattleAction::makeMove(const CStack *stack, SBattleHex dest) { BattleAction ba; ba.side = !stack->attackerOwned; diff --git a/lib/BattleAction.h b/lib/BattleAction.h index 896bda764..84b508838 100644 --- a/lib/BattleAction.h +++ b/lib/BattleAction.h @@ -1,7 +1,7 @@ #pragma once -#include "SHexField.h" +#include "SBattleHex.h" /* * BattleAction.h, part of VCMI engine @@ -26,7 +26,7 @@ struct DLL_LINKAGE BattleAction STACK_HEAL, DAEMON_SUMMONING }; si8 actionType; //use ActionType enum for values - SHexField destinationTile; + SBattleHex destinationTile; si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6 template void serialize(Handler &h, const int version) { @@ -37,8 +37,8 @@ struct DLL_LINKAGE BattleAction static BattleAction makeDefend(const CStack *stack); static BattleAction makeWait(const CStack *stack); - static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, SHexField attackFrom = SHexField::INVALID); + static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, SBattleHex attackFrom = SBattleHex::INVALID); static BattleAction makeShotAttack(const CStack *shooter, const CStack *target); - static BattleAction makeMove(const CStack *stack, SHexField dest); + static BattleAction makeMove(const CStack *stack, SBattleHex dest); static BattleAction makeEndOFTacticPhase(ui8 side); }; diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index e25c6c44b..8343cf40f 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -103,7 +103,7 @@ const CStack * BattleInfo::getStack(int stackID, bool onlyAlive) const return const_cast(this)->getStack(stackID, onlyAlive); } -CStack * BattleInfo::getStackT(SHexField tileID, bool onlyAlive) +CStack * BattleInfo::getStackT(SBattleHex tileID, bool onlyAlive) { for(ui32 g=0; g(this)->getStackT(tileID, onlyAlive); } -void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack * stackToOmmit) const +void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack * stackToOmmit) const { memset(accessibility, 1, GameConstants::BFIELD_SIZE); //initialize array with trues @@ -153,7 +153,7 @@ void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool atta //obstacles for(ui32 b=0; b blocked = VLC->heroh->obstacles[obstacles[b].ID].getBlocked(obstacles[b].pos); + std::vector blocked = VLC->heroh->obstacles[obstacles[b].ID].getBlocked(obstacles[b].pos); for(ui32 c=0; c=0 && blocked[c] < GameConstants::BFIELD_SIZE) @@ -170,9 +170,9 @@ void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool atta accessibility[permanentlyLocked[b]] = false; } - static const std::pair lockedIfNotDestroyed[] = //(which part of wall, which hex is blocked if this part of wall is not destroyed - {std::make_pair(2, SHexField(182)), std::make_pair(3, SHexField(130)), - std::make_pair(4, SHexField(62)), std::make_pair(5, SHexField(29))}; + static const std::pair lockedIfNotDestroyed[] = //(which part of wall, which hex is blocked if this part of wall is not destroyed + {std::make_pair(2, SBattleHex(182)), std::make_pair(3, SBattleHex(130)), + std::make_pair(4, SBattleHex(62)), std::make_pair(5, SBattleHex(29))}; for(int b=0; b rem; //tiles to unlock + std::set rem; //tiles to unlock for(int h=0; h > hexq; //bfs queue (second filed used only if fillPredecessors is true) + std::queue< std::pair > hexq; //bfs queue (second filed used only if fillPredecessors is true) hexq.push(std::make_pair(start, true)); dists[hexq.front().first] = 0; int curNext = -1; //for bfs loop only (helper var) while(!hexq.empty()) //bfs loop { - std::pair curHex = hexq.front(); - std::vector neighbours = curHex.first.neighbouringTiles(); + std::pair curHex = hexq.front(); + std::vector neighbours = curHex.first.neighbouringTiles(); hexq.pop(); for(ui32 nr=0; nr BattleInfo::getAccessibility( const CStack * stack, bool addOccupiable, std::vector * attackable ) const +std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOccupiable, std::vector * attackable ) const { - std::vector ret; + std::vector ret; bool ac[GameConstants::BFIELD_SIZE]; if(stack->position < 0) //turrets - return std::vector(); + return std::vector(); - std::set occupyable; + std::set occupyable; getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, addOccupiable, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); - SHexField pr[GameConstants::BFIELD_SIZE]; + SBattleHex pr[GameConstants::BFIELD_SIZE]; int dist[GameConstants::BFIELD_SIZE]; makeBFS(stack->position, ac, pr, dist, stack->doubleWide(), stack->attackerOwned, stack->hasBonusOfType(Bonus::FLYING), false); @@ -285,7 +285,7 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool { if(!addOccupiable) { - std::vector rem; + std::vector rem; for(int b=0; b BattleInfo::getAccessibility( const CStack * stack, bool { struct HLP { - static bool meleeAttackable(SHexField hex, const std::vector & baseRng) + static bool meleeAttackable(SBattleHex hex, const std::vector & baseRng) { - BOOST_FOREACH(SHexField h, baseRng) + BOOST_FOREACH(SBattleHex h, baseRng) { - if(SHexField::mutualPosition(h, hex) > 0) + if(SBattleHex::mutualPosition(h, hex) > 0) return true; } @@ -347,7 +347,7 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool if(otherSt->owner == stack->owner) continue; - std::vector occupiedBySecond; + std::vector occupiedBySecond; occupiedBySecond.push_back(otherSt->position); if(otherSt->doubleWide()) occupiedBySecond.push_back(otherSt->occupiedHex()); @@ -360,7 +360,7 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool } - BOOST_FOREACH(SHexField he, occupiedBySecond) + BOOST_FOREACH(SBattleHex he, occupiedBySecond) { if(HLP::meleeAttackable(he, ret)) attackable->push_back(he); @@ -386,7 +386,7 @@ int BattleInfo::getAvaliableHex(TCreature creID, bool attackerOwned, int initial } bool ac[GameConstants::BFIELD_SIZE]; - std::set occupyable; + std::set occupyable; bool twoHex = VLC->creh->creatures[creID]->isDoubleWide(); bool flying = VLC->creh->creatures[creID]->isFlying();// vstd::contains(VLC->creh->creatures[creID]->bonuses, Bonus::FLYING); getAccessibilityMap(ac, twoHex, attackerOwned, true, occupyable, flying); @@ -419,21 +419,21 @@ bool BattleInfo::isStackBlocked(const CStack * stack) const return false; } -std::pair< std::vector, int > BattleInfo::getPath(SHexField start, SHexField dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned) +std::pair< std::vector, int > BattleInfo::getPath(SBattleHex start, SBattleHex dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned) { - SHexField predecessor[GameConstants::BFIELD_SIZE]; //for getting the Path + SBattleHex predecessor[GameConstants::BFIELD_SIZE]; //for getting the Path int dist[GameConstants::BFIELD_SIZE]; //calculated distances makeBFS(start, accessibility, predecessor, dist, twoHex, attackerOwned, flyingCreature, false); if(predecessor[dest] == -1) //cannot reach destination { - return std::make_pair(std::vector(), 0); + return std::make_pair(std::vector(), 0); } //making the Path - std::vector path; - SHexField curElem = dest; + std::vector path; + SBattleHex curElem = dest; while(curElem != start) { path.push_back(curElem); @@ -721,7 +721,7 @@ void BattleInfo::calculateCasualties( std::map *casualties ) const } } -std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SHexField destinationTile ) +std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SBattleHex destinationTile ) { std::set attackedHexes = s->rangeInHexes(destinationTile, skillLevel); std::set attackedCres; /*std::set to exclude multiple occurrences of two hex creatures*/ @@ -801,24 +801,24 @@ std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLe } return attackedCres; } -void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SHexField destinationTile, SHexField attackerPos) +void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos) { const int WN = GameConstants::BFIELD_WIDTH; - ui16 hex = (attackerPos != SHexField::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position + ui16 hex = (attackerPos != SBattleHex::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position if (attacker->hasBonusOfType(Bonus::ATTACKS_ALL_ADJACENT)) { - std::vector hexes = attacker->getSurroundingHexes(attackerPos); - BOOST_FOREACH (SHexField tile, hexes) + std::vector hexes = attacker->getSurroundingHexes(attackerPos); + BOOST_FOREACH (SBattleHex tile, hexes) { at.hostileCreaturePositions.insert(tile); } } if (attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK)) { - std::vector hexes = attacker->getSurroundingHexes(attackerPos); - BOOST_FOREACH (SHexField tile, hexes) + std::vector hexes = attacker->getSurroundingHexes(attackerPos); + BOOST_FOREACH (SBattleHex tile, hexes) { - if ((SHexField::mutualPosition(tile, destinationTile) > -1 && SHexField::mutualPosition(tile, hex) > -1) //adjacent both to attacker's head and attacked tile + if ((SBattleHex::mutualPosition(tile, destinationTile) > -1 && SBattleHex::mutualPosition(tile, hex) > -1) //adjacent both to attacker's head and attacked tile || tile == destinationTile) //or simply attacked directly { CStack * st = getStackT(tile, true); @@ -831,26 +831,26 @@ void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack } if (attacker->hasBonusOfType(Bonus::TWO_HEX_ATTACK_BREATH)) { - std::vector hexes; //only one, in fact + std::vector hexes; //only one, in fact int pseudoVector = destinationTile.hex - hex; switch (pseudoVector) { case 1: case -1: - SHexField::checkAndPush(destinationTile.hex + pseudoVector, hexes); + SBattleHex::checkAndPush(destinationTile.hex + pseudoVector, hexes); break; case WN: //17 case WN + 1: //18 case -WN: //-17 case -WN + 1: //-16 - SHexField::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : -1 ), hexes); + SBattleHex::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : -1 ), hexes); break; case WN-1: //16 case -WN-1: //-18 - SHexField::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes); + SBattleHex::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes); break; } - BOOST_FOREACH (SHexField tile, hexes) + BOOST_FOREACH (SBattleHex tile, hexes) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -860,12 +860,12 @@ void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack } } } -std::set BattleInfo::getAttackedCreatures(const CStack* attacker, SHexField destinationTile, SHexField attackerPos) +std::set BattleInfo::getAttackedCreatures(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos) { //TODO: caching? AttackableTiles at; getPotentiallyAttackableHexes(at, attacker, destinationTile, attackerPos); std::set attackedCres; - BOOST_FOREACH (SHexField tile, at.hostileCreaturePositions) //all around & three-headed attack + BOOST_FOREACH (SBattleHex tile, at.hostileCreaturePositions) //all around & three-headed attack { CStack * st = getStackT(tile, true); if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk? @@ -873,7 +873,7 @@ std::set BattleInfo::getAttackedCreatures(const CStack* attacker, SHexF attackedCres.insert(st); } } - BOOST_FOREACH (SHexField tile, at.friendlyCreaturePositions) + BOOST_FOREACH (SBattleHex tile, at.friendlyCreaturePositions) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -884,12 +884,12 @@ std::set BattleInfo::getAttackedCreatures(const CStack* attacker, SHexF return attackedCres; } -std::set BattleInfo::getAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos) +std::set BattleInfo::getAttackedHexes(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos) { AttackableTiles at; getPotentiallyAttackableHexes(at, attacker, destinationTile, attackerPos); - std::set attackedHexes; - BOOST_FOREACH (SHexField tile, at.hostileCreaturePositions) + std::set attackedHexes; + BOOST_FOREACH (SBattleHex tile, at.hostileCreaturePositions) { CStack * st = getStackT(tile, true); if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk? @@ -897,7 +897,7 @@ std::set BattleInfo::getAttackedHexes(const CStack* attacker, SHexFie attackedHexes.insert(tile); } } - BOOST_FOREACH (SHexField tile, at.friendlyCreaturePositions) + BOOST_FOREACH (SBattleHex tile, at.friendlyCreaturePositions) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -913,7 +913,7 @@ std::set BattleInfo::getAdjacentCreatures (const CStack * stack) const std::set stacks; CStack * localStack; - BOOST_FOREACH (SHexField hex, stack->getSurroundingHexes()) + BOOST_FOREACH (SBattleHex hex, stack->getSurroundingHexes()) { localStack = const_cast(getStackT(hex, true)); //only alive? if (localStack) @@ -940,7 +940,7 @@ int BattleInfo::calculateSpellDuration( const CSpell * spell, const CGHeroInstan } } -CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SHexField position) const +CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SBattleHex position) const { int owner = attackerOwned ? sides[0] : sides[1]; assert((owner >= GameConstants::PLAYER_LIMIT) || @@ -950,7 +950,7 @@ CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, b ret->position = position; return ret; } -CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SHexField position) const +CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SBattleHex position) const { int owner = attackerOwned ? sides[0] : sides[1]; CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot); @@ -981,7 +981,7 @@ ui32 BattleInfo::getSpellCost(const CSpell * sp, const CGHeroInstance * caster) return ret - manaReduction + manaIncrease; } -int BattleInfo::hexToWallPart(SHexField hex) const +int BattleInfo::hexToWallPart(SBattleHex hex) const { if(siege == 0) //there is no battle! return -1; @@ -1007,14 +1007,14 @@ int BattleInfo::lineToWallHex( int line ) const return lineToHex[line]; } -std::pair BattleInfo::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const +std::pair BattleInfo::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const { bool ac[GameConstants::BFIELD_SIZE]; - std::set occupyable; + std::set occupyable; getAccessibilityMap(ac, closest->doubleWide(), closest->attackerOwned, false, occupyable, closest->hasBonusOfType(Bonus::FLYING), closest); - SHexField predecessor[GameConstants::BFIELD_SIZE]; + SBattleHex predecessor[GameConstants::BFIELD_SIZE]; int dist[GameConstants::BFIELD_SIZE]; makeBFS(closest->position, ac, predecessor, dist, closest->doubleWide(), closest->attackerOwned, closest->hasBonusOfType(Bonus::FLYING), true); @@ -1055,7 +1055,7 @@ std::pair BattleInfo::getNearestStack(const CStack * return std::make_pair(minPair.second, predecessor[minPair.first.second]); } - return std::make_pair(NULL, SHexField::INVALID); + return std::make_pair(NULL, SBattleHex::INVALID); } ui32 BattleInfo::calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const { @@ -1251,13 +1251,13 @@ void BattleInfo::getStackQueue( std::vector &out, int howMany, i } } -si8 BattleInfo::hasDistancePenalty( const CStack * stack, SHexField destHex ) const +si8 BattleInfo::hasDistancePenalty( const CStack * stack, SBattleHex destHex ) const { struct HLP { - static bool lowerAnalyze(const CStack * stack, SHexField hex) + static bool lowerAnalyze(const CStack * stack, SBattleHex hex) { - int distance = SHexField::getDistance(hex, stack->position); + int distance = SBattleHex::getDistance(hex, stack->position); //I hope it's approximately correct return distance > 10 && !stack->hasBonusOfType(Bonus::NO_DISTANCE_PENALTY); @@ -1283,7 +1283,7 @@ si8 BattleInfo::sameSideOfWall(int pos1, int pos2) const return stackLeft != destLeft; } -si8 BattleInfo::hasWallPenalty( const CStack* stack, SHexField destHex ) const +si8 BattleInfo::hasWallPenalty( const CStack* stack, SBattleHex destHex ) const { if (!siege || stack->hasBonusOfType(Bonus::NO_WALL_PENALTY)) { @@ -1308,11 +1308,11 @@ si8 BattleInfo::hasWallPenalty( const CStack* stack, SHexField destHex ) const return false; } -si8 BattleInfo::canTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) const +si8 BattleInfo::canTeleportTo(const CStack * stack, SBattleHex destHex, int telportLevel) const { bool ac[GameConstants::BFIELD_SIZE]; - std::set occupyable; + std::set occupyable; getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, false, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); @@ -1327,7 +1327,7 @@ si8 BattleInfo::canTeleportTo(const CStack * stack, SHexField destHex, int telpo } -bool BattleInfo::battleCanShoot(const CStack * stack, SHexField dest) const +bool BattleInfo::battleCanShoot(const CStack * stack, SBattleHex dest) const { const CStack *dst = getStackT(dest); @@ -1375,7 +1375,7 @@ bool BattleInfo::battleCanFlee(int player) const return true; } -const CStack * BattleInfo::battleGetStack(SHexField pos, bool onlyAlive) +const CStack * BattleInfo::battleGetStack(SBattleHex pos, bool onlyAlive) { CStack * stack = NULL; for(ui32 g=0; gdoubleWide() && stacks[g]->attackerOwned) { - stacks[g]->position += SHexField::RIGHT; + stacks[g]->position += SBattleHex::RIGHT; } else if(stacks[g]->doubleWide() && !stacks[g]->attackerOwned) { if (stacks[g]->position.getX() > 1) - stacks[g]->position += SHexField::LEFT; + stacks[g]->position += SBattleHex::LEFT; } } @@ -1663,7 +1663,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const coi.uniqueID = curB->obstacles.size(); coi.ID = possibleObstacles[rand()%possibleObstacles.size()]; coi.pos = rand()%GameConstants::BFIELD_SIZE; - std::vector block = VLC->heroh->obstacles[coi.ID].getBlocked(coi.pos); + std::vector block = VLC->heroh->obstacles[coi.ID].getBlocked(coi.pos); bool badObstacle = false; for(int b=0; b 0 && dest.getX() <= tacticDistance) @@ -1931,7 +1931,7 @@ ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int pla return ESpellCastProblem::OK; } -ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastThisSpellHere( int player, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest ) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastThisSpellHere( int player, const CSpell * spell, ECastingMode::ECastingMode mode, SBattleHex dest ) const { ESpellCastProblem::ESpellCastProblem moreGeneralProblem = battleCanCastThisSpell(player, spell, mode); if(moreGeneralProblem != ESpellCastProblem::OK) @@ -2093,7 +2093,7 @@ bool BattleInfo::battleTestElementalImmunity(const CStack * subject, const CSpel return false; } -ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SBattleHex dest) const { const CStack * subject = getStackT(dest, false); if(subject) @@ -2320,7 +2320,7 @@ void CStack::init() owner = 255; slot = 255; attackerOwned = false; - position = SHexField(); + position = SBattleHex(); counterAttacks = -1; } @@ -2605,7 +2605,7 @@ bool CStack::doubleWide() const return getCreature()->doubleWide; } -SHexField CStack::occupiedHex() const +SBattleHex CStack::occupiedHex() const { if (doubleWide()) { @@ -2616,54 +2616,54 @@ SHexField CStack::occupiedHex() const } else { - return SHexField::INVALID; + return SBattleHex::INVALID; } } -std::vector CStack::getHexes() const +std::vector CStack::getHexes() const { - std::vector hexes; - hexes.push_back(SHexField(position)); - SHexField occupied = occupiedHex(); + std::vector hexes; + hexes.push_back(SBattleHex(position)); + SBattleHex occupied = occupiedHex(); if(occupied.isValid()) hexes.push_back(occupied); return hexes; } -bool CStack::coversPos(SHexField pos) const +bool CStack::coversPos(SBattleHex pos) const { return vstd::contains(getHexes(), pos); } -std::vector CStack::getSurroundingHexes(SHexField attackerPos) const +std::vector CStack::getSurroundingHexes(SBattleHex attackerPos) const { - SHexField hex = (attackerPos != SHexField::INVALID) ? attackerPos : position; //use hypothetical position - std::vector hexes; + SBattleHex hex = (attackerPos != SBattleHex::INVALID) ? attackerPos : position; //use hypothetical position + std::vector hexes; if (doubleWide()) { const int WN = GameConstants::BFIELD_WIDTH; if(attackerOwned) { //position is equal to front hex - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+2 : WN+1 ), hexes); - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); - SHexField::checkAndPush(hex - 2, hexes); - SHexField::checkAndPush(hex + 1, hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-2 : WN-1 ), hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN+2 : WN+1 ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); + SBattleHex::checkAndPush(hex - 2, hexes); + SBattleHex::checkAndPush(hex + 1, hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN-2 : WN-1 ), hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); } else { - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); - SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN-1 : WN-2 ), hexes); - SHexField::checkAndPush(hex + 2, hexes); - SHexField::checkAndPush(hex - 1, hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); - SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN+1 : WN+2 ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); + SBattleHex::checkAndPush(hex - ( (hex/WN)%2 ? WN-1 : WN-2 ), hexes); + SBattleHex::checkAndPush(hex + 2, hexes); + SBattleHex::checkAndPush(hex - 1, hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); + SBattleHex::checkAndPush(hex + ( (hex/WN)%2 ? WN+1 : WN+2 ), hexes); } return hexes; } @@ -2764,7 +2764,7 @@ void CStack::prepareAttacked(BattleStackAttacked &bsa) const } } -bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SHexField attackerPos /*= SHexField::INVALID*/, SHexField defenderPos /*= SHexField::INVALID*/) +bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SBattleHex attackerPos /*= SBattleHex::INVALID*/, SBattleHex defenderPos /*= SBattleHex::INVALID*/) { if (!attackerPos.isValid()) { @@ -2776,13 +2776,13 @@ bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defen } return - (SHexField::mutualPosition(attackerPos, defenderPos) >= 0) //front <=> front + (SBattleHex::mutualPosition(attackerPos, defenderPos) >= 0) //front <=> front || (attacker->doubleWide() //back <=> front - && SHexField::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos) >= 0) + && SBattleHex::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos) >= 0) || (defender->doubleWide() //front <=> back - && SHexField::mutualPosition(attackerPos, defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0) + && SBattleHex::mutualPosition(attackerPos, defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0) || (defender->doubleWide() && attacker->doubleWide()//back <=> back - && SHexField::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0); + && SBattleHex::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0); } diff --git a/lib/BattleState.h b/lib/BattleState.h index f4f6f29d0..2b15989b3 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -1,7 +1,7 @@ #pragma once -#include "SHexField.h" +#include "SBattleHex.h" #include "HeroBonus.h" #include "CCreatureSet.h" #include "CObjectHandler.h" @@ -41,8 +41,8 @@ struct DLL_LINKAGE SiegeInfo struct DLL_LINKAGE AttackableTiles { - std::set hostileCreaturePositions; - std::set friendlyCreaturePositions; //for Dragon Breath + std::set hostileCreaturePositions; + std::set friendlyCreaturePositions; //for Dragon Breath template void serialize(Handler &h, const int version) { h & hostileCreaturePositions & friendlyCreaturePositions; @@ -87,14 +87,14 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode void getStackQueue(std::vector &out, int howMany, int turn = 0, int lastMoved = -1) const; //returns stack in order of their movement action CStack * getStack(int stackID, bool onlyAlive = true); const CStack * getStack(int stackID, bool onlyAlive = true) const; - CStack * getStackT(SHexField tileID, bool onlyAlive = true); - const CStack * getStackT(SHexField tileID, bool onlyAlive = true) const; - void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes - static bool isAccessible(SHexField hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS + CStack * getStackT(SBattleHex tileID, bool onlyAlive = true); + const CStack * getStackT(SBattleHex tileID, bool onlyAlive = true) const; + void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes + static bool isAccessible(SBattleHex hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS int getAvaliableHex(TCreature creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects - void makeBFS(SHexField start, bool*accessibility, SHexField *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result - std::pair< std::vector, int > getPath(SHexField start, SHexField dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned); //returned value: pair; length may be different than number of elements in path since flying vreatures jump between distant hexes - std::vector getAccessibility(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL) const; //returns vector of accessible tiles (taking into account the creature range) + void makeBFS(SBattleHex start, bool*accessibility, SBattleHex *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result + std::pair< std::vector, int > getPath(SBattleHex start, SBattleHex dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned); //returned value: pair; length may be different than number of elements in path since flying vreatures jump between distant hexes + std::vector getAccessibility(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL) const; //returns vector of accessible tiles (taking into account the creature range) bool isStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack @@ -102,35 +102,35 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, TQuantity attackerCount, TQuantity defenderCount, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair void calculateCasualties(std::map *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount) - std::set getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SHexField destinationTile); //calculates stack affected by given spell - void getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SHexField destinationTile, SHexField attackerPos); //hexes around target that could be attacked in melee - std::set getAttackedCreatures(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); //calculates range of multi-hex attacks - std::set getAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); //calculates range of multi-hex attacks + std::set getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SBattleHex destinationTile); //calculates stack affected by given spell + void getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos); //hexes around target that could be attacked in melee + std::set getAttackedCreatures(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos = SBattleHex::INVALID); //calculates range of multi-hex attacks + std::set getAttackedHexes(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos = SBattleHex::INVALID); //calculates range of multi-hex attacks std::set getAdjacentCreatures (const CStack * stack) const; static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster, int usedSpellPower); - CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SHexField position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield - CStack * generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SHexField position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield + CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SBattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield + CStack * generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SBattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield ui32 getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell - int hexToWallPart(SHexField hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found + int hexToWallPart(SBattleHex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found int lineToWallHex(int line) const; //returns hex with wall in given line - std::pair getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex) + std::pair getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex) ui32 calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const; ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature, int spellSchoolLevel, int usedSpellPower) const; //calculates damage inflicted by spell ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack) const; ui32 calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const; //for Archangel ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //unused bool resurrects(TSpell spellid) const; //TODO: move it to spellHandler? - si8 hasDistancePenalty(const CStack * stackID, SHexField destHex) const; //determines if given stack has distance penalty shooting given pos + si8 hasDistancePenalty(const CStack * stackID, SBattleHex destHex) const; //determines if given stack has distance penalty shooting given pos si8 sameSideOfWall(int pos1, int pos2) const; //determines if given positions are on the same side of wall - si8 hasWallPenalty(const CStack * stack, SHexField destHex) const; //determines if given stack has wall penalty shooting given pos - si8 canTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) const; //determines if given stack can teleport to given place - bool battleCanShoot(const CStack * stack, SHexField dest) const; //determines if stack with given ID shoot at the selected destination + si8 hasWallPenalty(const CStack * stack, SBattleHex destHex) const; //determines if given stack has wall penalty shooting given pos + si8 canTeleportTo(const CStack * stack, SBattleHex destHex, int telportLevel) const; //determines if given stack can teleport to given place + bool battleCanShoot(const CStack * stack, SBattleHex dest) const; //determines if stack with given ID shoot at the selected destination const CGHeroInstance * getHero(int player) const; //returns fighting hero that belongs to given player ESpellCastProblem::ESpellCastProblem battleCanCastSpell(int player, ECastingMode::ECastingMode mode) const; //returns true if there are no general issues preventing from casting a spell ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(int player, const CSpell * spell, ECastingMode::ECastingMode mode) const; //checks if given player can cast given spell - ESpellCastProblem::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. - ESpellCastProblem::ESpellCastProblem battleCanCastThisSpellHere(int player, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const; //checks if given player can cast given spell at given tile in given mode + ESpellCastProblem::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SBattleHex dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpellHere(int player, const CSpell * spell, ECastingMode::ECastingMode mode, SBattleHex dest) const; //checks if given player can cast given spell at given tile in given mode bool battleTestElementalImmunity(const CStack * subject, const CSpell * spell, Bonus::BonusType element, bool damageSpell) const; TSpell getRandomBeneficialSpell(const CStack * subject) const; TSpell getRandomCastedSpell(const CStack * caster) const; //called at the beginning of turn for Faerie Dragon @@ -139,12 +139,12 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode bool battleCanFlee(int player) const; //returns true if player can flee from the battle - const CStack * battleGetStack(SHexField pos, bool onlyAlive); //returns stack at given tile + const CStack * battleGetStack(SBattleHex pos, bool onlyAlive); //returns stack at given tile const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; NULL if none si8 battleMinSpellLevel() const; //calculates minimum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned void localInit(); static BattleInfo * setupBattle( int3 tile, int terrain, int terType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ); - bool isInTacticRange( SHexField dest ) const; + bool isInTacticRange( SBattleHex dest ) const; int getSurrenderingCost(int player) const; int theOtherPlayer(int player) const; @@ -161,7 +161,7 @@ public: ui32 firstHPleft; //HP of first creature in stack ui8 owner, slot; //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures) ui8 attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle) - SHexField position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower + SBattleHex position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower ui8 counterAttacks; //how many counter attacks can be performed more in this turn (by default set at the beginning of the round to 1) si16 shots; //how many shots left ui8 casts; //how many casts left @@ -207,13 +207,13 @@ public: return ret; } - static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SHexField attackerPos = SHexField::INVALID, SHexField defenderPos = SHexField::INVALID); + static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SBattleHex attackerPos = SBattleHex::INVALID, SBattleHex defenderPos = SBattleHex::INVALID); bool doubleWide() const; - SHexField occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1 - std::vector getHexes() const; //up to two occupied hexes, starting from front - bool coversPos(SHexField position) const; //checks also if unit is double-wide - std::vector getSurroundingHexes(SHexField attackerPos = SHexField::INVALID) const; // get six or 8 surrounding hexes depending on creature size + SBattleHex occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1 + std::vector getHexes() const; //up to two occupied hexes, starting from front + bool coversPos(SBattleHex position) const; //checks also if unit is double-wide + std::vector getSurroundingHexes(SBattleHex attackerPos = SBattleHex::INVALID) const; // get six or 8 surrounding hexes depending on creature size void prepareAttacked(BattleStackAttacked &bsa) const; //requires bsa.damageAmout filled diff --git a/lib/CGameInterface.cpp b/lib/CGameInterface.cpp index a7e09e895..c40b02553 100644 --- a/lib/CGameInterface.cpp +++ b/lib/CGameInterface.cpp @@ -170,7 +170,7 @@ void CAdventureAI::battleNewStackAppeared(const CStack * stack) battleAI->battleNewStackAppeared(stack); } -void CAdventureAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CAdventureAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) { battleAI->battleStackMoved(stack, dest, distance); } diff --git a/lib/CGameInterface.h b/lib/CGameInterface.h index 118ba2d71..97729ebe5 100644 --- a/lib/CGameInterface.h +++ b/lib/CGameInterface.h @@ -95,7 +95,7 @@ public: virtual void yourTurn() OVERRIDE{}; virtual void heroKilled(const CGHeroInstance*){}; virtual void heroCreated(const CGHeroInstance*) OVERRIDE{}; - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE{}; + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE{}; virtual void battleStackAttacking(int ID, int dest) {}; virtual void battleStacksAttacked(const std::vector & bsa) OVERRIDE{}; virtual BattleAction activeStack(const CStack * stack) OVERRIDE; @@ -127,7 +127,7 @@ public: virtual void battleStacksRemoved(const BattleStacksRemoved & bsr); virtual void battleObstaclesRemoved(const std::set & removedObstacles); virtual void battleNewStackAppeared(const CStack * stack); - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance); + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance); virtual void battleAttack(const BattleAttack *ba); virtual void battleSpellCast(const BattleSpellCast *sc); virtual void battleEnd(const BattleResult *br); diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 6203eb019..5f750f8ff 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -92,9 +92,9 @@ int CObstacleInfo::getHeight() const return ret; } -std::vector CObstacleInfo::getBlocked(SHexField hex) const +std::vector CObstacleInfo::getBlocked(SBattleHex hex) const { - std::vector ret; + std::vector ret; int cur = hex; //currently browsed hex int curBeg = hex; //beginning of current line for(int h=0; h CObstacleInfo::getBlocked(SHexField hex) const return ret; } -SHexField CObstacleInfo::getMaxBlocked(SHexField hex) const +SBattleHex CObstacleInfo::getMaxBlocked(SBattleHex hex) const { - std::vector blocked = getBlocked(hex); + std::vector blocked = getBlocked(hex); return *std::max_element(blocked.begin(), blocked.end()); } diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 5cd4a069b..16e99455a 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -1,7 +1,7 @@ #pragma once -#include "SHexField.h" +#include "SBattleHex.h" #include "../lib/ConstTransitivePtr.h" #include "GameConstants.h" @@ -96,8 +96,8 @@ struct DLL_LINKAGE CObstacleInfo std::pair posShift; //shift of obstacle's position in the battlefield , eg. if it's <-1, 2> obstacle will be printed one pixel to the left and two to the bottom int getWidth() const; //returns width of obstacle in hexes int getHeight() const; //returns height of obstacle in hexes - std::vector getBlocked(SHexField hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex' - SHexField getMaxBlocked(SHexField hex) const; //returns maximal hex (max number) covered by this obstacle + std::vector getBlocked(SBattleHex hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex' + SBattleHex getMaxBlocked(SBattleHex hex) const; //returns maximal hex (max number) covered by this obstacle template void serialize(Handler &h, const int version) { h & ID & defName & blockmap & allowedTerrains & posShift; diff --git a/lib/StopWatch.h b/lib/CStopWatch.h similarity index 91% rename from lib/StopWatch.h rename to lib/CStopWatch.h index 03a3d2300..009d354fb 100644 --- a/lib/StopWatch.h +++ b/lib/CStopWatch.h @@ -20,12 +20,12 @@ * */ -class StopWatch +class CStopWatch { si64 start, last, mem; public: - StopWatch() + CStopWatch() : start(clock()) { last=clock(); diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index b915e3410..e197953ce 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -39,31 +39,31 @@ boost::shared_mutex& CCallbackBase::getGsMutex() return *gs->mx; } -si8 CBattleInfoCallback::battleHasDistancePenalty( const CStack * stack, SHexField destHex ) +si8 CBattleInfoCallback::battleHasDistancePenalty( const CStack * stack, SBattleHex destHex ) { return gs->curB->hasDistancePenalty(stack, destHex); } -si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, SHexField destHex ) +si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, SBattleHex destHex ) { return gs->curB->hasWallPenalty(stack, destHex); } -si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) +si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, SBattleHex destHex, int telportLevel) { return gs->curB->canTeleportTo(stack, destHex, telportLevel); } -std::vector CBattleInfoCallback::battleGetDistances(const CStack * stack, SHexField hex /*= SHexField::INVALID*/, SHexField * predecessors /*= NULL*/) +std::vector CBattleInfoCallback::battleGetDistances(const CStack * stack, SBattleHex hex /*= SBattleHex::INVALID*/, SBattleHex * predecessors /*= NULL*/) { if(!hex.isValid()) hex = stack->position; std::vector ret; bool ac[GameConstants::BFIELD_SIZE] = {0}; - std::set occupyable; + std::set occupyable; gs->curB->getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, false, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); - SHexField pr[GameConstants::BFIELD_SIZE]; + SBattleHex pr[GameConstants::BFIELD_SIZE]; int dist[GameConstants::BFIELD_SIZE]; gs->curB->makeBFS(stack->position, ac, pr, dist, stack->doubleWide(), stack->attackerOwned, stack->hasBonusOfType(Bonus::FLYING), false); @@ -77,18 +77,18 @@ std::vector CBattleInfoCallback::battleGetDistances(const CStack * stack, S if(predecessors) { - memcpy(predecessors, pr, GameConstants::BFIELD_SIZE * sizeof(SHexField)); + memcpy(predecessors, pr, GameConstants::BFIELD_SIZE * sizeof(SBattleHex)); } return ret; } -std::set CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos /*= SHexField::INVALID*/) +std::set CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos /*= SBattleHex::INVALID*/) { if(!gs->curB) { tlog1 << "battleGetAttackedHexes called when there is no battle!\n"; - std::set set; + std::set set; return set; } @@ -107,7 +107,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell return gs->curB->battleCanCastThisSpell(player, spell, ECastingMode::HERO_CASTING); } -ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell(const CSpell * spell, SHexField destination) +ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell(const CSpell * spell, SBattleHex destination) { if(!gs->curB) { @@ -185,7 +185,7 @@ int CBattleInfoCallback::battleGetBattlefieldType() return gs->curB->battlefieldType; } -int CBattleInfoCallback::battleGetObstaclesAtTile(SHexField tile) //returns bitfield +int CBattleInfoCallback::battleGetObstaclesAtTile(SBattleHex tile) //returns bitfield { //TODO - write return -1; @@ -207,26 +207,26 @@ const CStack* CBattleInfoCallback::battleGetStackByID(int ID, bool onlyAlive) return gs->curB->getStack(ID, onlyAlive); } -const CStack* CBattleInfoCallback::battleGetStackByPos(SHexField pos, bool onlyAlive) +const CStack* CBattleInfoCallback::battleGetStackByPos(SBattleHex pos, bool onlyAlive) { //boost::shared_lock lock(*gs->mx); return gs->curB->battleGetStack(pos, onlyAlive); } -SHexField CBattleInfoCallback::battleGetPos(int stack) +SBattleHex CBattleInfoCallback::battleGetPos(int stack) { //boost::shared_lock lock(*gs->mx); if(!gs->curB) { tlog2<<"battleGetPos called when there is no battle!"<curB->stacks.size(); ++g) { if(gs->curB->stacks[g]->ID == stack) return gs->curB->stacks[g]->position; } - return SHexField::INVALID; + return SBattleHex::INVALID; } TStacks CBattleInfoCallback::battleGetStacks(EStackOwnership whose /*= MINE_AND_ENEMY*/, bool onlyAlive /*= true*/) @@ -268,24 +268,24 @@ void CBattleInfoCallback::battleGetStackCountOutsideHexes(bool *ac) for (int i = 0; i < GameConstants::BFIELD_SIZE; ++i) ac[i] = false; } else { - std::set ignored; + std::set ignored; gs->curB->getAccessibilityMap(ac, false /*ignored*/, false, false, ignored, false /*ignored*/, NULL); } } -std::vector CBattleInfoCallback::battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable) +std::vector CBattleInfoCallback::battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable) { //boost::shared_lock lock(*gs->mx); if(!gs->curB) { tlog2<<"battleGetAvailableHexes called when there is no battle!"<(); + return std::vector(); } return gs->curB->getAccessibility(stack, addOccupiable, attackable); //return gs->battleGetRange(ID); } -bool CBattleInfoCallback::battleCanShoot(const CStack * stack, SHexField dest) +bool CBattleInfoCallback::battleCanShoot(const CStack * stack, SBattleHex dest) { //boost::shared_lock lock(*gs->mx); @@ -324,7 +324,7 @@ ui8 CBattleInfoCallback::battleGetWallState(int partOfWall) return gs->curB->si.wallState[partOfWall]; } -int CBattleInfoCallback::battleGetWallUnderHex(SHexField hex) +int CBattleInfoCallback::battleGetWallUnderHex(SBattleHex hex) { if(!gs->curB || gs->curB->siege == 0) { diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index c19ccbe45..bde5a4ec3 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -1,7 +1,7 @@ #pragma once -#include "SHexField.h" +#include "SBattleHex.h" #include "../client/FunctionList.h" #include "CObstacleInstance.h" #include "ResourceSet.h" @@ -94,33 +94,33 @@ public: //battle int battleGetBattlefieldType(); // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship - int battleGetObstaclesAtTile(SHexField tile); //returns bitfield + int battleGetObstaclesAtTile(SBattleHex tile); //returns bitfield std::vector battleGetAllObstacles(); //returns all obstacles on the battlefield const CStack * battleGetStackByID(int ID, bool onlyAlive = true); //returns stack info by given ID - const CStack * battleGetStackByPos(SHexField pos, bool onlyAlive = true); //returns stack info by given pos - SHexField battleGetPos(int stack); //returns position (tile ID) of stack + const CStack * battleGetStackByPos(SBattleHex pos, bool onlyAlive = true); //returns stack info by given pos + SBattleHex battleGetPos(int stack); //returns position (tile ID) of stack TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true); //returns stacks on battlefield void getStackQueue( std::vector &out, int howMany ); //returns vector of stack in order of their move sequence void battleGetStackCountOutsideHexes(bool *ac); // returns hexes which when in front of a stack cause us to move the amount box back - std::vector battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL); //returns numbers of hexes reachable by creature with id ID - std::vector battleGetDistances(const CStack * stack, SHexField hex = SHexField::INVALID, SHexField * predecessors = NULL); //returns vector of distances to [dest hex number] - std::set battleGetAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); - bool battleCanShoot(const CStack * stack, SHexField dest); //returns true if unit with id ID can shoot to dest + std::vector battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL); //returns numbers of hexes reachable by creature with id ID + std::vector battleGetDistances(const CStack * stack, SBattleHex hex = SBattleHex::INVALID, SBattleHex * predecessors = NULL); //returns vector of distances to [dest hex number] + std::set battleGetAttackedHexes(const CStack* attacker, SBattleHex destinationTile, SBattleHex attackerPos = SBattleHex::INVALID); + bool battleCanShoot(const CStack * stack, SBattleHex dest); //returns true if unit with id ID can shoot to dest bool battleCanCastSpell(); //returns true, if caller can cast a spell ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell); //determines if given spell can be casted (and returns problem description) - ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell, SHexField destination); //determines if creature can cast a spell here + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell, SBattleHex destination); //determines if creature can cast a spell here ui32 battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode); bool battleCanFlee(); //returns true if caller can flee from the battle int battleGetSurrenderCost(); //returns cost of surrendering battle, -1 if surrendering is not possible const CGTownInstance * battleGetDefendedTown(); //returns defended town if current battle is a siege, NULL instead ui8 battleGetWallState(int partOfWall); //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle - int battleGetWallUnderHex(SHexField hex); //returns part of destructible wall / gate / keep under given hex or -1 if not found + int battleGetWallUnderHex(SBattleHex hex); //returns part of destructible wall / gate / keep under given hex or -1 if not found std::pair battleEstimateDamage(const CStack * attacker, const CStack * defender, std::pair * retaliationDmg = NULL); //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair ui8 battleGetSiegeLevel(); //returns 0 when there is no siege, 1 if fort, 2 is citadel, 3 is castle const CGHeroInstance * battleGetFightingHero(ui8 side) const; //returns hero corresponding to given side (0 - attacker, 1 - defender) - si8 battleHasDistancePenalty(const CStack * stack, SHexField destHex); //checks if given stack has distance penalty - si8 battleHasWallPenalty(const CStack * stack, SHexField destHex); //checks if given stack has wall penalty - si8 battleCanTeleportTo(const CStack * stack, SHexField destHex, int telportLevel); //checks if teleportation of given stack to given position can take place + si8 battleHasDistancePenalty(const CStack * stack, SBattleHex destHex); //checks if given stack has distance penalty + si8 battleHasWallPenalty(const CStack * stack, SBattleHex destHex); //checks if given stack has wall penalty + si8 battleCanTeleportTo(const CStack * stack, SBattleHex destHex, int telportLevel); //checks if teleportation of given stack to given position can take place si8 battleGetTacticDist(); //returns tactic distance for calling player or 0 if player is not in tactic phase ui8 battleGetMySide(); //return side of player in battle (attacker/defender) diff --git a/lib/IGameEventsReceiver.h b/lib/IGameEventsReceiver.h index 964645fe5..8db5226cf 100644 --- a/lib/IGameEventsReceiver.h +++ b/lib/IGameEventsReceiver.h @@ -1,7 +1,7 @@ #pragma once -#include "SHexField.h" +#include "SBattleHex.h" #include "int3.h" class CGTownInstance; @@ -45,7 +45,7 @@ public: virtual void battleEnd(const BattleResult *br){}; virtual void battleNewRoundFirst(int round){}; //called at the beginning of each turn before changes are applied; virtual void battleNewRound(int round){}; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance){}; + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance){}; virtual void battleSpellCast(const BattleSpellCast *sc){}; virtual void battleStacksEffectsSet(const SetStackEffect & sse){};//called when a specific effect is set to stacks virtual void battleTriggerEffect(const BattleTriggerEffect & bte){}; //called for various one-shot effects diff --git a/lib/Makefile.am b/lib/Makefile.am index 531f0a491..1c6fdf49e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -67,8 +67,8 @@ libvcmi_la_SOURCES = \ ResourceSet.cpp \ ResourceSet.h \ RegisterTypes.h \ - SHexField.cpp \ - SHexField.h \ + SBattleHex.cpp \ + SBattleHex.h \ VCMIDirs.h \ VCMI_Lib.cpp \ VCMI_Lib.h \ diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 8dc4c2fbe..2c18f2b02 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1214,7 +1214,7 @@ struct BattleResult : public CPackForClient//3003 struct BattleStackMoved : public CPackForClient//3004 { ui32 stack; - std::vector tilesToMove; + std::vector tilesToMove; ui8 distance, teleporting; BattleStackMoved(){type = 3004;}; void applyFirstCl(CClient *cl); @@ -1382,7 +1382,7 @@ struct BattleSpellCast : public CPackForClient//3009 ui8 skill; //caster's skill level ui8 spellCost; ui8 manaGained; //mana channeling ability - SHexField tile; //destination tile (may not be set in some global/mass spells + SBattleHex tile; //destination tile (may not be set in some global/mass spells std::vector resisted; //ids of creatures that resisted this spell std::set affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure) TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact) diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 5b045693c..4d628e6cb 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1150,7 +1150,7 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs ) CStack * changedStack = gs->curB->getStack(healedStacks[g].stackID, false); //checking if we resurrect a stack that is under a living stack - std::vector access = gs->curB->getAccessibility(changedStack, true); + std::vector access = gs->curB->getAccessibility(changedStack, true); bool acc[GameConstants::BFIELD_SIZE]; for(int h=0; h SHexField::neighbouringTiles() const +std::vector SBattleHex::neighbouringTiles() const { - std::vector ret; + std::vector ret; const int WN = GameConstants::BFIELD_WIDTH; checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), ret); checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), ret); @@ -53,7 +53,7 @@ std::vector SHexField::neighbouringTiles() const return ret; } -signed char SHexField::mutualPosition(SHexField hex1, SHexField hex2) +signed char SBattleHex::mutualPosition(SBattleHex hex1, SBattleHex hex2) { if(hex2 == hex1 - ( (hex1/17)%2 ? 18 : 17 )) //top left return 0; @@ -70,16 +70,16 @@ signed char SHexField::mutualPosition(SHexField hex1, SHexField hex2) return -1; } -char SHexField::getDistance(SHexField hex1, SHexField hex2) +char SBattleHex::getDistance(SBattleHex hex1, SBattleHex hex2) { int xDst = std::abs(hex1 % GameConstants::BFIELD_WIDTH - hex2 % GameConstants::BFIELD_WIDTH), yDst = std::abs(hex1 / GameConstants::BFIELD_WIDTH - hex2 / GameConstants::BFIELD_WIDTH); return std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2; } -void SHexField::checkAndPush(int tile, std::vector & ret) +void SBattleHex::checkAndPush(int tile, std::vector & ret) { if( tile>=0 && tile - SHexField(inttype x, inttype y) + SBattleHex(inttype x, inttype y) { setXY(x, y); } template - SHexField(std::pair xy) + SBattleHex(std::pair xy) { setXY(xy); } @@ -89,21 +89,21 @@ struct DLL_LINKAGE SHexField //moving to direction void operator+=(EDir dir); - //generates new SHexField moved by given dir - SHexField operator+(EDir dir) const; + //generates new SBattleHex moved by given dir + SBattleHex operator+(EDir dir) const; - std::vector neighbouringTiles() const; + std::vector neighbouringTiles() const; //returns info about mutual position of given hexes (-1 - they're distant, 0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left) - static signed char mutualPosition(SHexField hex1, SHexField hex2); + static signed char mutualPosition(SBattleHex hex1, SBattleHex hex2); //returns distance between given hexes - static char getDistance(SHexField hex1, SHexField hex2); + static char getDistance(SBattleHex hex1, SBattleHex hex2); template void serialize(Handler &h, const int version) { h & hex; } - static void checkAndPush(int tile, std::vector & ret); + static void checkAndPush(int tile, std::vector & ret); }; \ No newline at end of file diff --git a/lib/StdInc.h b/lib/StdInc.h index 18659d5ee..76e828312 100644 --- a/lib/StdInc.h +++ b/lib/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 5add0d34f..f83924410 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -13,7 +13,7 @@ #include "CSpellHandler.h" #include "CGeneralTextHandler.h" #include "IGameEventsReceiver.h" -#include "StopWatch.h" +#include "CStopWatch.h" /* * VCMI_Lib.cpp, part of VCMI engine @@ -161,7 +161,7 @@ DLL_LINKAGE void loadToIt(si32 &dest, const std::string &src, int &iter, int mod void LibClasses::init() { - StopWatch pomtime; + CStopWatch pomtime; generaltexth = new CGeneralTextHandler; generaltexth->load(); @@ -234,7 +234,7 @@ void LibClasses::makeNull() LibClasses::LibClasses() { //load .lod archives - StopWatch pomtime; + CStopWatch pomtime; spriteh = new CLodHandler(); spriteh->init(GameConstants::DATA_DIR + "/Data/H3sprite.lod", GameConstants::DATA_DIR + "/Sprites"); bitmaph = new CLodHandler; diff --git a/lib/VCMI_lib.cbp b/lib/VCMI_lib.cbp deleted file mode 100644 index f59a312f5..000000000 --- a/lib/VCMI_lib.cbp +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - diff --git a/lib/VCMI_lib.vcxproj b/lib/VCMI_lib.vcxproj index e7c3cd122..c820c0580 100644 --- a/lib/VCMI_lib.vcxproj +++ b/lib/VCMI_lib.vcxproj @@ -241,7 +241,7 @@ - + VCMI_DLL;%(PreprocessorDefinitions) Create @@ -250,6 +250,7 @@ + @@ -276,6 +277,7 @@ + @@ -289,10 +291,9 @@ - + - diff --git a/lib/map.cpp b/lib/map.cpp index 92f65b962..bfc0fd6e0 100644 --- a/lib/map.cpp +++ b/lib/map.cpp @@ -13,7 +13,7 @@ #include "../lib/JsonNode.h" #include "vcmi_endian.h" #include "GameConstants.h" -#include "StopWatch.h" +#include "CStopWatch.h" /* * map.cpp, part of VCMI engine @@ -406,7 +406,7 @@ void Mapa::initFromBytes(const ui8 * bufor, size_t size) int i=0; initFromMemory(bufor,i); - StopWatch th; + CStopWatch th; th.getDiff(); readHeader(bufor, i); tlog0<<"\tReading header: "< Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf - - -# clean -.clean-impl: .clean-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf - - -# clobber -.clobber-impl: .clobber-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ - done - -# all -.all-impl: .all-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf; \ - done - -# dependency checking support -.depcheck-impl: - @echo "# This code depends on make tool being used" >.dep.inc - @if [ -n "${MAKE_VERSION}" ]; then \ - echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ - echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ - echo "include \$${DEPFILES}" >>.dep.inc; \ - echo "endif" >>.dep.inc; \ - else \ - echo ".KEEP_STATE:" >>.dep.inc; \ - echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ - fi - -# configuration validation -.validate-impl: - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - echo ""; \ - echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ - echo "See 'make help' for details."; \ - echo "Current directory: " `pwd`; \ - echo ""; \ - fi - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - exit 1; \ - fi - - -# help -.help-impl: .help-pre - @echo "This makefile supports the following configurations:" - @echo " ${ALLCONFS}" - @echo "" - @echo "and the following targets:" - @echo " build (default target)" - @echo " clean" - @echo " clobber" - @echo " all" - @echo " help" - @echo "" - @echo "Makefile Usage:" - @echo " make [CONF=] [SUB=no] build" - @echo " make [CONF=] [SUB=no] clean" - @echo " make [SUB=no] clobber" - @echo " make [SUB=no] all" - @echo " make help" - @echo "" - @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," - @echo " also clean subprojects." - @echo "Target 'clobber' will remove all built files from all configurations and," - @echo " unless 'SUB=no', also from subprojects." - @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'help' prints this message." - @echo "" - diff --git a/lib/vcmi_lib/nbproject/Package-Debug.bash b/lib/vcmi_lib/nbproject/Package-Debug.bash deleted file mode 100644 index 4e56f25ce..000000000 --- a/lib/vcmi_lib/nbproject/Package-Debug.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Debug/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Debug/${PLATFORM}/libvcmi_lib.so -OUTPUT_BASENAME=libvcmi_lib.so -PACKAGE_TOP_DIR=libvcmilib.so/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Debug/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/libvcmilib.so/lib -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Debug/${PLATFORM}/package/libvcmilib.so.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Debug/${PLATFORM}/package/libvcmilib.so.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/lib/vcmi_lib/nbproject/Package-Release.bash b/lib/vcmi_lib/nbproject/Package-Release.bash deleted file mode 100644 index ca8da21d4..000000000 --- a/lib/vcmi_lib/nbproject/Package-Release.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Release/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Release/${PLATFORM}/libvcmi_lib.so -OUTPUT_BASENAME=libvcmi_lib.so -PACKAGE_TOP_DIR=libvcmilib.so/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Release/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/libvcmilib.so/lib -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Release/${PLATFORM}/package/libvcmilib.so.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Release/${PLATFORM}/package/libvcmilib.so.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/lib/vcmi_lib/nbproject/configurations.xml b/lib/vcmi_lib/nbproject/configurations.xml deleted file mode 100644 index ab02cda1a..000000000 --- a/lib/vcmi_lib/nbproject/configurations.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - ../BattleAction.h - ../../hch/CArtHandler.h - ../../hch/CBuildingHandler.h - ../../CConsoleHandler.h - ../../hch/CCreatureHandler.h - ../../hch/CDefObjInfoHandler.h - ../../CGameInfo.h - ../../CGameState.h - ../../hch/CGeneralTextHandler.h - ../../hch/CHeroHandler.h - ../../hch/CLodHandler.h - ../../hch/CObjectHandler.h - ../CondSh.h - ../Connection.h - ../../hch/CSpellHandler.h - ../../hch/CTownHandler.h - ../Interprocess.h - ../../map.h - ../NetPacks.h - ../VCMI_Lib.h - - - - - ../../hch/CArtHandler.cpp - ../../hch/CBuildingHandler.cpp - ../../CConsoleHandler.cpp - ../../hch/CCreatureHandler.cpp - ../../hch/CDefObjInfoHandler.cpp - ../../CGameInfo.cpp - ../../CGameState.cpp - ../../hch/CGeneralTextHandler.cpp - ../../hch/CHeroHandler.cpp - ../../hch/CLodHandler.cpp - ../../hch/CObjectHandler.cpp - ../Connection.cpp - ../../hch/CSpellHandler.cpp - ../../hch/CTownHandler.cpp - ../../map.cpp - ../VCMI_Lib.cpp - - - Makefile-nb - - - Makefile-nb - - - - localhost - GNU|GNU - 2 - - - - - ../../hch - ../.. - ../../../../boost/include/boost-1_37 - /usr/include/SDL - ../../../../boost/include/boost-1_37/boost - - - - dist/Debug/${PLATFORM}/libvcmi_lib.so - - ../../../../boost/lib - - - - - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - - - localhost - GNU|GNU - 2 - - - - 5 - - - 5 - - - 5 - - - - - - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - 3 - - - 3 - - - 1 - - - 3 - - - - diff --git a/lib/vcmi_lib/nbproject/project.properties b/lib/vcmi_lib/nbproject/project.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/vcmi_lib/nbproject/project.xml b/lib/vcmi_lib/nbproject/project.xml deleted file mode 100644 index 2b0f72060..000000000 --- a/lib/vcmi_lib/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - vcmi_lib - 0 - - cpp - h - UTF-8 - - - - diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 45e69cbbb..1b0c53434 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -682,7 +682,7 @@ void CGameHandler::handleConnection(std::set players, CConnection &c) tlog1 << "Ended handling connection\n"; } -int CGameHandler::moveStack(int stack, SHexField dest) +int CGameHandler::moveStack(int stack, SBattleHex dest) { int ret = 0; @@ -699,7 +699,7 @@ int CGameHandler::moveStack(int stack, SHexField dest) //initing necessary tables bool accessibility[GameConstants::BFIELD_SIZE]; - std::vector accessible = gs->curB->getAccessibility(curStack, false); + std::vector accessible = gs->curB->getAccessibility(curStack, false); for(int b=0; battackerOwned) { if(accessibility[dest+1]) - dest += SHexField::RIGHT; + dest += SBattleHex::RIGHT; } else { if(accessibility[dest-1]) - dest += SHexField::LEFT; + dest += SBattleHex::LEFT; } } @@ -728,7 +728,7 @@ int CGameHandler::moveStack(int stack, SHexField dest) return 0; bool accessibilityWithOccupyable[GameConstants::BFIELD_SIZE]; - std::vector accOc = gs->curB->getAccessibility(curStack, true); + std::vector accOc = gs->curB->getAccessibility(curStack, true); for(int b=0; b curStack->creature->speed && !(stackAtEnd && dists[dest] == curStack->creature->speed+1)) //we can attack a stack if we can go to adjacent hex // return false; - std::pair< std::vector, int > path = gs->curB->getPath(curStack->position, dest, accessibilityWithOccupyable, curStack->hasBonusOfType(Bonus::FLYING), curStack->doubleWide(), curStack->attackerOwned); + std::pair< std::vector, int > path = gs->curB->getPath(curStack->position, dest, accessibilityWithOccupyable, curStack->hasBonusOfType(Bonus::FLYING), curStack->doubleWide(), curStack->attackerOwned); ret = path.second; @@ -754,7 +754,7 @@ int CGameHandler::moveStack(int stack, SHexField dest) //inform clients about move BattleStackMoved sm; sm.stack = curStack->ID; - std::vector tiles; + std::vector tiles; tiles.push_back(path.first[0]); sm.tilesToMove = tiles; sm.distance = path.second; @@ -765,7 +765,7 @@ int CGameHandler::moveStack(int stack, SHexField dest) else //for non-flying creatures { // send one package with the creature path information - std::vector tiles; + std::vector tiles; int tilesToMove = std::max((int)(path.first.size() - creSpeed), 0); for(int v=path.first.size()-1; v>=tilesToMove; --v) { @@ -3330,7 +3330,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) CStack * stack = gs->curB->getStack(ba.stackNumber); int spellID = ba.additionalInfo; - SHexField destination(ba.destinationTile); + SBattleHex destination(ba.destinationTile); int spellLvl = 0; Bonus * bonus = stack->getBonus(Selector::typeSubtype(Bonus::SPELLCASTER, spellID)); @@ -3486,7 +3486,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) } } -void CGameHandler::handleSpellCasting( int spellID, int spellLvl, SHexField destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack) +void CGameHandler::handleSpellCasting( int spellID, int spellLvl, SBattleHex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack) { const CSpell *spell = VLC->spellh->spells[spellID]; @@ -3737,7 +3737,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, SHexField dest BattleStackMoved bsm; bsm.distance = -1; bsm.stack = gs->curB->activeStack; - std::vector tiles; + std::vector tiles; tiles.push_back(destination); bsm.tilesToMove = tiles; bsm.teleporting = true; @@ -3826,7 +3826,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, SHexField dest ObstaclesRemoved obr; for(int g=0; gcurB->obstacles.size(); ++g) { - std::vector blockedHexes = VLC->heroh->obstacles[gs->curB->obstacles[g].ID].getBlocked(gs->curB->obstacles[g].pos); + std::vector blockedHexes = VLC->heroh->obstacles[gs->curB->obstacles[g].ID].getBlocked(gs->curB->obstacles[g].pos); if(vstd::contains(blockedHexes, destination)) //this obstacle covers given hex { diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 724f910da..1a635dd5e 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -101,7 +101,7 @@ public: bool isAllowedExchange(int id1, int id2); bool isAllowedArrangePack(const ArrangeStacks *pack); void giveSpells(const CGTownInstance *t, const CGHeroInstance *h); - int moveStack(int stack, SHexField dest); //returned value - travelled distance + int moveStack(int stack, SBattleHex dest); //returned value - travelled distance void startBattle(const CArmedInstance *armies[2], int3 tile, const CGHeroInstance *heroes[2], bool creatureBank, boost::function cb, const CGTownInstance *town = NULL); //use hero=NULL for no hero void runBattle(); void checkLossVictory(ui8 player); @@ -192,7 +192,7 @@ public: void playerMessage( ui8 player, const std::string &message); bool makeBattleAction(BattleAction &ba); - void handleSpellCasting(int spellID, int spellLvl, SHexField destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack); + void handleSpellCasting(int spellID, int spellLvl, SBattleHex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack); bool makeCustomAction(BattleAction &ba); void stackTurnTrigger(const CStack * stack); bool queryReply( ui32 qid, ui32 answer, ui8 player ); diff --git a/server/StdInc.h b/server/StdInc.h index 18659d5ee..76e828312 100644 --- a/server/StdInc.h +++ b/server/StdInc.h @@ -1,325 +1,7 @@ #pragma once -// Standard include file -// Should be treated as a precompiled header file in the compiler settings -// We generate a .PCH file for every project due to simplicity and some annoying bugs in VisualStudio -// This file shouldn't be changed, except if there is a important header file which is missing. +#include "../Global.h" -/* - * StdInc.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ +// This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#ifdef _WIN32 -#include -#else -#include "../tchar_amigaos4.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -//filesystem version 3 causes problems (and it's default as of boost 1.46) -#define BOOST_FILESYSTEM_VERSION 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -#include -#endif - -// Integral data types -typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) -typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) -typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) -typedef boost::int64_t si64; //signed int 64 bits (8 bytes) -typedef boost::int32_t si32; //signed int 32 bits (4 bytes) -typedef boost::int16_t si16; //signed int 16 bits (2 bytes) -typedef boost::int8_t si8; //signed int 8 bits (1 byte) - -// Import + Export macro declarations -#ifdef _WIN32 -#define DLL_EXPORT __declspec(dllexport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility("default"))) -#else -#define DLL_EXPORT -#endif -#endif - -#ifdef _WIN32 -#define DLL_IMPORT __declspec(dllimport) -#else -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DLL_IMPORT __attribute__ ((visibility("default"))) -#else -#define DLL_IMPORT -#endif -#endif - -#ifdef VCMI_DLL -#define DLL_LINKAGE DLL_EXPORT -#else -#define DLL_LINKAGE DLL_IMPORT -#endif - - -//a normal std::map with a const operator[] for sanity -template -class bmap : public std::map -{ -public: - const ValT & operator[](KeyT key) const - { - return find(key)->second; - } - ValT & operator[](KeyT key) - { - return static_cast &>(*this)[key]; - } - template void serialize(Handler &h, const int version) - { - h & static_cast &>(*this); - } -}; - -namespace vstd -{ - //returns true if container c contains item i - template - bool contains(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i) != c.end(); - } - - //returns true if map c contains item i - template - bool contains(const std::map & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if bmap c contains item i - template - bool contains(const bmap & c, const Item2 &i) - { - return c.find(i)!=c.end(); - } - - //returns true if unordered set c contains item i - template - bool contains(const boost::unordered_set & c, const Item &i) - { - return c.find(i)!=c.end(); - } - - //returns position of first element in vector c equal to s, if there is no such element, -1 is returned - template - int find_pos(const std::vector & c, const T2 &s) - { - for(size_t i=0; i < c.size(); ++i) - if(c[i] == s) - return i; - return -1; - } - - //Func(T1,T2) must say if these elements matches - template - int find_pos(const std::vector & c, const T2 &s, const Func &f) - { - for(size_t i=0; i < c.size(); ++i) - if(f(c[i],s)) - return i; - return -1; - } - - //returns iterator to the given element if present in container, end() if not - template - typename Container::iterator find(Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //returns const iterator to the given element if present in container, end() if not - template - typename Container::const_iterator find(const Container & c, const Item &i) - { - return std::find(c.begin(),c.end(),i); - } - - //removes element i from container c, returns false if c does not contain i - template - typename Container::size_type operator-=(Container &c, const Item &i) - { - typename Container::iterator itr = find(c,i); - if(itr == c.end()) - return false; - c.erase(itr); - return true; - } - - //assigns greater of (a, b) to a and returns maximum of (a, b) - template - t1 &amax(t1 &a, const t2 &b) - { - if(a >= b) - return a; - else - { - a = b; - return a; - } - } - - //assigns smaller of (a, b) to a and returns minimum of (a, b) - template - t1 &amin(t1 &a, const t2 &b) - { - if(a <= b) - return a; - else - { - a = b; - return a; - } - } - - //makes a to fit the range - template - t1 &abetween(t1 &a, const t2 &b, const t3 &c) - { - amax(a,b); - amin(a,c); - return a; - } - - //checks if a is between b and c - template - bool isbetween(const t1 &a, const t2 &b, const t3 &c) - { - return a > b && a < c; - } - - //checks if a is within b and c - template - bool iswithin(const t1 &a, const t2 &b, const t3 &c) - { - return a >= b && a <= c; - } - - template - struct assigner - { - public: - t1 &op1; - t2 op2; - assigner(t1 &a1, const t2 & a2) - :op1(a1), op2(a2) - {} - void operator()() - { - op1 = op2; - } - }; - - // Assigns value a2 to a1. The point of time of the real operation can be controlled - // with the () operator. - template - assigner assigno(t1 &a1, const t2 &a2) - { - return assigner(a1,a2); - } - - //deleted pointer and sets it to NULL - template - void clear_pointer(T* &ptr) - { - delete ptr; - ptr = NULL; - } -} -using vstd::operator-=; - -// can be used for counting arrays -template char (&_ArrayCountObj(const T (&)[N]))[N]; -#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) - -//for explicit overrides -#ifdef _MSC_VER -#define OVERRIDE override -#else -#define OVERRIDE //is there any working counterpart? -#endif - -//XXX pls dont - 'debug macros' are usually more trouble than it's worth -#define HANDLE_EXCEPTION \ - catch (const std::exception& e) { \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::exception * e) \ -{ \ - tlog1 << e->what()<< std::endl; \ - throw; \ -} \ - catch (const std::string& e) { \ - tlog1 << e << std::endl; \ - throw; \ -} - -#define HANDLE_EXCEPTIONC(COMMAND) \ - catch (const std::exception& e) { \ - COMMAND; \ - tlog1 << e.what() << std::endl; \ - throw; \ -} \ - catch (const std::string &e) \ -{ \ - COMMAND; \ - tlog1 << e << std::endl; \ - throw; \ -} - - -#include "../lib/CLogger.h" +// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file diff --git a/server/VCMI_server.cbp b/server/VCMI_server.cbp deleted file mode 100644 index 402648ec9..000000000 --- a/server/VCMI_server.cbp +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - diff --git a/server/VCMI_server.vcxproj b/server/VCMI_server.vcxproj index 1a5a4e52a..e2a1b84ce 100644 --- a/server/VCMI_server.vcxproj +++ b/server/VCMI_server.vcxproj @@ -204,6 +204,7 @@ + diff --git a/server/vcmi_server/Makefile b/server/vcmi_server/Makefile deleted file mode 100644 index 30bc67837..000000000 --- a/server/vcmi_server/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# -# NOCDDL - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: .build-impl -# Add your post 'build' code here... - - -# clean -clean: .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: .clean-impl -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: .clobber-impl -# Add your post 'clobber' code here... - - -# all -all: .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: .all-impl -# Add your post 'all' code here... - - -# help -help: .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: .help-impl -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/server/vcmi_server/nbproject/Makefile-Debug.mk b/server/vcmi_server/nbproject/Makefile-Debug.mk deleted file mode 100644 index b386e2aae..000000000 --- a/server/vcmi_server/nbproject/Makefile-Debug.mk +++ /dev/null @@ -1,81 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran - -# Macros -PLATFORM=GNU-Linux-x86 - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=build/Debug/${PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS= -CXXFLAGS= - -# Fortran Compiler Flags -FFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS=-L../../../../boost/lib -Wl,-rpath ../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86 -L../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86 -lvcmi_lib - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - ${MAKE} -f nbproject/Makefile-Debug.mk dist/Debug/${PLATFORM}/vcmi_server - -dist/Debug/${PLATFORM}/vcmi_server: ../../lib/vcmi_lib/dist/Debug/GNU-Linux-x86/libvcmi_lib.so - -dist/Debug/${PLATFORM}/vcmi_server: ${OBJECTFILES} - ${MKDIR} -p dist/Debug/${PLATFORM} - ${LINK.cc} -lboost_system-mt -lboost_thread-mt -lboost_filesystem-mt -lz -o dist/Debug/${PLATFORM}/vcmi_server ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o: ../CVCMIServer.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/.. - $(COMPILE.cc) -g -I../../../../boost/include/boost-1_37 -I../.. -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o ../CVCMIServer.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o: ../../hch/CLodHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch - $(COMPILE.cc) -g -I../../../../boost/include/boost-1_37 -I../.. -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o ../../hch/CLodHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o: ../CGameHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/.. - $(COMPILE.cc) -g -I../../../../boost/include/boost-1_37 -I../.. -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o ../CGameHandler.cpp - -# Subprojects -.build-subprojects: - cd ../../lib/vcmi_lib && ${MAKE} -f Makefile-nb CONF=Debug - -# Clean Targets -.clean-conf: ${CLEAN_SUBPROJECTS} - ${RM} -r build/Debug - ${RM} dist/Debug/${PLATFORM}/vcmi_server - -# Subprojects -.clean-subprojects: - cd ../../lib/vcmi_lib && ${MAKE} -f Makefile-nb CONF=Debug clean diff --git a/server/vcmi_server/nbproject/Makefile-Release.mk b/server/vcmi_server/nbproject/Makefile-Release.mk deleted file mode 100644 index 36953cf2e..000000000 --- a/server/vcmi_server/nbproject/Makefile-Release.mk +++ /dev/null @@ -1,77 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran - -# Macros -PLATFORM=GNU-Linux-x86 - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=build/Release/${PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o \ - ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS= -CXXFLAGS= - -# Fortran Compiler Flags -FFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS= - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - ${MAKE} -f nbproject/Makefile-Release.mk dist/Release/${PLATFORM}/vcmi_server - -dist/Release/${PLATFORM}/vcmi_server: ${OBJECTFILES} - ${MKDIR} -p dist/Release/${PLATFORM} - ${LINK.cc} -o dist/Release/${PLATFORM}/vcmi_server ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o: ../CVCMIServer.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CVCMIServer.o ../CVCMIServer.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o: ../../hch/CLodHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../../hch/CLodHandler.o ../../hch/CLodHandler.cpp - -${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o: ../CGameHandler.cpp - ${MKDIR} -p ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/.. - $(COMPILE.cc) -O2 -o ${OBJECTDIR}/_ext/home/t0/vcmi/trunk/server/vcmi_server/../CGameHandler.o ../CGameHandler.cpp - -# Subprojects -.build-subprojects: - -# Clean Targets -.clean-conf: - ${RM} -r build/Release - ${RM} dist/Release/${PLATFORM}/vcmi_server - -# Subprojects -.clean-subprojects: diff --git a/server/vcmi_server/nbproject/Makefile-impl.mk b/server/vcmi_server/nbproject/Makefile-impl.mk deleted file mode 100644 index debd44e0d..000000000 --- a/server/vcmi_server/nbproject/Makefile-impl.mk +++ /dev/null @@ -1,123 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a pre- and a post- target defined where you can add customization code. -# -# This makefile implements macros and targets common to all configurations. -# -# NOCDDL - - -# Building and Cleaning subprojects are done by default, but can be controlled with the SUB -# macro. If SUB=no, subprojects will not be built or cleaned. The following macro -# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf -# and .clean-reqprojects-conf unless SUB has the value 'no' -SUB_no=NO -SUBPROJECTS=${SUB_${SUB}} -BUILD_SUBPROJECTS_=.build-subprojects -BUILD_SUBPROJECTS_NO= -BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} -CLEAN_SUBPROJECTS_=.clean-subprojects -CLEAN_SUBPROJECTS_NO= -CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} - - -# Project Name -PROJECTNAME=vcmi_server - -# Active Configuration -DEFAULTCONF=Debug -CONF=${DEFAULTCONF} - -# All Configurations -ALLCONFS=Debug Release - - -# build -.build-impl: .build-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf - - -# clean -.clean-impl: .clean-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf - - -# clobber -.clobber-impl: .clobber-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ - done - -# all -.all-impl: .all-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - ${MAKE} -f nbproject/Makefile-$${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf; \ - done - -# dependency checking support -.depcheck-impl: - @echo "# This code depends on make tool being used" >.dep.inc - @if [ -n "${MAKE_VERSION}" ]; then \ - echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ - echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ - echo "include \$${DEPFILES}" >>.dep.inc; \ - echo "endif" >>.dep.inc; \ - else \ - echo ".KEEP_STATE:" >>.dep.inc; \ - echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ - fi - -# configuration validation -.validate-impl: - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - echo ""; \ - echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ - echo "See 'make help' for details."; \ - echo "Current directory: " `pwd`; \ - echo ""; \ - fi - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - exit 1; \ - fi - - -# help -.help-impl: .help-pre - @echo "This makefile supports the following configurations:" - @echo " ${ALLCONFS}" - @echo "" - @echo "and the following targets:" - @echo " build (default target)" - @echo " clean" - @echo " clobber" - @echo " all" - @echo " help" - @echo "" - @echo "Makefile Usage:" - @echo " make [CONF=] [SUB=no] build" - @echo " make [CONF=] [SUB=no] clean" - @echo " make [SUB=no] clobber" - @echo " make [SUB=no] all" - @echo " make help" - @echo "" - @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," - @echo " also clean subprojects." - @echo "Target 'clobber' will remove all built files from all configurations and," - @echo " unless 'SUB=no', also from subprojects." - @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'help' prints this message." - @echo "" - diff --git a/server/vcmi_server/nbproject/Package-Debug.bash b/server/vcmi_server/nbproject/Package-Debug.bash deleted file mode 100644 index e66fba47e..000000000 --- a/server/vcmi_server/nbproject/Package-Debug.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Debug/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Debug/${PLATFORM}/vcmi_server -OUTPUT_BASENAME=vcmi_server -PACKAGE_TOP_DIR=vcmiserver/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Debug/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/vcmiserver/bin -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Debug/${PLATFORM}/package/vcmiserver.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Debug/${PLATFORM}/package/vcmiserver.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/server/vcmi_server/nbproject/Package-Release.bash b/server/vcmi_server/nbproject/Package-Release.bash deleted file mode 100644 index 38729c9e3..000000000 --- a/server/vcmi_server/nbproject/Package-Release.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -PLATFORM=GNU-Linux-x86 -TMPDIR=build/Release/${PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=dist/Release/${PLATFORM}/vcmi_server -OUTPUT_BASENAME=vcmi_server -PACKAGE_TOP_DIR=vcmiserver/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p dist/Release/${PLATFORM}/package -rm -rf ${TMPDIR} -mkdir -p ${TMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory ${TMPDIR}/vcmiserver/bin -copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f dist/Release/${PLATFORM}/package/vcmiserver.tar -cd ${TMPDIR} -tar -vcf ../../../../dist/Release/${PLATFORM}/package/vcmiserver.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${TMPDIR} diff --git a/server/vcmi_server/nbproject/configurations.xml b/server/vcmi_server/nbproject/configurations.xml deleted file mode 100644 index 459da84a6..000000000 --- a/server/vcmi_server/nbproject/configurations.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - ../CGameHandler.h - ../../hch/CLodHandler.h - ../CVCMIServer.h - - - - - ../CGameHandler.cpp - ../../hch/CLodHandler.cpp - ../CVCMIServer.cpp - - - Makefile - - - - .. - - Makefile - - - - localhost - GNU|GNU - 2 - - - - - ../../../../boost/include/boost-1_37 - ../.. - - - - - ../../../../boost/lib - - - - - - - - -lboost_system-mt -lboost_thread-mt -lboost_filesystem-mt -lz - - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - - - localhost - GNU|GNU - 2 - - - - 5 - - - 5 - - - 5 - - - - - - - - 1 - - - 3 - - - 1 - - - 3 - - - 1 - - - 3 - - - - diff --git a/server/vcmi_server/nbproject/project.properties b/server/vcmi_server/nbproject/project.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/server/vcmi_server/nbproject/project.xml b/server/vcmi_server/nbproject/project.xml deleted file mode 100644 index c78e89cf9..000000000 --- a/server/vcmi_server/nbproject/project.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - vcmi_server - 0 - - cpp - h - UTF-8 - - ../../lib/vcmi_lib - - - - diff --git a/vcmi.workspace b/vcmi.workspace deleted file mode 100644 index 7f1ec3eca..000000000 --- a/vcmi.workspace +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - -