mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
* 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/...
This commit is contained in:
parent
6ea88593db
commit
2f5d6f2684
@ -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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "../../tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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.
|
@ -526,7 +526,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SHexField> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
|
||||
std::vector<SBattleHex> 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<ui16>(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<SHexField>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
for (std::vector<SBattleHex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
{
|
||||
if (*it == dest_tile)
|
||||
{
|
||||
|
@ -1311,7 +1311,7 @@ void CGeniusAI::battleNewRound(int round)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<SHexField> dest, int distance)
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<SBattleHex> dest, int distance)
|
||||
{
|
||||
std::string message("\t\t\tCGeniusAI::battleStackMoved ID(");
|
||||
message += boost::lexical_cast<std::string>(ID);
|
||||
@ -1345,7 +1345,7 @@ void CGeniusAI::battleSpellCast(const BattleSpellCast *sc)
|
||||
*
|
||||
*/
|
||||
// void CGeniusAI::battleStackMoved(int ID,
|
||||
// SHexField dest,
|
||||
// SBattleHex dest,
|
||||
// bool startMoving,
|
||||
// bool endMoving)
|
||||
// {
|
||||
|
@ -201,7 +201,7 @@ public:
|
||||
virtual void battleStacksAttacked(const std::set<BattleStackAttacked> & 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<SHexField> dest, int distance);
|
||||
virtual void battleStackMoved(int ID, std::vector<SBattleHex> 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<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
||||
|
@ -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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "../../tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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.
|
@ -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 // <composition>
|
||||
relation 129673 *---
|
||||
a role_name "" private
|
||||
classrelation_ref 130057 // <composition>
|
||||
b role_name "" private
|
||||
classrelation_ref 130185 // <composition>
|
||||
end
|
||||
|
||||
classrelation 130441 // <composition>
|
||||
relation_ref 129801 // <composition>
|
||||
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 // <composition>
|
||||
relation 129801 *---
|
||||
a role_name "" private
|
||||
classrelation_ref 130313 // <composition>
|
||||
b role_name "" private
|
||||
classrelation_ref 130441 // <composition>
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -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 // <realization>
|
||||
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 // <composition>
|
||||
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 // <composition>
|
||||
from ref 129033 z 2001 to ref 128905
|
||||
no_role_a no_role_b
|
||||
no_multiplicity_a no_multiplicity_b
|
||||
end
|
||||
end
|
@ -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 // <composition>
|
||||
relation 129545 *---
|
||||
a role_name "" private
|
||||
classrelation_ref 129801 // <composition>
|
||||
b role_name "" private
|
||||
classrelation_ref 129929 // <composition>
|
||||
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
|
@ -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 // <realization>
|
||||
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 // <composition>
|
||||
from ref 128393 z 2001 to ref 128009
|
||||
no_role_a no_role_b
|
||||
no_multiplicity_a no_multiplicity_b
|
||||
end
|
||||
end
|
@ -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 // <realization>
|
||||
relation 129161 -_-|>
|
||||
a public
|
||||
classrelation_ref 129161 // <realization>
|
||||
b parent class_ref 129289 // CGlobalAI
|
||||
end
|
||||
|
||||
classrelation 129929 // <composition>
|
||||
relation_ref 129545 // <composition>
|
||||
end
|
||||
|
||||
classrelation 130185 // <composition>
|
||||
relation_ref 129673 // <composition>
|
||||
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
|
@ -1,3 +0,0 @@
|
||||
format 66
|
||||
|
||||
end
|
@ -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
|
@ -1,13 +0,0 @@
|
||||
// "a type" "needed cpp_includes"
|
||||
"vector" "#include <vector>
|
||||
using namespace std;"
|
||||
|
||||
"list" "#include <list>
|
||||
using namespace std;"
|
||||
|
||||
"map" "#include <map>
|
||||
using namespace std;"
|
||||
|
||||
"string" "#include <string>
|
||||
using namespace std;"
|
||||
|
@ -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
|
||||
${comment}
|
||||
${definition}
|
||||
?>
|
||||
"
|
||||
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
|
@ -1 +0,0 @@
|
||||
// "a type" "needed idl_includes"
|
@ -1 +0,0 @@
|
||||
// "a type" "needed java_imports"
|
@ -1 +0,0 @@
|
||||
// "a type" "needed python_imports"
|
@ -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
|
@ -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
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="AI" />
|
||||
<Option platforms="Windows;" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="bin\Debug\GeniusAI" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="bin\Debug\" />
|
||||
<Option object_output="obj\Debug\" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-O0" />
|
||||
<Add option="-DWIN32" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_USRDLL" />
|
||||
<Add option="-DGENIUS_EXPORTS" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="..\..\lib\bin\Debug\libVCMI_lib.a" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="bin\Release\GeniusAI" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="bin\Release\" />
|
||||
<Option object_output="obj\Release\" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-Os" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-O1" />
|
||||
<Add option="-O" />
|
||||
<Add option="-W" />
|
||||
<Add option="-DWIN32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_USRDLL" />
|
||||
<Add option="-DGENIUS_EXPORTS" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add library="..\..\lib\bin\Release\libVCMI_lib.a" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-D_WIN32" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add directory="$(#boost.lib)" />
|
||||
</Linker>
|
||||
<Unit filename="CGeniusAI.cpp" />
|
||||
<Unit filename="CGeniusAI.h" />
|
||||
<Unit filename="DLLMain.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
@ -231,6 +231,7 @@
|
||||
<ClInclude Include="Common.h" />
|
||||
<ClInclude Include="neuralNetwork.h" />
|
||||
<ClInclude Include="StdInc.h" />
|
||||
<ClInclude Include="..\..\Global.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\VCMI_lib.vcxproj">
|
||||
|
@ -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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "../../tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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.
|
@ -39,7 +39,7 @@ struct EnemyInfo
|
||||
{
|
||||
const CStack * s;
|
||||
int adi, adr;
|
||||
std::vector<SHexField> attackFrom; //for melee fight
|
||||
std::vector<SBattleHex> 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<int> & dists, SHexField *chosenHex = NULL)
|
||||
int distToNearestNeighbour(SBattleHex hex, const std::vector<int> & 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::vector<in
|
||||
return distToNearestNeighbour(ei1.s->position, 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<SHexField> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<SBattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<int> dists = cb->battleGetDistances(stack);
|
||||
std::vector<EnemyInfo> 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<SHexField> dest, int distance)
|
||||
void CStupidAI::battleStackMoved(const CStack * stack, std::vector<SBattleHex> 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<int> 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<SHexField> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<SBattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
|
||||
if(!avHexes.size())
|
||||
{
|
||||
|
@ -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<SHexField> dest, int distance) OVERRIDE;
|
||||
void battleStackMoved(const CStack * stack, std::vector<SBattleHex> 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 );
|
||||
};
|
||||
|
||||
|
@ -166,6 +166,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdInc.h" />
|
||||
<ClInclude Include="StupidAI.h" />
|
||||
<ClInclude Include="..\..\Global.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
330
Global.h
Normal file
330
Global.h
Normal file
@ -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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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"
|
@ -129,6 +129,7 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Global.h" />
|
||||
<ClInclude Include="ERMInterpreter.h" />
|
||||
<ClInclude Include="ERMParser.h" />
|
||||
<ClInclude Include="ERMScriptModule.h" />
|
||||
|
@ -1,24 +1,11 @@
|
||||
#include "StdInc.h"
|
||||
#include "ERMParser.h"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
//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 <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
#include <boost/spirit/include/phoenix_object.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
|
||||
namespace spirit = boost::spirit;
|
||||
namespace qi = boost::spirit::qi;
|
||||
namespace ascii = spirit::ascii;
|
||||
namespace phoenix = boost::phoenix;
|
||||
|
||||
/*
|
||||
* ERMParser.cpp, part of VCMI engine
|
||||
*
|
||||
|
@ -1,10 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
|
||||
/*
|
||||
* ERMParser.h, part of VCMI engine
|
||||
*
|
||||
|
@ -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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "../../tchar_amigaos4.h"
|
||||
#endif
|
||||
// Here you can add specific libraries and macros which are specific to this project.
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
#include <boost/spirit/include/phoenix_object.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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;
|
||||
|
@ -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<double>(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<double>(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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GUIBase.h"
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../CSpellWindow.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../CConfigHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
void CBattleHero::show(SDL_Surface *to)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GUIBase.h"
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CDefHandler;
|
||||
|
@ -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<SHexField> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
|
||||
BOOST_FOREACH(SHexField hex, set)
|
||||
std::set<SBattleHex> 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<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
|
||||
std::multimap<SHexField, int> hexToObstacle;
|
||||
std::multimap<SBattleHex, int> 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<const CStack *> *aliveStacks,
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showObstacles(std::multimap<SHexField, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
|
||||
void CBattleInterface::showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
|
||||
{
|
||||
std::pair<std::multimap<SHexField, int>::const_iterator, std::multimap<SHexField, int>::const_iterator> obstRange =
|
||||
std::pair<std::multimap<SBattleHex, int>::const_iterator, std::multimap<SBattleHex, int>::const_iterator> obstRange =
|
||||
hexToObstacle->equal_range(hex);
|
||||
|
||||
for(std::multimap<SHexField, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
|
||||
for(std::multimap<SBattleHex, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
|
||||
{
|
||||
CObstacleInstance & curOb = obstacles[it->second];
|
||||
std::pair<si16, si16> 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<SHexField> destHex, int distance)
|
||||
void CBattleInterface::stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance)
|
||||
{
|
||||
addNewAnim(new CMovementAnimation(this, stack, destHex, distance));
|
||||
waitForAnims();
|
||||
@ -1605,7 +1605,7 @@ void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> 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<occupyableHexes.size(); ++b)
|
||||
{
|
||||
if(SHexField::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
|
||||
if(SBattleHex::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBattleInterface::blockedByObstacle(SHexField hex) const
|
||||
bool CBattleInterface::blockedByObstacle(SBattleHex hex) const
|
||||
{
|
||||
std::vector<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
|
||||
std::set<SHexField> coveredHexes;
|
||||
std::set<SBattleHex> coveredHexes;
|
||||
for(size_t b = 0; b < obstacles.size(); ++b)
|
||||
{
|
||||
std::vector<SHexField> blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
|
||||
std::vector<SBattleHex> 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<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<SBattleHex> 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<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<SBattleHex> 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<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<SBattleHex> 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<SHexField> hexesToShade = occupyableHexes;
|
||||
std::vector<SBattleHex> 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)
|
||||
{
|
||||
|
@ -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<SHexField> occupyableHexes, //hexes available for active stack
|
||||
std::vector<SBattleHex> 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<int, int> 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<const CStack *> *aliveStacks, int hex, std::vector<const CStack *> *flyingStacks, SDL_Surface *to); // loops through all stacks at a given hex position
|
||||
void showPieceOfWall(SDL_Surface * to, int hex, const std::vector<const CStack*> & stacks); //helper function for show
|
||||
void showObstacles(std::multimap<SHexField, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
|
||||
void showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &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<SProjectileInfo> 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<SBattleEffect> 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<BattleAction *> *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<SHexField> destHex, int distance); //stack with id number moved to destHex
|
||||
void stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance); //stack with id number moved to destHex
|
||||
void waitForAnims();
|
||||
void stacksAreAttacked(std::vector<SStackAttackedInfo> 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;
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GUIBase.h"
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CPicture;
|
||||
|
@ -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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GUIBase.h"
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class AdventureMapButton;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
};
|
@ -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)
|
@ -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();
|
||||
};
|
@ -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
|
@ -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
|
@ -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"
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
@ -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);
|
||||
};
|
@ -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<SHexField> _destTiles, int _distance)
|
||||
CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance)
|
||||
: CBattleStackAnimation(_owner, _stack), destTiles(_destTiles), nextPos(0), distance(_distance), stepX(0.0), stepY(0.0)
|
||||
{
|
||||
curStackPos = stack->position;
|
||||
|
@ -20,8 +20,8 @@ class CStack;
|
||||
class CMovementAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
std::vector<SHexField> destTiles; //destination
|
||||
SHexField nextHex;
|
||||
std::vector<SBattleHex> 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<SHexField> _destTiles, int _distance);
|
||||
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance);
|
||||
};
|
@ -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)
|
||||
{
|
||||
}
|
@ -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);
|
||||
};
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
};
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
};
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
@ -8,6 +8,7 @@
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
void CStackQueue::update()
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GUIBase.h"
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class CStack;
|
||||
|
@ -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<int>((tilesw / static_cast<double>(mapSizes.x)) * pos.w), //width
|
||||
ry = static_cast<int>((tilesh / static_cast<double>(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<int,SDL_Color> &colors = adventureInt->minimap.colors;
|
||||
std::map<int,SDL_Color> &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; d<CGI->mh->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
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
||||
};
|
||||
|
@ -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; i<resAmount.size(); i++)
|
||||
{
|
||||
resPicture[i]->moveBy(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; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||
@ -1492,8 +1493,8 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
int posX = pos.w/2 - rowSize[row] * 40 + 24;
|
||||
for (size_t i=0; i<rowSize[row]; i++)
|
||||
{//Move current resource to correct position
|
||||
resPicture[index]->moveBy(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<Point> positions;
|
||||
positions += Point(10, 22), Point(404, 22),
|
||||
Point(10, 155), Point(404,155),
|
||||
Point(10, 288), Point(404,288);
|
||||
std::vector<SPoint> 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; i<fortSize; i++)
|
||||
{
|
||||
@ -1572,7 +1573,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town)
|
||||
resdatabar->pos.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<std::vector<Point> > positions;
|
||||
std::vector<std::vector<SPoint> > 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; i<owner->town->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,
|
||||
|
@ -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);
|
||||
|
@ -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<std::string>(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<std::string>(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;
|
||||
|
@ -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);
|
||||
|
@ -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; v<GameConstants::PRIMARY_SKILLS; ++v)
|
||||
{
|
||||
LRClickableAreaWTextComp *area = new LRClickableAreaWTextComp(Rect(30 + 70*v, 109, 42, 64), SComponent::primskill);
|
||||
LRClickableAreaWTextComp *area = new LRClickableAreaWTextComp(SRect(30 + 70*v, 109, 42, 64), SComponent::primskill);
|
||||
area->text = 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<size_t>(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<CExchangeWindow*>(isa))
|
||||
for(int g=0; g < ARRAY_COUNT(cew->heroInst); ++g)
|
||||
|
@ -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<const CGObjectInstance * > ownedObjects = LOCPLINT->cb->getMyObjects();
|
||||
generateObjectsList(ownedObjects);
|
||||
@ -530,7 +531,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
|
||||
objects.push_back(element.second);
|
||||
}
|
||||
dwellingsList = new CListBox(boost::bind(&CKingdomInterface::createOwnedObject, this, _1), CListBox::DestroyFunc(),
|
||||
Point(740,44), Point(0,57), dwellSize, visibleObjects.size());
|
||||
SPoint(740,44), SPoint(0,57), dwellSize, visibleObjects.size());
|
||||
}
|
||||
|
||||
CIntObject* CKingdomInterface::createOwnedObject(size_t index)
|
||||
@ -539,7 +540,7 @@ CIntObject* CKingdomInterface::createOwnedObject(size_t index)
|
||||
{
|
||||
OwnedObjectInfo &obj = objects[index];
|
||||
std::string value = boost::lexical_cast<std::string>(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<const CGObjectInstan
|
||||
for (int i=0; i<7; i++)
|
||||
{
|
||||
std::string value = boost::lexical_cast<std::string>(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<std::string>(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; i<town->creatures.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<void()>(), 269, 66, "HSBTNS3");
|
||||
btnRight = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 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; i<GameConstants::PRIMARY_SKILLS; i++)
|
||||
heroInfo.push_back(new InfoBox(Point(78+i*36, 26), InfoBox::POS_DOWN, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(SPoint(78+i*36, 26), InfoBox::POS_DOWN, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_PRIMARY_SKILL, hero, i)));
|
||||
|
||||
for (size_t i=0; i<GameConstants::SKILL_PER_HERO; i++)
|
||||
heroInfo.push_back(new InfoBox(Point(410+i*36, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(SPoint(410+i*36, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_SECONDARY_SKILL, hero, i)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(Point(375, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(SPoint(375, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_SPECIAL, hero)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(Point(330, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(SPoint(330, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_EXPERIENCE, hero)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(Point(280, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(SPoint(280, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_MANA, hero)));
|
||||
|
||||
morale = new MoraleLuckBox(true, Rect(225, 53, 30, 22), true);
|
||||
luck = new MoraleLuckBox(false, Rect(225, 28, 30, 22), true);
|
||||
morale = new MoraleLuckBox(true, SRect(225, 53, 30, 22), true);
|
||||
luck = new MoraleLuckBox(false, SRect(225, 28, 30, 22), true);
|
||||
|
||||
morale->set(hero);
|
||||
luck->set(hero);
|
||||
|
@ -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);
|
||||
|
@ -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<const CIntObject *>(child))
|
||||
printInfoAboutIntObject(obj, 0);
|
||||
|
@ -106,8 +106,8 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
|
||||
{
|
||||
for (int j=0; j<h; j+=background->h)
|
||||
{
|
||||
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; i<ret->buttons.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);
|
||||
}
|
||||
|
||||
|
@ -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<CKingdomInterface*>(isa);
|
||||
if (ki)
|
||||
@ -508,9 +509,9 @@ void CPlayerInterface::garrisonChanged( const CGObjectInstance * obj, bool updat
|
||||
if(updateInfobox)
|
||||
updateInfo(obj);
|
||||
|
||||
for(std::list<IShowActivable*>::iterator i = GH.listInt.begin(); i != GH.listInt.end(); i++)
|
||||
for(std::list<IShowActivatable*>::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<CGarrisonHolder*>(*i);
|
||||
cgh->updateGarrisons();
|
||||
@ -755,7 +756,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
|
||||
battleInt->battleFinished(*br);
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<SHexField> dest, int distance)
|
||||
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<SBattleHex> 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<CKingdomInterface*>(isa);
|
||||
if (ki && townObj)
|
||||
@ -2339,9 +2340,9 @@ void CPlayerInterface::artifactPut(const ArtifactLocation &al)
|
||||
void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> 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<CArtifactHolder*>(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<boost::recursive_mutex> 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<CArtifactHolder*>(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<boost::recursive_mutex> 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<CArtifactHolder*>(isa))->artifactAssembled(al);
|
||||
}
|
||||
@ -2375,9 +2376,9 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
|
||||
void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> 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<CArtifactHolder*>(isa))->artifactDisassembled(al);
|
||||
}
|
||||
|
@ -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<SHexField> dest, int distance) OVERRIDE;
|
||||
void battleStackMoved(const CStack * stack, std::vector<SBattleHex> 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "CPreGame.h"
|
||||
|
||||
#include <zlib.h>
|
||||
#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::function<void(
|
||||
positions = 16;
|
||||
}
|
||||
if(tabType == CMenuScreen::saveGame)
|
||||
txt = new CTextInput(Rect(32, 539, 350, 20), Point(-32, -25), "GSSTRIP.bmp", 0);
|
||||
txt = new CTextInput(SRect(32, 539, 350, 20), SPoint(-32, -25), "GSSTRIP.bmp", 0);
|
||||
break;
|
||||
case CMenuScreen::campaignList:
|
||||
getFiles(toParse, GameConstants::DATA_DIR + "/Maps", "h3c"); //get all campaigns
|
||||
@ -1446,7 +1447,7 @@ void SelectionTab::onDoubleClick()
|
||||
int SelectionTab::getLine()
|
||||
{
|
||||
int line = -1;
|
||||
Point clickPos(GH.current->button.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<CSelectionScreen*>(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)
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
#include <SDL.h>
|
||||
#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);
|
||||
|
||||
|
@ -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};
|
||||
|
@ -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
|
||||
|
@ -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<CGameInfo*>(CGI)->state = new CGameState();
|
||||
tlog0 <<"\tGamestate: "<<tmh.getDiff()<<std::endl;
|
||||
CConnection &c(*serv);
|
||||
@ -553,7 +553,7 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
def = NULL;
|
||||
|
||||
if(att || def || gs->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);
|
||||
|
@ -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
|
||||
|
1071
client/GUIBase.cpp
1071
client/GUIBase.cpp
File diff suppressed because it is too large
Load Diff
626
client/GUIBase.h
626
client/GUIBase.h
@ -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 <typename T> 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<typename T>
|
||||
Point operator+(const T &b) const
|
||||
{
|
||||
return Point(x+b.x,y+b.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point operator*(const T &mul) const
|
||||
{
|
||||
return Point(x*mul, y*mul);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point& operator+=(const T &b)
|
||||
{
|
||||
x += b.x;
|
||||
y += b.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point operator-(const T &b) const
|
||||
{
|
||||
return Point(x - b.x, y - b.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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<typename T> Point& operator=(const T &t)
|
||||
{
|
||||
x = t.x;
|
||||
y = t.y;
|
||||
return *this;
|
||||
}
|
||||
template<typename T> bool operator==(const T &t) const
|
||||
{
|
||||
return x == t.x && y == t.y;
|
||||
}
|
||||
template<typename T> 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 && qx<x+w && qy>y && qy<y+h)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool isIn(const Point &q) const //determines if given point lies inside rect
|
||||
{
|
||||
return isIn(q.x,q.y);
|
||||
}
|
||||
Point topLeft() const //top left corner of this rect
|
||||
{
|
||||
return Point(x,y);
|
||||
}
|
||||
Point topRight() const //top right corner of this rect
|
||||
{
|
||||
return Point(x+w,y);
|
||||
}
|
||||
Point bottomLeft() const //bottom left corner of this rect
|
||||
{
|
||||
return Point(x,y+h);
|
||||
}
|
||||
Point bottomRight() const //bottom right corner of this rect
|
||||
{
|
||||
return Point(x+w,y+h);
|
||||
}
|
||||
Rect operator+(const Rect &p) const //moves this rect by p's rect position
|
||||
{
|
||||
return Rect(x+p.x,y+p.y,w,h);
|
||||
}
|
||||
Rect operator+(const Point &p) const //moves this rect by p's point position
|
||||
{
|
||||
return Rect(x+p.x,y+p.y,w,h);
|
||||
}
|
||||
Rect& operator=(const Point &p) //assignment operator
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator=(const Rect &p) //assignment operator
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
w = p.w;
|
||||
h = p.h;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator+=(const Rect &p) //works as operator+
|
||||
{
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator+=(const Point &p) //works as operator+
|
||||
{
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator-=(const Rect &p) //works as operator+
|
||||
{
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator-=(const Point &p) //works as operator+
|
||||
{
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
return *this;
|
||||
}
|
||||
template<typename T> 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<CIntObject *> 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 <typename T> 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<int> assignedKeys;
|
||||
KeyShortcut(){}; //c-tor
|
||||
KeyShortcut(int key){assignedKeys.insert(key);}; //c-tor
|
||||
KeyShortcut(std::set<int> 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<IShowActivable *> 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<CIntObject*> lclickable;
|
||||
std::list<CIntObject*> rclickable;
|
||||
std::list<CIntObject*> hoverable;
|
||||
std::list<CIntObject*> keyinterested;
|
||||
std::list<CIntObject*> motioninterested;
|
||||
std::list<CIntObject*> timeinterested;
|
||||
std::list<CIntObject*> wheelInterested;
|
||||
std::list<CIntObject*> doubleClickInterested;
|
||||
|
||||
//objs to blit
|
||||
std::vector<IShowable*> 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<CIntObject *> 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 <typename T> 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)
|
@ -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<CIntObject*>::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;i<creatures.size();i++)
|
||||
{
|
||||
Rect creaPos = Rect(creatures[i].pos) + pos;
|
||||
SRect creaPos = SRect(creatures[i].pos) + pos;
|
||||
if(isItIn(&creaPos, GH.current->motion.x, GH.current->motion.y))
|
||||
{
|
||||
which = i;
|
||||
@ -1930,7 +1931,7 @@ void CRecruitmentWindow::clickRight(tribool down, bool previousState)
|
||||
for(int i=0;i<creatures.size();i++)
|
||||
{
|
||||
const int sCREATURE_WIDTH = CREATURE_WIDTH; // gcc -O0 workaround
|
||||
Rect creatureRect = genRect(132, sCREATURE_WIDTH, pos.x+curx, pos.y+64);
|
||||
SRect creatureRect = genRect(132, sCREATURE_WIDTH, pos.x+curx, pos.y+64);
|
||||
if(isItIn(&creatureRect, GH.current->motion.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<int> *ids = getItemsIds(Left);
|
||||
std::vector<Rect> pos;
|
||||
std::vector<SRect> pos;
|
||||
int amount = -1;
|
||||
|
||||
getPositionsFor(pos, Left, itemsType[Left]);
|
||||
@ -3035,7 +3036,7 @@ std::vector<int> *CTradeWindow::getItemsIds(bool Left)
|
||||
return ids;
|
||||
}
|
||||
|
||||
void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const
|
||||
void CTradeWindow::getPositionsFor(std::vector<SRect> &poss, bool Left, EType type) const
|
||||
{
|
||||
if(mode == EMarketMode::ARTIFACT_EXP && !Left)
|
||||
{
|
||||
@ -3048,10 +3049,10 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &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<Rect> &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<Rect> positions;
|
||||
std::vector<SRect> 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<const CGHeroInstance*>(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<CArtPlace *> 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<Rect> slotPos;
|
||||
std::vector<SRect> 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<si32> &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<void(const std::string &)> &CB )
|
||||
CTextInput::CTextInput( const SRect &Pos, const SPoint &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &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
|
||||
|
@ -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<AdventureMapButton *> 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<CAnimImage* > 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<void(const std::string &)> &CB);
|
||||
CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
|
||||
CTextInput(const SRect &Pos, const SPoint &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &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<Rect> areas;//areas for each visible item
|
||||
std::vector<SRect> areas;//areas for each visible item
|
||||
std::vector<int> 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<void()> 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<int> *getItemsIds(bool Left); //NULL if default
|
||||
void getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const;
|
||||
void getPositionsFor(std::vector<SRect> &poss, bool Left, EType type) const;
|
||||
void removeItems(const std::set<CTradeableItem *> &toRemove);
|
||||
void removeItem(CTradeableItem * t);
|
||||
void getEmptySlots(std::set<CTradeableItem *> &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<CArtPlace *> ArtWorn, std::vector<CArtPlace *> 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
|
||||
{
|
||||
|
@ -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<std::vector<CDefEssential *> Graphics::*,
|
||||
void Graphics::loadHeroFlags()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
StopWatch th;
|
||||
CStopWatch th;
|
||||
std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4];
|
||||
pr[0].first = &Graphics::flags1;
|
||||
pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"),
|
||||
|
@ -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 <x, y>
|
||||
std::vector< SPoint > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall <x, y>
|
||||
//abilities
|
||||
CDefEssential * abils32, * abils44, * abils82;
|
||||
//spells
|
||||
|
@ -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 \
|
||||
|
@ -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...
|
||||
|
@ -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; i<r.w; i++)
|
||||
@ -1270,7 +1269,7 @@ void CSDL_Ext::blitSurface( SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface *
|
||||
}
|
||||
else
|
||||
{
|
||||
betterDst = Rect(0, 0, dst->w, 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);
|
||||
}
|
||||
|
@ -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<std::string> & 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
|
||||
|
324
client/StdInc.h
324
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 <cstdio>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "../tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
|
||||
//filesystem version 3 causes problems (and it's default as of boost 1.46)
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#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<typename KeyT, typename ValT>
|
||||
class bmap : public std::map<KeyT, ValT>
|
||||
{
|
||||
public:
|
||||
const ValT & operator[](KeyT key) const
|
||||
{
|
||||
return find(key)->second;
|
||||
}
|
||||
ValT & operator[](KeyT key)
|
||||
{
|
||||
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<std::map<KeyT, ValT> &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
//returns true if container c contains item i
|
||||
template <typename Container, typename Item>
|
||||
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 <typename V, typename Item, typename Item2>
|
||||
bool contains(const std::map<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if bmap c contains item i
|
||||
template <typename V, typename Item, typename Item2>
|
||||
bool contains(const bmap<Item,V> & c, const Item2 &i)
|
||||
{
|
||||
return c.find(i)!=c.end();
|
||||
}
|
||||
|
||||
//returns true if unordered set c contains item i
|
||||
template <typename Item>
|
||||
bool contains(const boost::unordered_set<Item> & 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 <typename T1, typename T2>
|
||||
int find_pos(const std::vector<T1> & 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 <typename T1, typename T2, typename Func>
|
||||
int find_pos(const std::vector<T1> & 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, typename Item>
|
||||
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, typename Item>
|
||||
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, typename Item>
|
||||
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 <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
t1 &amin(t1 &a, const t2 &b)
|
||||
{
|
||||
if(a <= b)
|
||||
return a;
|
||||
else
|
||||
{
|
||||
a = b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//makes a to fit the range <b, c>
|
||||
template <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
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 <typename t1, typename t2, typename t3>
|
||||
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
|
||||
{
|
||||
return a >= b && a <= c;
|
||||
}
|
||||
|
||||
template <typename t1, typename t2>
|
||||
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 <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
|
||||
//deleted pointer and sets it to NULL
|
||||
template <typename T>
|
||||
void clear_pointer(T* &ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
// can be used for counting arrays
|
||||
template<typename T, size_t N> 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.
|
461
client/UIFramework/CGuiHandler.cpp
Normal file
461
client/UIFramework/CGuiHandler.cpp
Normal file
@ -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<SDL_Event*> 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;i<objsToBlit.size();i++)
|
||||
objsToBlit[i]->showAll(screen2);
|
||||
|
||||
blitAt(screen2,0,0,screen);
|
||||
}
|
||||
|
||||
void CGuiHandler::updateTime()
|
||||
{
|
||||
int tv = th.getDiff();
|
||||
std::list<CIntObject*> hlp = timeinterested;
|
||||
for (std::list<CIntObject*>::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<boost::mutex> 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<CIntObject*>::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++)
|
||||
{
|
||||
if((*i)->captureAllKeys)
|
||||
{
|
||||
keysCaptured = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<CIntObject*> miCopy = keyinterested;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = doubleClickInterested;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = lclickable;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = rclickable;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = wheelInterested;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = lclickable;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp = rclickable;
|
||||
for(std::list<CIntObject*>::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<CIntObject*> hlp;
|
||||
for(std::list<CIntObject*>::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; i<hlp.size();i++)
|
||||
{
|
||||
hlp[i]->hover(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<CIntObject*> miCopy = motioninterested;
|
||||
for(std::list<CIntObject*>::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<std::string>(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;
|
||||
}
|
117
client/UIFramework/CGuiHandler.h
Normal file
117
client/UIFramework/CGuiHandler.h
Normal file
@ -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<IShowActivatable *> 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<CIntObject*> lclickable;
|
||||
std::list<CIntObject*> rclickable;
|
||||
std::list<CIntObject*> hoverable;
|
||||
std::list<CIntObject*> keyinterested;
|
||||
std::list<CIntObject*> motioninterested;
|
||||
std::list<CIntObject*> timeinterested;
|
||||
std::list<CIntObject*> wheelInterested;
|
||||
std::list<CIntObject*> doubleClickInterested;
|
||||
|
||||
//objs to blit
|
||||
std::vector<IShowable*> 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<CIntObject *> 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 <typename T> 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)
|
443
client/UIFramework/CIntObject.cpp
Normal file
443
client/UIFramework/CIntObject.cpp
Normal file
@ -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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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<CIntObject*>::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;
|
||||
}
|
135
client/UIFramework/CIntObject.h
Normal file
135
client/UIFramework/CIntObject.h
Normal file
@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_events.h>
|
||||
#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<CIntObject *> 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 <typename T> 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;
|
||||
}
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user