mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merged Beegee's classesRefactoring1 branch.
This commit is contained in:
commit
8f1048f835
@ -1,5 +1,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "CEmptyAI.h"
|
||||
#include <iostream>
|
||||
|
||||
void CEmptyAI::init(CCallback * CB)
|
||||
{
|
||||
cb = CB;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../AI_Base.h"
|
||||
#include "../../CCallback.h"
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
vcmiai_LTLIBRARIES = libEmptyAI.la
|
||||
libEmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libEmptyAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libEmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libEmptyAI_la_SOURCES = \
|
||||
CEmptyAI.cpp \
|
||||
CEmptyAI.h \
|
||||
exp_funcs.cpp
|
||||
|
||||
|
@ -79,15 +79,16 @@ am__base_list = \
|
||||
am__installdirs = "$(DESTDIR)$(vcmiaidir)"
|
||||
LTLIBRARIES = $(vcmiai_LTLIBRARIES)
|
||||
libEmptyAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la
|
||||
am_libEmptyAI_la_OBJECTS = CEmptyAI.lo exp_funcs.lo
|
||||
am_libEmptyAI_la_OBJECTS = libEmptyAI_la-CEmptyAI.lo \
|
||||
libEmptyAI_la-exp_funcs.lo
|
||||
libEmptyAI_la_OBJECTS = $(am_libEmptyAI_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
libEmptyAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libEmptyAI_la_LDFLAGS) $(LDFLAGS) \
|
||||
-o $@
|
||||
$(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) $(libEmptyAI_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
@ -270,15 +271,18 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
vcmiai_LTLIBRARIES = libEmptyAI.la
|
||||
libEmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libEmptyAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libEmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libEmptyAI_la_SOURCES = \
|
||||
CEmptyAI.cpp \
|
||||
CEmptyAI.h \
|
||||
exp_funcs.cpp
|
||||
|
||||
all: all-am
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
@ -352,8 +356,8 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CEmptyAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_funcs.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libEmptyAI_la-CEmptyAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libEmptyAI_la-exp_funcs.Plo@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@ -379,6 +383,22 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
libEmptyAI_la-CEmptyAI.lo: CEmptyAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -MT libEmptyAI_la-CEmptyAI.lo -MD -MP -MF $(DEPDIR)/libEmptyAI_la-CEmptyAI.Tpo -c -o libEmptyAI_la-CEmptyAI.lo `test -f 'CEmptyAI.cpp' || echo '$(srcdir)/'`CEmptyAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libEmptyAI_la-CEmptyAI.Tpo $(DEPDIR)/libEmptyAI_la-CEmptyAI.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CEmptyAI.cpp' object='libEmptyAI_la-CEmptyAI.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libEmptyAI_la-CEmptyAI.lo `test -f 'CEmptyAI.cpp' || echo '$(srcdir)/'`CEmptyAI.cpp
|
||||
|
||||
libEmptyAI_la-exp_funcs.lo: exp_funcs.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -MT libEmptyAI_la-exp_funcs.lo -MD -MP -MF $(DEPDIR)/libEmptyAI_la-exp_funcs.Tpo -c -o libEmptyAI_la-exp_funcs.lo `test -f 'exp_funcs.cpp' || echo '$(srcdir)/'`exp_funcs.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libEmptyAI_la-exp_funcs.Tpo $(DEPDIR)/libEmptyAI_la-exp_funcs.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='exp_funcs.cpp' object='libEmptyAI_la-exp_funcs.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libEmptyAI_la-exp_funcs.lo `test -f 'exp_funcs.cpp' || echo '$(srcdir)/'`exp_funcs.cpp
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -468,13 +488,15 @@ distdir: $(DISTFILES)
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(vcmiaidir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
@ -499,6 +521,7 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-vcmiaiLTLIBRARIES \
|
||||
@ -570,7 +593,7 @@ ps-am:
|
||||
|
||||
uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
.MAKE: all check install install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-vcmiaiLTLIBRARIES ctags distclean \
|
||||
@ -586,6 +609,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
2
AI/EmptyAI/StdInc.cpp
Normal file
2
AI/EmptyAI/StdInc.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// Creates the precompiled header
|
||||
#include "StdInc.h"
|
7
AI/EmptyAI/StdInc.h
Normal file
7
AI/EmptyAI/StdInc.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Global.h"
|
||||
|
||||
// This header should be treated as a pre compiled header file(PCH) in the compiler building settings.
|
||||
|
||||
// Here you can add specific libraries and macros which are specific to this project.
|
@ -1,30 +1,30 @@
|
||||
#define VCMI_DLL
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "../../AI_Base.h"
|
||||
#include "CEmptyAI.h"
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
|
||||
std::set<CGlobalAI*> ais;
|
||||
extern "C" DLL_EXPORT int GetGlobalAiVersion()
|
||||
extern "C" DLL_LINKAGE int GetGlobalAiVersion()
|
||||
{
|
||||
return AI_INTERFACE_VER;
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
extern "C" DLL_LINKAGE void GetAiName(char* name)
|
||||
{
|
||||
strcpy(name,NAME);
|
||||
}
|
||||
extern "C" DLL_EXPORT char * GetAiNameS()
|
||||
extern "C" DLL_LINKAGE char * GetAiNameS()
|
||||
{
|
||||
char * ret = new char[50];
|
||||
strcpy(ret,NAME);
|
||||
return ret;
|
||||
}
|
||||
extern "C" DLL_EXPORT CGlobalAI * GetNewAI()
|
||||
extern "C" DLL_LINKAGE CGlobalAI * GetNewAI()
|
||||
{
|
||||
return new CEmptyAI();
|
||||
// return
|
||||
}
|
||||
extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI * i)
|
||||
extern "C" DLL_LINKAGE void ReleaseAI(CGlobalAI * i)
|
||||
{
|
||||
delete (CEmptyAI*)i;
|
||||
ais.erase(i);
|
||||
|
@ -1,13 +1,12 @@
|
||||
#ifndef AI_PRIORITIES
|
||||
#define AI_PRIORITIES
|
||||
#include "StdInc.h"
|
||||
#include "AIPriorities.h"
|
||||
#include <sstream>
|
||||
|
||||
// TODO: No using namespace!!
|
||||
using namespace geniusai;
|
||||
|
||||
Network::Network()
|
||||
{}
|
||||
Network::Network(vector<unsigned int> whichFeatures)// random network
|
||||
Network::Network(vector<ui32> whichFeatures)// random network
|
||||
: whichFeatures(whichFeatures),
|
||||
net(whichFeatures.size(),
|
||||
whichFeatures.size() * 0.601 + 2,
|
||||
@ -34,15 +33,15 @@ Network::Network(istream & input)
|
||||
}
|
||||
|
||||
|
||||
float Network::feedForward(const vector<float> & stateFeatures)
|
||||
double Network::feedForward(const vector<double> & stateFeatures)
|
||||
{
|
||||
// TODO: Should comment/rewrite it...
|
||||
return (rand() % 1000) / 800.0f;
|
||||
return (rand() % 1000) / 800.0;
|
||||
double * input = new double[whichFeatures.size()];
|
||||
for (int i = 0; i < whichFeatures.size(); i++)
|
||||
input[i] = stateFeatures[whichFeatures[i]];
|
||||
|
||||
float ans = net.feedForwardPattern(input)[0];
|
||||
double ans = net.feedForwardPattern(input)[0];
|
||||
|
||||
delete input;
|
||||
return ans;
|
||||
@ -98,18 +97,18 @@ void Priorities::fillFeatures(const CGeniusAI::HypotheticalGameState & hgs)
|
||||
|
||||
}
|
||||
|
||||
float Priorities::getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay)
|
||||
double Priorities::getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay)
|
||||
{
|
||||
if(!resourceCosts.size())return -1;
|
||||
//TODO: replace with ann
|
||||
float cost = resourceCosts[0]/4.0+resourceCosts[1]/2.0+resourceCosts[2]/4.0+resourceCosts[3]/2.0+resourceCosts[4]/2.0+resourceCosts[5]/2.0+resourceCosts[6]/3000.0;
|
||||
double cost = resourceCosts[0]/4.0+resourceCosts[1]/2.0+resourceCosts[2]/4.0+resourceCosts[3]/2.0+resourceCosts[4]/2.0+resourceCosts[5]/2.0+resourceCosts[6]/3000.0;
|
||||
|
||||
if(moved) //TODO: multiply by importance of hero
|
||||
cost+=distOutOfTheWay/10000.0;
|
||||
return cost;
|
||||
}
|
||||
|
||||
float Priorities::getValue(const CGeniusAI::AIObjective & obj)
|
||||
double Priorities::getValue(const CGeniusAI::AIObjective & obj)
|
||||
{ //resource
|
||||
|
||||
vector<int> resourceAmounts(8,0);
|
||||
@ -117,7 +116,7 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj)
|
||||
|
||||
if(obj.type==CGeniusAI::AIObjective::finishTurn) //TODO: replace with value of visiting that object divided by days till completed
|
||||
return .0001; //small nonzero
|
||||
float a;
|
||||
double a;
|
||||
if(obj.type==CGeniusAI::AIObjective::attack)
|
||||
return 100;
|
||||
if(dynamic_cast<const CGeniusAI::HeroObjective* >(&obj))
|
||||
@ -250,4 +249,3 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,7 +1,5 @@
|
||||
#ifndef AIP_H
|
||||
#define AIP_H
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "CGeniusAI.h"
|
||||
#include "neuralNetwork.h"
|
||||
|
||||
@ -11,10 +9,10 @@ class Network
|
||||
{
|
||||
public:
|
||||
Network();
|
||||
Network(vector<unsigned int> whichFeatures);// random network
|
||||
Network(vector<ui32> whichFeatures);// random network
|
||||
Network(istream & input);
|
||||
vector<unsigned int> whichFeatures;
|
||||
float feedForward(const vector<float> & stateFeatures);
|
||||
vector<ui32> whichFeatures;
|
||||
double feedForward(const vector<double> & stateFeatures);
|
||||
neuralNetwork net; //a network with whichFeatures.size() inputs, and 1 output
|
||||
};
|
||||
|
||||
@ -25,15 +23,14 @@ public:
|
||||
Priorities(const string & filename); //read brain from file
|
||||
|
||||
|
||||
vector<float> stateFeatures;
|
||||
vector<double> stateFeatures;
|
||||
int specialFeaturesStart;
|
||||
int numSpecialFeatures;
|
||||
void fillFeatures(const CGeniusAI::HypotheticalGameState & AI);
|
||||
float getValue(const CGeniusAI::AIObjective & obj);
|
||||
float getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay);
|
||||
double getValue(const CGeniusAI::AIObjective & obj);
|
||||
double getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay);
|
||||
vector<vector<Network> > objectNetworks;
|
||||
vector<map<int,Network> > buildingNetworks;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
@ -1,11 +1,5 @@
|
||||
#include "StdInc.h"
|
||||
#include "BattleHelper.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace geniusai::BattleAI;
|
||||
using namespace std;
|
||||
@ -13,8 +7,8 @@ using namespace std;
|
||||
|
||||
CBattleHelper::CBattleHelper():
|
||||
InfiniteDistance(0xffff),
|
||||
BattlefieldWidth(BFIELD_WIDTH-2),
|
||||
BattlefieldHeight(BFIELD_HEIGHT),
|
||||
BattlefieldWidth(GameConstants::BFIELD_WIDTH-2),
|
||||
BattlefieldHeight(GameConstants::BFIELD_HEIGHT),
|
||||
m_voteForMaxDamage(10),
|
||||
m_voteForMinDamage(10),
|
||||
m_voteForMaxSpeed(10),
|
||||
@ -106,21 +100,21 @@ CBattleHelper::~CBattleHelper()
|
||||
|
||||
int CBattleHelper::GetBattleFieldPosition(int x, int y)
|
||||
{
|
||||
return x + BFIELD_WIDTH * (y - 1);
|
||||
return x + GameConstants::BFIELD_WIDTH * (y - 1);
|
||||
}
|
||||
|
||||
int CBattleHelper::DecodeXPosition(int battleFieldPosition)
|
||||
{
|
||||
int x = battleFieldPosition%BFIELD_WIDTH;
|
||||
assert( x > 0 && x < BFIELD_WIDTH-1 );
|
||||
int x = battleFieldPosition%GameConstants::BFIELD_WIDTH;
|
||||
assert( x > 0 && x < GameConstants::BFIELD_WIDTH-1 );
|
||||
return x;
|
||||
}
|
||||
|
||||
int CBattleHelper::DecodeYPosition(int battleFieldPosition)
|
||||
{
|
||||
|
||||
int y=battleFieldPosition/BFIELD_WIDTH +1;
|
||||
assert( y > 0 && y <= BFIELD_HEIGHT);
|
||||
int y=battleFieldPosition/GameConstants::BFIELD_WIDTH +1;
|
||||
assert( y > 0 && y <= GameConstants::BFIELD_HEIGHT);
|
||||
return y;
|
||||
}
|
||||
|
||||
@ -133,34 +127,34 @@ int CBattleHelper::StepLeft(int pos){
|
||||
}
|
||||
|
||||
int CBattleHelper::StepUpleft(int pos){
|
||||
if((pos/BFIELD_WIDTH)%2==0){
|
||||
return pos-BFIELD_WIDTH;
|
||||
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
|
||||
return pos-GameConstants::BFIELD_WIDTH;
|
||||
}else{
|
||||
return pos-BFIELD_WIDTH-1;
|
||||
return pos-GameConstants::BFIELD_WIDTH-1;
|
||||
}
|
||||
}
|
||||
|
||||
int CBattleHelper::StepUpright(int pos){
|
||||
if((pos/BFIELD_WIDTH)%2==0){
|
||||
return pos-BFIELD_WIDTH+1;
|
||||
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
|
||||
return pos-GameConstants::BFIELD_WIDTH+1;
|
||||
}else{
|
||||
return pos-BFIELD_WIDTH;
|
||||
return pos-GameConstants::BFIELD_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
int CBattleHelper::StepDownleft(int pos){
|
||||
if((pos/BFIELD_WIDTH)%2==0){
|
||||
return pos+BFIELD_WIDTH;
|
||||
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
|
||||
return pos+GameConstants::BFIELD_WIDTH;
|
||||
}else{
|
||||
return pos+BFIELD_WIDTH-1;
|
||||
return pos+GameConstants::BFIELD_WIDTH-1;
|
||||
}
|
||||
}
|
||||
|
||||
int CBattleHelper::StepDownright(int pos){
|
||||
if((pos/BFIELD_WIDTH)%2==0){
|
||||
return pos+BFIELD_WIDTH+1;
|
||||
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
|
||||
return pos+GameConstants::BFIELD_WIDTH+1;
|
||||
}else{
|
||||
return pos+BFIELD_WIDTH;
|
||||
return pos+GameConstants::BFIELD_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef __BATTLE_HELPER__
|
||||
#define __BATTLE_HELPER__
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
@ -48,5 +47,3 @@ private:
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif/*__BATTLE_HELPER__*/
|
@ -1,11 +1,10 @@
|
||||
#include "StdInc.h"
|
||||
#include "BattleLogic.h"
|
||||
|
||||
#include "../../lib/BattleState.h"
|
||||
#include <math.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/if.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
|
||||
@ -152,27 +151,27 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
//CGHeroInstance *defendingHero = (m_side)? m_hero2 : m_hero1;
|
||||
|
||||
int attackDefenseBonus = currentStack->Attack() - st->Defense();
|
||||
float damageFactor = 1.0f;
|
||||
double damageFactor = 1.0;
|
||||
if(attackDefenseBonus < 0) //decreasing dmg
|
||||
{
|
||||
if(0.02f * (-attackDefenseBonus) > 0.3f)
|
||||
if(0.02 * (-attackDefenseBonus) > 0.3)
|
||||
{
|
||||
damageFactor += -0.3f;
|
||||
damageFactor += -0.3;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageFactor += 0.02f * attackDefenseBonus;
|
||||
damageFactor += 0.02 * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
else //increasing dmg
|
||||
{
|
||||
if(0.05f * attackDefenseBonus > 4.0f)
|
||||
if(0.05 * attackDefenseBonus > 4.0)
|
||||
{
|
||||
damageFactor += 4.0f;
|
||||
damageFactor += 4.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageFactor += 0.05f * attackDefenseBonus;
|
||||
damageFactor += 0.05 * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,8 +221,8 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
totalHitPoints += hitPoints;
|
||||
}
|
||||
}
|
||||
if ((float)totalDamage / (float)totalEnemyDamage < 0.5f &&
|
||||
(float)totalHitPoints / (float)totalEnemyHitPoints < 0.5f)
|
||||
if (totalDamage / static_cast<double>(totalEnemyDamage) < 0.5 &&
|
||||
totalHitPoints / static_cast<double>(totalEnemyHitPoints) < 0.5)
|
||||
{
|
||||
m_bEnemyDominates = true;
|
||||
DbgBox("** EnemyDominates!");
|
||||
@ -240,29 +239,29 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
|
||||
// sort max damage
|
||||
std::sort(m_statMaxDamage.begin(), m_statMaxDamage.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort min damage
|
||||
std::sort(m_statMinDamage.begin(), m_statMinDamage.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort max speed
|
||||
std::sort(m_statMaxSpeed.begin(), m_statMaxSpeed.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort distance
|
||||
std::sort(m_statDistance.begin(), m_statDistance.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) < bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort distance from shooters
|
||||
std::sort(m_statDistanceFromShooters.begin(), m_statDistanceFromShooters.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) < bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort hit points
|
||||
std::sort(m_statHitPoints.begin(), m_statHitPoints.end(),
|
||||
bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2));
|
||||
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
|
||||
// sort casualties
|
||||
std::sort(m_statCasualties.begin(), m_statCasualties.end(),
|
||||
bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max,
|
||||
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, _1))
|
||||
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_1))
|
||||
>
|
||||
bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max,
|
||||
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, _2)));
|
||||
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_2)));
|
||||
}
|
||||
|
||||
BattleAction CBattleLogic::MakeDecision(int stackID)
|
||||
@ -527,7 +526,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<THex> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
|
||||
std::vector<BattleHex> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
|
||||
|
||||
if(fields.size() == 0)
|
||||
{
|
||||
@ -541,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(THex::mutualPosition(dest_tile, destStackPos) != -1)
|
||||
if(BattleHex::mutualPosition(dest_tile, destStackPos) != -1)
|
||||
ba.additionalInfo = destStackPos;
|
||||
else if(THex::mutualPosition(dest_tile, destStackPos+1) != -1)
|
||||
else if(BattleHex::mutualPosition(dest_tile, destStackPos+1) != -1)
|
||||
ba.additionalInfo = destStackPos+1;
|
||||
else if(THex::mutualPosition(dest_tile, destStackPos-1) != -1)
|
||||
else if(BattleHex::mutualPosition(dest_tile, destStackPos-1) != -1)
|
||||
ba.additionalInfo = destStackPos-1;
|
||||
else
|
||||
return BattleAction::makeDefend(attackerStack);
|
||||
@ -582,7 +581,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<THex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
for (std::vector<BattleHex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
{
|
||||
if (*it == dest_tile)
|
||||
{
|
||||
|
@ -1,11 +1,10 @@
|
||||
#ifndef __BATTLE_LOGIC_H__
|
||||
#define __BATTLE_LOGIC_H__
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
#include "BattleHelper.h"
|
||||
|
||||
#pragma warning (disable: 4100 4251 4245 4018 4081)
|
||||
#include "../../global.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
@ -130,5 +129,3 @@ private:
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif/*__BATTLE_LOGIC_H__*/
|
@ -1,8 +1,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "CGeniusAI.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../../lib/CBuildingHandler.h"
|
||||
#include "../../lib/CHeroHandler.h"
|
||||
@ -10,6 +8,7 @@
|
||||
#include "../../lib/NetPacks.h"
|
||||
#include "AIPriorities.h"
|
||||
#include "../../lib/CGameState.h"
|
||||
#include "../../lib/GameConstants.h"
|
||||
|
||||
using std::endl;
|
||||
using geniusai::CGeniusAI;
|
||||
@ -150,7 +149,7 @@ CGeniusAI::HeroObjective::HeroObjective(const HypotheticalGameState &hgs,
|
||||
}
|
||||
|
||||
|
||||
float CGeniusAI::HeroObjective::getValue() const
|
||||
double CGeniusAI::HeroObjective::getValue() const
|
||||
{
|
||||
if (_value >= 0)
|
||||
return _value - _cost;
|
||||
@ -165,7 +164,7 @@ float CGeniusAI::HeroObjective::getValue() const
|
||||
resourceCosts[6] += 1000;
|
||||
|
||||
// TODO: Add some meaningful (and not exploitable) number here.
|
||||
float bestCost = 9e9f;
|
||||
double bestCost = 9e9f;
|
||||
HypotheticalGameState::HeroModel* bestHero = NULL;
|
||||
if (type != AIObjective::finishTurn)
|
||||
{
|
||||
@ -195,7 +194,7 @@ float CGeniusAI::HeroObjective::getValue() const
|
||||
distOutOfTheWay-=path3.nodes[0].dist;
|
||||
}
|
||||
|
||||
float cost = AI->m_priorities->getCost(resourceCosts,
|
||||
double cost = AI->m_priorities->getCost(resourceCosts,
|
||||
whoCanAchieve[i]->h,
|
||||
distOutOfTheWay);
|
||||
if (cost < bestCost)
|
||||
@ -269,7 +268,7 @@ CGeniusAI::TownObjective::TownObjective(
|
||||
_value = -1;
|
||||
}
|
||||
|
||||
float CGeniusAI::TownObjective::getValue() const
|
||||
double CGeniusAI::TownObjective::getValue() const
|
||||
{
|
||||
if (_value >= 0)
|
||||
return _value - _cost;
|
||||
@ -278,7 +277,7 @@ float CGeniusAI::TownObjective::getValue() const
|
||||
vector<int> resourceCosts(8,0);
|
||||
CBuilding* b = NULL;
|
||||
CCreature* creature = NULL;
|
||||
float cost = 0; // TODO: Needed?
|
||||
double cost = 0; // TODO: Needed?
|
||||
int ID = 0;
|
||||
int newID = 0;
|
||||
int howMany = 0;
|
||||
@ -310,7 +309,7 @@ float CGeniusAI::TownObjective::getValue() const
|
||||
else
|
||||
creatures_max = INT_MAX; // TODO: Will have to rewrite it.
|
||||
// TODO: Buy the best units (the least I can buy)?
|
||||
amin(howMany, creatures_max);
|
||||
vstd::amin(howMany, creatures_max);
|
||||
}
|
||||
// The cost of recruiting the stack of creatures.
|
||||
for (int i = 0; creature && (i < creature->cost.size() ); ++i)
|
||||
@ -401,7 +400,7 @@ void CGeniusAI::TownObjective::print() const
|
||||
creatures_max = hgs.resourceAmounts[i]/creature->cost[i];
|
||||
else
|
||||
creatures_max = INT_MAX;
|
||||
amin(howMany, creatures_max);
|
||||
vstd::amin(howMany, creatures_max);
|
||||
}
|
||||
tlog6 << "recruit " << howMany << " " << creature->namePl
|
||||
<< " (Total AI Strength " << creature->AIValue*howMany
|
||||
@ -503,7 +502,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h
|
||||
// maybe the hero wants to visit a seemingly unguarded enemy town,
|
||||
// but there is a hero on top of it.
|
||||
// if(i->o->)
|
||||
if (i->o->ID != HEROI_TYPE)
|
||||
if (i->o->ID != GameConstants::HEROI_TYPE)
|
||||
{// Unless you are trying to visit a hero.
|
||||
bool heroThere = false;
|
||||
for(int j = 0; j < hgs.heroModels.size(); j++)
|
||||
@ -514,7 +513,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h
|
||||
if (heroThere) // It won't work if there is already someone visiting that spot.
|
||||
continue;
|
||||
}
|
||||
if (i->o->ID == HEROI_TYPE && // Visiting friendly heroes not yet supported.
|
||||
if (i->o->ID == GameConstants::HEROI_TYPE && // Visiting friendly heroes not yet supported.
|
||||
i->o->getOwner() == m_cb->getMyColor())
|
||||
continue;
|
||||
if (i->o->id == h.h->id) // Don't visit yourself (should be caught by above).
|
||||
@ -541,7 +540,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h
|
||||
// TODO: Make constants of those 1.2 & 2.5.
|
||||
if (dynamic_cast<const CGTownInstance*> (i->o))
|
||||
enemyStrength = static_cast<int>((dynamic_cast<const CGTownInstance*> (i->o))->getArmyStrength() * 1.2);
|
||||
float heroStrength = h.h->getTotalStrength();
|
||||
double heroStrength = h.h->getTotalStrength();
|
||||
// TODO: ballence these numbers using objective cost formula.
|
||||
// TODO: it would be nice to do a battle simulation.
|
||||
if (enemyStrength * 2.5 > heroStrength)
|
||||
@ -945,7 +944,7 @@ void CGeniusAI::TownObjective::fulfill(CGeniusAI& cg,
|
||||
creature = VLC->creh->creatures[ID];
|
||||
howMany = whichTown->creaturesToRecruit[which].first;
|
||||
for (int i = 0; i < creature->cost.size(); i++)
|
||||
amin(howMany, creature->cost[i] ? hgs.resourceAmounts[i]/creature->cost[i] : INT_MAX);
|
||||
vstd::amin(howMany, creature->cost[i] ? hgs.resourceAmounts[i]/creature->cost[i] : INT_MAX);
|
||||
if (howMany == 0)
|
||||
{
|
||||
tlog6 << "tried to recruit without enough money.";
|
||||
@ -1262,7 +1261,7 @@ void CGeniusAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2
|
||||
// TODO: Battle logic what...
|
||||
assert(!m_battleLogic);
|
||||
// We have been informed that battle will start (or we are neutral AI)
|
||||
assert( (playerID > PLAYER_LIMIT) || (m_state.get() == UPCOMING_BATTLE) );
|
||||
assert( (playerID > GameConstants::PLAYER_LIMIT) || (m_state.get() == UPCOMING_BATTLE) );
|
||||
|
||||
m_state.setn(ONGOING_BATTLE);
|
||||
m_battleLogic = new BattleAI::CBattleLogic(m_cb, army1, army2, tile, hero1,
|
||||
@ -1312,7 +1311,7 @@ void CGeniusAI::battleNewRound(int round)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<THex> dest, int distance)
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<BattleHex> dest, int distance)
|
||||
{
|
||||
std::string message("\t\t\tCGeniusAI::battleStackMoved ID(");
|
||||
message += boost::lexical_cast<std::string>(ID);
|
||||
@ -1346,7 +1345,7 @@ void CGeniusAI::battleSpellCast(const BattleSpellCast *sc)
|
||||
*
|
||||
*/
|
||||
// void CGeniusAI::battleStackMoved(int ID,
|
||||
// THex dest,
|
||||
// BattleHex dest,
|
||||
// bool startMoving,
|
||||
// bool endMoving)
|
||||
// {
|
||||
|
@ -1,13 +1,9 @@
|
||||
#ifndef __CGENIUSAI_H__
|
||||
#define __CGENIUSAI_H__
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
#include "BattleLogic.h"
|
||||
#include "GeneralAI.h"
|
||||
#include "../../lib/CondSh.h"
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <queue>
|
||||
|
||||
class CBuilding;
|
||||
|
||||
@ -101,7 +97,7 @@ private:
|
||||
virtual void fulfill(CGeniusAI &,HypotheticalGameState & hgs)=0;
|
||||
virtual HypotheticalGameState pretend(const HypotheticalGameState&) =0;
|
||||
virtual void print() const=0;
|
||||
virtual float getValue() const=0; //how much is it worth to the AI to achieve
|
||||
virtual double getValue() const=0; //how much is it worth to the AI to achieve
|
||||
};
|
||||
|
||||
class HeroObjective: public AIObjective
|
||||
@ -122,11 +118,11 @@ private:
|
||||
bool operator< (const HeroObjective &other) const;
|
||||
void fulfill(CGeniusAI &,HypotheticalGameState & hgs);
|
||||
HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;};
|
||||
float getValue() const;
|
||||
double getValue() const;
|
||||
void print() const;
|
||||
private:
|
||||
mutable float _value;
|
||||
mutable float _cost;
|
||||
mutable double _value;
|
||||
mutable double _cost;
|
||||
};
|
||||
|
||||
//town objectives
|
||||
@ -147,11 +143,11 @@ private:
|
||||
bool operator < (const TownObjective &other)const;
|
||||
void fulfill(CGeniusAI &,HypotheticalGameState & hgs);
|
||||
HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;};
|
||||
float getValue() const;
|
||||
double getValue() const;
|
||||
void print() const;
|
||||
private:
|
||||
mutable float _value;
|
||||
mutable float _cost;
|
||||
mutable double _value;
|
||||
mutable double _cost;
|
||||
};
|
||||
|
||||
class AIObjectivePtrCont
|
||||
@ -205,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<THex> dest, int distance);
|
||||
virtual void battleStackMoved(int ID, std::vector<BattleHex> 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
|
||||
@ -218,5 +214,3 @@ public:
|
||||
friend class Priorities;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __CGENIUSAI_H__
|
||||
|
@ -1,14 +1,11 @@
|
||||
#ifndef __GENIUS_COMMON__
|
||||
#define __GENIUS_COMMON__
|
||||
#pragma once
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define strcpy_s(a, b, c) strncpy(a, c, b)
|
||||
#endif
|
||||
|
||||
#pragma warning (disable: 4100 4244)
|
||||
#include "../../AI_Base.h"
|
||||
#include "../../lib/AI_Base.h"
|
||||
#pragma warning (default: 4100 4244)
|
||||
|
||||
void DbgBox(const char *msg, bool messageBox = false);
|
||||
|
||||
#endif/*__GENIUS_COMMON__*/
|
@ -1,40 +1,38 @@
|
||||
#pragma warning (disable: 4100 4251 4245 4018 4081)
|
||||
#include "../../AI_Base.h"
|
||||
#pragma warning (default: 4100 4251 4245 4018 4081)
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "../../lib/AI_Base.h"
|
||||
#include "CGeniusAI.h"
|
||||
|
||||
using namespace geniusai;
|
||||
|
||||
const char *g_cszAiName = "Genius 1.0";
|
||||
|
||||
extern "C" DLL_F_EXPORT int GetGlobalAiVersion()
|
||||
extern "C" DLL_EXPORT int GetGlobalAiVersion()
|
||||
{
|
||||
return AI_INTERFACE_VER;
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT void GetAiName(char* name)
|
||||
extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
{
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT char* GetAiNameS()
|
||||
extern "C" DLL_EXPORT char* GetAiNameS()
|
||||
{
|
||||
// need to be defined
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT CGlobalAI* GetNewAI()
|
||||
extern "C" DLL_EXPORT CGlobalAI* GetNewAI()
|
||||
{
|
||||
return new CGeniusAI();
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT void ReleaseAI(CGlobalAI* i)
|
||||
extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI* i)
|
||||
{
|
||||
delete (CGeniusAI*)i;
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI()
|
||||
extern "C" DLL_EXPORT CBattleGameInterface* GetNewBattleAI()
|
||||
{
|
||||
return new CGeniusAI();
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#include "StdInc.h"
|
||||
#include "GeneralAI.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "ExpertSystem.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../../global.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/HeroBonus.h"
|
||||
#include <boost/bind.hpp>
|
||||
@ -101,7 +101,7 @@ public:
|
||||
template <typename input, typename output> class Weight : public Rule <input, output>
|
||||
{
|
||||
public:
|
||||
float multiplier; //multiply input by value and return to output
|
||||
double multiplier; //multiply input by value and return to output
|
||||
void fireTule(){};
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "GeneralAI.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
using namespace geniusai::GeneralAI;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef __GENERAL_AI_H__
|
||||
#define __GENERAL_AI_H__
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
@ -17,5 +16,3 @@ namespace geniusai { namespace GeneralAI {
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif/*__GENERAL_AI_H__*/
|
@ -1,7 +1,11 @@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
vcmiai_LTLIBRARIES = libGeniusAI.la
|
||||
libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libGeniusAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libGeniusAI_la_SOURCES = \
|
||||
AIPriorities.cpp \
|
||||
|
@ -79,17 +79,18 @@ am__base_list = \
|
||||
am__installdirs = "$(DESTDIR)$(vcmiaidir)"
|
||||
LTLIBRARIES = $(vcmiai_LTLIBRARIES)
|
||||
libGeniusAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la
|
||||
am_libGeniusAI_la_OBJECTS = AIPriorities.lo BattleHelper.lo \
|
||||
BattleLogic.lo CGeniusAI.lo DLLMain.lo GeneralAI.lo \
|
||||
neuralNetwork.lo
|
||||
am_libGeniusAI_la_OBJECTS = libGeniusAI_la-AIPriorities.lo \
|
||||
libGeniusAI_la-BattleHelper.lo libGeniusAI_la-BattleLogic.lo \
|
||||
libGeniusAI_la-CGeniusAI.lo libGeniusAI_la-DLLMain.lo \
|
||||
libGeniusAI_la-GeneralAI.lo libGeniusAI_la-neuralNetwork.lo
|
||||
libGeniusAI_la_OBJECTS = $(am_libGeniusAI_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
libGeniusAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libGeniusAI_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
$(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(libGeniusAI_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
@ -272,8 +273,10 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
vcmiai_LTLIBRARIES = libGeniusAI.la
|
||||
libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libGeniusAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libGeniusAI_la_SOURCES = \
|
||||
AIPriorities.cpp \
|
||||
@ -291,7 +294,8 @@ libGeniusAI_la_SOURCES = \
|
||||
neuralNetwork.cpp \
|
||||
neuralNetwork.h
|
||||
|
||||
all: all-am
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
@ -365,13 +369,13 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AIPriorities.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BattleHelper.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BattleLogic.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CGeniusAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DLLMain.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GeneralAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neuralNetwork.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-AIPriorities.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleHelper.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleLogic.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-DLLMain.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-GeneralAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@ -397,6 +401,62 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
libGeniusAI_la-AIPriorities.lo: AIPriorities.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-AIPriorities.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo $(DEPDIR)/libGeniusAI_la-AIPriorities.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='AIPriorities.cpp' object='libGeniusAI_la-AIPriorities.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp
|
||||
|
||||
libGeniusAI_la-BattleHelper.lo: BattleHelper.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleHelper.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo $(DEPDIR)/libGeniusAI_la-BattleHelper.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleHelper.cpp' object='libGeniusAI_la-BattleHelper.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp
|
||||
|
||||
libGeniusAI_la-BattleLogic.lo: BattleLogic.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleLogic.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo $(DEPDIR)/libGeniusAI_la-BattleLogic.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleLogic.cpp' object='libGeniusAI_la-BattleLogic.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp
|
||||
|
||||
libGeniusAI_la-CGeniusAI.lo: CGeniusAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-CGeniusAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo $(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CGeniusAI.cpp' object='libGeniusAI_la-CGeniusAI.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp
|
||||
|
||||
libGeniusAI_la-DLLMain.lo: DLLMain.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-DLLMain.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo $(DEPDIR)/libGeniusAI_la-DLLMain.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='DLLMain.cpp' object='libGeniusAI_la-DLLMain.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp
|
||||
|
||||
libGeniusAI_la-GeneralAI.lo: GeneralAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-GeneralAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo $(DEPDIR)/libGeniusAI_la-GeneralAI.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='GeneralAI.cpp' object='libGeniusAI_la-GeneralAI.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp
|
||||
|
||||
libGeniusAI_la-neuralNetwork.lo: neuralNetwork.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-neuralNetwork.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo $(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='neuralNetwork.cpp' object='libGeniusAI_la-neuralNetwork.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -486,13 +546,15 @@ distdir: $(DISTFILES)
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(vcmiaidir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
@ -517,6 +579,7 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-vcmiaiLTLIBRARIES \
|
||||
@ -588,7 +651,7 @@ ps-am:
|
||||
|
||||
uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
.MAKE: all check install install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-vcmiaiLTLIBRARIES ctags distclean \
|
||||
@ -604,6 +667,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
2
AI/GeniusAI/StdInc.cpp
Normal file
2
AI/GeniusAI/StdInc.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// Creates the precompiled header
|
||||
#include "StdInc.h"
|
7
AI/GeniusAI/StdInc.h
Normal file
7
AI/GeniusAI/StdInc.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Global.h"
|
||||
|
||||
// This header should be treated as a pre compiled header file(PCH) in the compiler building settings.
|
||||
|
||||
// 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>
|
@ -107,11 +107,11 @@
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@ -216,6 +216,11 @@
|
||||
<ClCompile Include="CGeniusAI.cpp" />
|
||||
<ClCompile Include="DLLMain.cpp" />
|
||||
<ClCompile Include="neuralNetwork.cpp" />
|
||||
<ClCompile Include="StdInc.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BattleHelper.h" />
|
||||
@ -225,6 +230,8 @@
|
||||
<ClInclude Include="CGeniusAI.h" />
|
||||
<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,5 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "neuralNetwork.h"
|
||||
//using namespace std;
|
||||
@ -8,18 +7,18 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
static float norm(void)//add desired mean, multiply to get desired SD
|
||||
static double norm(void)//add desired mean, multiply to get desired SD
|
||||
{
|
||||
static float kept = 0;
|
||||
static double kept = 0;
|
||||
static bool in = 0;
|
||||
if(!in)
|
||||
{
|
||||
float x = (rand()+1)/float(RAND_MAX+1);
|
||||
float f = sqrtf( - 2.0f * log(x) );
|
||||
x = (rand()+1)/float(RAND_MAX+1);
|
||||
kept = f * cosf( 2.0f * M_PI * x );
|
||||
double x = (rand() + 1) / static_cast<double>(RAND_MAX + 1);
|
||||
double f = sqrtf( - 2.0 * log(x) );
|
||||
x = (rand() + 1) / static_cast<double>(RAND_MAX + 1);
|
||||
kept = f * cosf( 2.0 * M_PI * x );
|
||||
in = true;
|
||||
return f * sinf( 2.0f * M_PI * x );
|
||||
return f * sinf( 2.0 * M_PI * x );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,13 +8,8 @@
|
||||
* Bobby Anguelov - takinginitiative.wordpress.com (2008)
|
||||
* MSN & email: banguelov@cs.up.ac.za
|
||||
********************************************************************/
|
||||
#ifndef NEURAL_NETWORK_H
|
||||
#define NEURAL_NETWORK_H
|
||||
#pragma once
|
||||
//standard includes
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
|
||||
@ -64,4 +59,3 @@ private:
|
||||
|
||||
std::istream & operator >> (std::istream &, neuralNetwork & ann);
|
||||
std::ostream & operator << (std::ostream &, const neuralNetwork & ann);
|
||||
#endif
|
@ -1,12 +1,13 @@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
vcmiai_LTLIBRARIES = libStupidAI.la
|
||||
libStupidAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libStupidAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libStupidAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libStupidAI_la_SOURCES = \
|
||||
main.cpp\
|
||||
stdafx.cpp\
|
||||
stdafx.h\
|
||||
StupidAI.cpp\
|
||||
StupidAI.h
|
||||
|
||||
|
@ -79,15 +79,16 @@ am__base_list = \
|
||||
am__installdirs = "$(DESTDIR)$(vcmiaidir)"
|
||||
LTLIBRARIES = $(vcmiai_LTLIBRARIES)
|
||||
libStupidAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la
|
||||
am_libStupidAI_la_OBJECTS = main.lo stdafx.lo StupidAI.lo
|
||||
am_libStupidAI_la_OBJECTS = libStupidAI_la-main.lo \
|
||||
libStupidAI_la-StupidAI.lo
|
||||
libStupidAI_la_OBJECTS = $(am_libStupidAI_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
libStupidAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libStupidAI_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
$(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(libStupidAI_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
@ -270,17 +271,18 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
vcmiaidir = $(VCMI_AI_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
vcmiai_LTLIBRARIES = libStupidAI.la
|
||||
libStupidAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
|
||||
libStupidAI_la_CXXFLAGS = -DVCMI_DLL
|
||||
libStupidAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
|
||||
libStupidAI_la_SOURCES = \
|
||||
main.cpp\
|
||||
stdafx.cpp\
|
||||
stdafx.h\
|
||||
StupidAI.cpp\
|
||||
StupidAI.h
|
||||
|
||||
all: all-am
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
@ -354,9 +356,8 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StupidAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdafx.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libStupidAI_la-StupidAI.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libStupidAI_la-main.Plo@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@ -382,6 +383,22 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
libStupidAI_la-main.lo: main.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -MT libStupidAI_la-main.lo -MD -MP -MF $(DEPDIR)/libStupidAI_la-main.Tpo -c -o libStupidAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libStupidAI_la-main.Tpo $(DEPDIR)/libStupidAI_la-main.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cpp' object='libStupidAI_la-main.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libStupidAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
|
||||
|
||||
libStupidAI_la-StupidAI.lo: StupidAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -MT libStupidAI_la-StupidAI.lo -MD -MP -MF $(DEPDIR)/libStupidAI_la-StupidAI.Tpo -c -o libStupidAI_la-StupidAI.lo `test -f 'StupidAI.cpp' || echo '$(srcdir)/'`StupidAI.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libStupidAI_la-StupidAI.Tpo $(DEPDIR)/libStupidAI_la-StupidAI.Plo
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='StupidAI.cpp' object='libStupidAI_la-StupidAI.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libStupidAI_la-StupidAI.lo `test -f 'StupidAI.cpp' || echo '$(srcdir)/'`StupidAI.cpp
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -471,13 +488,15 @@ distdir: $(DISTFILES)
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(vcmiaidir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
@ -502,6 +521,7 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-vcmiaiLTLIBRARIES \
|
||||
@ -573,7 +593,7 @@ ps-am:
|
||||
|
||||
uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
.MAKE: all check install install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-vcmiaiLTLIBRARIES ctags distclean \
|
||||
@ -589,6 +609,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-vcmiaiLTLIBRARIES
|
||||
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
2
AI/StupidAI/StdInc.cpp
Normal file
2
AI/StupidAI/StdInc.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// Creates the precompiled header
|
||||
#include "StdInc.h"
|
7
AI/StupidAI/StdInc.h
Normal file
7
AI/StupidAI/StdInc.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Global.h"
|
||||
|
||||
// This header should be treated as a pre compiled header file(PCH) in the compiler building settings.
|
||||
|
||||
// Here you can add specific libraries and macros which are specific to this project.
|
@ -1,12 +1,9 @@
|
||||
#include "stdafx.h"
|
||||
#include "StdInc.h"
|
||||
#include "../../lib/AI_Base.h"
|
||||
#include "StupidAI.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../../CCallback.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include <algorithm>
|
||||
//#include <boost/thread.hpp>
|
||||
|
||||
CBattleCallback * cbc;
|
||||
|
||||
@ -42,7 +39,7 @@ struct EnemyInfo
|
||||
{
|
||||
const CStack * s;
|
||||
int adi, adr;
|
||||
std::vector<THex> attackFrom; //for melee fight
|
||||
std::vector<BattleHex> attackFrom; //for melee fight
|
||||
EnemyInfo(const CStack * _s) : s(_s)
|
||||
{}
|
||||
void calcDmg(const CStack * ourStack)
|
||||
@ -63,10 +60,10 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2)
|
||||
return (ei1.adi-ei1.adr) < (ei2.adi - ei2.adr);
|
||||
}
|
||||
|
||||
int distToNearestNeighbour(THex hex, const std::vector<int> & dists, THex *chosenHex = NULL)
|
||||
int distToNearestNeighbour(BattleHex hex, const std::vector<int> & dists, BattleHex *chosenHex = NULL)
|
||||
{
|
||||
int ret = 1000000;
|
||||
BOOST_FOREACH(THex n, hex.neighbouringTiles())
|
||||
BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
|
||||
{
|
||||
if(dists[n] >= 0 && dists[n] < ret)
|
||||
{
|
||||
@ -84,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 THex &h1, const THex &h2)
|
||||
static bool willSecondHexBlockMoreEnemyShooters(const BattleHex &h1, const BattleHex &h2)
|
||||
{
|
||||
int shooters[2] = {0}; //count of shooters on hexes
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
BOOST_FOREACH(THex neighbour, (i ? h2 : h1).neighbouringTiles())
|
||||
BOOST_FOREACH(BattleHex neighbour, (i ? h2 : h1).neighbouringTiles())
|
||||
if(const CStack *s = cbc->battleGetStackByPos(neighbour))
|
||||
if(s->getCreature()->isShooting())
|
||||
shooters[i]++;
|
||||
@ -101,7 +98,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
||||
{
|
||||
//boost::this_thread::sleep(boost::posix_time::seconds(2));
|
||||
print("activeStack called");
|
||||
std::vector<THex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<BattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<int> dists = cb->battleGetDistances(stack);
|
||||
std::vector<EnemyInfo> enemiesShootable, enemiesReachable, enemiesUnreachable;
|
||||
|
||||
@ -113,7 +110,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_FOREACH(THex hex, avHexes)
|
||||
BOOST_FOREACH(BattleHex hex, avHexes)
|
||||
{
|
||||
if(CStack::isMeleeAttackPossible(stack, s, hex))
|
||||
{
|
||||
@ -146,7 +143,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
||||
else
|
||||
{
|
||||
const EnemyInfo &ei= *std::min_element(enemiesUnreachable.begin(), enemiesUnreachable.end(), boost::bind(isCloser, _1, _2, boost::ref(dists)));
|
||||
if(distToNearestNeighbour(ei.s->position, dists) < BFIELD_SIZE)
|
||||
if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE)
|
||||
{
|
||||
return goTowards(stack, ei.s->position);
|
||||
}
|
||||
@ -185,7 +182,7 @@ void CStupidAI::battleNewRound(int round)
|
||||
print("battleNewRound called");
|
||||
}
|
||||
|
||||
void CStupidAI::battleStackMoved(const CStack * stack, std::vector<THex> dest, int distance)
|
||||
void CStupidAI::battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance)
|
||||
{
|
||||
print("battleStackMoved called");;
|
||||
}
|
||||
@ -236,19 +233,19 @@ void CStupidAI::print(const std::string &text) const
|
||||
tlog0 << "CStupidAI [" << this <<"]: " << text << std::endl;
|
||||
}
|
||||
|
||||
BattleAction CStupidAI::goTowards(const CStack * stack, THex hex)
|
||||
BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex hex)
|
||||
{
|
||||
THex realDest = hex;
|
||||
THex predecessors[BFIELD_SIZE];
|
||||
BattleHex realDest = hex;
|
||||
BattleHex predecessors[GameConstants::BFIELD_SIZE];
|
||||
std::vector<int> dists = cb->battleGetDistances(stack, hex);
|
||||
if(distToNearestNeighbour(hex, dists, &realDest) > BFIELD_SIZE)
|
||||
if(distToNearestNeighbour(hex, dists, &realDest) > GameConstants::BFIELD_SIZE)
|
||||
{
|
||||
print("goTowards: Cannot reach");
|
||||
return BattleAction::makeDefend(stack);
|
||||
}
|
||||
|
||||
dists = cb->battleGetDistances(stack, realDest, predecessors);
|
||||
std::vector<THex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<BattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
|
||||
if(!avHexes.size())
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../lib/BattleHex.h"
|
||||
|
||||
class CStupidAI : public CBattleGameInterface
|
||||
{
|
||||
int side;
|
||||
@ -21,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<THex> dest, int distance) OVERRIDE;
|
||||
void battleStackMoved(const CStack * stack, std::vector<BattleHex> 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;
|
||||
@ -32,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, THex hex );
|
||||
BattleAction goTowards(const CStack * stack, BattleHex hex );
|
||||
};
|
||||
|
||||
|
@ -91,7 +91,8 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -155,17 +156,17 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<ClCompile Include="StdInc.cpp">
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='RD|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StupidAI.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="StdInc.h" />
|
||||
<ClInclude Include="StupidAI.h" />
|
||||
<ClInclude Include="..\..\Global.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "../../lib/AI_Base.h"
|
||||
#include "StupidAI.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define strcpy_s(a, b, c) strncpy(a, c, b)
|
||||
@ -8,28 +9,28 @@
|
||||
|
||||
const char *g_cszAiName = "Stupid AI 0.1";
|
||||
|
||||
extern "C" DLL_F_EXPORT int GetGlobalAiVersion()
|
||||
extern "C" DLL_EXPORT int GetGlobalAiVersion()
|
||||
{
|
||||
return AI_INTERFACE_VER;
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT void GetAiName(char* name)
|
||||
extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
{
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT char* GetAiNameS()
|
||||
extern "C" DLL_EXPORT char* GetAiNameS()
|
||||
{
|
||||
// need to be defined
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI()
|
||||
extern "C" DLL_EXPORT CBattleGameInterface* GetNewBattleAI()
|
||||
{
|
||||
return new CStupidAI();
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT void ReleaseBattleAI(CBattleGameInterface* i)
|
||||
extern "C" DLL_EXPORT void ReleaseBattleAI(CBattleGameInterface* i)
|
||||
{
|
||||
delete (CStupidAI*)i;
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
#include "stdafx.h"
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../AI_Base.h"
|
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "StdInc.h"
|
||||
#include "CCallback.h"
|
||||
|
||||
#include "lib/CCreatureHandler.h"
|
||||
#include "client/CGameInfo.h"
|
||||
#include "lib/CGameState.h"
|
||||
@ -15,11 +16,9 @@
|
||||
#include "lib/Connection.h"
|
||||
#include "lib/NetPacks.h"
|
||||
#include "client/mapHandler.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include "lib/CSpellHandler.h"
|
||||
#include "lib/CArtHandler.h"
|
||||
#include "lib/GameConstants.h"
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
@ -247,7 +246,7 @@ void CCallback::setSelection(const CArmedInstance * obj)
|
||||
ss.id = obj->id;
|
||||
sendRequest(&(CPackForClient&)ss);
|
||||
|
||||
if(obj->ID == HEROI_TYPE)
|
||||
if(obj->ID == GameConstants::HEROI_TYPE)
|
||||
{
|
||||
if(cl->pathInfo->hero != obj) //calculate new paths only if we selected a different hero
|
||||
cl->calculatePaths(static_cast<const CGHeroInstance *>(obj));
|
||||
|
13
CCallback.h
13
CCallback.h
@ -1,14 +1,5 @@
|
||||
#ifndef __CCALLBACK_H__
|
||||
#define __CCALLBACK_H__
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#ifdef _WIN32
|
||||
#include "tchar.h"
|
||||
#else
|
||||
#include "tchar_amigaos4.h" //XXX this is mingw header are we need this for something? for 'true'
|
||||
//support of unicode we should use ICU or some boost wraper areound it
|
||||
//(boost using this lib during compilation i dont know what for exactly)
|
||||
#endif
|
||||
|
||||
#include "lib/IGameCallback.h"
|
||||
|
||||
@ -148,5 +139,3 @@ public:
|
||||
//friends
|
||||
friend class CClient;
|
||||
};
|
||||
|
||||
#endif // __CCALLBACK_H__
|
||||
|
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"
|
@ -90,8 +90,9 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/Zm207 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -129,14 +130,20 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Global.h" />
|
||||
<ClInclude Include="ERMInterpreter.h" />
|
||||
<ClInclude Include="ERMParser.h" />
|
||||
<ClInclude Include="ERMScriptModule.h" />
|
||||
<ClInclude Include="StdInc.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ERMInterpreter.cpp" />
|
||||
<ClCompile Include="ERMParser.cpp" />
|
||||
<ClCompile Include="ERMScriptModule.cpp" />
|
||||
<ClCompile Include="StdInc.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -1,13 +1,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "ERMInterpreter.h"
|
||||
#include <cctype>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/assign/std/vector.hpp> // for 'operator+=()'
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
#include "../../lib/CHeroHandler.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
@ -372,13 +366,13 @@ void ERMInterpreter::scanForScripts()
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
//parser checking
|
||||
if(!exists(DATA_DIR "/Data/s/"))
|
||||
if(!exists(GameConstants::DATA_DIR + "/Data/s/"))
|
||||
{
|
||||
tlog3 << "Warning: Folder " DATA_DIR "/Data/s/ doesn't exist!\n";
|
||||
tlog3 << "Warning: Folder " << GameConstants::DATA_DIR << "/Data/s/ doesn't exist!\n";
|
||||
return;
|
||||
}
|
||||
directory_iterator enddir;
|
||||
for (directory_iterator dir(DATA_DIR "/Data/s"); dir!=enddir; dir++)
|
||||
for (directory_iterator dir(GameConstants::DATA_DIR + "/Data/s"); dir!=enddir; dir++)
|
||||
{
|
||||
if(is_regular(dir->status()))
|
||||
{
|
||||
@ -2293,7 +2287,7 @@ void IexpValStr::setTo( int val )
|
||||
}
|
||||
}
|
||||
|
||||
void IexpValStr::setTo( float val )
|
||||
void IexpValStr::setTo( double val )
|
||||
{
|
||||
DBG_PRINT("setting " << getName() << " to " << val);
|
||||
switch(type)
|
||||
@ -2337,7 +2331,7 @@ int IexpValStr::getInt() const
|
||||
}
|
||||
}
|
||||
|
||||
float IexpValStr::getFloat() const
|
||||
double IexpValStr::getFloat() const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "../../global.h"
|
||||
|
||||
|
||||
#include "ERMParser.h"
|
||||
#include "ERMScriptModule.h"
|
||||
|
||||
@ -621,10 +622,10 @@ public:
|
||||
enum {WRONGVAL, INT, INTVAR, FLOATVAR, STRINGVAR} type;
|
||||
void setTo(const IexpValStr & second);
|
||||
void setTo(int val);
|
||||
void setTo(float val);
|
||||
void setTo(double val);
|
||||
void setTo(const std::string & val);
|
||||
int getInt() const;
|
||||
float getFloat() const;
|
||||
double getFloat() const;
|
||||
std::string getString() const;
|
||||
|
||||
IexpValStr() : type(WRONGVAL)
|
||||
@ -796,7 +797,7 @@ class ERMInterpreter : public CScriptingModule
|
||||
VERMInterpreter::Trigger * curTrigger;
|
||||
VERMInterpreter::FunctionLocalVars * curFunc;
|
||||
static const int TRIG_FUNC_NUM = 30000;
|
||||
VERMInterpreter::FunctionLocalVars funcVars[TRIG_FUNC_NUM+1]; //+1 because we use [0] as a global set of y-vars
|
||||
VERMInterpreter::FunctionLocalVars funcVars[TRIG_FUNC_NUM + 1]; //+1 because we use [0] as a global set of y-vars
|
||||
VERMInterpreter::FunctionLocalVars * getFuncVars(int funNum); //0 is a global func-like set
|
||||
|
||||
IexpValStr getIexp(const ERM::TIexp & iexp) const;
|
||||
|
@ -1,25 +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/bind.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 <fstream>
|
||||
#include <boost/algorithm/string/trim.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,9 +1,5 @@
|
||||
#pragma once
|
||||
#include "../../global.h"
|
||||
#include <fstream>
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
|
||||
|
||||
/*
|
||||
* ERMParser.h, part of VCMI engine
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "ERMScriptModule.h"
|
||||
|
||||
#include "ERMInterpreter.h"
|
||||
|
||||
/*
|
||||
@ -21,12 +23,12 @@ CPrivilagedInfoCallback *icb;
|
||||
|
||||
const char *g_cszAiName = "(V)ERM interpreter";
|
||||
|
||||
extern "C" DLL_F_EXPORT void GetAiName(char* name)
|
||||
extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
{
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_F_EXPORT CScriptingModule* GetNewModule()
|
||||
extern "C" DLL_EXPORT CScriptingModule* GetNewModule()
|
||||
{
|
||||
return new ERMInterpreter();
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
vcmiscriptingdir = $(VCMI_SCRIPTING_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
vcmiscripting_LTLIBRARIES = libvcmiERM.la
|
||||
libvcmiERM_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@
|
||||
libvcmiERM_la_CXXFLAGS =
|
||||
libvcmiERM_la_CXXFLAGS = -DVCMI_DLL
|
||||
libvcmiERM_la_SOURCES = \
|
||||
ERMInterpreter.cpp \
|
||||
ERMInterpreter.h \
|
||||
|
@ -271,9 +271,10 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
vcmiscriptingdir = $(VCMI_SCRIPTING_LIBS_DIR)
|
||||
BUILT_SOURCES = StdInc.h.gch
|
||||
vcmiscripting_LTLIBRARIES = libvcmiERM.la
|
||||
libvcmiERM_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@
|
||||
libvcmiERM_la_CXXFLAGS =
|
||||
libvcmiERM_la_CXXFLAGS = -DVCMI_DLL
|
||||
libvcmiERM_la_SOURCES = \
|
||||
ERMInterpreter.cpp \
|
||||
ERMInterpreter.h \
|
||||
@ -282,7 +283,8 @@ libvcmiERM_la_SOURCES = \
|
||||
ERMScriptModule.cpp \
|
||||
ERMScriptModule.h
|
||||
|
||||
all: all-am
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
@ -497,13 +499,15 @@ distdir: $(DISTFILES)
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(vcmiscriptingdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
@ -528,6 +532,7 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-vcmiscriptingLTLIBRARIES \
|
||||
@ -599,7 +604,7 @@ ps-am:
|
||||
|
||||
uninstall-am: uninstall-vcmiscriptingLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
.MAKE: all check install install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-vcmiscriptingLTLIBRARIES ctags distclean \
|
||||
@ -615,6 +620,8 @@ uninstall-am: uninstall-vcmiscriptingLTLIBRARIES
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-vcmiscriptingLTLIBRARIES
|
||||
|
||||
StdInc.h.gch: StdInc.h
|
||||
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
2
Scripting/ERM/StdInc.cpp
Normal file
2
Scripting/ERM/StdInc.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// Creates the precompiled header
|
||||
#include "StdInc.h"
|
23
Scripting/ERM/StdInc.h
Normal file
23
Scripting/ERM/StdInc.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Global.h"
|
||||
|
||||
// This header should be treated as a pre compiled header file(PCH) in the compiler building settings.
|
||||
|
||||
// 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>
|
||||
|
||||
namespace spirit = boost::spirit;
|
||||
namespace qi = boost::spirit::qi;
|
||||
namespace ascii = spirit::ascii;
|
||||
namespace phoenix = boost::phoenix;
|
@ -4,8 +4,8 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_PropertySheetDisplayName>VCMI_global</_PropertySheetDisplayName>
|
||||
<LibraryPath>$(SolutionDir)..\libs\$(PlatformShortName);$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\Programme\Boost\boost_1_48_0\stage\lib;$(SolutionDir)..\libs\$(PlatformShortName);$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\Programme\Boost\boost_1_48_0;$(SolutionDir)..\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
|
4
aclocal.m4
vendored
4
aclocal.m4
vendored
@ -13,8 +13,8 @@
|
||||
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
|
||||
[m4_warning([this file was generated for autoconf 2.67.
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
|
||||
[m4_warning([this file was generated for autoconf 2.66.
|
||||
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically `autoreconf'.])])
|
||||
|
@ -1,697 +0,0 @@
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAnimation.h"
|
||||
//#include "CAdvmapInterface.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
//#include "../lib/CGeneralTextHandler.h"
|
||||
//#include "../lib/CTownHandler.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CConfigHandler.h"
|
||||
//#include "Graphics.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "CMessage.h"
|
||||
#include "CMusicHandler.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
/*
|
||||
* AdventureMapButton.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
CButtonBase::CButtonBase()
|
||||
{
|
||||
swappedImages = keepFrame = false;
|
||||
bitmapOffset = 0;
|
||||
state=NORMAL;
|
||||
image = NULL;
|
||||
text = NULL;
|
||||
}
|
||||
|
||||
CButtonBase::~CButtonBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CButtonBase::update()
|
||||
{
|
||||
if (text)
|
||||
{
|
||||
if (state == PRESSED)
|
||||
text->moveTo(Point(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));
|
||||
}
|
||||
|
||||
int newPos = (int)state + bitmapOffset;
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
|
||||
if (state == HIGHLIGHTED && image->size() < 4)
|
||||
newPos = image->size()-1;
|
||||
|
||||
if (swappedImages)
|
||||
{
|
||||
if (newPos == 0) newPos = 1;
|
||||
else if (newPos == 1) newPos = 0;
|
||||
}
|
||||
|
||||
if (!keepFrame)
|
||||
image->setFrame(newPos);
|
||||
|
||||
if (active)
|
||||
redraw();
|
||||
}
|
||||
|
||||
void CButtonBase::addTextOverlay( const std::string &Text, EFonts font, SDL_Color color)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
delChild(text);
|
||||
text = new CLabel(pos.w/2, pos.h/2, font, CENTER, color, Text);
|
||||
update();
|
||||
}
|
||||
|
||||
void CButtonBase::setOffset(int newOffset)
|
||||
{
|
||||
if (bitmapOffset == newOffset)
|
||||
return;
|
||||
bitmapOffset = newOffset;
|
||||
update();
|
||||
}
|
||||
|
||||
void CButtonBase::setState(ButtonState newState)
|
||||
{
|
||||
if (state == newState)
|
||||
return;
|
||||
state = newState;
|
||||
update();
|
||||
}
|
||||
|
||||
CButtonBase::ButtonState CButtonBase::getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
bool CButtonBase::isBlocked()
|
||||
{
|
||||
return state == BLOCKED;
|
||||
}
|
||||
|
||||
bool CButtonBase::isHighlighted()
|
||||
{
|
||||
return state == HIGHLIGHTED;
|
||||
}
|
||||
|
||||
void CButtonBase::block(bool on)
|
||||
{
|
||||
setState(on?BLOCKED:NORMAL);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton ()
|
||||
{
|
||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||
used = LCLICK | RCLICK | HOVER | KEYBOARD;
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName,int key, std::vector<std::string> * add, bool playerColoredButton )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(Callback, pom, HelpBox, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key/*=0*/ )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(Callback, pom, HelpBox, info->playerColoured, info->defName, &info->additionalDefs, info->x, info->y, key);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = help.first;
|
||||
init(Callback, pom, help.second, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
void AdventureMapButton::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down)
|
||||
{
|
||||
if (!soundDisabled)
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
}
|
||||
else if(hoverable && hovered)
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
|
||||
if (actOnDown && down)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
else if (!actOnDown && previousState && (down==false))
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
void AdventureMapButton::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(down && helpBox.size()) //there is no point to show window with nothing inside...
|
||||
CRClickPopup::createAndPush(helpBox);
|
||||
}
|
||||
|
||||
void AdventureMapButton::hover (bool on)
|
||||
{
|
||||
if(hoverable)
|
||||
{
|
||||
if(on)
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
}
|
||||
|
||||
if(pressedL && on)
|
||||
setState(PRESSED);
|
||||
|
||||
std::string *name = (vstd::contains(hoverTexts,getState()))
|
||||
? (&hoverTexts[getState()])
|
||||
: (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : NULL);
|
||||
if(name && name->size() && !isBlocked()) //if there is no name, there is nohing to display also
|
||||
{
|
||||
if (LOCPLINT && LOCPLINT->battleInt) //for battle buttons
|
||||
{
|
||||
if(on && LOCPLINT->battleInt->console->alterTxt == "")
|
||||
{
|
||||
LOCPLINT->battleInt->console->alterTxt = *name;
|
||||
LOCPLINT->battleInt->console->whoSetAlter = 1;
|
||||
}
|
||||
else if (LOCPLINT->battleInt->console->alterTxt == *name)
|
||||
{
|
||||
LOCPLINT->battleInt->console->alterTxt = "";
|
||||
LOCPLINT->battleInt->console->whoSetAlter = 0;
|
||||
}
|
||||
}
|
||||
else if(GH.statusbar) //for other buttons
|
||||
{
|
||||
if (on)
|
||||
GH.statusbar->print(*name);
|
||||
else if ( GH.statusbar->getCurrent()==(*name) )
|
||||
GH.statusbar->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
|
||||
{
|
||||
currentImage = -1;
|
||||
used = LCLICK | RCLICK | HOVER | KEYBOARD;
|
||||
callback = Callback;
|
||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||
assignedKeys.insert(key);
|
||||
hoverTexts = Name;
|
||||
helpBox=HelpBox;
|
||||
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
|
||||
if (!defName.empty())
|
||||
imageNames.push_back(defName);
|
||||
if (add)
|
||||
for (size_t i=0; i<add->size();i++ )
|
||||
imageNames.push_back(add->at(i));
|
||||
setIndex(0, playerColoredButton);
|
||||
}
|
||||
|
||||
void AdventureMapButton::setIndex(size_t index, bool playerColoredButton)
|
||||
{
|
||||
if (index == currentImage || index>=imageNames.size())
|
||||
return;
|
||||
currentImage = index;
|
||||
setImage(new CAnimation(imageNames[index]), playerColoredButton);
|
||||
}
|
||||
|
||||
void AdventureMapButton::setImage(CAnimation* anim, bool playerColoredButton)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
|
||||
if (image && active)
|
||||
image->deactivate();
|
||||
delChild(image);
|
||||
image = new CAnimImage(anim, getState());
|
||||
if (active)
|
||||
image->activate();
|
||||
if (playerColoredButton)
|
||||
image->playerColored(LOCPLINT->playerID);
|
||||
|
||||
pos.w = image->pos.w;
|
||||
pos.h = image->pos.h;
|
||||
}
|
||||
|
||||
void AdventureMapButton::setPlayerColor(int player)
|
||||
{
|
||||
if (image)
|
||||
image->playerColored(player);
|
||||
}
|
||||
|
||||
void AdventureMapButton::showAll(SDL_Surface *to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
||||
if (borderEnabled && borderColor.unused == 0)
|
||||
CSDL_Ext::drawBorder(to, pos.x - 1, pos.y - 1, pos.w + 2, pos.h + 2, int3(borderColor.r, borderColor.g, borderColor.b));
|
||||
}
|
||||
|
||||
void CHighlightableButton::select(bool on)
|
||||
{
|
||||
selected = on;
|
||||
if (on)
|
||||
{
|
||||
setState(HIGHLIGHTED);
|
||||
callback();
|
||||
borderEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setState(NORMAL);
|
||||
callback2();
|
||||
borderEnabled = false;
|
||||
}
|
||||
|
||||
if(hoverTexts.size()>1)
|
||||
{
|
||||
hover(false);
|
||||
hover(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CHighlightableButton::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down && !(onlyOn && isHighlighted()))
|
||||
{
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
}
|
||||
|
||||
if(previousState && down == false && getState() == PRESSED)
|
||||
{
|
||||
//if(!onlyOn || !isHighlighted())
|
||||
select(!selected);
|
||||
}
|
||||
}
|
||||
|
||||
CHighlightableButton::CHighlightableButton( const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
|
||||
: onlyOn(false), selected(false), callback2(onDeselect)
|
||||
{
|
||||
init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,key);
|
||||
}
|
||||
|
||||
CHighlightableButton::CHighlightableButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
|
||||
: onlyOn(false), selected(false) // TODO: callback2(???)
|
||||
{
|
||||
ID = myid;
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = help.first;
|
||||
init(onSelect, pom, help.second, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
CHighlightableButton::CHighlightableButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
|
||||
: onlyOn(false), selected(false) // TODO: callback2(???)
|
||||
{
|
||||
ID = myid;
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(onSelect, pom,HelpBox, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::addButton(CHighlightableButton* bt)
|
||||
{
|
||||
if (bt->parent)
|
||||
bt->parent->removeChild(bt);
|
||||
addChild(bt);
|
||||
bt->recActions = defActions;//FIXME: not needed?
|
||||
|
||||
bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
|
||||
bt->onlyOn = true;
|
||||
buttons.push_back(bt);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect, int key)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
|
||||
if(musicLike)
|
||||
{
|
||||
if (buttons.size() > 3)
|
||||
bt->setOffset(buttons.size()-3);
|
||||
}
|
||||
bt->ID = uid;
|
||||
bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
|
||||
bt->onlyOn = true;
|
||||
buttons.push_back(bt);
|
||||
}
|
||||
|
||||
CHighlightableButtonsGroup::CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons)
|
||||
: onChange(OnChange), musicLike(musicLikeButtons)
|
||||
{}
|
||||
|
||||
CHighlightableButtonsGroup::~CHighlightableButtonsGroup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::select(int id, bool mode)
|
||||
{
|
||||
CHighlightableButton *bt = NULL;
|
||||
if(mode)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size() && !bt; ++i)
|
||||
if (buttons[i]->ID == id)
|
||||
bt = buttons[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = buttons[id];
|
||||
}
|
||||
bt->select(true);
|
||||
selectionChanged(bt->ID);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::selectionChanged(int to)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->ID!=to && buttons[i]->isHighlighted())
|
||||
buttons[i]->select(false);
|
||||
onChange(to);
|
||||
if (parent)
|
||||
parent->redraw();
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::show(SDL_Surface * to )
|
||||
{
|
||||
if (musicLike)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->isHighlighted())
|
||||
buttons[i]->show(to);
|
||||
}
|
||||
else
|
||||
CIntObject::show(to);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::showAll( SDL_Surface * to )
|
||||
{
|
||||
if (musicLike)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->isHighlighted())
|
||||
buttons[i]->showAll(to);
|
||||
}
|
||||
else
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::block( ui8 on )
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
{
|
||||
buttons[i]->block(on);
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::sliderClicked()
|
||||
{
|
||||
if(!(active & MOVE))
|
||||
{
|
||||
activateMouseMove();
|
||||
used |= MOVE;
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
float v = 0;
|
||||
if(horizontal)
|
||||
{
|
||||
if( std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2 )
|
||||
return;
|
||||
v = sEvent.x - pos.x - 24;
|
||||
v *= positions;
|
||||
v /= (pos.w - 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2+40 || std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2 )
|
||||
return;
|
||||
v = sEvent.y - pos.y - 24;
|
||||
v *= positions;
|
||||
v /= (pos.h - 48);
|
||||
}
|
||||
v += 0.5f;
|
||||
if(v!=value)
|
||||
{
|
||||
moveTo(v);
|
||||
redrawSlider();
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::redrawSlider()
|
||||
{
|
||||
//slider->show(screenBuf);
|
||||
}
|
||||
|
||||
void CSlider::moveLeft()
|
||||
{
|
||||
moveTo(value-1);
|
||||
}
|
||||
|
||||
void CSlider::moveRight()
|
||||
{
|
||||
moveTo(value+1);
|
||||
}
|
||||
|
||||
void CSlider::moveTo(int to)
|
||||
{
|
||||
amax(to, 0);
|
||||
amin(to, positions);
|
||||
|
||||
//same, old position?
|
||||
if(value == to)
|
||||
return;
|
||||
|
||||
value = to;
|
||||
if(horizontal)
|
||||
{
|
||||
if(positions)
|
||||
{
|
||||
float part = (float)to/positions;
|
||||
part*=(pos.w-48);
|
||||
int newPos = part + pos.x + 16 - slider->pos.x;
|
||||
slider->moveBy(Point(newPos, 0));
|
||||
}
|
||||
else
|
||||
slider->moveTo(Point(pos.x+16, pos.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(positions)
|
||||
{
|
||||
float part = (float)to/positions;
|
||||
part*=(pos.h-48);
|
||||
int newPos = part + pos.y + 16 - slider->pos.y;
|
||||
slider->moveBy(Point(0, newPos));
|
||||
}
|
||||
else
|
||||
slider->moveTo(Point(pos.x, pos.y+16));
|
||||
}
|
||||
|
||||
if(moved)
|
||||
moved(to);
|
||||
}
|
||||
|
||||
void CSlider::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(down && !slider->isBlocked())
|
||||
{
|
||||
float pw = 0;
|
||||
float rw = 0;
|
||||
if(horizontal)
|
||||
{
|
||||
pw = GH.current->motion.x-pos.x-25;
|
||||
rw = pw / ((float)(pos.w-48));
|
||||
}
|
||||
else
|
||||
{
|
||||
pw = GH.current->motion.y-pos.y-24;
|
||||
rw = pw / ((float)(pos.h-48));
|
||||
}
|
||||
if(pw < -8 || pw > (horizontal ? pos.w : pos.h) - 40)
|
||||
return;
|
||||
// if (rw>1) return;
|
||||
// if (rw<0) return;
|
||||
slider->clickLeft(true, slider->pressedL);
|
||||
moveTo(rw * positions + 0.5f);
|
||||
return;
|
||||
}
|
||||
if(active & MOVE)
|
||||
{
|
||||
deactivateMouseMove();
|
||||
used &= ~MOVE;
|
||||
}
|
||||
}
|
||||
|
||||
CSlider::~CSlider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
|
||||
:capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
setAmount(amount);
|
||||
|
||||
used = LCLICK;
|
||||
strongInterest = true;
|
||||
|
||||
|
||||
left = new AdventureMapButton();
|
||||
right = new AdventureMapButton();
|
||||
slider = new AdventureMapButton();
|
||||
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
|
||||
if(horizontal)
|
||||
{
|
||||
left->pos.y = slider->pos.y = right->pos.y = pos.y;
|
||||
left->pos.x = pos.x;
|
||||
right->pos.x = pos.x + totalw - 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
left->pos.x = slider->pos.x = right->pos.x = pos.x;
|
||||
left->pos.y = pos.y;
|
||||
right->pos.y = pos.y + totalw - 16;
|
||||
}
|
||||
|
||||
left->callback = boost::bind(&CSlider::moveLeft,this);
|
||||
right->callback = boost::bind(&CSlider::moveRight,this);
|
||||
slider->callback = boost::bind(&CSlider::sliderClicked,this);
|
||||
left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
|
||||
if(horizontal)
|
||||
{
|
||||
pos.h = 16;
|
||||
pos.w = totalw;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = 16;
|
||||
pos.h = totalw;
|
||||
}
|
||||
|
||||
if(style == 0)
|
||||
{
|
||||
std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
|
||||
CAnimation *animLeft = new CAnimation(name);
|
||||
left->setImage(animLeft);
|
||||
left->setOffset(0);
|
||||
|
||||
CAnimation *animRight = new CAnimation(name);
|
||||
right->setImage(animRight);
|
||||
right->setOffset(2);
|
||||
|
||||
CAnimation *animSlider = new CAnimation(name);
|
||||
slider->setImage(animSlider);
|
||||
slider->setOffset(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
left->setImage(new CAnimation(horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF"));
|
||||
right->setImage(new CAnimation(horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF"));
|
||||
slider->setImage(new CAnimation("SCNRBSL.DEF"));
|
||||
}
|
||||
slider->actOnDown = true;
|
||||
slider->soundDisabled = true;
|
||||
left->soundDisabled = true;
|
||||
right->soundDisabled = true;
|
||||
|
||||
value = -1;
|
||||
moveTo(Value);
|
||||
}
|
||||
|
||||
void CSlider::block( bool on )
|
||||
{
|
||||
left->block(on);
|
||||
right->block(on);
|
||||
slider->block(on);
|
||||
}
|
||||
|
||||
void CSlider::setAmount( int to )
|
||||
{
|
||||
amount = to;
|
||||
positions = to - capacity;
|
||||
amax(positions, 0);
|
||||
}
|
||||
|
||||
void CSlider::showAll(SDL_Surface * to)
|
||||
{
|
||||
CSDL_Ext::fillRect(to, &pos, 0);
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CSlider::wheelScrolled(bool down, bool in)
|
||||
{
|
||||
moveTo(value + 3 * (down ? +1 : -1));
|
||||
}
|
||||
|
||||
void CSlider::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(key.state != SDL_PRESSED) return;
|
||||
|
||||
int moveDest = 0;
|
||||
switch(key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
moveDest = value - 1;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
moveDest = value + 1;
|
||||
break;
|
||||
case SDLK_PAGEUP:
|
||||
moveDest = value - capacity + 1;
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
moveDest = value + capacity - 1;
|
||||
break;
|
||||
case SDLK_HOME:
|
||||
moveDest = 0;
|
||||
break;
|
||||
case SDLK_END:
|
||||
moveDest = amount - capacity;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
moveTo(moveDest);
|
||||
}
|
||||
|
||||
void CSlider::moveToMax()
|
||||
{
|
||||
moveTo(amount);
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
#ifndef __ADVENTUREMAPBUTTON_H__
|
||||
#define __ADVENTUREMAPBUTTON_H__
|
||||
|
||||
#include "FunctionList.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include "GUIBase.h"
|
||||
|
||||
/*
|
||||
* AdventureMapButton.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
|
||||
*
|
||||
*/
|
||||
|
||||
extern SDL_Color tytulowy, tlo, zwykly ;
|
||||
|
||||
class CAnimation;
|
||||
class CAnimImage;
|
||||
class CLabel;
|
||||
|
||||
namespace config{struct ButtonInfo;}
|
||||
|
||||
/// Base class for buttons.
|
||||
class CButtonBase : public KeyShortcut
|
||||
{
|
||||
public:
|
||||
enum ButtonState
|
||||
{
|
||||
NORMAL=0,
|
||||
PRESSED=1,
|
||||
BLOCKED=2,
|
||||
HIGHLIGHTED=3
|
||||
};
|
||||
private:
|
||||
int bitmapOffset; // base offset of visible bitmap from animation
|
||||
ButtonState state;//current state of button from enum
|
||||
|
||||
public:
|
||||
bool swappedImages,//fix for some buttons: normal and pressed image are swapped
|
||||
keepFrame; // don't change visual representation
|
||||
|
||||
void addTextOverlay(const std::string &Text, EFonts font, SDL_Color color = zwykly);
|
||||
void update();//to refresh button after image or text change
|
||||
|
||||
void setOffset(int newOffset);
|
||||
void setState(ButtonState newState);
|
||||
ButtonState getState();
|
||||
|
||||
//just to make code clearer
|
||||
void block(bool on);
|
||||
bool isBlocked();
|
||||
bool isHighlighted();
|
||||
|
||||
CAnimImage * image; //image for this button
|
||||
CLabel * text;//text overlay
|
||||
|
||||
CButtonBase(); //c-tor
|
||||
virtual ~CButtonBase(); //d-tor
|
||||
};
|
||||
|
||||
/// Typical Heroes 3 button which can be inactive or active and can
|
||||
/// hold further information if you right-click it
|
||||
class AdventureMapButton : public CButtonBase
|
||||
{
|
||||
std::vector<std::string> imageNames;//store list of images that can be used by this button
|
||||
size_t currentImage;
|
||||
public:
|
||||
std::map<int, std::string> hoverTexts; //text for statusbar
|
||||
std::string helpBox; //for right-click help
|
||||
CFunctionList<void()> callback;
|
||||
bool actOnDown,//runs when mouse is pressed down over it, not when up
|
||||
hoverable,//if true, button will be highlighted when hovered
|
||||
borderEnabled,
|
||||
soundDisabled;
|
||||
SDL_Color borderColor;
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
void hover (bool on);
|
||||
|
||||
AdventureMapButton(); //c-tor
|
||||
AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
AdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key=0);//c-tor
|
||||
|
||||
void init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key );
|
||||
|
||||
void setIndex(size_t index, bool playerColoredButton=false);
|
||||
void setImage(CAnimation* anim, bool playerColoredButton=false);
|
||||
void setPlayerColor(int player);
|
||||
void showAll(SDL_Surface *to);
|
||||
};
|
||||
|
||||
/// A button which can be selected/deselected
|
||||
class CHighlightableButton
|
||||
: public AdventureMapButton
|
||||
{
|
||||
public:
|
||||
CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key=0);
|
||||
CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
bool onlyOn;//button can not be de-selected
|
||||
bool selected;//state of highlightable button
|
||||
int ID; //for identification
|
||||
CFunctionList<void()> callback2; //when de-selecting
|
||||
void select(bool on);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
};
|
||||
|
||||
/// A group of buttons where one button can be selected
|
||||
class CHighlightableButtonsGroup : public CIntObject
|
||||
{
|
||||
public:
|
||||
CFunctionList2<void(int)> onChange; //called when changing selected button with new button's id
|
||||
std::vector<CHighlightableButton*> buttons;
|
||||
bool musicLike; //determines the behaviour of this group
|
||||
|
||||
//void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid);
|
||||
void addButton(CHighlightableButton* bt);//add existing button, it'll be deleted by CHighlightableButtonsGroup destructor
|
||||
void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect=0, int key=0); //creates new button
|
||||
CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons = false);
|
||||
~CHighlightableButtonsGroup();
|
||||
void select(int id, bool mode); //mode==0: id is serial; mode==1: id is unique button id
|
||||
void selectionChanged(int to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void block(ui8 on);
|
||||
};
|
||||
|
||||
/// A typical slider which can be orientated horizontally/vertically.
|
||||
class CSlider : public CIntObject
|
||||
{
|
||||
public:
|
||||
AdventureMapButton *left, *right, *slider; //if vertical then left=up
|
||||
int capacity,//how many elements can be active at same time
|
||||
amount, //how many elements
|
||||
positions, //number of highest position (0 if there is only one)
|
||||
value; //first active element
|
||||
bool horizontal;
|
||||
bool wheelScrolling;
|
||||
bool keyScrolling;
|
||||
|
||||
boost::function<void(int)> moved;
|
||||
|
||||
void redrawSlider();
|
||||
void sliderClicked();
|
||||
void moveLeft();
|
||||
void moveRight();
|
||||
void moveTo(int to);
|
||||
void block(bool on);
|
||||
void setAmount(int to);
|
||||
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void wheelScrolled(bool down, bool in);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void showAll(SDL_Surface * to);
|
||||
|
||||
CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount,
|
||||
int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue
|
||||
~CSlider();
|
||||
void moveToMax();
|
||||
};
|
||||
|
||||
#endif // __ADVENTUREMAPBUTTON_H__
|
1075
client/BattleInterface/CBattleAnimations.cpp
Normal file
1075
client/BattleInterface/CBattleAnimations.cpp
Normal file
File diff suppressed because it is too large
Load Diff
221
client/BattleInterface/CBattleAnimations.h
Normal file
221
client/BattleInterface/CBattleAnimations.h
Normal file
@ -0,0 +1,221 @@
|
||||
#pragma once
|
||||
|
||||
#include "../CAnimation.h"
|
||||
#include "../../lib/BattleHex.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
class CCreatureAnimation;
|
||||
struct CatapultProjectileInfo;
|
||||
struct StackAttackedInfo;
|
||||
|
||||
/*
|
||||
* CBattleAnimations.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
|
||||
*
|
||||
*/
|
||||
|
||||
/// Base class of battle animations
|
||||
class CBattleAnimation
|
||||
{
|
||||
protected:
|
||||
CBattleInterface * owner;
|
||||
public:
|
||||
virtual bool init()=0; //to be called - if returned false, call again until returns true
|
||||
virtual void nextFrame()=0; //call every new frame
|
||||
virtual void endAnim(); //to be called mostly internally; in this class it removes animation from pendingAnims list
|
||||
|
||||
bool isEarliest(bool perStackConcurrency); //determines if this animation is earliest of all
|
||||
|
||||
ui32 ID; //unique identifier
|
||||
|
||||
CBattleAnimation(CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
/// Sub-class which is responsible for managing the battle stack animation.
|
||||
class CBattleStackAnimation : public CBattleAnimation
|
||||
{
|
||||
public:
|
||||
const CStack * stack; //id of stack whose animation it is
|
||||
|
||||
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
|
||||
static bool isToReverseHlp(BattleHex hexFrom, BattleHex hexTo, bool curDir); //helper for isToReverse
|
||||
static bool isToReverse(BattleHex hexFrom, BattleHex 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
|
||||
};
|
||||
|
||||
/// This class is responsible for managing the battle attack animation
|
||||
class CAttackAnimation : public CBattleStackAnimation
|
||||
{
|
||||
protected:
|
||||
BattleHex dest; //attacked hex
|
||||
bool shooting;
|
||||
CCreatureAnim::EAnimType group; //if shooting is true, print this animation group
|
||||
const CStack *attackedStack;
|
||||
const CStack *attackingStack;
|
||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||
public:
|
||||
void nextFrame();
|
||||
bool checkInitialConditions();
|
||||
|
||||
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender);
|
||||
};
|
||||
|
||||
/// Animation of a defending unit
|
||||
class CDefenceAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
//std::vector<StackAttackedInfo> attackedInfos;
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
class CDummyAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
int counter;
|
||||
int howMany;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDummyAnimation(CBattleInterface * _owner, int howManyFrames);
|
||||
};
|
||||
|
||||
/// Hand-to-hand attack
|
||||
class CMeleeAttackAnimation : public CAttackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked);
|
||||
};
|
||||
|
||||
/// Move animation of a creature
|
||||
class CMovementAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
std::vector<BattleHex> destTiles; //destination
|
||||
BattleHex nextHex;
|
||||
ui32 nextPos;
|
||||
int distance;
|
||||
double stepX, stepY; //how far stack is moved in one frame
|
||||
double posX, posY;
|
||||
int steps, whichStep;
|
||||
int curStackPos; //position of stack before move
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance);
|
||||
};
|
||||
|
||||
/// Move end animation of a creature
|
||||
class CMovementEndAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
BattleHex destinationTile;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex destTile);
|
||||
};
|
||||
|
||||
/// Move start animation of a creature
|
||||
class CMovementStartAnimation : public CBattleStackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
};
|
||||
|
||||
/// Class responsible for animation of stack chaning direction (left <-> right)
|
||||
class CReverseAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
int partOfAnim; //1 - first, 2 - second
|
||||
bool secondPartSetup;
|
||||
BattleHex hex;
|
||||
public:
|
||||
bool priority; //true - high, false - low
|
||||
bool init();
|
||||
void nextFrame();
|
||||
|
||||
void setupSecondPart();
|
||||
void endAnim();
|
||||
|
||||
CReverseAnimation(CBattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority);
|
||||
};
|
||||
|
||||
/// Small struct which contains information about the position and the velocity of a projectile
|
||||
struct ProjectileInfo
|
||||
{
|
||||
double x, y; //position on the screen
|
||||
double dx, dy; //change in position in one step
|
||||
int step, lastStep; //to know when finish showing this projectile
|
||||
int creID; //ID of creature that shot this projectile
|
||||
int stackID; //ID of stack
|
||||
int frameNum; //frame to display form projectile animation
|
||||
bool spin; //if true, frameNum will be increased
|
||||
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
|
||||
bool reverse; //if true, projectile will be flipped by vertical asix
|
||||
CatapultProjectileInfo * catapultInfo; // holds info about the parabolic trajectory of the cannon
|
||||
};
|
||||
|
||||
/// Shooting attack
|
||||
class CShootingAnimation : public CAttackAnimation
|
||||
{
|
||||
private:
|
||||
int catapultDamage;
|
||||
bool catapult;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
//last two params only for catapult attacks
|
||||
CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest,
|
||||
const CStack * _attacked, bool _catapult = false, int _catapultDmg = 0);
|
||||
};
|
||||
|
||||
/// This class manages a spell effect animation
|
||||
class CSpellEffectAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
ui32 effect;
|
||||
BattleHex destTile;
|
||||
std::string customAnim;
|
||||
int x, y, dx, dy;
|
||||
bool Vflip;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, BattleHex _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);
|
||||
};
|
File diff suppressed because it is too large
Load Diff
267
client/BattleInterface/CBattleInterface.h
Normal file
267
client/BattleInterface/CBattleInterface.h
Normal file
@ -0,0 +1,267 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../../lib/CCreatureSet.h"
|
||||
#include "../../lib/ConstTransitivePtr.h" //may be reundant
|
||||
#include "../CAnimation.h"
|
||||
#include "../../lib/GameConstants.h"
|
||||
|
||||
/*
|
||||
* CBattleInterface.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 CLabel;
|
||||
class CCreatureSet;
|
||||
class CGHeroInstance;
|
||||
class CDefHandler;
|
||||
class CStack;
|
||||
class CCallback;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
struct BattleResult;
|
||||
struct BattleSpellCast;
|
||||
struct CObstacleInstance;
|
||||
template <typename T> struct CondSh;
|
||||
struct SetStackEffect;;
|
||||
struct BattleAction;
|
||||
class CGTownInstance;
|
||||
struct CatapultAttack;
|
||||
struct CatapultProjectileInfo;
|
||||
struct BattleTriggerEffect;
|
||||
class CBattleAnimation;
|
||||
class CBattleHero;
|
||||
class CBattleConsole;
|
||||
class CBattleResultWindow;
|
||||
class CStackQueue;
|
||||
class CPlayerInterface;
|
||||
class CCreatureAnimation;
|
||||
struct ProjectileInfo;
|
||||
class CClickableHex;
|
||||
struct BattleHex;
|
||||
|
||||
/// Class which manages the locked hex fields that are blocked e.g. by obstacles
|
||||
class CBattleObstacle
|
||||
{
|
||||
std::vector<int> lockedHexes;
|
||||
};
|
||||
|
||||
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
|
||||
struct StackAttackedInfo
|
||||
{
|
||||
const CStack * defender; //attacked stack
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
bool rebirth; //if true, play rebirth animation after all
|
||||
};
|
||||
|
||||
/// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
|
||||
struct BattleEffect
|
||||
{
|
||||
int x, y; //position on the screen
|
||||
int frame, maxFrame;
|
||||
CDefHandler * anim; //animation to display
|
||||
int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
|
||||
};
|
||||
|
||||
/// Small struct which is needed for drawing the parabolic trajectory of the catapult cannon
|
||||
struct CatapultProjectileInfo
|
||||
{
|
||||
const double facA, facB, facC;
|
||||
const int fromX, toX;
|
||||
|
||||
CatapultProjectileInfo() : facA(0), facB(0), facC(0), fromX(0), toX(0) { };
|
||||
CatapultProjectileInfo(double factorA, double factorB, double factorC, int fromXX, int toXX) : facA(factorA), facB(factorB), facC(factorC),
|
||||
fromX(fromXX), toX(toXX) { };
|
||||
|
||||
double calculateY(double x);
|
||||
};
|
||||
|
||||
/// Big class which handles the overall battle interface actions and it is also responsible for
|
||||
/// drawing everything correctly.
|
||||
class CBattleInterface : public CIntObject
|
||||
{
|
||||
enum SpellSelectionType
|
||||
{
|
||||
ANY_LOCATION = 0, FRIENDLY_CREATURE, HOSTILE_CREATURE, ANY_CREATURE, OBSTACLE, TELEPORT, NO_LOCATION = -1, STACK_SPELL_CANCELLED = -2
|
||||
};
|
||||
private:
|
||||
SDL_Surface * background, * menu, * amountNormal, * amountNegative, * amountPositive, * amountEffNeutral, * cellBorders, * backgroundWithHexes;
|
||||
CAdventureMapButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
|
||||
* bWait, * bDefence, * bConsoleUp, * bConsoleDown, *btactNext, *btactEnd;
|
||||
CBattleConsole * console;
|
||||
CBattleHero * attackingHero, * defendingHero; //fighting heroes
|
||||
CStackQueue *queue;
|
||||
const CCreatureSet *army1, *army2; //copy of initial armies (for result window)
|
||||
const CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
|
||||
std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
|
||||
std::map< int, CDefHandler * > idToProjectile; //projectiles of creatures (creatureID, defhandler)
|
||||
std::map< int, CDefHandler * > idToObstacle; //obstacles located on the battlefield
|
||||
std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation>
|
||||
ui8 animCount;
|
||||
const CStack * activeStack; //number of active stack; NULL - no one
|
||||
const CStack * stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; NULL of none
|
||||
void activateStack(); //sets activeStack to stackToActivate etc.
|
||||
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<BattleHex> 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
|
||||
int currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
|
||||
int attackingHex; //hex from which the stack would perform attack with current cursor
|
||||
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
|
||||
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
|
||||
SpellSelectionType spellSelMode;
|
||||
BattleAction * spellToCast; //spell for which player is choosing destination
|
||||
ui32 creatureSpellToCast;
|
||||
void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
|
||||
|
||||
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<BattleHex, 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<ProjectileInfo> projectiles; //projectiles flying on battlefield
|
||||
void projectileShowHelper(SDL_Surface * to); //prints projectiles present on the battlefield
|
||||
void giveCommand(ui8 action, BattleHex tile, ui32 stack, si32 additional=-1);
|
||||
bool isTileAttackable(const BattleHex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
|
||||
bool blockedByObstacle(BattleHex hex) const;
|
||||
bool isCatapultAttackable(BattleHex hex) const; //returns true if given tile can be attacked by catapult
|
||||
|
||||
std::list<BattleEffect> battleEffects; //different animations to display on the screen like spell effects
|
||||
|
||||
/// Class which is responsible for drawing the wall of a siege during battle
|
||||
class SiegeHelper
|
||||
{
|
||||
private:
|
||||
static std::string townTypeInfixes[GameConstants::F_NUMBER]; //for internal use only - to build filenames
|
||||
SDL_Surface* walls[18];
|
||||
const CBattleInterface * owner;
|
||||
public:
|
||||
const CGTownInstance * town; //besieged town
|
||||
|
||||
SiegeHelper(const CGTownInstance * siegeTown, const CBattleInterface * _owner); //c-tor
|
||||
~SiegeHelper(); //d-tor
|
||||
|
||||
//filename getters
|
||||
std::string getSiegeName(ui16 what, ui16 additInfo = 1) const; //what: 0 - background, 1 - background wall, 2 - keep, 3 - bottom tower, 4 - bottom wall, 5 - below gate, 6 - over gate, 7 - upper wall, 8 - uppert tower, 9 - gate, 10 - gate arch, 11 - bottom static wall, 12 - upper static wall, 13 - moat, 14 - mlip, 15 - keep creature cover, 16 - bottom turret creature cover, 17 - upper turret creature cover; additInfo: 1 - intact, 2 - damaged, 3 - destroyed
|
||||
|
||||
void printPartOfWall(SDL_Surface * to, int what);//what: 1 - background wall, 2 - keep, 3 - bottom tower, 4 - bottom wall, 5 - below gate, 6 - over gate, 7 - upper wall, 8 - uppert tower, 9 - gate, 10 - gate arch, 11 - bottom static wall, 12 - upper static wall, 15 - keep creature cover, 16 - bottom turret creature cover, 17 - upper turret creature cover
|
||||
|
||||
friend class CBattleInterface;
|
||||
} * siegeH;
|
||||
|
||||
CPlayerInterface * attackerInt, * defenderInt; //because LOCPLINT is not enough in hotSeat
|
||||
const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
|
||||
public:
|
||||
CPlayerInterface * curInt; //current player interface
|
||||
std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
|
||||
void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims
|
||||
ui32 animIDhelper; //for giving IDs for animations
|
||||
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
||||
|
||||
CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen); //c-tor
|
||||
~CBattleInterface(); //d-tor
|
||||
|
||||
//std::vector<TimeInterested*> timeinterested; //animation handling
|
||||
void setPrintCellBorders(bool set); //if true, cell borders will be printed
|
||||
void setPrintStackRange(bool set); //if true,range of active stack will be printed
|
||||
void setPrintMouseShadow(bool set); //if true, hex under mouse will be shaded
|
||||
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
|
||||
|
||||
std::vector<CClickableHex> bfield; //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
|
||||
bool myTurn; //if true, interface is active (commands can be ordered)
|
||||
CBattleResultWindow * resWindow; //window of end of battle
|
||||
|
||||
bool moveStarted; //if true, the creature that is already moving is going to make its first step
|
||||
int moveSh; // sound handler used when moving a unit
|
||||
|
||||
//button handle funcs:
|
||||
void bOptionsf();
|
||||
void bSurrenderf();
|
||||
void bFleef();
|
||||
void reallyFlee(); //performs fleeing without asking player
|
||||
void reallySurrender(); //performs surrendering without asking player
|
||||
void bAutofightf();
|
||||
void bSpellf();
|
||||
void bWaitf();
|
||||
void bDefencef();
|
||||
void bConsoleUpf();
|
||||
void bConsoleDownf();
|
||||
void bTacticNextStack();
|
||||
void bEndTacticPhase();
|
||||
//end of button handle funcs
|
||||
//napisz tu klase odpowiadajaca za wyswietlanie bitwy i obsluge uzytkownika, polecenia ma przekazywac callbackiem
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to);
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void mouseMoved(const SDL_MouseMotionEvent &sEvent);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
|
||||
//call-ins
|
||||
void startAction(const BattleAction* action);
|
||||
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<BattleHex> destHex, int distance); //stack with id number moved to destHex
|
||||
void waitForAnims();
|
||||
void stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
|
||||
void stackAttacking(const CStack * attacker, BattleHex 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
|
||||
void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls
|
||||
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
|
||||
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
|
||||
void displayBattleFinished(); //displays battle result
|
||||
void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
|
||||
void castThisSpell(int spellID); //called when player has chosen a spell from spellbook
|
||||
void displayEffect(ui32 effect, int destTile); //displays effect of a spell on the battlefield; affected: true - attacker. false - defender
|
||||
void battleTriggerEffect(const BattleTriggerEffect & bte);
|
||||
void setBattleCursor(const int myNumber); //really complex and messy
|
||||
void endAction(const BattleAction* action);
|
||||
void hideQueue();
|
||||
void showQueue();
|
||||
|
||||
|
||||
friend class CPlayerInterface;
|
||||
friend class CAdventureMapButton;
|
||||
friend class CInGameConsole;
|
||||
|
||||
friend class CBattleResultWindow;
|
||||
friend class CBattleHero;
|
||||
friend class CSpellEffectAnimation;
|
||||
friend class CBattleStackAnimation;
|
||||
friend class CReverseAnimation;
|
||||
friend class CDefenceAnimation;
|
||||
friend class CMovementAnimation;
|
||||
friend class CMovementStartAnimation;
|
||||
friend class CAttackAnimation;
|
||||
friend class CMeleeAttackAnimation;
|
||||
friend class CShootingAnimation;
|
||||
friend class CClickableHex;
|
||||
};
|
754
client/BattleInterface/CBattleInterfaceClasses.cpp
Normal file
754
client/BattleInterface/CBattleInterfaceClasses.cpp
Normal file
@ -0,0 +1,754 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleInterfaceClasses.h"
|
||||
|
||||
#include "../UIFramework/SDL_Extensions.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CDefHandler.h"
|
||||
#include "../UIFramework/CCursorHandler.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../CSpellWindow.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../CConfigHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
#include "../UIFramework/CIntObjectClasses.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../../lib/NetPacks.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CVideoHandler.h"
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../CCreatureWindow.h"
|
||||
|
||||
CBattleConsole::~CBattleConsole()
|
||||
{
|
||||
texts.clear();
|
||||
}
|
||||
|
||||
void CBattleConsole::show(SDL_Surface * to)
|
||||
{
|
||||
if(ingcAlter.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(ingcAlter, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else if(alterTxt.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(alterTxt, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else if(texts.size())
|
||||
{
|
||||
if(texts.size()==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[0], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown-1], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown], pos.x + pos.w/2, pos.y + 27, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleConsole::addText(const std::string & text)
|
||||
{
|
||||
if(text.size()>70)
|
||||
return false; //text too long!
|
||||
int firstInToken = 0;
|
||||
for(size_t i = 0; i < text.size(); ++i) //tokenize
|
||||
{
|
||||
if(text[i] == 10)
|
||||
{
|
||||
texts.push_back( text.substr(firstInToken, i-firstInToken) );
|
||||
firstInToken = i+1;
|
||||
}
|
||||
}
|
||||
|
||||
texts.push_back( text.substr(firstInToken, text.size()) );
|
||||
lastShown = texts.size()-1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBattleConsole::eraseText(ui32 pos)
|
||||
{
|
||||
if(pos < texts.size())
|
||||
{
|
||||
texts.erase(texts.begin() + pos);
|
||||
if(lastShown == texts.size())
|
||||
--lastShown;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleConsole::changeTextAt(const std::string & text, ui32 pos)
|
||||
{
|
||||
if(pos >= texts.size()) //no such pos
|
||||
return;
|
||||
texts[pos] = text;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollUp(ui32 by)
|
||||
{
|
||||
if(lastShown > static_cast<int>(by))
|
||||
lastShown -= by;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollDown(ui32 by)
|
||||
{
|
||||
if(lastShown + by < texts.size())
|
||||
lastShown += by;
|
||||
}
|
||||
|
||||
void CBattleHero::show(SDL_Surface * to)
|
||||
{
|
||||
//animation of flag
|
||||
if(flip)
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 61,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 72,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
++flagAnimCount;
|
||||
if(flagAnimCount%4==0)
|
||||
{
|
||||
++flagAnim;
|
||||
flagAnim %= flag->ourImages.size();
|
||||
}
|
||||
//animation of hero
|
||||
int tick=-1;
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i)
|
||||
{
|
||||
if(dh->ourImages[i].groupNumber==phase)
|
||||
++tick;
|
||||
if(tick==image)
|
||||
{
|
||||
SDL_Rect posb = pos;
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb);
|
||||
if(phase != 4 || nextPhase != -1 || image < 4)
|
||||
{
|
||||
if(flagAnimCount%2==0)
|
||||
{
|
||||
++image;
|
||||
}
|
||||
if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame
|
||||
{
|
||||
image = 0;
|
||||
}
|
||||
}
|
||||
if(phase == 4 && nextPhase != -1 && image == 7)
|
||||
{
|
||||
phase = nextPhase;
|
||||
nextPhase = -1;
|
||||
image = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::activate()
|
||||
{
|
||||
activateLClick();
|
||||
}
|
||||
void CBattleHero::deactivate()
|
||||
{
|
||||
deactivateLClick();
|
||||
}
|
||||
|
||||
void CBattleHero::setPhase(int newPhase)
|
||||
{
|
||||
if(phase != 4)
|
||||
{
|
||||
phase = newPhase;
|
||||
image = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPhase = newPhase;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(myOwner->spellDestSelectMode) //we are casting a spell
|
||||
return;
|
||||
|
||||
if(!down && myHero != NULL && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
|
||||
{
|
||||
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
||||
{
|
||||
if(myOwner->bfield[it].hovered && myOwner->bfield[it].strictHovered)
|
||||
return;
|
||||
}
|
||||
CCS->curh->changeGraphic(0,0);
|
||||
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), myHero, myOwner->curInt);
|
||||
GH.pushInt(spellWindow);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, ui8 player, const CGHeroInstance * hero, const CBattleInterface * owner): flip(flipG), myHero(hero), myOwner(owner), phase(phaseG), nextPhase(-1), image(imageG), flagAnim(0), flagAnimCount(0)
|
||||
{
|
||||
dh = CDefHandler::giveDef( defName );
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i) //transforming images
|
||||
{
|
||||
if(flip)
|
||||
{
|
||||
SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
|
||||
SDL_FreeSurface(dh->ourImages[i].bitmap);
|
||||
dh->ourImages[i].bitmap = hlp;
|
||||
}
|
||||
CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
|
||||
}
|
||||
|
||||
if(flip)
|
||||
flag = CDefHandler::giveDef("CMFLAGR.DEF");
|
||||
else
|
||||
flag = CDefHandler::giveDef("CMFLAGL.DEF");
|
||||
|
||||
//coloring flag and adding transparency
|
||||
for(size_t i = 0; i < flag->ourImages.size(); ++i)
|
||||
{
|
||||
CSDL_Ext::alphaTransform(flag->ourImages[i].bitmap);
|
||||
graphics->blueToPlayersAdv(flag->ourImages[i].bitmap, player);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::~CBattleHero()
|
||||
{
|
||||
delete dh;
|
||||
delete flag;
|
||||
}
|
||||
|
||||
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
pos = position;
|
||||
background = new CPicture("comopbck.bmp");
|
||||
background->colorize(owner->curInt->playerID);
|
||||
|
||||
viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", NULL, 25, 56, false);
|
||||
viewGrid->select(owner->curInt->sysOpts.printCellBorders);
|
||||
movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", NULL, 25, 89, false);
|
||||
movementShadow->select(owner->curInt->sysOpts.printStackRange);
|
||||
mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", NULL, 25, 122, false);
|
||||
mouseShadow->select(owner->curInt->sysOpts.printMouseShadow);
|
||||
|
||||
animSpeeds = new CHighlightableButtonsGroup(0);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[422].first),CGI->generaltexth->zelp[422].second, "sysopb9.def", 28, 225, 1);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[423].first),CGI->generaltexth->zelp[423].second, "sysob10.def", 92, 225, 2);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[424].first),CGI->generaltexth->zelp[424].second, "sysob11.def",156, 225, 4);
|
||||
animSpeeds->select(owner->getAnimSpeed(), 1);
|
||||
animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
|
||||
|
||||
setToDefault = new CAdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
|
||||
setToDefault->swappedImages = true;
|
||||
setToDefault->update();
|
||||
exit = new CAdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
|
||||
exit->swappedImages = true;
|
||||
exit->update();
|
||||
|
||||
//creating labels
|
||||
labels.push_back(new CLabel(242, 32, FONT_BIG, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[392]));//window title
|
||||
labels.push_back(new CLabel(122, 214, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[393]));//animation speed
|
||||
labels.push_back(new CLabel(122, 293, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[394]));//music volume
|
||||
labels.push_back(new CLabel(122, 359, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[395]));//effects' volume
|
||||
labels.push_back(new CLabel(353, 66, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[396]));//auto - combat options
|
||||
labels.push_back(new CLabel(353, 265, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[397]));//creature info
|
||||
|
||||
//auto - combat options
|
||||
labels.push_back(new CLabel(283, 86, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[398]));//creatures
|
||||
labels.push_back(new CLabel(283, 116, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[399]));//spells
|
||||
labels.push_back(new CLabel(283, 146, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[400]));//catapult
|
||||
labels.push_back(new CLabel(283, 176, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[151]));//ballista
|
||||
labels.push_back(new CLabel(283, 206, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[401]));//first aid tent
|
||||
|
||||
//creature info
|
||||
labels.push_back(new CLabel(283, 285, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[402]));//all stats
|
||||
labels.push_back(new CLabel(283, 315, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[403]));//spells only
|
||||
|
||||
//general options
|
||||
labels.push_back(new CLabel(61, 57, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[404]));
|
||||
labels.push_back(new CLabel(61, 90, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[405]));
|
||||
labels.push_back(new CLabel(61, 123, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[406]));
|
||||
labels.push_back(new CLabel(61, 156, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bDefaultf()
|
||||
{
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bExitf()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner)
|
||||
: owner(_owner)
|
||||
{
|
||||
this->pos = pos;
|
||||
background = BitmapHandler::loadBitmap("CPRESULT.BMP", true);
|
||||
graphics->blueToPlayersAdv(background, owner->curInt->playerID);
|
||||
SDL_Surface * pom = SDL_ConvertSurface(background, screen->format, screen->flags);
|
||||
SDL_FreeSurface(background);
|
||||
background = pom;
|
||||
exit = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleResultWindow::bExitf,this), 384 + pos.x, 505 + pos.y, "iok6432.def", SDLK_RETURN);
|
||||
exit->borderColor = Colors::MetallicGold;
|
||||
exit->borderEnabled = true;
|
||||
|
||||
if(br.winner==0) //attacker won
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 59, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 408, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
else //if(br.winner==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 59, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 412, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
|
||||
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[407], 232, 302, FONT_BIG, Colors::Jasmine, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[408], 232, 332, FONT_BIG, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[409], 237, 428, FONT_BIG, Colors::Cornsilk, background);
|
||||
|
||||
std::string attackerName, defenderName;
|
||||
|
||||
if(owner->attackingHeroInstance) //a hero attacked
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->attackingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = owner->attackingHeroInstance->name;
|
||||
}
|
||||
else //a monster attacked
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army1->Slots().begin(); it!=owner->army1->Slots().end(); ++it)
|
||||
{
|
||||
if(it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
if(owner->defendingHeroInstance) //a hero defended
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->defendingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = owner->defendingHeroInstance->name;
|
||||
}
|
||||
else //a monster defended
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army2->Slots().begin(); it!=owner->army2->Slots().end(); ++it)
|
||||
{
|
||||
if( it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
|
||||
//printing attacker and defender's names
|
||||
CSDL_Ext::printAt(attackerName, 89, 37, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printTo(defenderName, 381, 53, FONT_SMALL, Colors::Cornsilk, background);
|
||||
//printing casualities
|
||||
for(int step = 0; step < 2; ++step)
|
||||
{
|
||||
if(br.casualties[step].size()==0)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[523], 235, 360 + 97*step, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
else
|
||||
{
|
||||
int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
|
||||
int yPos = 344 + step*97;
|
||||
for(std::map<ui32,si32>::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it)
|
||||
{
|
||||
blitAt(graphics->smallImgs[it->first], xPos, yPos, background);
|
||||
std::ostringstream amount;
|
||||
amount<<it->second;
|
||||
CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, FONT_SMALL, Colors::Cornsilk, background);
|
||||
xPos += 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printing result description
|
||||
bool weAreAttacker = (owner->curInt->playerID == owner->attackingHeroInstance->tempOwner);
|
||||
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
||||
{
|
||||
int text=-1;
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: text = 304; break;
|
||||
case 1: text = 303; break;
|
||||
case 2: text = 302; break;
|
||||
}
|
||||
|
||||
CCS->musich->playMusic(musicBase::winBattle);
|
||||
CCS->videoh->open(VIDEO_WIN);
|
||||
std::string str = CGI->generaltexth->allTexts[text];
|
||||
|
||||
const CGHeroInstance * ourHero = weAreAttacker? owner->attackingHeroInstance : owner->defendingHeroInstance;
|
||||
if (ourHero)
|
||||
{
|
||||
str += CGI->generaltexth->allTexts[305];
|
||||
boost::algorithm::replace_first(str,"%s",ourHero->name);
|
||||
boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
|
||||
}
|
||||
CSDL_Ext::printAtMiddleWB(str, 235, 235, FONT_SMALL, 55, Colors::Cornsilk, background);
|
||||
}
|
||||
else // we lose
|
||||
{
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: //normal victory
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::loseCombat);
|
||||
CCS->videoh->open(VIDEO_LOSE_BATTLE_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[311], 235, 235, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
case 1: //flee
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::retreatBattle);
|
||||
CCS->videoh->open(VIDEO_RETREAT_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[310], 235, 235, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
case 2: //surrender
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::surrenderBattle);
|
||||
CCS->videoh->open(VIDEO_SURRENDER);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[309], 235, 220, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBattleResultWindow::~CBattleResultWindow()
|
||||
{
|
||||
SDL_FreeSurface(background);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::activate()
|
||||
{
|
||||
owner->curInt->showingDialog->set(true);
|
||||
exit->activate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::deactivate()
|
||||
{
|
||||
exit->deactivate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::show(SDL_Surface * to)
|
||||
{
|
||||
//evaluating to
|
||||
if(!to)
|
||||
to = screen;
|
||||
|
||||
CCS->videoh->update(107, 70, background, false, true);
|
||||
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
exit->showAll(to);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::bExitf()
|
||||
{
|
||||
if(LOCPLINT->cb->getStartInfo()->mode == StartInfo::DUEL)
|
||||
{
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
CPlayerInterface * intTmp = owner->curInt;
|
||||
GH.popInts(2); //first - we; second - battle interface
|
||||
intTmp->showingDialog->setn(false);
|
||||
CCS->videoh->close();
|
||||
}
|
||||
|
||||
Point CClickableHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi)
|
||||
{
|
||||
Point ret(-500, -500); //returned value
|
||||
if(stack && stack->position < 0) //creatures in turrets
|
||||
{
|
||||
switch(stack->position)
|
||||
{
|
||||
case -2: //keep
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][17];
|
||||
break;
|
||||
case -3: //lower turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][18];
|
||||
break;
|
||||
case -4: //upper turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][19];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.y = -139 + 42 * (hexNum/GameConstants::BFIELD_WIDTH); //counting y
|
||||
//counting x
|
||||
if(attacker)
|
||||
{
|
||||
ret.x = -160 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x = -219 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
//shifting position for double - hex creatures
|
||||
if(stack && stack->doubleWide())
|
||||
{
|
||||
if(attacker)
|
||||
{
|
||||
ret.x -= 44;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x += 45;
|
||||
}
|
||||
}
|
||||
}
|
||||
//returning
|
||||
return ret +CPlayerInterface::battleInt->pos;
|
||||
}
|
||||
void CClickableHex::activate()
|
||||
{
|
||||
activateHover();
|
||||
activateMouseMove();
|
||||
activateLClick();
|
||||
activateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::deactivate()
|
||||
{
|
||||
deactivateHover();
|
||||
deactivateMouseMove();
|
||||
deactivateLClick();
|
||||
deactivateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::hover(bool on)
|
||||
{
|
||||
hovered = on;
|
||||
//Hoverable::hover(on);
|
||||
if(!on && setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
if(myInterface->cellShade)
|
||||
{
|
||||
if(CSDL_Ext::SDL_GetPixel(myInterface->cellShade, sEvent.x-pos.x, sEvent.y-pos.y) == 0) //hovered pixel is outside hex
|
||||
{
|
||||
strictHovered = false;
|
||||
}
|
||||
else //hovered pixel is inside hex
|
||||
{
|
||||
strictHovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hovered && strictHovered) //print attacked creature to console
|
||||
{
|
||||
const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
|
||||
if(myInterface->console->alterTxt.size() == 0 &&attackedStack != NULL &&
|
||||
attackedStack->owner != myInterface->curInt->playerID &&
|
||||
attackedStack->alive())
|
||||
{
|
||||
char tabh[160];
|
||||
const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl;
|
||||
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
|
||||
myInterface->console->alterTxt = std::string(tabh);
|
||||
setAlterText = true;
|
||||
}
|
||||
}
|
||||
else if(setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(!down && hovered && strictHovered) //we've been really clicked!
|
||||
{
|
||||
myInterface->hexLclicked(myNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
|
||||
if(hovered && strictHovered && myst!=NULL)
|
||||
{
|
||||
|
||||
if(!myst->alive()) return;
|
||||
if(down)
|
||||
{
|
||||
GH.pushInt(createCreWindow(myst));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::update()
|
||||
{
|
||||
stacksSorted.clear();
|
||||
owner->curInt->cb->getStackQueue(stacksSorted, QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE ; i++)
|
||||
{
|
||||
stackBoxes[i]->setStack(stacksSorted[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
||||
:embedded(Embedded), owner(_owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
if(embedded)
|
||||
{
|
||||
box = NULL;
|
||||
bg = NULL;
|
||||
pos.w = QUEUE_SIZE * 37;
|
||||
pos.h = 32; //height of small creature img
|
||||
pos.x = screen->w/2 - pos.w/2;
|
||||
pos.y = (screen->h - 600)/2 + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
box = BitmapHandler::loadBitmap("CHRROP.pcx");
|
||||
bg = BitmapHandler::loadBitmap("DIBOXPI.pcx");
|
||||
pos.w = 600;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
|
||||
stackBoxes.resize(QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE; i++)
|
||||
{
|
||||
stackBoxes[i] = new StackBox(box);
|
||||
stackBoxes[i]->pos.x += 6 + (embedded ? 37 : 79)*i;
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::~CStackQueue()
|
||||
{
|
||||
SDL_FreeSurface(box);
|
||||
}
|
||||
|
||||
void CStackQueue::showAll(SDL_Surface * to)
|
||||
{
|
||||
blitBg(to);
|
||||
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CStackQueue::blitBg( SDL_Surface * to )
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
for (int w = 0; w < pos.w; w += bg->w)
|
||||
{
|
||||
blitAtLoc(bg, w, 0, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::showAll(SDL_Surface * to)
|
||||
{
|
||||
assert(my);
|
||||
if(bg)
|
||||
{
|
||||
graphics->blueToPlayersAdv(bg, my->owner);
|
||||
//SDL_UpdateRect(bg, 0, 0, 0, 0);
|
||||
SDL_Rect temp_rect = genRect(bg->h, bg->w, pos.x, pos.y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(bg, NULL, to, &temp_rect);
|
||||
//blitAt(bg, pos, to);
|
||||
blitAt(graphics->bigImgs[my->getCreature()->idNumber], pos.x +9, pos.y + 1, to);
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 12, FONT_MEDIUM, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
blitAt(graphics->smallImgs[-2], pos, to);
|
||||
blitAt(graphics->smallImgs[my->getCreature()->idNumber], pos, to);
|
||||
const SDL_Color &ownerColor = (my->owner == 255 ? *graphics->neutralColor : graphics->playerColors[my->owner]);
|
||||
CSDL_Ext::drawBorder(to, pos, int3(ownerColor.r, ownerColor.g, ownerColor.b));
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 8, FONT_TINY, Colors::Cornsilk, to);
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::setStack( const CStack *nStack )
|
||||
{
|
||||
my = nStack;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::StackBox(SDL_Surface *BG)
|
||||
:my(NULL), bg(BG)
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
pos.w = bg->w;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = pos.h = 32;
|
||||
}
|
||||
|
||||
pos.y += 2;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::~StackBox()
|
||||
{
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::hover( bool on )
|
||||
{
|
||||
|
||||
}
|
159
client/BattleInterface/CBattleInterfaceClasses.h
Normal file
159
client/BattleInterface/CBattleInterfaceClasses.h
Normal file
@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class CDefHandler;
|
||||
class CGHeroInstance;
|
||||
class CBattleInterface;
|
||||
class CPicture;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CLabel;
|
||||
class BattleResult;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CBattleInterfaceClasses.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 which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class CBattleConsole : public CIntObject
|
||||
{
|
||||
private:
|
||||
std::vector< std::string > texts; //a place where texts are stored
|
||||
int lastShown; //last shown line of text
|
||||
public:
|
||||
std::string alterTxt; //if it's not empty, this text is displayed
|
||||
std::string ingcAlter; //alternative text set by in-game console - very important!
|
||||
int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button
|
||||
CBattleConsole() : lastShown(-1), alterTxt(""), whoSetAlter(0) {}
|
||||
~CBattleConsole(); //d-tor
|
||||
void show(SDL_Surface * to = 0);
|
||||
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
||||
void eraseText(ui32 pos); //erases added text at position pos
|
||||
void changeTextAt(const std::string &text, ui32 pos); //if we have more than pos texts, pos-th is changed to given one
|
||||
void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
void scrollDown(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
};
|
||||
|
||||
/// Hero battle animation
|
||||
class CBattleHero : public CIntObject
|
||||
{
|
||||
public:
|
||||
bool flip; //false if it's attacking hero, true otherwise
|
||||
CDefHandler *dh, *flag; //animation and flag
|
||||
const CGHeroInstance * myHero; //this animation's hero instance
|
||||
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
||||
int image; //frame of animation
|
||||
ui8 flagAnim, flagAnimCount; //for flag animation
|
||||
void show(SDL_Surface * to); //prints next frame of animation to to
|
||||
void activate();
|
||||
void deactivate();
|
||||
void setPhase(int newPhase); //sets phase of hero animation
|
||||
void clickLeft(tribool down, bool previousState); //call-in
|
||||
CBattleHero(const std::string &defName, int phaseG, int imageG, bool filpG, ui8 player, const CGHeroInstance *hero, const CBattleInterface *owner); //c-tor
|
||||
~CBattleHero(); //d-tor
|
||||
};
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class CBattleOptionsWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
CBattleInterface * myInt;
|
||||
CPicture * background;
|
||||
CAdventureMapButton * setToDefault, * exit;
|
||||
CHighlightableButton * viewGrid, * movementShadow, * mouseShadow;
|
||||
CHighlightableButtonsGroup * animSpeeds;
|
||||
|
||||
std::vector<CLabel*> labels;
|
||||
public:
|
||||
CBattleOptionsWindow(const SDL_Rect &position, CBattleInterface *owner); //c-tor
|
||||
|
||||
void bDefaultf(); //default button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class CBattleResultWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface *background;
|
||||
CAdventureMapButton *exit;
|
||||
CBattleInterface *owner;
|
||||
public:
|
||||
CBattleResultWindow(const BattleResult & br, const SDL_Rect & pos, CBattleInterface * _owner); //c-tor
|
||||
~CBattleResultWindow(); //d-tor
|
||||
|
||||
void bExitf(); //exit button callback
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = 0);
|
||||
};
|
||||
|
||||
/// Class which stands for a single hex field on a battlefield
|
||||
class CClickableHex : public CIntObject
|
||||
{
|
||||
private:
|
||||
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
||||
public:
|
||||
ui32 myNumber; //number of hex in commonly used format
|
||||
bool accessible; //if true, this hex is accessible for units
|
||||
//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
|
||||
|
||||
//for user interactions
|
||||
void hover (bool on);
|
||||
void activate();
|
||||
void deactivate();
|
||||
void mouseMoved (const SDL_MouseMotionEvent &sEvent);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
CClickableHex();
|
||||
};
|
||||
|
||||
/// Shows the stack queue
|
||||
class CStackQueue : public CIntObject
|
||||
{
|
||||
class StackBox : public CIntObject
|
||||
{
|
||||
public:
|
||||
const CStack *my;
|
||||
SDL_Surface *bg;
|
||||
|
||||
void hover (bool on);
|
||||
void showAll(SDL_Surface * to);
|
||||
void setStack(const CStack *nStack);
|
||||
StackBox(SDL_Surface *BG);
|
||||
~StackBox();
|
||||
};
|
||||
|
||||
public:
|
||||
static const int QUEUE_SIZE = 10;
|
||||
const bool embedded;
|
||||
std::vector<const CStack *> stacksSorted;
|
||||
std::vector<StackBox *> stackBoxes;
|
||||
|
||||
SDL_Surface *box;
|
||||
SDL_Surface *bg;
|
||||
CBattleInterface * owner;
|
||||
|
||||
void showAll(SDL_Surface * to);
|
||||
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
||||
~CStackQueue();
|
||||
void update();
|
||||
void blitBg( SDL_Surface * to );
|
||||
//void showAll(SDL_Surface * to);
|
||||
};
|
@ -1,9 +1,10 @@
|
||||
#include "StdInc.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../lib/CLodHandler.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../lib/vcmi_endian.h"
|
||||
#include <assert.h>
|
||||
#include "SDL_Extensions.h"
|
||||
|
||||
#include "../../lib/CLodHandler.h"
|
||||
#include "../../lib/VCMI_Lib.h"
|
||||
#include "../../lib/vcmi_endian.h"
|
||||
#include "../UIFramework/SDL_Extensions.h"
|
||||
|
||||
/*
|
||||
* CCreatureAnimation.cpp, part of VCMI engine
|
||||
@ -95,7 +96,7 @@ CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), onc
|
||||
frames = totalEntries;
|
||||
}
|
||||
|
||||
int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
||||
int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
||||
{
|
||||
return nextFrame(dest, x-fullWidth/2, y-fullHeight/2, attacker, animCount, incrementFrame, yellowBorder, blueBorder, destRect);
|
||||
}
|
||||
@ -159,7 +160,7 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
|
||||
|
||||
|
||||
template<int bpp>
|
||||
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
|
||||
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
|
||||
{
|
||||
//increasing frame number
|
||||
int SIndex = curFrame;
|
||||
@ -172,17 +173,17 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack
|
||||
i, FullHeight,
|
||||
|
||||
#endif
|
||||
unsigned char SegmentType, SegmentLength;
|
||||
unsigned int i;
|
||||
ui8 SegmentType, SegmentLength;
|
||||
ui32 i;
|
||||
|
||||
i = SEntries[SIndex].offset;
|
||||
|
||||
/*int prSize = read_le_u32(FDef + i);*/ i += 4; //TODO use me
|
||||
const unsigned int defType2 = read_le_u32(FDef + i); i += 4;
|
||||
const unsigned int FullWidth = read_le_u32(FDef + i); i += 4;
|
||||
const unsigned int FullHeight = read_le_u32(FDef + i); i += 4;
|
||||
const unsigned int SpriteWidth = read_le_u32(FDef + i); i += 4;
|
||||
const unsigned int SpriteHeight = read_le_u32(FDef + i); i += 4;
|
||||
const ui32 defType2 = read_le_u32(FDef + i); i += 4;
|
||||
const ui32 FullWidth = read_le_u32(FDef + i); i += 4;
|
||||
const ui32 FullHeight = read_le_u32(FDef + i); i += 4;
|
||||
const ui32 SpriteWidth = read_le_u32(FDef + i); i += 4;
|
||||
const ui32 SpriteHeight = read_le_u32(FDef + i); i += 4;
|
||||
const int LeftMargin = read_le_u32(FDef + i); i += 4;
|
||||
const int TopMargin = read_le_u32(FDef + i); i += 4;
|
||||
const int RightMargin = FullWidth - SpriteWidth - LeftMargin;
|
||||
@ -224,7 +225,7 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack
|
||||
const int remainder = ftcp % FullWidth;
|
||||
int xB = (attacker ? remainder : FullWidth - remainder - 1) + x;
|
||||
|
||||
const unsigned char aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4;
|
||||
const ui8 aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4;
|
||||
|
||||
for (int k = 0; k <= SegmentLength; k++)
|
||||
{
|
||||
@ -265,7 +266,7 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
||||
int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
||||
{
|
||||
switch(dest->format->BytesPerPixel)
|
||||
{
|
||||
@ -296,10 +297,10 @@ inline void CCreatureAnimation::putPixel(
|
||||
const int & ftcpX,
|
||||
const int & ftcpY,
|
||||
const BMPPalette & color,
|
||||
const unsigned char & palc,
|
||||
const ui8 & palc,
|
||||
const bool & yellowBorder,
|
||||
const bool & blueBorder,
|
||||
const unsigned char & animCount
|
||||
const ui8 & animCount
|
||||
) const
|
||||
{
|
||||
if(palc!=0)
|
@ -1,12 +1,9 @@
|
||||
#ifndef __CCREATUREANIMATION_H__
|
||||
#define __CCREATUREANIMATION_H__
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../global.h"
|
||||
#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
|
||||
@ -19,6 +16,7 @@
|
||||
*/
|
||||
|
||||
struct BMPPalette;
|
||||
class CIntObject;
|
||||
|
||||
/// Class which manages animations of creatures/units inside battles
|
||||
class CCreatureAnimation : public CIntObject
|
||||
@ -41,22 +39,22 @@ private:
|
||||
const int & ftcpX,
|
||||
const int & ftcpY,
|
||||
const BMPPalette & color,
|
||||
const unsigned char & palc,
|
||||
const ui8 & palc,
|
||||
const bool & yellowBorder,
|
||||
const bool & blueBorder,
|
||||
const unsigned char & animCount
|
||||
const ui8 & animCount
|
||||
) const;
|
||||
|
||||
////////////
|
||||
|
||||
unsigned char * FDef; //animation raw data
|
||||
ui8 * FDef; //animation raw data
|
||||
int curFrame, internalFrame; //number of currently displayed frame
|
||||
unsigned int frames; //number of frames
|
||||
ui32 frames; //number of frames
|
||||
CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
|
||||
|
||||
template<int bpp>
|
||||
int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
|
||||
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
|
||||
bool once;
|
||||
@ -69,7 +67,7 @@ public:
|
||||
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
||||
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
||||
|
||||
int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
void incrementFrame();
|
||||
int getFrame() const; // Gets the current frame ID relative to DEF file.
|
||||
int getAnimationFrame() const; // Gets the current frame ID relative to frame group.
|
||||
@ -80,5 +78,3 @@ public:
|
||||
|
||||
int framesInGroup(CCreatureAnim::EAnimType group) const; //retirns number of fromes in given group
|
||||
};
|
||||
|
||||
#endif // __CCREATUREANIMATION_H__
|
@ -1,14 +1,15 @@
|
||||
#include "AdventureMapButton.h"
|
||||
#include "StdInc.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
|
||||
#include "../CCallback.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "CMessage.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CSpellWindow.h"
|
||||
@ -21,19 +22,14 @@
|
||||
#include "../lib/map.h"
|
||||
#include "../lib/JsonNode.h"
|
||||
#include "mapHandler.h"
|
||||
#include "../stdafx.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <sstream>
|
||||
#include "CPreGame.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../lib/CSpellHandler.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include "CSoundBase.h"
|
||||
#include "../lib/CGameState.h"
|
||||
#include "CMusicHandler.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4355)
|
||||
@ -71,7 +67,7 @@ CMinimap::CMinimap()
|
||||
temps = newSurface(pos.w,pos.h);
|
||||
aiShield = new CPicture("AISHIELD.bmp");
|
||||
|
||||
const JsonNode config(DATA_DIR "/config/minimap.json");
|
||||
const JsonNode config(GameConstants::DATA_DIR + "/config/minimap.json");
|
||||
const JsonVector &minimap_vec = config["MinimapColors"].Vector();
|
||||
|
||||
BOOST_FOREACH(const JsonNode &m, minimap_vec) {
|
||||
@ -123,7 +119,7 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
int3 hpos = hh[i]->getPosition(false);
|
||||
if(hpos.z!=adventureInt->position.z)
|
||||
continue;
|
||||
//float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
|
||||
|
||||
int3 maplgp ( (hpos.x*mw)/mapSizes.x, (hpos.y*mh)/mapSizes.y, hpos.z );
|
||||
for (int ii=0; ii<wo; ii++)
|
||||
{
|
||||
@ -142,10 +138,10 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
//draw radar
|
||||
const int tilesw=(ADVOPT.advmapW+31)/32;
|
||||
const int tilesh=(ADVOPT.advmapH+31)/32;
|
||||
int bx = (((float)adventureInt->position.x)/(((float)mapSizes.x)))*pos.w,
|
||||
by = (((float)adventureInt->position.y)/(((float)mapSizes.y)))*pos.h,
|
||||
rx = (((float)tilesw)/(mapSizes.x))*((float)pos.w), //width
|
||||
ry = (((float)tilesh)/(mapSizes.y))*((float)pos.h); //height
|
||||
int bx = static_cast<int>((adventureInt->position.x / static_cast<double>(mapSizes.x)) * pos.w),
|
||||
by = static_cast<int>((adventureInt->position.y / static_cast<double>(mapSizes.y)) * pos.h),
|
||||
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));
|
||||
|
||||
@ -295,8 +291,8 @@ void CMinimap::clickLeft(tribool down, bool previousState)
|
||||
if (!((bool)down))
|
||||
return;
|
||||
|
||||
float dx=((float)(GH.current->motion.x-pos.x))/((float)pos.w),
|
||||
dy=((float)(GH.current->motion.y-pos.y))/((float)pos.h);
|
||||
double dx = (GH.current->motion.x - pos.x) / static_cast<double>(pos.w),
|
||||
dy = (GH.current->motion.y - pos.y) / static_cast<double>(pos.h);
|
||||
|
||||
int3 newCPos;
|
||||
newCPos.x = (CGI->mh->sizes.x*dx);
|
||||
@ -778,24 +774,24 @@ void CResDataBar::draw(SDL_Surface * to)
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,FONT_SMALL,zwykly,to);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,FONT_SMALL,Colors::Cornsilk,to);
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
|
||||
printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,FONT_SMALL,zwykly,to);
|
||||
printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,FONT_SMALL,Colors::Cornsilk,to);
|
||||
temp.clear();
|
||||
//updateRect(&pos,screen);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void CResDataBar::show( SDL_Surface * to )
|
||||
void CResDataBar::show(SDL_Surface * to)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CResDataBar::showAll( SDL_Surface * to )
|
||||
void CResDataBar::showAll(SDL_Surface * to)
|
||||
{
|
||||
draw(to);
|
||||
}
|
||||
@ -878,7 +874,7 @@ void CInfoBar::blitAnim(int mode)//0 - day, 1 - week
|
||||
txt << CGI->generaltexth->allTexts[64] << " " << LOCPLINT->cb->getDate(1);
|
||||
}
|
||||
blitAt(anim->ourImages[pom].bitmap,pos.x+9,pos.y+10);
|
||||
printAtMiddle(txt.str(),pos.x+95,pos.y+31,FONT_MEDIUM,zwykly);
|
||||
printAtMiddle(txt.str(),pos.x+95,pos.y+31,FONT_MEDIUM,Colors::Cornsilk);
|
||||
if (pom == anim->ourImages.size()-1)
|
||||
toNextTick+=750;
|
||||
}
|
||||
@ -918,9 +914,9 @@ void CInfoBar::newDay(int Day)
|
||||
blitAnim(mode);
|
||||
}
|
||||
|
||||
void CInfoBar::showComp(SComponent * comp, int time)
|
||||
void CInfoBar::showComp(CComponent * comp, int time)
|
||||
{
|
||||
if(comp->type != SComponent::hero)
|
||||
if(comp->type != CComponent::hero)
|
||||
{
|
||||
curSel = NULL;
|
||||
}
|
||||
@ -928,8 +924,8 @@ void CInfoBar::showComp(SComponent * comp, int time)
|
||||
SDL_Surface * b = BitmapHandler::loadBitmap("ADSTATOT.bmp");
|
||||
blitAt(b,pos.x+8,pos.y+11);
|
||||
blitAt(comp->getImg(),pos.x+52,pos.y+54);
|
||||
printAtMiddle(comp->subtitle,pos.x+91,pos.y+158,FONT_SMALL,zwykly);
|
||||
printAtMiddleWB(comp->description,pos.x+94,pos.y+31,FONT_SMALL,26,zwykly);
|
||||
printAtMiddle(comp->subtitle,pos.x+91,pos.y+158,FONT_SMALL,Colors::Cornsilk);
|
||||
printAtMiddleWB(comp->description,pos.x+94,pos.y+31,FONT_SMALL,26,Colors::Cornsilk);
|
||||
SDL_FreeSurface(b);
|
||||
if(!(active & TIME))
|
||||
activateTimer();
|
||||
@ -962,7 +958,7 @@ void CInfoBar::tick()
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBar::show( SDL_Surface * to )
|
||||
void CInfoBar::show(SDL_Surface * to)
|
||||
{
|
||||
|
||||
}
|
||||
@ -981,7 +977,7 @@ void CInfoBar::deactivate()
|
||||
|
||||
void CInfoBar::updateSelection(const CGObjectInstance *obj)
|
||||
{
|
||||
if(obj->ID == HEROI_TYPE)
|
||||
if(obj->ID == GameConstants::HEROI_TYPE)
|
||||
curSel = static_cast<const CGHeroInstance*>(obj);
|
||||
else
|
||||
curSel = NULL;
|
||||
@ -1154,7 +1150,7 @@ void CAdvMapInt::fendTurn()
|
||||
for (int i = 0; i < LOCPLINT->wanderingHeroes.size(); i++)
|
||||
if (!isHeroSleeping(LOCPLINT->wanderingHeroes[i]) && (LOCPLINT->wanderingHeroes[i]->movement > 0))
|
||||
{
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::vector<SComponent*>(), boost::bind(&CAdvMapInt::endingTurn, this), 0, false);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::vector<CComponent*>(), boost::bind(&CAdvMapInt::endingTurn, this), 0, false);
|
||||
return;
|
||||
}
|
||||
endingTurn();
|
||||
@ -1278,7 +1274,7 @@ void CAdvMapInt::deactivate()
|
||||
if(LOCPLINT->cingconsole->active) //TODO
|
||||
LOCPLINT->cingconsole->deactivate();
|
||||
}
|
||||
void CAdvMapInt::showAll(SDL_Surface *to)
|
||||
void CAdvMapInt::showAll(SDL_Surface * to)
|
||||
{
|
||||
blitAt(bg,0,0,to);
|
||||
|
||||
@ -1327,7 +1323,7 @@ void CAdvMapInt::setHeroSleeping(const CGHeroInstance *hero, bool sleep)
|
||||
updateNextHero(NULL);
|
||||
}
|
||||
|
||||
void CAdvMapInt::show(SDL_Surface *to)
|
||||
void CAdvMapInt::show(SDL_Surface * to)
|
||||
{
|
||||
if(state != INGAME)
|
||||
return;
|
||||
@ -1486,7 +1482,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
if(townWithMarket) //if any town has marketplace, open window
|
||||
GH.pushInt(new CMarketplaceWindow(townWithMarket));
|
||||
else //if not - complain
|
||||
LOCPLINT->showInfoDialog("No available marketplace!", std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
LOCPLINT->showInfoDialog("No available marketplace!", std::vector<CComponent*>(), soundBase::sound_todo);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
@ -1496,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)
|
||||
{
|
||||
@ -1514,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
|
||||
@ -1593,9 +1589,9 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
|
||||
centerOn(sel);
|
||||
|
||||
terrain.currentPath = NULL;
|
||||
if(sel->ID==TOWNI_TYPE)
|
||||
if(sel->ID==GameConstants::TOWNI_TYPE)
|
||||
{
|
||||
int pos = vstd::findPos(LOCPLINT->towns,sel);
|
||||
int pos = vstd::find_pos(LOCPLINT->towns,sel);
|
||||
townList.selected = pos;
|
||||
townList.fixPos();
|
||||
updateSleepWake(NULL);
|
||||
@ -1736,10 +1732,10 @@ void CAdvMapInt::tileLClicked(const int3 &mp)
|
||||
return;
|
||||
}
|
||||
//check if we can select this object
|
||||
bool canSelect = topBlocking && topBlocking->ID == HEROI_TYPE && topBlocking->tempOwner == LOCPLINT->playerID;
|
||||
canSelect |= topBlocking && topBlocking->ID == TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner);
|
||||
bool canSelect = topBlocking && topBlocking->ID == GameConstants::HEROI_TYPE && topBlocking->tempOwner == LOCPLINT->playerID;
|
||||
canSelect |= topBlocking && topBlocking->ID == GameConstants::TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner);
|
||||
|
||||
if (selection->ID != HEROI_TYPE) //hero is not selected (presumably town)
|
||||
if (selection->ID != GameConstants::HEROI_TYPE) //hero is not selected (presumably town)
|
||||
{
|
||||
assert(!terrain.currentPath); //path can be active only when hero is selected
|
||||
if(selection == topBlocking) //selected town clicked
|
||||
@ -1820,7 +1816,7 @@ void CAdvMapInt::tileHovered(const int3 &tile)
|
||||
bool accessible = pnode->turns < 255;
|
||||
|
||||
int turns = pnode->turns;
|
||||
amin(turns, 3);
|
||||
vstd::amin(turns, 3);
|
||||
|
||||
if(!selection) //may occur just at the start of game (fake move before full intiialization)
|
||||
return;
|
||||
@ -1850,13 +1846,13 @@ void CAdvMapInt::tileHovered(const int3 &tile)
|
||||
|
||||
const bool guardingCreature = CGI->mh->map->isInTheMap(LOCPLINT->cb->guardingCreaturePosition(tile));
|
||||
|
||||
if(selection->ID == TOWNI_TYPE)
|
||||
if(selection->ID == GameConstants::TOWNI_TYPE)
|
||||
{
|
||||
if(objAtTile)
|
||||
{
|
||||
if(objAtTile->ID == TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, objAtTile->tempOwner))
|
||||
if(objAtTile->ID == GameConstants::TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, objAtTile->tempOwner))
|
||||
CCS->curh->changeGraphic(0, 3);
|
||||
else if(objAtTile->ID == HEROI_TYPE && objAtTile->tempOwner == LOCPLINT->playerID)
|
||||
else if(objAtTile->ID == GameConstants::HEROI_TYPE && objAtTile->tempOwner == LOCPLINT->playerID)
|
||||
CCS->curh->changeGraphic(0, 2);
|
||||
}
|
||||
else
|
||||
@ -1866,7 +1862,7 @@ void CAdvMapInt::tileHovered(const int3 &tile)
|
||||
{
|
||||
if(objAtTile)
|
||||
{
|
||||
if(objAtTile->ID == HEROI_TYPE)
|
||||
if(objAtTile->ID == GameConstants::HEROI_TYPE)
|
||||
{
|
||||
if(!LOCPLINT->cb->getPlayerRelations( LOCPLINT->playerID, objAtTile->tempOwner)) //enemy hero
|
||||
{
|
||||
@ -1885,7 +1881,7 @@ void CAdvMapInt::tileHovered(const int3 &tile)
|
||||
CCS->curh->changeGraphic(0, 2);
|
||||
}
|
||||
}
|
||||
else if(objAtTile->ID == TOWNI_TYPE)
|
||||
else if(objAtTile->ID == GameConstants::TOWNI_TYPE)
|
||||
{
|
||||
if(!LOCPLINT->cb->getPlayerRelations( LOCPLINT->playerID, objAtTile->tempOwner)) //enemy town
|
||||
{
|
||||
@ -2042,7 +2038,7 @@ void CAdvMapInt::leaveCastingMode(bool cast /*= false*/, int3 dest /*= int3(-1,
|
||||
|
||||
const CGHeroInstance * CAdvMapInt::curHero() const
|
||||
{
|
||||
if(selection && selection->ID == HEROI_TYPE)
|
||||
if(selection && selection->ID == GameConstants::HEROI_TYPE)
|
||||
return static_cast<const CGHeroInstance *>(selection);
|
||||
else
|
||||
return NULL;
|
||||
@ -2050,7 +2046,7 @@ const CGHeroInstance * CAdvMapInt::curHero() const
|
||||
|
||||
const CGTownInstance * CAdvMapInt::curTown() const
|
||||
{
|
||||
if(selection && selection->ID == TOWNI_TYPE)
|
||||
if(selection && selection->ID == GameConstants::TOWNI_TYPE)
|
||||
return static_cast<const CGTownInstance *>(selection);
|
||||
else
|
||||
return NULL;
|
||||
@ -2072,18 +2068,18 @@ CAdventureOptions::CAdventureOptions()
|
||||
bg = new CPicture("ADVOPTS.bmp");
|
||||
graphics->blueToPlayersAdv(bg->bg, LOCPLINT->playerID);
|
||||
pos = bg->center();
|
||||
exit = new AdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
exit = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
//scenInfo = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 24, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 198, "ADVINFO.DEF",SDLK_i);
|
||||
//scenInfo = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 24, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 198, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo->callback += CAdventureOptions::showScenarioInfo;
|
||||
//viewWorld = new AdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
//viewWorld = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
|
||||
puzzle = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 81, "ADVPUZ.DEF");
|
||||
puzzle = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 81, "ADVPUZ.DEF");
|
||||
puzzle->callback += boost::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
|
||||
|
||||
dig = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 139, "ADVDIG.DEF");
|
||||
dig = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 139, "ADVDIG.DEF");
|
||||
if(const CGHeroInstance *h = adventureInt->curHero())
|
||||
dig->callback += boost::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
|
||||
else
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef __CADVMAPINTERFACE_H__
|
||||
#define __CADVMAPINTERFACE_H__
|
||||
#pragma once
|
||||
|
||||
#include <typeinfo>
|
||||
#include "../global.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include <map>
|
||||
#include "AdventureMapButton.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class CDefHandler;
|
||||
class CCallback;
|
||||
struct CGPath;
|
||||
@ -33,7 +33,7 @@ class CAdventureOptions : public CIntObject
|
||||
{
|
||||
public:
|
||||
CPicture *bg;
|
||||
AdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
|
||||
CAdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
|
||||
|
||||
CAdventureOptions();
|
||||
~CAdventureOptions();
|
||||
@ -135,7 +135,7 @@ public:
|
||||
class CInfoBar : public CIntObject
|
||||
{
|
||||
CDefHandler *day, *week1, *week2, *week3, *week4;
|
||||
SComponent * current;
|
||||
CComponent * current;
|
||||
int pom;
|
||||
SDL_Surface *selInfoWin; //info box for selection
|
||||
CDefHandler * getAnim(int mode);
|
||||
@ -146,7 +146,7 @@ public:
|
||||
CInfoBar();
|
||||
~CInfoBar();
|
||||
void newDay(int Day); //start showing new day/week animation
|
||||
void showComp(SComponent * comp, int time=5000);
|
||||
void showComp(CComponent * comp, int time=5000);
|
||||
void tick();
|
||||
void showAll(SDL_Surface * to); // if specific==0 function draws info about selected hero/town
|
||||
void blitAnim(int mode);//0 - day, 1 - week
|
||||
@ -176,15 +176,15 @@ public:
|
||||
enum{NA, INGAME, WAITING} state;
|
||||
|
||||
bool updateScreen, updateMinimap ;
|
||||
unsigned char anim, animValHitCount; //animation frame
|
||||
unsigned char heroAnim, heroAnimValHitCount; //animation frame
|
||||
ui8 anim, animValHitCount; //animation frame
|
||||
ui8 heroAnim, heroAnimValHitCount; //animation frame
|
||||
|
||||
SDL_Surface * bg;
|
||||
std::vector<CDefHandler *> gems;
|
||||
CMinimap minimap;
|
||||
CStatusBar statusbar;
|
||||
|
||||
AdventureMapButton kingOverview,//- kingdom overview
|
||||
CAdventureMapButton kingOverview,//- kingdom overview
|
||||
underground,//- underground switch
|
||||
questlog,//- questlog
|
||||
sleepWake, //- sleep/wake hero
|
||||
@ -256,5 +256,3 @@ public:
|
||||
};
|
||||
|
||||
extern CAdvMapInt *adventureInt;
|
||||
|
||||
#endif // __CADVMAPINTERFACE_H__
|
||||
|
@ -1,7 +1,4 @@
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "StdInc.h"
|
||||
#include <SDL_image.h>
|
||||
|
||||
#include "../lib/CLodHandler.h"
|
||||
@ -11,7 +8,7 @@
|
||||
#include "CBitmapHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "CAnimation.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
|
||||
/*
|
||||
* CAnimation.cpp, part of VCMI engine
|
||||
@ -23,8 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern DLL_EXPORT CLodHandler *spriteh;
|
||||
extern DLL_EXPORT CLodHandler *bitmaph;
|
||||
extern DLL_LINKAGE CLodHandler *spriteh;
|
||||
extern DLL_LINKAGE CLodHandler *bitmaph;
|
||||
|
||||
typedef std::map <size_t, std::vector <JsonNode> > source_map;
|
||||
typedef std::map<size_t, IImage* > image_map;
|
||||
@ -53,7 +50,7 @@ class CompImageLoader
|
||||
CompImage * image;
|
||||
ui8 *position;
|
||||
ui8 *entry;
|
||||
unsigned int currentLine;
|
||||
ui32 currentLine;
|
||||
|
||||
inline ui8 typeOf(ui8 color);
|
||||
inline void NewEntry(ui8 color, size_t size);
|
||||
@ -97,15 +94,15 @@ CDefFile::CDefFile(std::string Name):
|
||||
palette = new SDL_Color[256];
|
||||
int it = 0;
|
||||
|
||||
unsigned int type = read_le_u32(data + it);
|
||||
ui32 type = read_le_u32(data + it);
|
||||
it+=4;
|
||||
//int width = read_le_u32(data + it); it+=4;//not used
|
||||
//int height = read_le_u32(data + it); it+=4;
|
||||
it+=8;
|
||||
unsigned int totalBlocks = read_le_u32(data + it);
|
||||
ui32 totalBlocks = read_le_u32(data + it);
|
||||
it+=4;
|
||||
|
||||
for (unsigned int i= 0; i<256; i++)
|
||||
for (ui32 i= 0; i<256; i++)
|
||||
{
|
||||
palette[i].r = data[it++];
|
||||
palette[i].g = data[it++];
|
||||
@ -117,7 +114,7 @@ CDefFile::CDefFile(std::string Name):
|
||||
else
|
||||
memcpy(palette, H3Palette, sizeof(SDL_Color)*8);//initialize shadow\selection colors
|
||||
|
||||
for (unsigned int i=0; i<totalBlocks; i++)
|
||||
for (ui32 i=0; i<totalBlocks; i++)
|
||||
{
|
||||
size_t blockID = read_le_u32(data + it);
|
||||
it+=4;
|
||||
@ -128,7 +125,7 @@ CDefFile::CDefFile(std::string Name):
|
||||
//13 bytes for name of every frame in this block - not used, skipping
|
||||
it+= 13 * totalEntries;
|
||||
|
||||
for (unsigned int j=0; j<totalEntries; j++)
|
||||
for (ui32 j=0; j<totalEntries; j++)
|
||||
{
|
||||
size_t currOffset = read_le_u32(data + it);
|
||||
offset[blockID].push_back(currOffset);
|
||||
@ -158,8 +155,8 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
sprite.leftMargin = SDL_SwapLE32(sd.leftMargin);
|
||||
sprite.topMargin = SDL_SwapLE32(sd.topMargin);
|
||||
|
||||
unsigned int currentOffset = sizeof(SSpriteDef);
|
||||
unsigned int BaseOffset = sizeof(SSpriteDef);
|
||||
ui32 currentOffset = sizeof(SSpriteDef);
|
||||
ui32 BaseOffset = sizeof(SSpriteDef);
|
||||
|
||||
loader.init(Point(sprite.width, sprite.height),
|
||||
Point(sprite.leftMargin, sprite.topMargin),
|
||||
@ -170,7 +167,7 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
case 0:
|
||||
{
|
||||
//pixel data is not compressed, copy data to surface
|
||||
for (unsigned int i=0; i<sprite.height; i++)
|
||||
for (ui32 i=0; i<sprite.height; i++)
|
||||
{
|
||||
loader.Load(sprite.width, FDef[currentOffset]);
|
||||
currentOffset += sprite.width;
|
||||
@ -184,16 +181,16 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
const ui32 * RWEntriesLoc = reinterpret_cast<const ui32 *>(FDef+currentOffset);
|
||||
currentOffset += sizeof(ui32) * sprite.height;
|
||||
|
||||
for (unsigned int i=0; i<sprite.height; i++)
|
||||
for (ui32 i=0; i<sprite.height; i++)
|
||||
{
|
||||
//get position of the line
|
||||
currentOffset=BaseOffset + read_le_u32(RWEntriesLoc + i);
|
||||
unsigned int TotalRowLength = 0;
|
||||
ui32 TotalRowLength = 0;
|
||||
|
||||
while (TotalRowLength<sprite.width)
|
||||
{
|
||||
unsigned char type=FDef[currentOffset++];
|
||||
unsigned int length=FDef[currentOffset++] + 1;
|
||||
ui8 type=FDef[currentOffset++];
|
||||
ui32 length=FDef[currentOffset++] + 1;
|
||||
|
||||
if (type==0xFF)//Raw data
|
||||
{
|
||||
@ -215,15 +212,15 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
{
|
||||
currentOffset = BaseOffset + read_le_u16(FDef + BaseOffset);
|
||||
|
||||
for (unsigned int i=0; i<sprite.height; i++)
|
||||
for (ui32 i=0; i<sprite.height; i++)
|
||||
{
|
||||
unsigned int TotalRowLength=0;
|
||||
ui32 TotalRowLength=0;
|
||||
|
||||
while (TotalRowLength<sprite.width)
|
||||
{
|
||||
unsigned char SegmentType=FDef[currentOffset++];
|
||||
unsigned char code = SegmentType / 32;
|
||||
unsigned char length = (SegmentType & 31) + 1;
|
||||
ui8 SegmentType=FDef[currentOffset++];
|
||||
ui8 code = SegmentType / 32;
|
||||
ui8 length = (SegmentType & 31) + 1;
|
||||
|
||||
if (code==7)//Raw data
|
||||
{
|
||||
@ -242,16 +239,16 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
for (unsigned int i=0; i<sprite.height; i++)
|
||||
for (ui32 i=0; i<sprite.height; i++)
|
||||
{
|
||||
currentOffset = BaseOffset + read_le_u16(FDef + BaseOffset+i*2*(sprite.width/32));
|
||||
unsigned int TotalRowLength=0;
|
||||
ui32 TotalRowLength=0;
|
||||
|
||||
while (TotalRowLength<sprite.width)
|
||||
{
|
||||
unsigned char segment = FDef[currentOffset++];
|
||||
unsigned char code = segment / 32;
|
||||
unsigned char length = (segment & 31) + 1;
|
||||
ui8 segment = FDef[currentOffset++];
|
||||
ui8 code = segment / 32;
|
||||
ui8 length = (segment & 31) + 1;
|
||||
|
||||
if (code==7)//Raw data
|
||||
{
|
||||
@ -366,7 +363,7 @@ void CompImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_
|
||||
memcpy((void*)image->palette, (void*)pal, 256*sizeof(SDL_Color));
|
||||
//Allocate enought space for worst possible case, c-style malloc used due to resizing after load
|
||||
image->surf = (ui8*)malloc(SpriteSize.x*SpriteSize.y*3);
|
||||
image->line = new unsigned int[SpriteSize.y+1];
|
||||
image->line = new ui32[SpriteSize.y+1];
|
||||
image->line[0] = 0;
|
||||
position = image->surf;
|
||||
}
|
||||
@ -591,7 +588,7 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
||||
}
|
||||
}
|
||||
|
||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const
|
||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotation) const
|
||||
{
|
||||
if (!surf)
|
||||
return;
|
||||
@ -751,7 +748,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
|
||||
for (size_t i=0; i<size; i++)
|
||||
{
|
||||
SDL_Color col = palette[*(data++)];
|
||||
col.unused = (unsigned int)col.unused*(255-alpha)/255;
|
||||
col.unused = (ui32)col.unused*(255-alpha)/255;
|
||||
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
||||
}
|
||||
return;
|
||||
@ -811,7 +808,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
|
||||
void CompImage::playerColored(int player)
|
||||
{
|
||||
SDL_Color *pal = NULL;
|
||||
if(player < PLAYER_LIMIT && player >= 0)
|
||||
if(player < GameConstants::PLAYER_LIMIT && player >= 0)
|
||||
{
|
||||
pal = graphics->playerColorPalette + 32*player;
|
||||
}
|
||||
@ -941,7 +938,7 @@ void CAnimation::init(CDefFile * file)
|
||||
if (spriteh->haveFile(name, FILE_TEXT))
|
||||
{
|
||||
int size = 0;
|
||||
unsigned char * configFile = spriteh->giveFile(name, FILE_TEXT, &size);
|
||||
ui8 * configFile = spriteh->giveFile(name, FILE_TEXT, &size);
|
||||
|
||||
const JsonNode config((char*)configFile, size);
|
||||
delete configFile;
|
||||
@ -1118,7 +1115,7 @@ void CAnimation::getAnimInfo()
|
||||
}
|
||||
}
|
||||
|
||||
CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, unsigned char Flags):
|
||||
CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, ui8 Flags):
|
||||
frame(Frame),
|
||||
group(Group),
|
||||
player(-1),
|
||||
@ -1130,7 +1127,7 @@ CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int
|
||||
init();
|
||||
}
|
||||
|
||||
CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int y, unsigned char Flags):
|
||||
CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int y, ui8 Flags):
|
||||
anim(Anim),
|
||||
frame(Frame),
|
||||
group(Group),
|
||||
@ -1169,7 +1166,7 @@ CAnimImage::~CAnimImage()
|
||||
delete anim;
|
||||
}
|
||||
|
||||
void CAnimImage::showAll(SDL_Surface *to)
|
||||
void CAnimImage::showAll(SDL_Surface * to)
|
||||
{
|
||||
IImage *img = anim->getImage(frame, group);
|
||||
if (img)
|
||||
@ -1206,7 +1203,7 @@ void CAnimImage::playerColored(int currPlayer)
|
||||
anim->getImage(0, group)->playerColored(player);
|
||||
}
|
||||
|
||||
CShowableAnim::CShowableAnim(int x, int y, std::string name, unsigned char Flags, unsigned int Delay, size_t Group):
|
||||
CShowableAnim::CShowableAnim(int x, int y, std::string name, ui8 Flags, ui32 Delay, size_t Group):
|
||||
anim(name, Flags & USE_RLE),
|
||||
group(Group),
|
||||
frame(0),
|
||||
@ -1232,9 +1229,9 @@ CShowableAnim::~CShowableAnim()
|
||||
anim.unloadGroup(group);
|
||||
}
|
||||
|
||||
void CShowableAnim::setAlpha(unsigned int alphaValue)
|
||||
void CShowableAnim::setAlpha(ui32 alphaValue)
|
||||
{
|
||||
alpha = std::min<unsigned int>(alphaValue, 255);
|
||||
alpha = std::min<ui32>(alphaValue, 255);
|
||||
}
|
||||
|
||||
bool CShowableAnim::set(size_t Group, size_t from, size_t to)
|
||||
@ -1288,7 +1285,7 @@ void CShowableAnim::clipRect(int posX, int posY, int width, int height)
|
||||
pos.h = height;
|
||||
}
|
||||
|
||||
void CShowableAnim::show(SDL_Surface *to)
|
||||
void CShowableAnim::show(SDL_Surface * to)
|
||||
{
|
||||
if ( flags & BASE && frame != first)
|
||||
blitImage(first, group, to);
|
||||
@ -1302,7 +1299,7 @@ void CShowableAnim::show(SDL_Surface *to)
|
||||
}
|
||||
}
|
||||
|
||||
void CShowableAnim::showAll(SDL_Surface *to)
|
||||
void CShowableAnim::showAll(SDL_Surface * to)
|
||||
{
|
||||
if ( flags & BASE && frame != first)
|
||||
blitImage(first, group, to);
|
||||
@ -1320,14 +1317,14 @@ void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to)
|
||||
|
||||
void CShowableAnim::rotate(bool on, bool vertical)
|
||||
{
|
||||
unsigned char flag = vertical? VERTICAL_FLIP:HORIZONTAL_FLIP;
|
||||
ui8 flag = vertical? VERTICAL_FLIP:HORIZONTAL_FLIP;
|
||||
if (on)
|
||||
flags |= flag;
|
||||
else
|
||||
flags &= ~flag;
|
||||
}
|
||||
|
||||
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, unsigned char flags, EAnimType type):
|
||||
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, ui8 flags, EAnimType type):
|
||||
CShowableAnim(x,y,name,flags,3,type)
|
||||
{
|
||||
xOffset = picPos.x;
|
||||
|
@ -1,15 +1,6 @@
|
||||
#ifndef __CANIMATION_H__
|
||||
#define __CANIMATION_H__
|
||||
#pragma once
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
|
||||
#include "../global.h"
|
||||
#include "GUIBase.h"
|
||||
#include "UIFramework/CIntObject.h"
|
||||
|
||||
/*
|
||||
* CAnimation.h, part of VCMI engine
|
||||
@ -46,7 +37,7 @@ private:
|
||||
//offset[group][frame] - offset of frame data in file
|
||||
std::map<size_t, std::vector <size_t> > offset;
|
||||
|
||||
unsigned char * data;
|
||||
ui8 * data;
|
||||
SDL_Color * palette;
|
||||
|
||||
public:
|
||||
@ -135,7 +126,7 @@ class CompImage : public IImage
|
||||
//RLE-d data
|
||||
ui8 * surf;
|
||||
//array of offsets for each line
|
||||
unsigned int * line;
|
||||
ui32 * line;
|
||||
//palette
|
||||
SDL_Color *palette;
|
||||
|
||||
@ -237,13 +228,13 @@ private:
|
||||
size_t frame;
|
||||
size_t group;
|
||||
int player;
|
||||
unsigned char flags;
|
||||
ui8 flags;
|
||||
|
||||
void init();
|
||||
|
||||
public:
|
||||
CAnimImage(std::string name, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0);
|
||||
CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0);
|
||||
CAnimImage(std::string name, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0);
|
||||
CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0);
|
||||
~CAnimImage();//d-tor
|
||||
|
||||
//size of animation
|
||||
@ -255,7 +246,7 @@ public:
|
||||
//makes image player-colored
|
||||
void playerColored(int player);
|
||||
|
||||
void showAll(SDL_Surface *to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Base class for displaying animation, used as superclass for different animations
|
||||
@ -278,10 +269,10 @@ protected:
|
||||
size_t first, last; //animation range
|
||||
|
||||
//TODO: replace with time delay(needed for battles)
|
||||
unsigned int frameDelay;//delay in frames of each image
|
||||
unsigned int value;//how many times current frame was showed
|
||||
ui32 frameDelay;//delay in frames of each image
|
||||
ui32 value;//how many times current frame was showed
|
||||
|
||||
unsigned char flags;//Flags from EFlags enum
|
||||
ui8 flags;//Flags from EFlags enum
|
||||
|
||||
//blit image with optional rotation, fitting into rect, etc
|
||||
void blitImage(size_t frame, size_t group, SDL_Surface *to);
|
||||
@ -296,9 +287,9 @@ public:
|
||||
boost::function<void()> callback;
|
||||
|
||||
//Set per-surface alpha, 0 = transparent, 255 = opaque
|
||||
void setAlpha(unsigned int alphaValue);
|
||||
void setAlpha(ui32 alphaValue);
|
||||
|
||||
CShowableAnim(int x, int y, std::string name, unsigned char flags=0, unsigned int Delay=4, size_t Group=0);
|
||||
CShowableAnim(int x, int y, std::string name, ui8 flags=0, ui32 Delay=4, size_t Group=0);
|
||||
~CShowableAnim();
|
||||
|
||||
//set animation to group or part of group
|
||||
@ -315,8 +306,8 @@ public:
|
||||
virtual void reset();
|
||||
|
||||
//show current frame and increase counter
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Creature-dependend animations like attacking, moving,...
|
||||
@ -376,8 +367,6 @@ public:
|
||||
void clearAndSet(EAnimType type);
|
||||
|
||||
CCreatureAnim(int x, int y, std::string name, Rect picPos,
|
||||
unsigned char flags= USE_RLE, EAnimType = HOLDING );
|
||||
ui8 flags= USE_RLE, EAnimType = HOLDING );
|
||||
|
||||
};
|
||||
|
||||
#endif // __CANIMATIONHANDLER_H__
|
||||
|
@ -1,597 +0,0 @@
|
||||
#ifndef __CBATTLEINTERFACE_H__
|
||||
#define __CBATTLEINTERFACE_H__
|
||||
|
||||
#include "../global.h"
|
||||
#include <list>
|
||||
#include "GUIBase.h"
|
||||
#include "../lib/CCreatureSet.h"
|
||||
#include "../lib/ConstTransitivePtr.h" //may be reundant
|
||||
#include "CAnimation.h"
|
||||
|
||||
/*
|
||||
* CBattleInterface.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 CLabel;
|
||||
class CCreatureSet;
|
||||
class CGHeroInstance;
|
||||
class CDefHandler;
|
||||
class CStack;
|
||||
class CCallback;
|
||||
class AdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
struct BattleResult;
|
||||
struct BattleSpellCast;
|
||||
struct CObstacleInstance;
|
||||
template <typename T> struct CondSh;
|
||||
struct SetStackEffect;;
|
||||
struct BattleAction;
|
||||
class CGTownInstance;
|
||||
struct CatapultAttack;
|
||||
class CBattleInterface;
|
||||
struct CatapultProjectileInfo;
|
||||
struct BattleTriggerEffect;
|
||||
|
||||
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
|
||||
struct SStackAttackedInfo
|
||||
{
|
||||
const CStack * defender; //attacked stack
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
bool rebirth; //if true, play rebirth animation after all
|
||||
};
|
||||
|
||||
/// Small struct which contains information about the position and the velocity of a projectile
|
||||
struct SProjectileInfo
|
||||
{
|
||||
double x, y; //position on the screen
|
||||
double dx, dy; //change in position in one step
|
||||
int step, lastStep; //to know when finish showing this projectile
|
||||
int creID; //ID of creature that shot this projectile
|
||||
int stackID; //ID of stack
|
||||
int frameNum; //frame to display form projectile animation
|
||||
bool spin; //if true, frameNum will be increased
|
||||
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
|
||||
bool reverse; //if true, projectile will be flipped by vertical asix
|
||||
CatapultProjectileInfo *catapultInfo; // holds info about the parabolic trajectory of the cannon
|
||||
};
|
||||
|
||||
|
||||
/// Base class of battle animations
|
||||
class CBattleAnimation
|
||||
{
|
||||
protected:
|
||||
CBattleInterface * owner;
|
||||
public:
|
||||
virtual bool init()=0; //to be called - if returned false, call again until returns true
|
||||
virtual void nextFrame()=0; //call every new frame
|
||||
virtual void endAnim(); //to be called mostly internally; in this class it removes animation from pendingAnims list
|
||||
|
||||
bool isEarliest(bool perStackConcurrency); //determines if this animation is earliest of all
|
||||
|
||||
unsigned int ID; //unique identifier
|
||||
|
||||
CBattleAnimation(CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
class CDummyAnim : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
int counter;
|
||||
int howMany;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDummyAnim(CBattleInterface * _owner, int howManyFrames);
|
||||
};
|
||||
|
||||
/// This class manages a spell effect animation
|
||||
class CSpellEffectAnim : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
ui32 effect;
|
||||
THex destTile;
|
||||
std::string customAnim;
|
||||
int x, y, dx, dy;
|
||||
bool Vflip;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CSpellEffectAnim(CBattleInterface * _owner, ui32 _effect, THex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
CSpellEffectAnim(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
};
|
||||
|
||||
/// Sub-class which is responsible for managing the battle stack animation.
|
||||
class CBattleStackAnimation : public CBattleAnimation
|
||||
{
|
||||
public:
|
||||
const CStack * stack; //id of stack whose animation it is
|
||||
|
||||
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
static bool isToReverseHlp(THex hexFrom, THex hexTo, bool curDir); //helper for isToReverse
|
||||
static bool isToReverse(THex hexFrom, THex 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
|
||||
};
|
||||
|
||||
/// Class responsible for animation of stack chaning direction (left <-> right)
|
||||
class CReverseAnim : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
int partOfAnim; //1 - first, 2 - second
|
||||
bool secondPartSetup;
|
||||
THex hex;
|
||||
public:
|
||||
bool priority; //true - high, false - low
|
||||
bool init();
|
||||
void nextFrame();
|
||||
|
||||
void setupSecondPart();
|
||||
void endAnim();
|
||||
|
||||
CReverseAnim(CBattleInterface * _owner, const CStack * stack, THex dest, bool _priority);
|
||||
};
|
||||
|
||||
/// Animation of a defending unit
|
||||
class CDefenceAnim : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
//std::vector<SStackAttackedInfo> attackedInfos;
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDefenceAnim(SStackAttackedInfo _attackedInfo, CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
/// Move animation of a creature
|
||||
class CBattleStackMoved : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
std::vector<THex> destTiles; //destination
|
||||
THex nextHex;
|
||||
int nextPos;
|
||||
int distance;
|
||||
float stepX, stepY; //how far stack is moved in one frame
|
||||
float posX, posY;
|
||||
int steps, whichStep;
|
||||
int curStackPos; //position of stack before move
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CBattleStackMoved(CBattleInterface * _owner, const CStack * _stack, std::vector<THex> _destTiles, int _distance);
|
||||
};
|
||||
|
||||
/// Move start animation of a creature
|
||||
class CBattleMoveStart : public CBattleStackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CBattleMoveStart(CBattleInterface * _owner, const CStack * _stack);
|
||||
};
|
||||
|
||||
/// Move end animation of a creature
|
||||
class CBattleMoveEnd : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
THex destinationTile;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CBattleMoveEnd(CBattleInterface * _owner, const CStack * _stack, THex destTile);
|
||||
};
|
||||
|
||||
/// This class is responsible for managing the battle attack animation
|
||||
class CBattleAttack : public CBattleStackAnimation
|
||||
{
|
||||
protected:
|
||||
THex dest; //atacked hex
|
||||
bool shooting;
|
||||
CCreatureAnim::EAnimType group; //if shooting is true, print this animation group
|
||||
const CStack * attackedStack;
|
||||
const CStack * attackingStack;
|
||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||
public:
|
||||
void nextFrame();
|
||||
|
||||
bool checkInitialConditions();
|
||||
|
||||
|
||||
CBattleAttack(CBattleInterface * _owner, const CStack * attacker, THex _dest, const CStack * defender);
|
||||
};
|
||||
|
||||
/// Hand-to-hand attack
|
||||
class CMeleeAttack : public CBattleAttack
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMeleeAttack(CBattleInterface * _owner, const CStack * attacker, THex _dest, const CStack * _attacked);
|
||||
};
|
||||
|
||||
/// Shooting attack
|
||||
class CShootingAnim : public CBattleAttack
|
||||
{
|
||||
private:
|
||||
int catapultDamage;
|
||||
bool catapult;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CShootingAnim(CBattleInterface * _owner, const CStack * attacker, THex _dest, const CStack * _attacked, bool _catapult = false, int _catapultDmg = 0); //last param only for catapult attacks
|
||||
};
|
||||
|
||||
//end of battle animation handlers
|
||||
|
||||
/// Hero battle animation
|
||||
class CBattleHero : public CIntObject
|
||||
{
|
||||
public:
|
||||
bool flip; //false if it's attacking hero, true otherwise
|
||||
CDefHandler * dh, *flag; //animation and flag
|
||||
const CGHeroInstance * myHero; //this animation's hero instance
|
||||
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
||||
int image; //frame of animation
|
||||
unsigned char flagAnim, flagAnimCount; //for flag animation
|
||||
void show(SDL_Surface * to); //prints next frame of animation to to
|
||||
void activate();
|
||||
void deactivate();
|
||||
void setPhase(int newPhase); //sets phase of hero animation
|
||||
void clickLeft(tribool down, bool previousState); //call-in
|
||||
CBattleHero(const std::string & defName, int phaseG, int imageG, bool filpG, unsigned char player, const CGHeroInstance * hero, const CBattleInterface * owner); //c-tor
|
||||
~CBattleHero(); //d-tor
|
||||
};
|
||||
|
||||
/// Class which stands for a single hex field on a battlefield
|
||||
class CBattleHex : public CIntObject
|
||||
{
|
||||
private:
|
||||
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
||||
public:
|
||||
unsigned int myNumber; //number of hex in commonly used format
|
||||
bool accessible; //if true, this hex is accessible for units
|
||||
//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
|
||||
//for user interactions
|
||||
void hover (bool on);
|
||||
void activate();
|
||||
void deactivate();
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
CBattleHex();
|
||||
};
|
||||
|
||||
/// Class which manages the locked hex fields that are blocked e.g. by obstacles
|
||||
class CBattleObstacle
|
||||
{
|
||||
std::vector<int> lockedHexes;
|
||||
};
|
||||
|
||||
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class CBattleConsole : public CIntObject
|
||||
{
|
||||
private:
|
||||
std::vector< std::string > texts; //a place where texts are stored
|
||||
int lastShown; //last shown line of text
|
||||
public:
|
||||
std::string alterTxt; //if it's not empty, this text is displayed
|
||||
std::string ingcAlter; //alternative text set by in-game console - very important!
|
||||
int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button
|
||||
CBattleConsole(); //c-tor
|
||||
~CBattleConsole(); //d-tor
|
||||
void show(SDL_Surface * to = 0);
|
||||
bool addText(const std::string & text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
||||
void eraseText(unsigned int pos); //erases added text at position pos
|
||||
void changeTextAt(const std::string & text, unsigned int pos); //if we have more than pos texts, pos-th is changed to given one
|
||||
void scrollUp(unsigned int by = 1); //scrolls console up by 'by' positions
|
||||
void scrollDown(unsigned int by = 1); //scrolls console up by 'by' positions
|
||||
};
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class CBattleResultWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface * background;
|
||||
AdventureMapButton * exit;
|
||||
CBattleInterface * owner;
|
||||
public:
|
||||
CBattleResultWindow(const BattleResult & br, const SDL_Rect & pos, CBattleInterface * _owner); //c-tor
|
||||
~CBattleResultWindow(); //d-tor
|
||||
|
||||
void bExitf(); //exit button callback
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = 0);
|
||||
};
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class CBattleOptionsWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
CBattleInterface * myInt;
|
||||
CPicture * background;
|
||||
AdventureMapButton * setToDefault, * exit;
|
||||
CHighlightableButton * viewGrid, * movementShadow, * mouseShadow;
|
||||
CHighlightableButtonsGroup * animSpeeds;
|
||||
|
||||
std::vector<CLabel*> labels;
|
||||
public:
|
||||
CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface * owner); //c-tor
|
||||
|
||||
void bDefaultf(); //dafault button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
||||
|
||||
/// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
|
||||
struct SBattleEffect
|
||||
{
|
||||
int x, y; //position on the screen
|
||||
int frame, maxFrame;
|
||||
CDefHandler * anim; //animation to display
|
||||
int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
|
||||
};
|
||||
|
||||
/// Shows the stack queue
|
||||
class CStackQueue : public CIntObject
|
||||
{
|
||||
class StackBox : public CIntObject
|
||||
{
|
||||
public:
|
||||
const CStack *my;
|
||||
SDL_Surface *bg;
|
||||
|
||||
void hover (bool on);
|
||||
void showAll(SDL_Surface *to);
|
||||
void setStack(const CStack *nStack);
|
||||
StackBox(SDL_Surface *BG);
|
||||
~StackBox();
|
||||
};
|
||||
|
||||
public:
|
||||
static const int QUEUE_SIZE = 10;
|
||||
const bool embedded;
|
||||
std::vector<const CStack *> stacksSorted;
|
||||
std::vector<StackBox *> stackBoxes;
|
||||
|
||||
SDL_Surface *box;
|
||||
SDL_Surface *bg;
|
||||
CBattleInterface * owner;
|
||||
|
||||
void showAll(SDL_Surface *to);
|
||||
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
||||
~CStackQueue();
|
||||
void update();
|
||||
void blitBg( SDL_Surface * to );
|
||||
//void showAll(SDL_Surface *to);
|
||||
};
|
||||
|
||||
/// Small struct which is needed for drawing the parabolic trajectory of the catapult cannon
|
||||
struct CatapultProjectileInfo
|
||||
{
|
||||
const double facA, facB, facC;
|
||||
const int fromX, toX;
|
||||
|
||||
CatapultProjectileInfo() : facA(0), facB(0), facC(0), fromX(0), toX(0) { };
|
||||
CatapultProjectileInfo(double factorA, double factorB, double factorC, int fromXX, int toXX) : facA(factorA), facB(factorB), facC(factorC),
|
||||
fromX(fromXX), toX(toXX) { };
|
||||
|
||||
double calculateY(double x);
|
||||
};
|
||||
|
||||
/// Big class which handles the overall battle interface actions and it is also responsible for
|
||||
/// drawing everything correctly.
|
||||
class CBattleInterface : public CIntObject
|
||||
{
|
||||
enum SpellSelectionType
|
||||
{
|
||||
ANY_LOCATION = 0, FRIENDLY_CREATURE, HOSTILE_CREATURE, ANY_CREATURE, OBSTACLE, TELEPORT, NO_LOCATION = -1, STACK_SPELL_CANCELLED = -2
|
||||
};
|
||||
private:
|
||||
SDL_Surface * background, * menu, * amountNormal, * amountNegative, * amountPositive, * amountEffNeutral, * cellBorders, * backgroundWithHexes;
|
||||
AdventureMapButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
|
||||
* bWait, * bDefence, * bConsoleUp, * bConsoleDown, *btactNext, *btactEnd;
|
||||
CBattleConsole * console;
|
||||
CBattleHero * attackingHero, * defendingHero; //fighting heroes
|
||||
CStackQueue *queue;
|
||||
const CCreatureSet *army1, *army2; //copy of initial armies (for result window)
|
||||
const CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
|
||||
std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
|
||||
std::map< int, CDefHandler * > idToProjectile; //projectiles of creatures (creatureID, defhandler)
|
||||
std::map< int, CDefHandler * > idToObstacle; //obstacles located on the battlefield
|
||||
std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation>
|
||||
unsigned char animCount;
|
||||
const CStack * activeStack; //number of active stack; NULL - no one
|
||||
const CStack * stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; NULL of none
|
||||
void activateStack(); //sets activeStack to stackToActivate etc.
|
||||
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<THex> occupyableHexes, //hexes available for active stack
|
||||
attackableHexes; //hexes attackable by active stack
|
||||
bool stackCountOutsideHexes[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
|
||||
int currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
|
||||
int attackingHex; //hex from which the stack would perform attack with current cursor
|
||||
float 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
|
||||
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
|
||||
SpellSelectionType spellSelMode;
|
||||
BattleAction * spellToCast; //spell for which player is choosing destination
|
||||
TSpell creatureSpellToCast;
|
||||
void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
|
||||
|
||||
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<THex, 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, THex tile, ui32 stack, si32 additional=-1);
|
||||
bool isTileAttackable(const THex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
|
||||
bool blockedByObstacle(THex hex) const;
|
||||
bool isCatapultAttackable(THex 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
|
||||
|
||||
/// Class which is responsible for drawing the wall of a siege during battle
|
||||
class SiegeHelper
|
||||
{
|
||||
private:
|
||||
static std::string townTypeInfixes[F_NUMBER]; //for internal use only - to build filenames
|
||||
SDL_Surface * walls[18];
|
||||
const CBattleInterface * owner;
|
||||
public:
|
||||
const CGTownInstance * town; //besieged town
|
||||
|
||||
SiegeHelper(const CGTownInstance * siegeTown, const CBattleInterface * _owner); //c-tor
|
||||
~SiegeHelper(); //d-tor
|
||||
|
||||
//filename getters
|
||||
std::string getSiegeName(ui16 what, ui16 additInfo = 1) const; //what: 0 - background, 1 - background wall, 2 - keep, 3 - bottom tower, 4 - bottom wall, 5 - below gate, 6 - over gate, 7 - upper wall, 8 - uppert tower, 9 - gate, 10 - gate arch, 11 - bottom static wall, 12 - upper static wall, 13 - moat, 14 - mlip, 15 - keep creature cover, 16 - bottom turret creature cover, 17 - upper turret creature cover; additInfo: 1 - intact, 2 - damaged, 3 - destroyed
|
||||
|
||||
void printPartOfWall(SDL_Surface * to, int what);//what: 1 - background wall, 2 - keep, 3 - bottom tower, 4 - bottom wall, 5 - below gate, 6 - over gate, 7 - upper wall, 8 - uppert tower, 9 - gate, 10 - gate arch, 11 - bottom static wall, 12 - upper static wall, 15 - keep creature cover, 16 - bottom turret creature cover, 17 - upper turret creature cover
|
||||
|
||||
friend class CBattleInterface;
|
||||
} * siegeH;
|
||||
|
||||
CPlayerInterface * attackerInt, * defenderInt; //because LOCPLINT is not enough in hotSeat
|
||||
const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
|
||||
public:
|
||||
CPlayerInterface * curInt; //current player interface
|
||||
std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
|
||||
void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims
|
||||
unsigned int animIDhelper; //for giving IDs for animations
|
||||
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
||||
|
||||
CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen); //c-tor
|
||||
~CBattleInterface(); //d-tor
|
||||
|
||||
//std::vector<TimeInterested*> timeinterested; //animation handling
|
||||
void setPrintCellBorders(bool set); //if true, cell borders will be printed
|
||||
void setPrintStackRange(bool set); //if true,range of active stack will be printed
|
||||
void setPrintMouseShadow(bool set); //if true, hex under mouse will be shaded
|
||||
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
|
||||
|
||||
CBattleHex bfield[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
|
||||
bool myTurn; //if true, interface is active (commands can be ordered)
|
||||
CBattleResultWindow * resWindow; //window of end of battle
|
||||
|
||||
bool moveStarted; //if true, the creature that is already moving is going to make its first step
|
||||
int moveSh; // sound handler used when moving a unit
|
||||
|
||||
//button handle funcs:
|
||||
void bOptionsf();
|
||||
void bSurrenderf();
|
||||
void bFleef();
|
||||
void reallyFlee(); //performs fleeing without asking player
|
||||
void reallySurrender(); //performs surrendering without asking player
|
||||
void bAutofightf();
|
||||
void bSpellf();
|
||||
void bWaitf();
|
||||
void bDefencef();
|
||||
void bConsoleUpf();
|
||||
void bConsoleDownf();
|
||||
void bTacticNextStack();
|
||||
void bEndTacticPhase();
|
||||
//end of button handle funcs
|
||||
//napisz tu klase odpowiadajaca za wyswietlanie bitwy i obsluge uzytkownika, polecenia ma przekazywac callbackiem
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to);
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void mouseMoved(const SDL_MouseMotionEvent &sEvent);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
|
||||
//call-ins
|
||||
void startAction(const BattleAction* action);
|
||||
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<THex> 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, THex 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
|
||||
void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls
|
||||
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
|
||||
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
|
||||
void displayBattleFinished(); //displays battle result
|
||||
void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
|
||||
void castThisSpell(int spellID); //called when player has chosen a spell from spellbook
|
||||
void displayEffect(ui32 effect, int destTile); //displays effect of a spell on the battlefield; affected: true - attacker. false - defender
|
||||
void battleTriggerEffect(const BattleTriggerEffect & bte);
|
||||
void setBattleCursor(const int myNumber); //really complex and messy
|
||||
void endAction(const BattleAction* action);
|
||||
void hideQueue();
|
||||
void showQueue();
|
||||
friend class CBattleHex;
|
||||
friend class CBattleResultWindow;
|
||||
friend class CPlayerInterface;
|
||||
friend class AdventureMapButton;
|
||||
friend class CInGameConsole;
|
||||
friend class CReverseAnim;
|
||||
friend class CBattleStackAnimation;
|
||||
friend class CBattleAnimation;
|
||||
friend class CDefenceAnim;
|
||||
friend class CBattleStackMoved;
|
||||
friend class CBattleMoveStart;
|
||||
friend class CBattleMoveEnd;
|
||||
friend class CBattleAttack;
|
||||
friend class CMeleeAttack;
|
||||
friend class CShootingAnim;
|
||||
friend class CSpellEffectAnim;
|
||||
friend class CBattleHero;
|
||||
};
|
||||
|
||||
#endif // __CBATTLEINTERFACE_H__
|
@ -1,12 +1,11 @@
|
||||
#include "../stdafx.h"
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_image.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "../lib/CLodHandler.h"
|
||||
#include "../lib/vcmi_endian.h"
|
||||
#include <sstream>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
/*
|
||||
* CBitmapHandler.cpp, part of VCMI engine
|
||||
@ -18,14 +17,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern DLL_EXPORT CLodHandler *bitmaph;
|
||||
extern DLL_EXPORT CLodHandler *bitmaph_ab;
|
||||
extern DLL_EXPORT CLodHandler *spriteh;
|
||||
extern DLL_LINKAGE CLodHandler *bitmaph;
|
||||
extern DLL_LINKAGE CLodHandler *bitmaph_ab;
|
||||
extern DLL_LINKAGE CLodHandler *spriteh;
|
||||
|
||||
void CPCXConv::openPCX(char * PCX, int len)
|
||||
{
|
||||
pcxs=len;
|
||||
pcx=(unsigned char*)PCX;
|
||||
pcx=(ui8*)PCX;
|
||||
}
|
||||
void CPCXConv::fromFile(std::string path)
|
||||
{
|
||||
@ -34,7 +33,7 @@ void CPCXConv::fromFile(std::string path)
|
||||
is.seekg(0,std::ios::end); // to the end
|
||||
pcxs = is.tellg(); // read length
|
||||
is.seekg(0,std::ios::beg); // wracamy na poczatek
|
||||
pcx = new unsigned char[pcxs]; // allocate memory
|
||||
pcx = new ui8[pcxs]; // allocate memory
|
||||
is.read((char*)pcx, pcxs); // read map file to buffer
|
||||
is.close();
|
||||
}
|
||||
@ -119,7 +118,7 @@ SDL_Surface * CPCXConv::getSurface() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isPCX(const unsigned char *header)//check whether file can be PCX according to 1st 12 bytes
|
||||
bool isPCX(const ui8 *header)//check whether file can be PCX according to 1st 12 bytes
|
||||
{
|
||||
int fSize = read_le_u32(header + 0);
|
||||
int width = read_le_u32(header + 4);
|
||||
@ -142,7 +141,7 @@ SDL_Surface * BitmapHandler::loadBitmapFromLod(CLodHandler *lod, std::string fna
|
||||
|
||||
SDL_Surface * ret=NULL;
|
||||
int size;
|
||||
unsigned char * file = 0;
|
||||
ui8 * file = 0;
|
||||
file = lod->giveFile(fname, FILE_GRAPHICS, &size);
|
||||
|
||||
if (isPCX(file))
|
||||
|
@ -1,8 +1,7 @@
|
||||
#ifndef __CBITMAPHANDLER_H__
|
||||
#define __CBITMAPHANDLER_H__
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
#include "../global.h"
|
||||
struct SDL_Surface;
|
||||
class CLodHandler;
|
||||
|
||||
@ -21,14 +20,14 @@ enum Epcxformat {PCX8B, PCX24B};
|
||||
/// Struct which stands for a simple rgba palette
|
||||
struct BMPPalette
|
||||
{
|
||||
unsigned char R,G,B,F;
|
||||
ui8 R,G,B,F;
|
||||
};
|
||||
|
||||
/// Class which converts pcx to bmp images
|
||||
class CPCXConv
|
||||
{
|
||||
public:
|
||||
unsigned char * pcx, *bmp;
|
||||
ui8 * pcx, *bmp;
|
||||
int pcxs, bmps;
|
||||
void fromFile(std::string path);
|
||||
void saveBMP(std::string path) const;
|
||||
@ -52,5 +51,3 @@ namespace BitmapHandler
|
||||
//Load file from any LODs
|
||||
SDL_Surface * loadBitmap(std::string fname, bool setKey=true);
|
||||
};
|
||||
|
||||
#endif // __CBITMAPHANDLER_H__
|
||||
|
@ -1,13 +1,6 @@
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CCastleInterface.h"
|
||||
|
||||
#include "../CCallback.h"
|
||||
#include "../lib/CArtHandler.h"
|
||||
#include "../lib/CBuildingHandler.h"
|
||||
@ -16,7 +9,6 @@
|
||||
#include "../lib/CObjectHandler.h"
|
||||
#include "../lib/CSpellHandler.h"
|
||||
#include "../lib/CTownHandler.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "CAnimation.h"
|
||||
#include "CBitmapHandler.h"
|
||||
@ -27,7 +19,10 @@
|
||||
#include "CMusicHandler.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "Graphics.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
using namespace boost::assign;
|
||||
|
||||
@ -126,23 +121,23 @@ void CBuildingRect::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
int bid = hordeToDwellingID(str->ID);
|
||||
const CBuilding *bld = CGI->buildh->buildings[str->townID].find(bid)->second;
|
||||
if (bid < Buildings::DWELL_FIRST)
|
||||
if (bid < EBuilding::DWELL_FIRST)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building, bld->tid, bld->bid,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building, bld->tid, bld->bid,
|
||||
LOCPLINT->castleInt->bicons->ourImages[bld->bid].bitmap, false));
|
||||
|
||||
CRClickPopup::createAndPush(bld->Description(), comps);
|
||||
}
|
||||
else
|
||||
{
|
||||
int level = ( bid - Buildings::DWELL_FIRST ) % CREATURES_PER_TOWN;
|
||||
int level = ( bid - EBuilding::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
|
||||
GH.pushInt(new CDwellingInfoBox(parent->pos.x+parent->pos.w/2, parent->pos.y+parent->pos.h/2, town, level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, float f)
|
||||
SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, double f)
|
||||
{
|
||||
SDL_Color ret;
|
||||
ret.r = a.r*f + b.r*(1-f);
|
||||
@ -151,14 +146,14 @@ SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, float f)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CBuildingRect::show(SDL_Surface *to)
|
||||
void CBuildingRect::show(SDL_Surface * to)
|
||||
{
|
||||
const unsigned int stageDelay = 16;
|
||||
const ui32 stageDelay = 16;
|
||||
|
||||
const unsigned int S1_TRANSP = 16; //0.5 sec building appear 0->100 transparency
|
||||
const unsigned int S2_WHITE_B = 32; //0.5 sec border glows from white to yellow
|
||||
const unsigned int S3_YELLOW_B= 48; //0.5 sec border glows from yellow to normal
|
||||
const unsigned int BUILDED = 80; // 1 sec delay, nothing happens
|
||||
const ui32 S1_TRANSP = 16; //0.5 sec building appear 0->100 transparency
|
||||
const ui32 S2_WHITE_B = 32; //0.5 sec border glows from white to yellow
|
||||
const ui32 S3_YELLOW_B= 48; //0.5 sec border glows from yellow to normal
|
||||
const ui32 BUILDED = 80; // 1 sec delay, nothing happens
|
||||
|
||||
if (stateCounter < S1_TRANSP)
|
||||
{
|
||||
@ -184,15 +179,15 @@ void CBuildingRect::show(SDL_Surface *to)
|
||||
SDL_Color c2 = {120, 100, 60, 255};
|
||||
SDL_Color c3 = {200, 180, 110, 255};
|
||||
|
||||
unsigned int colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b);
|
||||
ui32 colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b);
|
||||
SDL_Color oldColor = border->format->palette->colors[colorID];
|
||||
SDL_Color newColor;
|
||||
|
||||
if (stateCounter < S2_WHITE_B)
|
||||
newColor = multiplyColors(c1, c2, float(stateCounter%stageDelay)/stageDelay);
|
||||
newColor = multiplyColors(c1, c2, static_cast<double>(stateCounter % stageDelay) / stageDelay);
|
||||
else
|
||||
if (stateCounter < S3_YELLOW_B)
|
||||
newColor = multiplyColors(c2, c3, float(stateCounter%stageDelay)/stageDelay);
|
||||
newColor = multiplyColors(c2, c3, static_cast<double>(stateCounter % stageDelay) / stageDelay);
|
||||
else
|
||||
newColor = oldColor;
|
||||
|
||||
@ -205,7 +200,7 @@ void CBuildingRect::show(SDL_Surface *to)
|
||||
stateCounter++;
|
||||
}
|
||||
|
||||
void CBuildingRect::showAll(SDL_Surface *to)
|
||||
void CBuildingRect::showAll(SDL_Surface * to)
|
||||
{
|
||||
if (stateCounter == 0)
|
||||
return;
|
||||
@ -224,7 +219,7 @@ std::string getBuildingSubtitle(int tid, int bid)//hover text for building
|
||||
return CGI->buildh->buildings[tid].find(bid)->second->Name();
|
||||
else//dwellings - recruit %creature%
|
||||
{
|
||||
int creaID = t->creatures[(bid-30)%CREATURES_PER_TOWN].second.back();//taking last of available creatures
|
||||
int creaID = t->creatures[(bid-30)%GameConstants::CREATURES_PER_TOWN].second.back();//taking last of available creatures
|
||||
return CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creaID]->namePl;
|
||||
}
|
||||
}
|
||||
@ -265,19 +260,19 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc
|
||||
|
||||
const CCreature * creature = CGI->creh->creatures[Town->creatures[level].second.back()];
|
||||
|
||||
title = new CLabel(80, 30, FONT_SMALL, CENTER, zwykly, creature->namePl);
|
||||
title = new CLabel(80, 30, FONT_SMALL, CENTER, Colors::Cornsilk, creature->namePl);
|
||||
animation = new CCreaturePic(30, 44, creature, true, true);
|
||||
|
||||
std::string text = boost::lexical_cast<std::string>(Town->creatures[level].first);
|
||||
available = new CLabel(80,190, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[217] + text);
|
||||
costPerTroop = new CLabel(80, 227, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[346]);
|
||||
available = new CLabel(80,190, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->allTexts[217] + text);
|
||||
costPerTroop = new CLabel(80, 227, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->allTexts[346]);
|
||||
|
||||
for(int i = 0; i<RESOURCE_QUANTITY; i++)
|
||||
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||
{
|
||||
if(creature->cost[i])
|
||||
{
|
||||
resPicture.push_back(new CPicture(graphics->resources32->ourImages[i].bitmap, 0, 0, false));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, zwykly, boost::lexical_cast<std::string>(creature->cost[i])));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, Colors::Cornsilk, boost::lexical_cast<std::string>(creature->cost[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,12 +366,12 @@ void CHeroGSlot::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
std::string tmp = CGI->generaltexth->allTexts[18]; //You already have %d adventuring heroes under your command.
|
||||
boost::algorithm::replace_first(tmp,"%d",boost::lexical_cast<std::string>(LOCPLINT->cb->howManyHeroes(false)));
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<CComponent*>(), soundBase::sound_todo);
|
||||
allow = false;
|
||||
}
|
||||
else if(!other->hero->stacksCount()) //hero has no creatures - strange, but if we have appropriate error message...
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<SComponent*>(), soundBase::sound_todo); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<CComponent*>(), soundBase::sound_todo); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
allow = false;
|
||||
}
|
||||
}
|
||||
@ -484,7 +479,7 @@ CCastleBuildings::CCastleBuildings(const CGTownInstance* Town):
|
||||
if(shipyard && vstd::contains(groups, shipyard->group))
|
||||
{
|
||||
std::vector <const CGObjectInstance *> vobjs = LOCPLINT->cb->getVisitableObjs(town->bestLocation());
|
||||
if(!vobjs.empty() && (vobjs.front()->ID == 8 || vobjs.front()->ID == HEROI_TYPE)) //there is visitable obj at shipyard output tile and it's a boat or hero (on boat)
|
||||
if(!vobjs.empty() && (vobjs.front()->ID == 8 || vobjs.front()->ID == GameConstants::HEROI_TYPE)) //there is visitable obj at shipyard output tile and it's a boat or hero (on boat)
|
||||
{
|
||||
groups[shipyard->group].push_back(CGI->townh->structures[town->subID][20]);
|
||||
}
|
||||
@ -623,14 +618,14 @@ void CCastleBuildings::removeBuilding(int building)
|
||||
checkRules();
|
||||
}
|
||||
|
||||
void CCastleBuildings::show(SDL_Surface *to)
|
||||
void CCastleBuildings::show(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
for (std::vector< CBuildingRect* >::const_iterator it=buildings.begin() ; it !=buildings.end(); it++ )
|
||||
(*it)->show(to);
|
||||
}
|
||||
|
||||
void CCastleBuildings::showAll(SDL_Surface *to)
|
||||
void CCastleBuildings::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
for (std::vector< CBuildingRect* >::const_iterator it=buildings.begin() ; it !=buildings.end(); it++ )
|
||||
@ -652,52 +647,52 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
building = hordeToDwellingID(building);
|
||||
const CBuilding *b = CGI->buildh->buildings[town->subID].find(building)->second;
|
||||
|
||||
if(building >= Buildings::DWELL_FIRST)
|
||||
if(building >= EBuilding::DWELL_FIRST)
|
||||
{
|
||||
enterDwelling((building-Buildings::DWELL_FIRST)%CREATURES_PER_TOWN);
|
||||
enterDwelling((building-EBuilding::DWELL_FIRST)%GameConstants::CREATURES_PER_TOWN);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(building)
|
||||
{
|
||||
case Buildings::MAGES_GUILD_1:
|
||||
case Buildings::MAGES_GUILD_2:
|
||||
case Buildings::MAGES_GUILD_3:
|
||||
case Buildings::MAGES_GUILD_4:
|
||||
case Buildings::MAGES_GUILD_5:
|
||||
case EBuilding::MAGES_GUILD_1:
|
||||
case EBuilding::MAGES_GUILD_2:
|
||||
case EBuilding::MAGES_GUILD_3:
|
||||
case EBuilding::MAGES_GUILD_4:
|
||||
case EBuilding::MAGES_GUILD_5:
|
||||
enterMagesGuild();
|
||||
break;
|
||||
|
||||
case Buildings::TAVERN:
|
||||
case EBuilding::TAVERN:
|
||||
LOCPLINT->showTavernWindow(town);
|
||||
break;
|
||||
|
||||
case Buildings::SHIPYARD:
|
||||
case EBuilding::SHIPYARD:
|
||||
LOCPLINT->showShipyardDialog(town);
|
||||
break;
|
||||
|
||||
case Buildings::FORT:
|
||||
case Buildings::CITADEL:
|
||||
case Buildings::CASTLE:
|
||||
case EBuilding::FORT:
|
||||
case EBuilding::CITADEL:
|
||||
case EBuilding::CASTLE:
|
||||
GH.pushInt(new CFortScreen(town));
|
||||
break;
|
||||
|
||||
case Buildings::VILLAGE_HALL:
|
||||
case Buildings::CITY_HALL:
|
||||
case Buildings::TOWN_HALL:
|
||||
case Buildings::CAPITOL:
|
||||
case EBuilding::VILLAGE_HALL:
|
||||
case EBuilding::CITY_HALL:
|
||||
case EBuilding::TOWN_HALL:
|
||||
case EBuilding::CAPITOL:
|
||||
enterTownHall();
|
||||
break;
|
||||
|
||||
case Buildings::MARKETPLACE:
|
||||
case EBuilding::MARKETPLACE:
|
||||
GH.pushInt(new CMarketplaceWindow(town, town->visitingHero));
|
||||
break;
|
||||
|
||||
case Buildings::BLACKSMITH:
|
||||
case EBuilding::BLACKSMITH:
|
||||
enterBlacksmith(town->town->warMachine);
|
||||
break;
|
||||
|
||||
case Buildings::SPECIAL_1:
|
||||
case EBuilding::SPECIAL_1:
|
||||
switch(town->subID)
|
||||
{
|
||||
case 1://Mystic Pond
|
||||
@ -706,7 +701,7 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
|
||||
case 2: case 5: case 8://Artifact Merchant
|
||||
if(town->visitingHero)
|
||||
GH.pushInt(new CMarketplaceWindow(town, town->visitingHero, RESOURCE_ARTIFACT));
|
||||
GH.pushInt(new CMarketplaceWindow(town, town->visitingHero, EMarketMode::RESOURCE_ARTIFACT));
|
||||
else
|
||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->Name())); //Only visiting heroes may use the %s.
|
||||
break;
|
||||
@ -717,11 +712,11 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
}
|
||||
break;
|
||||
|
||||
case Buildings::SHIP:
|
||||
case EBuilding::SHIP:
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat
|
||||
break;
|
||||
|
||||
case Buildings::SPECIAL_2:
|
||||
case EBuilding::SPECIAL_2:
|
||||
switch(town->subID)
|
||||
{
|
||||
case 1: //Fountain of Fortune
|
||||
@ -730,7 +725,7 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
|
||||
case 6: //Freelancer's Guild
|
||||
if(getHero())
|
||||
GH.pushInt(new CMarketplaceWindow(town, getHero(), CREATURE_RESOURCE));
|
||||
GH.pushInt(new CMarketplaceWindow(town, getHero(), EMarketMode::CREATURE_RESOURCE));
|
||||
else
|
||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->Name())); //Only visiting heroes may use the %s.
|
||||
break;
|
||||
@ -748,7 +743,7 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
}
|
||||
break;
|
||||
|
||||
case Buildings::SPECIAL_3:
|
||||
case EBuilding::SPECIAL_3:
|
||||
switch(town->subID)
|
||||
{
|
||||
case 0: //Brotherhood of sword
|
||||
@ -764,10 +759,10 @@ void CCastleBuildings::buildingClicked(int building)
|
||||
break;
|
||||
|
||||
case 5: //Portal of Summoning
|
||||
if (town->creatures[CREATURES_PER_TOWN].second.empty())//No creatures
|
||||
if (town->creatures[GameConstants::CREATURES_PER_TOWN].second.empty())//No creatures
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->tcommands[30]);
|
||||
else
|
||||
enterDwelling(CREATURES_PER_TOWN);
|
||||
enterDwelling(GameConstants::CREATURES_PER_TOWN);
|
||||
break;
|
||||
|
||||
case 6: //Ballista Yard
|
||||
@ -802,8 +797,8 @@ void CCastleBuildings::enterBlacksmith(int ArtifactID)
|
||||
|
||||
void CCastleBuildings::enterBuilding(int building)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building, town->subID,building,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building, town->subID,building,
|
||||
LOCPLINT->castleInt->bicons->ourImages[building].bitmap, false));
|
||||
|
||||
LOCPLINT->showInfoDialog(
|
||||
@ -841,8 +836,8 @@ void CCastleBuildings::enterDwelling(int level)
|
||||
|
||||
void CCastleBuildings::enterFountain(int building)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building,town->subID,building,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building,town->subID,building,
|
||||
LOCPLINT->castleInt->bicons->ourImages[building].bitmap,false));
|
||||
|
||||
std::string descr = CGI->buildh->buildings[town->subID].find(building)->second->Description();
|
||||
@ -873,7 +868,7 @@ void CCastleBuildings::enterMagesGuild()
|
||||
{
|
||||
CFunctionList<void()> functionList = boost::bind(&CCallback::buyArtifact,LOCPLINT->cb, hero,0);
|
||||
functionList += boost::bind(&CCastleBuildings::openMagesGuild,this);
|
||||
std::vector<SComponent*> components(1, new SComponent(SComponent::artifact,0,0));
|
||||
std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,0,0));
|
||||
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[214], components, functionList, 0, true);
|
||||
}
|
||||
@ -887,13 +882,13 @@ void CCastleBuildings::enterMagesGuild()
|
||||
void CCastleBuildings::enterTownHall()
|
||||
{
|
||||
if(town->visitingHero && town->visitingHero->hasArt(2) &&
|
||||
!vstd::contains(town->builtBuildings, Buildings::GRAIL)) //hero has grail, but town does not have it
|
||||
!vstd::contains(town->builtBuildings, EBuilding::GRAIL)) //hero has grail, but town does not have it
|
||||
{
|
||||
if(!vstd::contains(town->forbiddenBuildings, Buildings::GRAIL))
|
||||
if(!vstd::contains(town->forbiddenBuildings, EBuilding::GRAIL))
|
||||
{
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[597], //Do you wish this to be the permanent home of the Grail?
|
||||
std::vector<SComponent*>(),
|
||||
boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, Buildings::GRAIL),
|
||||
std::vector<CComponent*>(),
|
||||
boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, EBuilding::GRAIL),
|
||||
boost::bind(&CCastleBuildings::openTownHall, this), true);
|
||||
}
|
||||
else
|
||||
@ -935,15 +930,15 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos):
|
||||
|
||||
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);
|
||||
title = new CLabel(85, 387, FONT_MEDIUM, TOPLEFT, zwykly, town->name);
|
||||
title = new CLabel(85, 387, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, town->name);
|
||||
income = new CLabel(195, 443, FONT_SMALL, CENTER);
|
||||
icon = new CAnimImage("ITPT", 0, 0, 15, 387);
|
||||
|
||||
exit = new AdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
|
||||
exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
exit->setOffset(4);
|
||||
|
||||
split = new AdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
|
||||
split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
|
||||
split->callback += boost::bind(&HeroSlots::splitClicked, heroes);
|
||||
removeChild(split);
|
||||
garr->addSplitBtn(split);
|
||||
@ -954,11 +949,11 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos):
|
||||
|
||||
townlist = new CTownList(3, 744, 414, "IAM014", "IAM015");
|
||||
townlist->fun = boost::bind(&CCastleInterface::townChange, this);
|
||||
townlist->selected = vstd::findPos(LOCPLINT->towns, Town);
|
||||
townlist->selected = vstd::find_pos(LOCPLINT->towns, Town);
|
||||
|
||||
townlist->from = townlist->selected - listPos;
|
||||
amax(townlist->from, 0);
|
||||
amin(townlist->from, LOCPLINT->towns.size() - townlist->SIZE);
|
||||
vstd::amax(townlist->from, 0);
|
||||
vstd::amin(townlist->from, LOCPLINT->towns.size() - townlist->SIZE);
|
||||
|
||||
LOCPLINT->castleInt = this;
|
||||
recreateIcons();
|
||||
@ -985,7 +980,7 @@ void CCastleInterface::close()
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
void CCastleInterface::showAll(SDL_Surface *to)
|
||||
void CCastleInterface::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
if(screen->w != 800 || screen->h !=600)
|
||||
@ -1034,9 +1029,9 @@ void CCastleInterface::recreateIcons()
|
||||
|
||||
size_t iconIndex = town->subID*2;
|
||||
if (!town->hasFort())
|
||||
iconIndex += F_NUMBER*2;
|
||||
iconIndex += GameConstants::F_NUMBER*2;
|
||||
|
||||
if(town->builded >= MAX_BUILDING_PER_TURN)
|
||||
if(town->builded >= GameConstants::MAX_BUILDING_PER_TURN)
|
||||
iconIndex++;
|
||||
|
||||
icon->setFrame(iconIndex);
|
||||
@ -1073,7 +1068,7 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool
|
||||
}
|
||||
used = LCLICK | RCLICK | HOVER;
|
||||
|
||||
unsigned int creatureID = town->creatures[level].second.back();
|
||||
ui32 creatureID = town->creatures[level].second.back();
|
||||
creature = CGI->creh->creatures[creatureID];
|
||||
|
||||
picture = new CAnimImage("CPRSMALL", creatureID+2, 0, 8, 0);
|
||||
@ -1086,14 +1081,14 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool
|
||||
|
||||
if (compact)
|
||||
{
|
||||
label = new CLabel(40, 32, FONT_TINY, BOTTOMRIGHT, zwykly, value);
|
||||
label = new CLabel(40, 32, FONT_TINY, BOTTOMRIGHT, Colors::Cornsilk, value);
|
||||
pos.x += 8;
|
||||
pos.w = 32;
|
||||
pos.h = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
label = new CLabel(24, 40, FONT_SMALL, CENTER, zwykly, value);
|
||||
label = new CLabel(24, 40, FONT_SMALL, CENTER, Colors::Cornsilk, value);
|
||||
pos.w = 48;
|
||||
pos.h = 48;
|
||||
}
|
||||
@ -1297,9 +1292,9 @@ void CHallInterface::CBuildingBox::hover(bool on)
|
||||
if(on)
|
||||
{
|
||||
std::string toPrint;
|
||||
if(state==Buildings::PREREQUIRES)
|
||||
if(state==EBuildingState::PREREQUIRES)
|
||||
toPrint = CGI->generaltexth->hcommands[5];
|
||||
else if(state==Buildings::CANT_BUILD_TODAY)
|
||||
else if(state==EBuildingState::CANT_BUILD_TODAY)
|
||||
toPrint = CGI->generaltexth->allTexts[223];
|
||||
else
|
||||
toPrint = CGI->generaltexth->hcommands[state];
|
||||
@ -1334,7 +1329,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
|
||||
pos.h = 92;
|
||||
|
||||
state = LOCPLINT->cb->canBuildStructure(town,building->bid);
|
||||
assert(state < Buildings::ERROR);
|
||||
assert(state < EBuildingState::BUILDING_ERROR);
|
||||
static int panelIndex[9] = { 3, 3, 3, 0, 0, 2, 2, 1, 2};
|
||||
static int iconIndex[9] = {-1, -1, -1, 0, 0, 1, 2, -1, 1};
|
||||
|
||||
@ -1342,7 +1337,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
|
||||
panel = new CAnimImage("TPTHBAR", panelIndex[state], 0, 1, 73);
|
||||
if ( iconIndex[state] >=0 )
|
||||
icon = new CAnimImage("TPTHCHK", iconIndex[state], 0, 136, 56);
|
||||
label = new CLabel(75, 81, FONT_SMALL, CENTER, zwykly, building->Name());
|
||||
label = new CLabel(75, 81, FONT_SMALL, CENTER, Colors::Cornsilk, building->Name());
|
||||
}
|
||||
|
||||
CHallInterface::CHallInterface(const CGTownInstance *Town):
|
||||
@ -1359,8 +1354,8 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
|
||||
Rect 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()+Buildings::VILLAGE_HALL]->Name());
|
||||
exit = new AdventureMapButton(CGI->generaltexth->hcommands[8], "",
|
||||
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->buildh->buildings[town->subID][town->hallLevel()+EBuilding::VILLAGE_HALL]->Name());
|
||||
exit = new CAdventureMapButton(CGI->generaltexth->hcommands[8], "",
|
||||
boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
@ -1462,23 +1457,23 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
Rect barRect(9, 494, 380, 18);
|
||||
statusBar = new CGStatusBar(new CPicture(*background, barRect, 9, 494, false));
|
||||
|
||||
title = new CLabel(197, 30, FONT_MEDIUM, CENTER, zwykly,
|
||||
title = new CLabel(197, 30, FONT_MEDIUM, CENTER, Colors::Cornsilk,
|
||||
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);
|
||||
|
||||
//Create objects for all required resources
|
||||
for(int i = 0; i<RESOURCE_QUANTITY; i++)
|
||||
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||
{
|
||||
if(building->resources[i])
|
||||
{
|
||||
resPicture.push_back(new CPicture(graphics->resources32->ourImages[i].bitmap, 0, 0, false));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, zwykly,
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, Colors::Cornsilk,
|
||||
boost::lexical_cast<std::string>(building->resources[i])));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int rowSize[2];
|
||||
ui32 rowSize[2];
|
||||
int posY;
|
||||
if (resAmount.size() > 4)
|
||||
{//Resources will be placed in multiple rows
|
||||
@ -1492,7 +1487,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
}
|
||||
rowSize[1] = resAmount.size() - rowSize[0];
|
||||
|
||||
unsigned int index=0;
|
||||
ui32 index=0;
|
||||
for (size_t row=0; row<2; row++)
|
||||
{
|
||||
int posX = pos.w/2 - rowSize[row] * 40 + 24;
|
||||
@ -1508,12 +1503,12 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
|
||||
if(!mode)
|
||||
{
|
||||
buy = new AdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
|
||||
buy = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
|
||||
"", boost::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
|
||||
buy->borderColor = Colors::MetallicGold;
|
||||
buy->borderEnabled = true;
|
||||
|
||||
cancel = new AdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
|
||||
cancel = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
|
||||
"", boost::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
|
||||
cancel->borderColor = Colors::MetallicGold;
|
||||
cancel->borderEnabled = true;
|
||||
@ -1532,11 +1527,11 @@ void CFortScreen::close()
|
||||
CFortScreen::CFortScreen(const CGTownInstance * town)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
unsigned int fortSize = town->creatures.size();
|
||||
if (fortSize > CREATURES_PER_TOWN && town->creatures.back().second.empty())
|
||||
ui32 fortSize = town->creatures.size();
|
||||
if (fortSize > GameConstants::CREATURES_PER_TOWN && town->creatures.back().second.empty())
|
||||
fortSize--;
|
||||
|
||||
if (fortSize == CREATURES_PER_TOWN)
|
||||
if (fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
background = new CPicture("TPCASTL7");
|
||||
else
|
||||
background = new CPicture("TPCASTL8");
|
||||
@ -1544,30 +1539,30 @@ CFortScreen::CFortScreen(const CGTownInstance * town)
|
||||
pos = background->center();
|
||||
|
||||
const CBuilding *fortBuilding = CGI->buildh->buildings[town->subID][town->fortLevel()+6];
|
||||
title = new CLabel(400, 12, FONT_BIG, CENTER, zwykly, fortBuilding->Name());
|
||||
title = new CLabel(400, 12, FONT_BIG, CENTER, Colors::Cornsilk, fortBuilding->Name());
|
||||
|
||||
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);
|
||||
exit = new CAdventureMapButton(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);
|
||||
|
||||
if (fortSize == CREATURES_PER_TOWN)
|
||||
if (fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
positions += Point(206,421);
|
||||
else
|
||||
positions += Point(10, 421), Point(404,421);
|
||||
|
||||
for (unsigned int i=0; i<fortSize; i++)
|
||||
for (ui32 i=0; i<fortSize; i++)
|
||||
{
|
||||
int buildingID;
|
||||
if (fortSize == CREATURES_PER_TOWN)
|
||||
if (fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
{
|
||||
if (vstd::contains(town->builtBuildings, Buildings::DWELL_UP_FIRST+i))
|
||||
buildingID = Buildings::DWELL_UP_FIRST+i;
|
||||
if (vstd::contains(town->builtBuildings, EBuilding::DWELL_UP_FIRST+i))
|
||||
buildingID = EBuilding::DWELL_UP_FIRST+i;
|
||||
else
|
||||
buildingID = Buildings::DWELL_FIRST+i;
|
||||
buildingID = EBuilding::DWELL_FIRST+i;
|
||||
}
|
||||
else
|
||||
buildingID = 22;
|
||||
@ -1618,8 +1613,8 @@ void LabeledValue::init(std::string nameText, std::string descr, int min, int ma
|
||||
if (min != max)
|
||||
valueText += '-' + boost::lexical_cast<std::string>(max);
|
||||
}
|
||||
name = new CLabel(3, 0, FONT_SMALL, TOPLEFT, zwykly, nameText);
|
||||
value = new CLabel(pos.w-3, pos.h-2, FONT_SMALL, BOTTOMRIGHT, zwykly, valueText);
|
||||
name = new CLabel(3, 0, FONT_SMALL, TOPLEFT, Colors::Cornsilk, nameText);
|
||||
value = new CLabel(pos.w-3, pos.h-2, FONT_SMALL, BOTTOMRIGHT, Colors::Cornsilk, valueText);
|
||||
}
|
||||
|
||||
void LabeledValue::hover(bool on)
|
||||
@ -1673,14 +1668,14 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
||||
sizes.y+=20;
|
||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[194], CGI->generaltexth->fcommands[5], town->creatureGrowth(level)));
|
||||
|
||||
creatureName = new CLabel(78, 11, FONT_SMALL, CENTER, zwykly, creature->namePl);
|
||||
dwellingName = new CLabel(78, 101, FONT_SMALL, CENTER, zwykly, CGI->buildh->buildings[town->subID][buildingID]->Name());
|
||||
creatureName = new CLabel(78, 11, FONT_SMALL, CENTER, Colors::Cornsilk, creature->namePl);
|
||||
dwellingName = new CLabel(78, 101, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->buildh->buildings[town->subID][buildingID]->Name());
|
||||
|
||||
if (vstd::contains(town->builtBuildings, buildingID))
|
||||
{
|
||||
unsigned int available = town->creatures[level].first;
|
||||
ui32 available = town->creatures[level].first;
|
||||
std::string availableText = CGI->generaltexth->allTexts[217]+ boost::lexical_cast<std::string>(available);
|
||||
availableCount = new CLabel(78, 119, FONT_SMALL, CENTER, zwykly, availableText);
|
||||
availableCount = new CLabel(78, 119, FONT_SMALL, CENTER, Colors::Cornsilk, availableText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1727,7 +1722,7 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner)
|
||||
Rect 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 = new CAdventureMapButton(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;
|
||||
@ -1771,8 +1766,8 @@ void CMageGuildScreen::Scroll::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(down)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::spell,spell->id,0)
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::spell,spell->id,0)
|
||||
);
|
||||
LOCPLINT->showInfoDialog(spell->descriptions[0],comps, soundBase::sound_todo);
|
||||
}
|
||||
@ -1819,17 +1814,17 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, int aid, i
|
||||
anim = new CCreatureAnim(64, 50, creature->animDefName, Rect());
|
||||
anim->clipRect(113,125,200,150);
|
||||
|
||||
title = new CLabel(165, 28, FONT_BIG, CENTER, tytulowy,
|
||||
title = new CLabel(165, 28, FONT_BIG, CENTER, Colors::Jasmine,
|
||||
boost::str(boost::format(CGI->generaltexth->allTexts[274]) % creature->nameSing));
|
||||
costText = new CLabel(165, 218, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->jktexts[43]);
|
||||
costValue = new CLabel(165, 290, FONT_MEDIUM, CENTER, zwykly,
|
||||
costText = new CLabel(165, 218, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->jktexts[43]);
|
||||
costValue = new CLabel(165, 290, FONT_MEDIUM, CENTER, Colors::Cornsilk,
|
||||
boost::lexical_cast<std::string>(CGI->arth->artifacts[aid]->price));
|
||||
|
||||
std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing);
|
||||
buy = new AdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
|
||||
buy = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
|
||||
|
||||
text = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % creature->nameSing);
|
||||
cancel = new AdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
|
||||
cancel = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
|
||||
|
||||
if(possible)
|
||||
buy->callback += boost::bind(&CCallback::buyArtifact,LOCPLINT->cb,LOCPLINT->cb->getHero(hid),aid);
|
||||
|
@ -1,11 +1,10 @@
|
||||
#ifndef __CCASTLEINTERFACE_H__
|
||||
#define __CCASTLEINTERFACE_H__
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../global.h"
|
||||
#include "CAnimation.h"
|
||||
#include "GUIBase.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CBuilding;
|
||||
class CCastleBuildings;
|
||||
class CCreaturePic;
|
||||
@ -20,6 +19,9 @@ class CStatusBar;
|
||||
class CTextBox;
|
||||
class CTownList;
|
||||
struct Structure;
|
||||
class CGHeroInstance;
|
||||
class CGarrisonInt;
|
||||
class CCreature;
|
||||
|
||||
/*
|
||||
* CCastleInterface.h, part of VCMI engine
|
||||
@ -31,6 +33,7 @@ struct Structure;
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/// Building "button"
|
||||
class CBuildingRect : public CShowableAnim
|
||||
{
|
||||
@ -41,7 +44,7 @@ public:
|
||||
SDL_Surface* border;
|
||||
SDL_Surface* area;
|
||||
|
||||
unsigned int stateCounter;//For building construction - current stage in animation
|
||||
ui32 stateCounter;//For building construction - current stage in animation
|
||||
|
||||
CBuildingRect(CCastleBuildings * Par, const CGTownInstance *Town, const Structure *Str); //c-tor
|
||||
~CBuildingRect(); //d-tor
|
||||
@ -50,8 +53,8 @@ public:
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Dwelling info box - right-click screen for dwellings
|
||||
@ -143,8 +146,8 @@ public:
|
||||
void addBuilding(int building);
|
||||
void removeBuilding(int building);//FIXME: not tested!!!
|
||||
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Creature info window
|
||||
@ -198,8 +201,8 @@ class CCastleInterface : public CWindowWithGarrison
|
||||
CTownInfo *hall, *fort;
|
||||
CTownList * townlist;
|
||||
|
||||
AdventureMapButton *exit;
|
||||
AdventureMapButton *split;
|
||||
CAdventureMapButton *exit;
|
||||
CAdventureMapButton *split;
|
||||
|
||||
std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
|
||||
|
||||
@ -218,7 +221,7 @@ public:
|
||||
void castleTeleport(int where);
|
||||
void townChange();
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void showAll(SDL_Surface *to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void close();
|
||||
void addBuilding(int bid);
|
||||
void removeBuilding(int bid);
|
||||
@ -234,7 +237,7 @@ class CHallInterface : public CIntObject
|
||||
const CGTownInstance * town;
|
||||
const CBuilding * building;
|
||||
|
||||
unsigned int state;//Buildings::EBuildStructure enum
|
||||
ui32 state;//Buildings::EBuildStructure enum
|
||||
|
||||
CAnimImage * picture;
|
||||
CAnimImage * panel;
|
||||
@ -254,7 +257,7 @@ class CHallInterface : public CIntObject
|
||||
CLabel *title;
|
||||
CGStatusBar *statusBar;
|
||||
CMinorResDataBar * resdatabar;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
|
||||
public:
|
||||
CHallInterface(const CGTownInstance * Town); //c-tor
|
||||
@ -271,8 +274,8 @@ class CBuildWindow: public CIntObject
|
||||
|
||||
CPicture *background;
|
||||
CAnimImage *buildingPic;
|
||||
AdventureMapButton *buy;
|
||||
AdventureMapButton *cancel;
|
||||
CAdventureMapButton *buy;
|
||||
CAdventureMapButton *cancel;
|
||||
|
||||
CLabel * title;
|
||||
CTextBox * buildingDescr;
|
||||
@ -338,7 +341,7 @@ class CFortScreen : public CIntObject
|
||||
std::vector<RecruitArea*> recAreas;
|
||||
CMinorResDataBar * resdatabar;
|
||||
CGStatusBar *statusBar;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
|
||||
public:
|
||||
CFortScreen(const CGTownInstance * town); //c-tor
|
||||
@ -363,7 +366,7 @@ class CMageGuildScreen : public CIntObject
|
||||
};
|
||||
CPicture *background;
|
||||
CPicture *window;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
std::vector<Scroll *> spells;
|
||||
CMinorResDataBar * resdatabar;
|
||||
CGStatusBar *statusBar;
|
||||
@ -377,7 +380,7 @@ public:
|
||||
/// The blacksmith window where you can buy available in town war machine
|
||||
class CBlacksmithDialog : public CIntObject
|
||||
{
|
||||
AdventureMapButton *buy, *cancel;
|
||||
CAdventureMapButton *buy, *cancel;
|
||||
CPicture *background;
|
||||
CPicture *animBG;
|
||||
CCreatureAnim * anim;
|
||||
@ -392,5 +395,3 @@ class CBlacksmithDialog : public CIntObject
|
||||
public:
|
||||
CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid);
|
||||
};
|
||||
|
||||
#endif // __CCASTLEINTERFACE_H__
|
||||
|
@ -1,11 +1,9 @@
|
||||
//#define BOOST_SPIRIT_DEBUG
|
||||
#include "CConfigHandler.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include "StdInc.h"
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <fstream>
|
||||
#include "CConfigHandler.h"
|
||||
|
||||
#include "../lib/JsonNode.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
|
||||
using namespace config;
|
||||
|
||||
@ -148,10 +146,11 @@ CConfigHandler::~CConfigHandler(void)
|
||||
void config::CConfigHandler::init()
|
||||
{
|
||||
std::vector<char> settings;
|
||||
std::ifstream ifs(DATA_DIR "/config/settings.txt");
|
||||
std::string settingsDir = GameConstants::DATA_DIR + "/config/settings.txt";
|
||||
std::ifstream ifs(settingsDir.c_str());
|
||||
if(!ifs)
|
||||
{
|
||||
tlog1 << "Cannot open " DATA_DIR "/config/settings.txt !" << std::endl;
|
||||
tlog1 << "Cannot open " << GameConstants::DATA_DIR << "/config/settings.txt !" << std::endl;
|
||||
return;
|
||||
}
|
||||
ifs.unsetf(std::ios::skipws); // Turn of white space skipping on the stream
|
||||
@ -170,7 +169,7 @@ void config::CConfigHandler::init()
|
||||
tlog2 << "Not entire config/settings.txt parsed!\n";
|
||||
|
||||
/* Read resolutions. */
|
||||
const JsonNode config(DATA_DIR "/config/resolutions.json");
|
||||
const JsonNode config(GameConstants::DATA_DIR + "/config/resolutions.json");
|
||||
const JsonVector &guisettings_vec = config["GUISettings"].Vector();
|
||||
|
||||
BOOST_FOREACH(const JsonNode &g, guisettings_vec) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef __CCONFIGHANDLER_H__
|
||||
#define __CCONFIGHANDLER_H__
|
||||
#include "../global.h"
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
class CAdvMapInt;
|
||||
|
||||
/*
|
||||
@ -95,5 +96,3 @@ namespace config
|
||||
};
|
||||
}
|
||||
extern config::CConfigHandler conf;
|
||||
|
||||
#endif // __CCONFIGHANDLER_H__
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "CCreatureWindow.h"
|
||||
|
||||
#include "../lib/CCreatureSet.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "../lib/CGeneralTextHandler.h"
|
||||
@ -6,25 +8,21 @@
|
||||
#include "../CCallback.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CAnimation.h"
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../lib/BattleState.h"
|
||||
#include "../lib/CSpellHandler.h"
|
||||
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
using namespace CSDL_Ext;
|
||||
|
||||
class CBonusItem;
|
||||
@ -86,7 +84,7 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
|
||||
{
|
||||
BLOCK_CAPTURING;
|
||||
upgResCost.push_back(new SComponent(SComponent::resource, i->resType, i->resVal));
|
||||
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
|
||||
}
|
||||
|
||||
if(LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost))
|
||||
@ -96,11 +94,11 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
fs += boost::bind(&CCreatureWindow::close,this);
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog, LOCPLINT, CGI->generaltexth->allTexts[207], boost::ref(upgResCost), fs, 0, false);
|
||||
upgrade = new AdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,385, 148,"IVIEWCR.DEF",SDLK_u);
|
||||
upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,385, 148,"IVIEWCR.DEF",SDLK_u);
|
||||
}
|
||||
else
|
||||
{
|
||||
upgrade = new AdventureMapButton("",CGI->generaltexth->zelp[446].second,boost::function<void()>(),385, 148,"IVIEWCR.DEF");
|
||||
upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,boost::function<void()>(),385, 148,"IVIEWCR.DEF");
|
||||
upgrade->callback.funcs.clear();
|
||||
upgrade->setOffset(2);
|
||||
}
|
||||
@ -113,8 +111,8 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
fs[0] += Dsm; //dismiss
|
||||
fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],std::vector<SComponent*>(),fs[0],fs[1],false);
|
||||
dismiss = new AdventureMapButton("",CGI->generaltexth->zelp[445].second,cfl,333, 148,"IVIEWCR2.DEF",SDLK_d);
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],std::vector<CComponent*>(),fs[0],fs[1],false);
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second,cfl,333, 148,"IVIEWCR2.DEF",SDLK_d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,15 +178,15 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
}
|
||||
|
||||
bonusRows = std::min ((int)((bonusItems.size() + 1) / 2), (conf.cc.resy - 230) / 60);
|
||||
amin(bonusRows, 4);
|
||||
amax(bonusRows, 1);
|
||||
vstd::amin(bonusRows, 4);
|
||||
vstd::amax(bonusRows, 1);
|
||||
|
||||
bitmap = new CPicture("CreWin" + boost::lexical_cast<std::string>(bonusRows) + ".pcx"); //1 to 4 rows for now
|
||||
bitmap->colorizeAndConvert(LOCPLINT->playerID);
|
||||
pos = bitmap->center();
|
||||
|
||||
//Buttons
|
||||
ok = new AdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
|
||||
ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
|
||||
|
||||
if (type <= BATTLE) //in battle or info window
|
||||
{
|
||||
@ -206,15 +204,15 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
new CPicture(graphics->pskillsm->ourImages[4].bitmap, 335, 50, false); //exp icon - Print it always?
|
||||
if (type) //not in fort window
|
||||
{
|
||||
if (STACK_EXP)
|
||||
if (GameConstants::STACK_EXP)
|
||||
{
|
||||
int rank = std::min(stack->getExpRank(), 10); //hopefully nobody adds more
|
||||
printAtMiddle(CGI->generaltexth->zcrexp[rank] + " [" + boost::lexical_cast<std::string>(rank) + "]", 436, 62, FONT_MEDIUM, tytulowy,*bitmap);
|
||||
printAtMiddle(boost::lexical_cast<std::string>(stack->experience), 436, 82, FONT_SMALL, zwykly,*bitmap);
|
||||
printAtMiddle(CGI->generaltexth->zcrexp[rank] + " [" + boost::lexical_cast<std::string>(rank) + "]", 436, 62, FONT_MEDIUM, Colors::Jasmine,*bitmap);
|
||||
printAtMiddle(boost::lexical_cast<std::string>(stack->experience), 436, 82, FONT_SMALL, Colors::Cornsilk,*bitmap);
|
||||
if (type > BATTLE) //we need it only on adv. map
|
||||
{
|
||||
int tier = stack->type->level;
|
||||
if (!iswith(tier, 1, 7))
|
||||
if (!vstd::iswithin(tier, 1, 7))
|
||||
tier = 0;
|
||||
int number;
|
||||
std::string expText = CGI->generaltexth->zcrexp[324];
|
||||
@ -247,20 +245,20 @@ 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(Rect(334, 49, 160, 44),CComponent::experience);
|
||||
expArea->text = expText;
|
||||
expArea->bonusValue = 0; //TDO: some specific value or no number at all
|
||||
}
|
||||
}
|
||||
|
||||
if (STACK_ARTIFACT && type > BATTLE)
|
||||
if (GameConstants::STACK_ARTIFACT && type > BATTLE)
|
||||
{
|
||||
//SDL_Rect rect = genRect(44,44,465,98);
|
||||
//creatureArtifact = new CArtPlace(NULL);
|
||||
//creatureArtifact->pos = rect;
|
||||
//creatureArtifact->ourOwner = NULL; //hmm?
|
||||
leftArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||
rightArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
||||
leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||
rightArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
||||
}
|
||||
else
|
||||
creatureArtifact = NULL;
|
||||
@ -305,7 +303,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
|
||||
void CCreatureWindow::printLine(int nr, const std::string &text, int baseVal, int val/*=-1*/, bool range/*=false*/)
|
||||
{
|
||||
printAt(text, 162, 48 + nr*19, FONT_SMALL, zwykly, *bitmap);
|
||||
printAt(text, 162, 48 + nr*19, FONT_SMALL, Colors::Cornsilk, *bitmap);
|
||||
|
||||
std::string hlp;
|
||||
if(range && baseVal != val)
|
||||
@ -315,7 +313,7 @@ void CCreatureWindow::printLine(int nr, const std::string &text, int baseVal, in
|
||||
else
|
||||
hlp = boost::lexical_cast<std::string>(baseVal);
|
||||
|
||||
printTo(hlp, 325, 64 + nr*19, FONT_SMALL, zwykly, *bitmap);
|
||||
printTo(hlp, 325, 64 + nr*19, FONT_SMALL, Colors::Cornsilk, *bitmap);
|
||||
}
|
||||
|
||||
void CCreatureWindow::recreateSkillList(int Pos)
|
||||
@ -351,7 +349,7 @@ void CCreatureWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
||||
printAtMiddle(c->namePl, 180, 30, FONT_SMALL, tytulowy,*bitmap); //creature name
|
||||
printAtMiddle(c->namePl, 180, 30, FONT_SMALL, Colors::Jasmine,*bitmap); //creature name
|
||||
|
||||
printLine(0, CGI->generaltexth->primarySkillNames[0], c->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK), stackNode->Attack());
|
||||
printLine(1, CGI->generaltexth->primarySkillNames[1], c->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE), stackNode->Defense());
|
||||
@ -380,7 +378,7 @@ void CCreatureWindow::showAll(SDL_Surface * to)
|
||||
void CCreatureWindow::show(SDL_Surface * to)
|
||||
{
|
||||
if (count.size()) //army stack
|
||||
printTo(count, pos.x + 114, pos.y + 174,FONT_TIMES, zwykly, to);
|
||||
printTo(count, pos.x + 114, pos.y + 174,FONT_TIMES, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
|
||||
@ -450,8 +448,8 @@ void CBonusItem::showAll (SDL_Surface * to)
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
printAt(name, pos.x + 72, pos.y + 6, FONT_SMALL, tytulowy, to);
|
||||
printAt(description, pos.x + 72, pos.y + 30, FONT_SMALL, zwykly, to);
|
||||
printAt(name, pos.x + 72, pos.y + 6, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAt(description, pos.x + 72, pos.y + 30, FONT_SMALL, Colors::Cornsilk, to);
|
||||
if (bonusGraphics && bonusGraphics->bg)
|
||||
blitAtLoc(bonusGraphics->bg, 12, 2, to);
|
||||
}
|
||||
@ -461,3 +459,192 @@ CBonusItem::~CBonusItem()
|
||||
{
|
||||
//delete bonusGraphics; //automatic destruction
|
||||
}
|
||||
|
||||
void CCreInfoWindow::show(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
creatureCount->showAll(to);
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost::function<void()> upgradeFunc, boost::function<void()> dismissFunc, UpgradeInfo *upgradeInfo)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
init(stack.type, &stack, dynamic_cast<const CGHeroInstance*>(stack.armyObj), stack.count, LClicked);
|
||||
|
||||
//additional buttons if opened with left click
|
||||
if(LClicked)
|
||||
{
|
||||
boost::function<void()> closeFunc = boost::bind(&CCreInfoWindow::close,this);
|
||||
|
||||
if(upgradeFunc && upgradeInfo)
|
||||
{
|
||||
TResources upgradeCost = upgradeInfo->cost[0] * stack.count;
|
||||
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
|
||||
{
|
||||
BLOCK_CAPTURING;
|
||||
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
|
||||
}
|
||||
|
||||
CFunctionList<void()> onUpgrade;
|
||||
onUpgrade += upgradeFunc;
|
||||
onUpgrade += closeFunc;
|
||||
|
||||
boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
|
||||
LOCPLINT,
|
||||
CGI->generaltexth->allTexts[207],
|
||||
boost::ref(upgResCost),
|
||||
onUpgrade, 0, false);
|
||||
|
||||
upgrade = new CAdventureMapButton("", CGI->generaltexth->zelp[446].second, dialog, 76, 237, "IVIEWCR", SDLK_u);
|
||||
upgrade->block(!LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost));
|
||||
}
|
||||
|
||||
if(dismissFunc)
|
||||
{
|
||||
CFunctionList<void()> onDismiss;
|
||||
onDismiss += dismissFunc;
|
||||
onDismiss += closeFunc;
|
||||
|
||||
boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
|
||||
LOCPLINT,
|
||||
CGI->generaltexth->allTexts[12],
|
||||
std::vector<CComponent*>(),
|
||||
onDismiss, 0, true);
|
||||
|
||||
dismiss = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second, dialog, 21, 237, "IVIEWCR2",SDLK_d);
|
||||
}
|
||||
|
||||
ok = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second,
|
||||
boost::bind(&CCreInfoWindow::close,this), 216, 237, "IOKAY.DEF", SDLK_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(int creatureID, bool LClicked, int creatureCount)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
const CCreature *creature = CGI->creh->creatures[creatureID];
|
||||
init(creature, NULL, NULL, creatureCount, LClicked);
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(const CStack &stack, bool LClicked)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
init(stack.getCreature(), &stack, stack.getMyHero(), stack.count, LClicked);
|
||||
}
|
||||
|
||||
CCreInfoWindow::~CCreInfoWindow()
|
||||
{
|
||||
BOOST_FOREACH(CComponent* object, upgResCost)
|
||||
delete object;
|
||||
}
|
||||
|
||||
void CCreInfoWindow::printLine(int position, const std::string &text, int baseVal, int val/*=-1*/, bool range/*=false*/)
|
||||
{
|
||||
infoTexts[position].first = new CLabel(155, 48 + position*19, FONT_SMALL, TOPLEFT, Colors::Cornsilk, text);
|
||||
std::string valueStr;
|
||||
|
||||
if(range && baseVal != val)
|
||||
valueStr = boost::str(boost::format("%d - %d") % baseVal % val);
|
||||
|
||||
else if(baseVal != val && val>=0)
|
||||
valueStr = boost::str(boost::format("%d (%d)") % baseVal % val);
|
||||
|
||||
else
|
||||
valueStr = boost::lexical_cast<std::string>(baseVal);
|
||||
|
||||
infoTexts[position].second = new CLabel(276, 63 + position*19, FONT_SMALL, BOTTOMRIGHT, Colors::Cornsilk, valueStr);
|
||||
}
|
||||
|
||||
void CCreInfoWindow::init(const CCreature *creature, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner, int count, bool LClicked)
|
||||
{
|
||||
used = 0;
|
||||
if (!LClicked)
|
||||
used |= RCLICK;
|
||||
|
||||
if(!stackNode)
|
||||
stackNode = creature;
|
||||
|
||||
background = new CPicture("CRSTKPU");
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
pos = background->center();
|
||||
|
||||
animation = new CCreaturePic(21, 48, creature);
|
||||
|
||||
std::string countStr = boost::lexical_cast<std::string>(count);
|
||||
creatureCount = new CLabel(114, 174, FONT_TIMES, BOTTOMRIGHT, Colors::Cornsilk, countStr);
|
||||
|
||||
creatureName = new CLabel(149, 30, FONT_SMALL, CENTER, Colors::Jasmine, creature->namePl);
|
||||
|
||||
printLine(0, CGI->generaltexth->primarySkillNames[0], creature->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK), stackNode->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK));
|
||||
printLine(1, CGI->generaltexth->primarySkillNames[1], creature->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE), stackNode->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE));
|
||||
|
||||
if(stackNode->valOfBonuses(Bonus::SHOTS))
|
||||
printLine(2, CGI->generaltexth->allTexts[198], stackNode->valOfBonuses(Bonus::SHOTS));
|
||||
|
||||
//TODO
|
||||
int dmgMultiply = 1;
|
||||
if(heroOwner && stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON))
|
||||
dmgMultiply += heroOwner->Attack();
|
||||
|
||||
printLine(3, CGI->generaltexth->allTexts[199], stackNode->getMinDamage() * dmgMultiply, stackNode->getMaxDamage() * dmgMultiply, true);
|
||||
printLine(4, CGI->generaltexth->allTexts[388], creature->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH));
|
||||
printLine(6, CGI->generaltexth->zelp[441].first, creature->valOfBonuses(Bonus::STACKS_SPEED), stackNode->valOfBonuses(Bonus::STACKS_SPEED));
|
||||
|
||||
//setting morale
|
||||
morale = new MoraleLuckBox(true, genRect(42, 42, 22, 186));
|
||||
morale->set(stackNode);
|
||||
//setting luck
|
||||
luck = new MoraleLuckBox(false, genRect(42, 42, 75, 186));
|
||||
luck->set(stackNode);
|
||||
|
||||
if(!LClicked)
|
||||
abilityText = new CLabel(17, 231, FONT_SMALL, TOPLEFT, Colors::Cornsilk, creature->abilityText);
|
||||
else
|
||||
abilityText = NULL;
|
||||
|
||||
//if we are displying window fo r stack in battle, there are several more things that we need to display
|
||||
if(const CStack *battleStack = dynamic_cast<const CStack*>(stackNode))
|
||||
{
|
||||
//print at most 3 spell effects
|
||||
std::vector<si32> spells = battleStack->activeSpells();
|
||||
for (size_t i=0; i< std::min(spells.size(), size_t(3)); i++)
|
||||
effects.push_back(new CAnimImage("SpellInt", spells[i]+1, 0, 127 + 52*i, 186));
|
||||
|
||||
//print current health
|
||||
printLine(5, CGI->generaltexth->allTexts[200], battleStack->firstHPleft);
|
||||
}
|
||||
}
|
||||
|
||||
void CCreInfoWindow::close()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
void CCreInfoWindow::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(const CStack *s)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(*s);
|
||||
else
|
||||
return new CCreatureWindow(*s, CCreatureWindow::BATTLE);
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(int Cid, int Type, int creatureCount)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(Cid, Type, creatureCount);
|
||||
else
|
||||
return new CCreatureWindow(Cid, Type, creatureCount);
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(*s, type==3, Upg, Dsm, ui);
|
||||
else
|
||||
return new CCreatureWindow(*s, type, Upg, Dsm, ui);
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "../global.h"
|
||||
#include "GUIBase.h"
|
||||
#include "GUIClasses.h"
|
||||
#pragma once
|
||||
|
||||
#include "UIFramework/CIntObject.h"
|
||||
#include "../lib/HeroBonus.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
/*
|
||||
* CCreatureWindow.h, part of VCMI engine
|
||||
@ -17,9 +18,23 @@ struct Bonus;
|
||||
class CCreature;
|
||||
class CStackInstance;
|
||||
class CStack;
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CBonusItem;
|
||||
class CGHeroInstance;
|
||||
class CComponent;
|
||||
class LRClickableAreaWText;
|
||||
class MoraleLuckBox;
|
||||
class CAdventureMapButton;
|
||||
struct UpgradeInfo;
|
||||
class CPicture;
|
||||
class CCreaturePic;
|
||||
class LRClickableAreaWTextComp;
|
||||
class CArtPlace;
|
||||
class CSlider;
|
||||
class CLabel;
|
||||
class CAnimImage;
|
||||
|
||||
// Classical creature window
|
||||
class CCreatureWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
@ -33,7 +48,7 @@ public:
|
||||
const CStackInstance *stack;
|
||||
const CBonusSystemNode *stackNode;
|
||||
const CGHeroInstance *heroOwner;
|
||||
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CBonusItem*> bonusItems;
|
||||
std::vector<LRClickableAreaWText*> spellEffects;
|
||||
|
||||
@ -43,8 +58,8 @@ public:
|
||||
LRClickableAreaWTextComp * expArea; //displays exp details
|
||||
CArtPlace *creatureArtifact;
|
||||
CSlider * slider; //Abilities
|
||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||
AdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
||||
CAdventureMapButton *dismiss, *upgrade, *ok;
|
||||
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
||||
//TODO: Artifact drop
|
||||
|
||||
boost::function<void()> dsm; //dismiss button callback
|
||||
@ -83,3 +98,38 @@ public:
|
||||
void setBonus (const Bonus &bonus);
|
||||
void showAll (SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// New Creature info window
|
||||
class CCreInfoWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
CPicture * background;
|
||||
CLabel * creatureCount;
|
||||
CLabel * creatureName;
|
||||
CLabel * abilityText;
|
||||
|
||||
CCreaturePic * animation;
|
||||
std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CAnimImage *> effects;
|
||||
std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
|
||||
|
||||
MoraleLuckBox * luck, * morale;
|
||||
|
||||
CAdventureMapButton * dismiss, * upgrade, * ok;
|
||||
|
||||
CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
|
||||
CCreInfoWindow(const CStack & st, bool LClicked = 0);
|
||||
CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
|
||||
~CCreInfoWindow();
|
||||
|
||||
void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
|
||||
void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void close();
|
||||
void show(SDL_Surface * to);
|
||||
};
|
||||
|
||||
CIntObject *createCreWindow(const CStack *s);
|
||||
CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
|
||||
CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "StdInc.h"
|
||||
#include "SDL.h"
|
||||
#include "CDefHandler.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "../lib/CLodHandler.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../lib/vcmi_endian.h"
|
||||
@ -51,19 +51,19 @@ CDefEssential::~CDefEssential()
|
||||
SDL_FreeSurface(ourImages[i].bitmap);
|
||||
}
|
||||
|
||||
void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
|
||||
void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
|
||||
{
|
||||
BMPPalette palette[256];
|
||||
SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
|
||||
unsigned char *p;
|
||||
ui8 *p;
|
||||
|
||||
defName = name;
|
||||
DEFType = SDL_SwapLE32(de.DEFType);
|
||||
width = SDL_SwapLE32(de.width);
|
||||
height = SDL_SwapLE32(de.height);
|
||||
unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks);
|
||||
ui32 totalBlocks = SDL_SwapLE32(de.totalBlocks);
|
||||
|
||||
for (unsigned int it=0;it<256;it++)
|
||||
for (ui32 it=0;it<256;it++)
|
||||
{
|
||||
palette[it].R = de.palette[it].R;
|
||||
palette[it].G = de.palette[it].G;
|
||||
@ -72,22 +72,22 @@ void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
|
||||
}
|
||||
|
||||
// The SDefEntryBlock starts just after the SDefEntry
|
||||
p = reinterpret_cast<unsigned char *>(&de);
|
||||
p = reinterpret_cast<ui8 *>(&de);
|
||||
p += sizeof(de);
|
||||
|
||||
int totalEntries=0;
|
||||
for (unsigned int z=0; z<totalBlocks; z++)
|
||||
for (ui32 z=0; z<totalBlocks; z++)
|
||||
{
|
||||
SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
|
||||
unsigned int totalInBlock;
|
||||
ui32 totalInBlock;
|
||||
|
||||
totalInBlock = read_le_u32(&block.totalInBlock);
|
||||
|
||||
for (unsigned int j=SEntries.size(); j<totalEntries+totalInBlock; j++)
|
||||
for (ui32 j=SEntries.size(); j<totalEntries+totalInBlock; j++)
|
||||
SEntries.push_back(SEntry());
|
||||
|
||||
p = block.data;
|
||||
for (unsigned int j=0; j<totalInBlock; j++)
|
||||
for (ui32 j=0; j<totalInBlock; j++)
|
||||
{
|
||||
char Buffer[13];
|
||||
memcpy(Buffer, p, 12);
|
||||
@ -95,25 +95,25 @@ void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
|
||||
SEntries[totalEntries+j].name=Buffer;
|
||||
p += 13;
|
||||
}
|
||||
for (unsigned int j=0; j<totalInBlock; j++)
|
||||
for (ui32 j=0; j<totalInBlock; j++)
|
||||
{
|
||||
SEntries[totalEntries+j].offset = read_le_u32(p);
|
||||
p += 4;
|
||||
}
|
||||
//totalEntries+=totalInBlock;
|
||||
for(unsigned int hh=0; hh<totalInBlock; ++hh)
|
||||
for(ui32 hh=0; hh<totalInBlock; ++hh)
|
||||
{
|
||||
SEntries[totalEntries].group = z;
|
||||
++totalEntries;
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int j=0; j<SEntries.size(); ++j)
|
||||
for(ui32 j=0; j<SEntries.size(); ++j)
|
||||
{
|
||||
SEntries[j].name = SEntries[j].name.substr(0, SEntries[j].name.find('.')+4);
|
||||
}
|
||||
//RWEntries = new unsigned int[height];
|
||||
for(unsigned int i=0; i < SEntries.size(); ++i)
|
||||
//RWEntries = new ui32[height];
|
||||
for(ui32 i=0; i < SEntries.size(); ++i)
|
||||
{
|
||||
Cimage nimg;
|
||||
nimg.bitmap = getSprite(i, table, palette);
|
||||
@ -123,17 +123,17 @@ void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
|
||||
}
|
||||
}
|
||||
|
||||
void CDefHandler::expand(unsigned char N,unsigned char & BL, unsigned char & BR)
|
||||
void CDefHandler::expand(ui8 N,ui8 & BL, ui8 & BR)
|
||||
{
|
||||
BL = (N & 0xE0) >> 5;
|
||||
BR = N & 0x1F;
|
||||
}
|
||||
|
||||
SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const
|
||||
SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPalette * palette) const
|
||||
{
|
||||
SDL_Surface * ret=NULL;
|
||||
|
||||
unsigned int BaseOffset,
|
||||
ui32 BaseOffset,
|
||||
SpriteWidth, SpriteHeight, //format of sprite
|
||||
TotalRowLength, // length of read segment
|
||||
add, FullHeight,FullWidth,
|
||||
@ -143,7 +143,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
int LeftMargin, RightMargin, TopMargin, BottomMargin;
|
||||
|
||||
|
||||
unsigned char SegmentType;//, BL, BR; //TODO use me
|
||||
ui8 SegmentType;//, BL, BR; //TODO use me
|
||||
|
||||
BaseOffset = SEntries[SIndex].offset;
|
||||
SSpriteDef sd = * reinterpret_cast<const SSpriteDef *>(FDef + BaseOffset);
|
||||
@ -201,7 +201,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
for (unsigned int i=0;i<SpriteHeight;i++)
|
||||
for (ui32 i=0;i<SpriteHeight;i++)
|
||||
{
|
||||
if (LeftMargin>0)
|
||||
ftcp += LeftMargin;
|
||||
@ -218,9 +218,9 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
|
||||
case 1:
|
||||
{
|
||||
const unsigned int * RWEntriesLoc = reinterpret_cast<const unsigned int *>(FDef+BaseOffset);
|
||||
const ui32 * RWEntriesLoc = reinterpret_cast<const ui32 *>(FDef+BaseOffset);
|
||||
BaseOffset += sizeof(int) * SpriteHeight;
|
||||
for (unsigned int i=0;i<SpriteHeight;i++)
|
||||
for (ui32 i=0;i<SpriteHeight;i++)
|
||||
{
|
||||
BaseOffset=BaseOffsetor + read_le_u32(RWEntriesLoc + i);
|
||||
if (LeftMargin>0)
|
||||
@ -229,7 +229,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
TotalRowLength=0;
|
||||
do
|
||||
{
|
||||
unsigned int SegmentLength;
|
||||
ui32 SegmentLength;
|
||||
|
||||
SegmentType=FDef[BaseOffset++];
|
||||
SegmentLength=FDef[BaseOffset++] + 1;
|
||||
@ -262,7 +262,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
{
|
||||
BaseOffset = BaseOffsetor + read_le_u16(FDef + BaseOffsetor);
|
||||
|
||||
for (unsigned int i=0;i<SpriteHeight;i++)
|
||||
for (ui32 i=0;i<SpriteHeight;i++)
|
||||
{
|
||||
//BaseOffset = BaseOffsetor+RWEntries[i];
|
||||
if (LeftMargin>0)
|
||||
@ -273,8 +273,8 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
do
|
||||
{
|
||||
SegmentType=FDef[BaseOffset++];
|
||||
unsigned char code = SegmentType / 32;
|
||||
unsigned char value = (SegmentType & 31) + 1;
|
||||
ui8 code = SegmentType / 32;
|
||||
ui8 value = (SegmentType & 31) + 1;
|
||||
if(code==7)
|
||||
{
|
||||
memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, &FDef[BaseOffset], value);
|
||||
@ -302,7 +302,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
|
||||
case 3:
|
||||
{
|
||||
for (unsigned int i=0;i<SpriteHeight;i++)
|
||||
for (ui32 i=0;i<SpriteHeight;i++)
|
||||
{
|
||||
BaseOffset = BaseOffsetor + read_le_u16(FDef + BaseOffsetor+i*2*(SpriteWidth/32));
|
||||
if (LeftMargin>0)
|
||||
@ -313,11 +313,11 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
|
||||
do
|
||||
{
|
||||
SegmentType=FDef[BaseOffset++];
|
||||
unsigned char code = SegmentType / 32;
|
||||
unsigned char value = (SegmentType & 31) + 1;
|
||||
ui8 code = SegmentType / 32;
|
||||
ui8 value = (SegmentType & 31) + 1;
|
||||
|
||||
int len = std::min<unsigned int>(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin);
|
||||
amax(len, 0);
|
||||
int len = std::min<ui32>(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin);
|
||||
vstd::amax(len, 0);
|
||||
|
||||
if(code==7)
|
||||
{
|
||||
@ -365,7 +365,7 @@ CDefEssential * CDefHandler::essentialize()
|
||||
|
||||
CDefHandler * CDefHandler::giveDef(const std::string & defName)
|
||||
{
|
||||
unsigned char * data = spriteh->giveFile(defName, FILE_ANIMATION);
|
||||
ui8 * data = spriteh->giveFile(defName, FILE_ANIMATION);
|
||||
if(!data)
|
||||
throw "bad def name!";
|
||||
CDefHandler * nh = new CDefHandler();
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __CDEFHANDLER_H__
|
||||
#define __CDEFHANDLER_H__
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
struct BMPPalette;
|
||||
@ -30,7 +29,7 @@ struct SDefEntryBlock {
|
||||
ui32 totalInBlock;
|
||||
ui32 unknown2;
|
||||
ui32 unknown3;
|
||||
unsigned char data[0];
|
||||
ui8 data[0];
|
||||
};
|
||||
|
||||
// Def entry in file. Integer fields are all little endian and will
|
||||
@ -42,9 +41,9 @@ struct SDefEntry {
|
||||
ui32 totalBlocks;
|
||||
|
||||
struct {
|
||||
unsigned char R;
|
||||
unsigned char G;
|
||||
unsigned char B;
|
||||
ui8 R;
|
||||
ui8 G;
|
||||
ui8 B;
|
||||
} palette[256];
|
||||
|
||||
// SDefEntry is followed by a series of SDefEntryBlock
|
||||
@ -75,9 +74,9 @@ public:
|
||||
class CDefHandler
|
||||
{
|
||||
private:
|
||||
unsigned int DEFType;
|
||||
ui32 DEFType;
|
||||
int length;
|
||||
//unsigned int * RWEntries;
|
||||
//ui32 * RWEntries;
|
||||
struct SEntry
|
||||
{
|
||||
std::string name;
|
||||
@ -94,15 +93,11 @@ public:
|
||||
|
||||
CDefHandler(); //c-tor
|
||||
~CDefHandler(); //d-tor
|
||||
SDL_Surface * getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const; //saves picture with given number to "testtt.bmp"
|
||||
static void expand(unsigned char N,unsigned char & BL, unsigned char & BR);
|
||||
void openFromMemory(unsigned char * table, const std::string & name);
|
||||
SDL_Surface * getSprite (int SIndex, const ui8 * FDef, const BMPPalette * palette) const; //saves picture with given number to "testtt.bmp"
|
||||
static void expand(ui8 N,ui8 & BL, ui8 & BR);
|
||||
void openFromMemory(ui8 * table, const std::string & name);
|
||||
CDefEssential * essentialize();
|
||||
|
||||
static CDefHandler * giveDef(const std::string & defName);
|
||||
static CDefEssential * giveDefEss(const std::string & defName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // __CDEFHANDLER_H__
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "../stdafx.h"
|
||||
#include "StdInc.h"
|
||||
#include "CGameInfo.h"
|
||||
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
|
||||
/*
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef __CGAMEINFO_H__
|
||||
#define __CGAMEINFO_H__
|
||||
#include "../global.h"
|
||||
#include "../lib/ConstTransitivePtr.h"
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../lib/ConstTransitivePtr.h"
|
||||
|
||||
/*
|
||||
* CGameInfo.h, part of VCMI engine
|
||||
*
|
||||
@ -42,6 +41,7 @@ public:
|
||||
CCursorHandler * curh;
|
||||
IMainVideoPlayer * videoh;
|
||||
};
|
||||
extern CClientState * CCS;
|
||||
|
||||
struct Mapa;
|
||||
|
||||
@ -70,13 +70,4 @@ public:
|
||||
|
||||
CGameInfo();
|
||||
};
|
||||
|
||||
//
|
||||
// public:
|
||||
//
|
||||
// ConstTransitivePtr<CGeneralTextHandler> generaltexth;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __CGAMEINFO_H__
|
||||
extern const CGameInfo* CGI;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "../stdafx.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CGameInfo.h"
|
||||
@ -7,27 +7,22 @@
|
||||
#include "CMessage.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "CSpellWindow.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "../global.h"
|
||||
|
||||
#include "../lib/CArtHandler.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "../lib/CGeneralTextHandler.h"
|
||||
#include "../lib/CHeroHandler.h"
|
||||
#include "../lib/CLodHandler.h"
|
||||
#include "../lib/CObjectHandler.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
#undef min
|
||||
|
||||
@ -110,10 +105,10 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero)
|
||||
//artifs = new CArtifactsOfHero(pos.topLeft(), true);
|
||||
ourBar = new CGStatusBar(7, 559, "ADROLLVR.bmp", 660); // new CStatusBar(pos.x+72, pos.y+567, "ADROLLVR.bmp", 660);
|
||||
|
||||
quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),boost::bind(&CHeroWindow::quit,this), 609, 516, "hsbtns.def", SDLK_RETURN);
|
||||
quitButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),boost::bind(&CHeroWindow::quit,this), 609, 516, "hsbtns.def", SDLK_RETURN);
|
||||
quitButton->assignedKeys.insert(SDLK_ESCAPE);
|
||||
dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
|
||||
questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
|
||||
dismissButton = new CAdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
|
||||
questlogButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
|
||||
|
||||
formations = new CHighlightableButtonsGroup(0);
|
||||
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[23]),CGI->generaltexth->heroscrn[29], "hsbtns6.def", 481, 483, 0, 0, SDLK_t);
|
||||
@ -131,9 +126,9 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero)
|
||||
//areas
|
||||
portraitArea = new LRClickableAreaWText(Rect(18, 18, 58, 64));
|
||||
|
||||
for(int v=0; v<PRIMARY_SKILLS; ++v)
|
||||
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(Rect(30 + 70*v, 109, 42, 64), CComponent::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]);
|
||||
@ -149,7 +144,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero)
|
||||
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);
|
||||
secSkillAreas.push_back(new LRClickableAreaWTextComp(r, SComponent::secskill));
|
||||
secSkillAreas.push_back(new LRClickableAreaWTextComp(r, CComponent::secskill));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////???????????????
|
||||
@ -198,14 +193,14 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
|
||||
portraitArea->text = curHero->getBiography();
|
||||
|
||||
{
|
||||
AdventureMapButton * split = NULL;
|
||||
CAdventureMapButton * split = NULL;
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
if(!garr)
|
||||
{
|
||||
garr = new CGarrisonInt(15, 485, 8, Point(), background->bg, Point(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
|
||||
split = new CAdventureMapButton(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
|
||||
boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
||||
}
|
||||
garr->addSplitBtn(split);
|
||||
@ -250,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)
|
||||
@ -292,7 +287,7 @@ void CHeroWindow::dismissCurrent()
|
||||
{
|
||||
CFunctionList<void()> ony = boost::bind(&CHeroWindow::quit,this);
|
||||
ony += boost::bind(&CCallback::dismissHero,LOCPLINT->cb,curHero);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22],std::vector<SComponent*>(), ony, 0, false);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22],std::vector<CComponent*>(), ony, 0, false);
|
||||
}
|
||||
|
||||
void CHeroWindow::questlog()
|
||||
@ -306,41 +301,41 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
blitAtLoc(graphics->portraitLarge[curHero->portrait], 19, 19, to);
|
||||
|
||||
//printing hero's name
|
||||
printAtMiddleLoc(curHero->name, 190, 38, FONT_BIG, tytulowy, to);
|
||||
printAtMiddleLoc(curHero->name, 190, 38, FONT_BIG, Colors::Jasmine, to);
|
||||
|
||||
//printing hero's level
|
||||
std::string secondLine= CGI->generaltexth->allTexts[342];
|
||||
boost::algorithm::replace_first(secondLine,"%d",boost::lexical_cast<std::string>(curHero->level));
|
||||
boost::algorithm::replace_first(secondLine,"%s",curHero->type->heroClass->name);
|
||||
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, zwykly, to);
|
||||
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, Colors::Cornsilk, to);
|
||||
|
||||
//primary skills names
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[3], 193, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[4], 262, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[3], 193, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[4], 262, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
|
||||
//dismiss / quest log
|
||||
std::vector<std::string> toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8]);
|
||||
if(toPrin.size()==1)
|
||||
{
|
||||
printAtLoc(toPrin[0], 372, 439, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 372, 439, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
printAtLoc(toPrin[0], 372, 430, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[1], 372, 446, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 372, 430, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(toPrin[1], 372, 446, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9]);
|
||||
if(toPrin.size()==1)
|
||||
{
|
||||
printAtLoc(toPrin[0], 512, 439, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 512, 439, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
printAtLoc(toPrin[0], 512, 430, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[1], 512, 446, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 512, 430, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(toPrin[1], 512, 446, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
//printing primary skills' amounts
|
||||
@ -348,7 +343,7 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
std::ostringstream primarySkill;
|
||||
primarySkill << primSkillAreas[m]->bonusValue;
|
||||
printAtMiddleLoc(primarySkill.str(), 53 + 70 * m, 166, FONT_SMALL, zwykly, to);
|
||||
printAtMiddleLoc(primarySkill.str(), 53 + 70 * m, 166, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
blitAtLoc(flags->ourImages[player].bitmap, 606, 8, to);
|
||||
@ -381,22 +376,22 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
for(size_t v=0; v<std::min(secSkillAreas.size(), curHero->secSkills.size()); ++v)
|
||||
{
|
||||
blitAtLoc(graphics->abils44->ourImages[curHero->secSkills[v].first*3+3+curHero->secSkills[v].second-1].bitmap, v%2 ? 161 : 18, 276 + 48 * (v/2), to);
|
||||
printAtLoc(CGI->generaltexth->levels[curHero->secSkills[v].second-1], v%2 ? 212 : 68, 280 + 48 * (v/2), FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->skillName[curHero->secSkills[v].first], v%2 ? 212 : 68, 300 + 48 * (v/2), FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->levels[curHero->secSkills[v].second-1], v%2 ? 212 : 68, 280 + 48 * (v/2), FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(CGI->generaltexth->skillName[curHero->secSkills[v].first], v%2 ? 212 : 68, 300 + 48 * (v/2), FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
//printing special ability
|
||||
blitAtLoc(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(CGI->generaltexth->hTxts[curHero->subID].bonusName, 69, 205, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtLoc(CGI->generaltexth->hTxts[curHero->subID].bonusName, 69, 205, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
//printing necessery texts
|
||||
printAtLoc(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 232, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 232, FONT_SMALL, Colors::Jasmine, to);
|
||||
std::ostringstream expstr;
|
||||
expstr << curHero->exp;
|
||||
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 213, 232, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 213, 232, FONT_SMALL, Colors::Jasmine, to);
|
||||
std::ostringstream manastr;
|
||||
manastr << curHero->mana << '/' << heroWArt.manaLimit();
|
||||
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#ifndef __CHEROWINDOW_H__
|
||||
#define __CHEROWINDOW_H__
|
||||
#pragma once
|
||||
|
||||
#include "../lib/HeroBonus.h"
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
struct SDL_Surface;
|
||||
class CGHeroInstance;
|
||||
class CDefHandler;
|
||||
@ -60,7 +60,7 @@ class CHeroWindow: public CWindowWithGarrison, public CWindowWithArtifacts
|
||||
CDefEssential *flags;
|
||||
|
||||
//buttons
|
||||
//AdventureMapButton * gar4button; //splitting
|
||||
//CAdventureMapButton * gar4button; //splitting
|
||||
std::vector<CHeroSwitcher *> heroListMi; //new better list of heroes
|
||||
|
||||
//clickable areas
|
||||
@ -75,7 +75,7 @@ class CHeroWindow: public CWindowWithGarrison, public CWindowWithArtifacts
|
||||
|
||||
public:
|
||||
const CGHeroInstance * curHero;
|
||||
AdventureMapButton * quitButton, * dismissButton, * questlogButton; //general
|
||||
CAdventureMapButton * quitButton, * dismissButton, * questlogButton; //general
|
||||
|
||||
CHighlightableButton *tacticsButton; //garrison / formation handling;
|
||||
CHighlightableButtonsGroup *formations;
|
||||
@ -95,5 +95,3 @@ public:
|
||||
friend void CArtPlace::clickLeft(tribool down, bool previousState);
|
||||
friend class CPlayerInterface;
|
||||
};
|
||||
|
||||
#endif // __CHEROWINDOW_H__
|
||||
|
@ -1,23 +1,19 @@
|
||||
#include "StdInc.h"
|
||||
#include "CKingdomInterface.h"
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "../CCallback.h"
|
||||
#include "../lib/CCreatureHandler.h" //creatures name for objects list
|
||||
#include "../lib/CGeneralTextHandler.h"
|
||||
#include "../lib/CObjectHandler.h" //Hero/Town objects
|
||||
#include "../lib/CHeroHandler.h" // only for calculating required xp? worth it?
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAnimation.h" //CAnimImage
|
||||
#include "CAdvmapInterface.h" //CResDataBar
|
||||
#include "CCastleInterface.h" //various town-specific classes
|
||||
#include "CConfigHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CPlayerInterface.h" //LOCPLINT
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
/*
|
||||
* CKingdomInterface.cpp, part of VCMI engine
|
||||
@ -49,21 +45,21 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data)
|
||||
pos = image->pos;
|
||||
|
||||
if (infoPos == POS_CORNER)
|
||||
value = new CLabel(pos.w, pos.h, font, BOTTOMRIGHT, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w, pos.h, font, BOTTOMRIGHT, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_INSIDE)
|
||||
value = new CLabel(pos.w/2, pos.h-6, font, CENTER, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w/2, pos.h-6, font, CENTER, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_UP_DOWN || infoPos == POS_DOWN)
|
||||
value = new CLabel(pos.w/2, pos.h+8, font, CENTER, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w/2, pos.h+8, font, CENTER, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_UP_DOWN)
|
||||
name = new CLabel(pos.w/2, -12, font, CENTER, zwykly, data->getNameText());
|
||||
name = new CLabel(pos.w/2, -12, font, CENTER, Colors::Cornsilk, data->getNameText());
|
||||
|
||||
if (infoPos == POS_RIGHT)
|
||||
{
|
||||
name = new CLabel(pos.w+6, 6, font, TOPLEFT, zwykly, data->getNameText());
|
||||
value = new CLabel(pos.w+6, pos.h-16, font, TOPLEFT, zwykly, data->getValueText());
|
||||
name = new CLabel(pos.w+6, 6, font, TOPLEFT, Colors::Cornsilk, data->getNameText());
|
||||
value = new CLabel(pos.w+6, pos.h-16, font, TOPLEFT, Colors::Cornsilk, data->getValueText());
|
||||
}
|
||||
pos = image->pos;
|
||||
if (name)
|
||||
@ -71,7 +67,7 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data)
|
||||
if (value)
|
||||
pos = pos | value->pos;
|
||||
|
||||
hover = new HoverableArea;
|
||||
hover = new CHoverableArea;
|
||||
hover->hoverText = data->getHoverText();
|
||||
hover->pos = pos;
|
||||
}
|
||||
@ -85,7 +81,7 @@ void InfoBox::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
SComponent *comp;
|
||||
CComponent *comp;
|
||||
std::string text;
|
||||
data->prepareMessage(text, &comp);
|
||||
if (comp)
|
||||
@ -99,11 +95,11 @@ void InfoBox::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if((!down) && previousState)
|
||||
{
|
||||
SComponent *comp;
|
||||
CComponent *comp;
|
||||
std::string text;
|
||||
data->prepareMessage(text, &comp);
|
||||
|
||||
std::vector<SComponent*> compVector;
|
||||
std::vector<CComponent*> compVector;
|
||||
if (comp)
|
||||
compVector.push_back(comp);
|
||||
LOCPLINT->showInfoDialog(text, compVector);
|
||||
@ -257,7 +253,7 @@ size_t InfoBoxAbstractHeroData::getImageIndex()
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **comp)
|
||||
bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, CComponent **comp)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -267,7 +263,7 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **com
|
||||
return true;
|
||||
case HERO_PRIMARY_SKILL:
|
||||
text = CGI->generaltexth->arraytxt[2+getSubID()];
|
||||
*comp =new SComponent(SComponent::primskill, getSubID(), getValue());
|
||||
*comp =new CComponent(CComponent::primskill, getSubID(), getValue());
|
||||
return true;
|
||||
case HERO_MANA:
|
||||
text = CGI->generaltexth->allTexts[149];
|
||||
@ -285,7 +281,7 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **com
|
||||
return false;
|
||||
|
||||
text = CGI->generaltexth->skillInfoTexts[subID][value-1];
|
||||
*comp = new SComponent(SComponent::secskill, subID, value);
|
||||
*comp = new CComponent(CComponent::secskill, subID, value);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@ -384,7 +380,7 @@ std::string InfoBoxHeroData::getValueText()
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoBoxHeroData::prepareMessage(std::string &text, SComponent**comp)
|
||||
bool InfoBoxHeroData::prepareMessage(std::string &text, CComponent**comp)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
@ -461,7 +457,7 @@ std::string InfoBoxCustom::getValueText()
|
||||
return valueText;
|
||||
}
|
||||
|
||||
bool InfoBoxCustom::prepareMessage(std::string &text, SComponent **comp)
|
||||
bool InfoBoxCustom::prepareMessage(std::string &text, CComponent **comp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -472,7 +468,7 @@ CKingdomInterface::CKingdomInterface()
|
||||
background = new CPicture(conf.go()->ac.overviewBg);
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
pos = background->center();
|
||||
unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
|
||||
tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4));
|
||||
|
||||
@ -487,7 +483,7 @@ CKingdomInterface::CKingdomInterface()
|
||||
|
||||
void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects)
|
||||
{
|
||||
unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
size_t dwellSize = (footerPos - 64)/57;
|
||||
|
||||
//Map used to determine image number for several objects
|
||||
@ -563,8 +559,8 @@ CIntObject * CKingdomInterface::createMainTab(size_t index)
|
||||
|
||||
void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects)
|
||||
{
|
||||
unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
||||
std::vector<int> minesCount(RESOURCE_QUANTITY, 0);
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
std::vector<int> minesCount(GameConstants::RESOURCE_QUANTITY, 0);
|
||||
int totalIncome=0;
|
||||
|
||||
BOOST_FOREACH(const CGObjectInstance * object, ownedObjects)
|
||||
@ -601,42 +597,42 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
|
||||
minesBox[i] = new InfoBox(Point(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 = new CHoverableArea;
|
||||
incomeArea->pos = Rect(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));
|
||||
incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, Colors::Cornsilk, boost::lexical_cast<std::string>(totalIncome));
|
||||
}
|
||||
|
||||
void CKingdomInterface::generateButtons()
|
||||
{
|
||||
unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
|
||||
//Main control buttons
|
||||
btnHeroes = new AdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
|
||||
btnHeroes = new CAdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
|
||||
boost::bind(&CKingdomInterface::activateTab, this, 0),748,28+footerPos,"OVBUTN1.DEF", SDLK_h);
|
||||
btnHeroes->block(true);
|
||||
|
||||
btnTowns = new AdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
|
||||
btnTowns = new CAdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
|
||||
boost::bind(&CKingdomInterface::activateTab, this, 1),748,64+footerPos,"OVBUTN6.DEF", SDLK_t);
|
||||
|
||||
btnExit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
||||
btnExit = new CAdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
||||
boost::bind(&CGuiHandler::popIntTotally,&GH, this),748,99+footerPos,"OVBUTN1.DEF", SDLK_RETURN);
|
||||
btnExit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
btnExit->setOffset(3);
|
||||
|
||||
//Object list control buttons
|
||||
dwellTop = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
|
||||
dwellTop = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
|
||||
733, 4, "OVBUTN4.DEF");
|
||||
|
||||
dwellBottom = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
|
||||
dwellBottom = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
|
||||
733, footerPos+2, "OVBUTN4.DEF");
|
||||
dwellBottom->setOffset(2);
|
||||
|
||||
dwellUp = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
|
||||
dwellUp = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
|
||||
733, 24, "OVBUTN4.DEF");
|
||||
dwellUp->setOffset(4);
|
||||
|
||||
dwellDown = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
|
||||
dwellDown = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
|
||||
733, footerPos-18, "OVBUTN4.DEF");
|
||||
dwellDown->setOffset(6);
|
||||
}
|
||||
@ -689,11 +685,11 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
title = new CPicture("OVTITLE",16,0);
|
||||
title->colorize(LOCPLINT->playerID);
|
||||
heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[0]);
|
||||
skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[1]);
|
||||
heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[0]);
|
||||
skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[1]);
|
||||
|
||||
unsigned int townCount = LOCPLINT->cb->howManyHeroes(false);
|
||||
unsigned int size = conf.go()->ac.overviewSize*116 + 19;
|
||||
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) );
|
||||
}
|
||||
@ -710,7 +706,7 @@ void CKingdHeroList::updateGarrisons()
|
||||
|
||||
CIntObject* CKingdHeroList::createHeroItem(size_t index)
|
||||
{
|
||||
unsigned int picCount = conf.go()->ac.overviewPics;
|
||||
ui32 picCount = conf.go()->ac.overviewPics;
|
||||
size_t heroesCount = LOCPLINT->cb->howManyHeroes(false);
|
||||
|
||||
if (index < heroesCount)
|
||||
@ -741,12 +737,12 @@ CKingdTownList::CKingdTownList(size_t maxSize)
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
title = new CPicture("OVTITLE",16,0);
|
||||
title->colorize(LOCPLINT->playerID);
|
||||
townLabel = new CLabel(146,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[3]);
|
||||
garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[4]);
|
||||
visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[5]);
|
||||
townLabel = new CLabel(146,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[3]);
|
||||
garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[4]);
|
||||
visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[5]);
|
||||
|
||||
unsigned int townCount = LOCPLINT->cb->howManyTowns();
|
||||
unsigned int size = conf.go()->ac.overviewSize*116 + 19;
|
||||
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) );
|
||||
}
|
||||
@ -774,7 +770,7 @@ void CKingdTownList::updateGarrisons()
|
||||
|
||||
CIntObject* CKingdTownList::createTownItem(size_t index)
|
||||
{
|
||||
unsigned int picCount = conf.go()->ac.overviewPics;
|
||||
ui32 picCount = conf.go()->ac.overviewPics;
|
||||
size_t townsCount = LOCPLINT->cb->howManyTowns();
|
||||
|
||||
if (index < townsCount)
|
||||
@ -788,9 +784,9 @@ CTownItem::CTownItem(const CGTownInstance* Town):
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
background = new CAnimImage("OVSLOT", 6);
|
||||
name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, zwykly, town->name);
|
||||
name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, Colors::Cornsilk, town->name);
|
||||
|
||||
income = new CLabel( 190, 60, FONT_SMALL, CENTER, zwykly, boost::lexical_cast<std::string>(town->dailyIncome()));
|
||||
income = new CLabel( 190, 60, FONT_SMALL, CENTER, Colors::Cornsilk, boost::lexical_cast<std::string>(town->dailyIncome()));
|
||||
hall = new CTownInfo( 69, 31, town, true);
|
||||
fort = new CTownInfo(111, 31, town, false);
|
||||
|
||||
@ -799,9 +795,9 @@ CTownItem::CTownItem(const CGTownInstance* Town):
|
||||
|
||||
size_t iconIndex = town->subID*2;
|
||||
if (!town->hasFort())
|
||||
iconIndex += F_NUMBER*2;
|
||||
iconIndex += GameConstants::F_NUMBER*2;
|
||||
|
||||
if(town->builded >= MAX_BUILDING_PER_TURN)
|
||||
if(town->builded >= GameConstants::MAX_BUILDING_PER_TURN)
|
||||
iconIndex++;
|
||||
|
||||
picture = new CAnimImage("ITPT", iconIndex, 0, 5, 6);
|
||||
@ -860,16 +856,16 @@ class BackpackTab : public CIntObject
|
||||
public:
|
||||
CAnimImage * background;
|
||||
std::vector<CArtPlace*> arts;
|
||||
AdventureMapButton *btnLeft;
|
||||
AdventureMapButton *btnRight;
|
||||
CAdventureMapButton *btnLeft;
|
||||
CAdventureMapButton *btnRight;
|
||||
|
||||
BackpackTab()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
background = new CAnimImage("OVSLOT", 5);
|
||||
pos = background->pos;
|
||||
btnLeft = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 269, 66, "HSBTNS3");
|
||||
btnRight = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 675, 66, "HSBTNS5");
|
||||
btnLeft = new CAdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 269, 66, "HSBTNS3");
|
||||
btnRight = new CAdventureMapButton(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)));
|
||||
}
|
||||
@ -891,7 +887,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
||||
arts2->recActions = DISPOSE | SHARE_POS;
|
||||
backpack->recActions = DISPOSE | SHARE_POS;
|
||||
|
||||
name = new CLabel(75, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
||||
name = new CLabel(75, 7, FONT_SMALL, TOPLEFT, Colors::Cornsilk, hero->name);
|
||||
|
||||
std::vector<CArtPlace*> arts;
|
||||
arts.insert(arts.end(), arts1->arts.begin(), arts1->arts.end());
|
||||
@ -915,7 +911,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
||||
size_t begin = overlay.find('{');
|
||||
size_t end = overlay.find('}', begin);
|
||||
overlay = overlay.substr(begin+1, end - begin);
|
||||
artButtons->buttons[it]->addTextOverlay(overlay, FONT_SMALL, tytulowy);
|
||||
artButtons->buttons[it]->addTextOverlay(overlay, FONT_SMALL, Colors::Jasmine);
|
||||
}
|
||||
artButtons->onChange += boost::bind(&CTabbedInt::setActive, artsTabs, _1);
|
||||
artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
|
||||
@ -926,14 +922,14 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
||||
portrait = new CAnimImage("PortraitsLarge", hero->subID, 0, 5, 6);
|
||||
heroArea = new CHeroArea(5, 6, hero);
|
||||
|
||||
name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
||||
artsText = new CLabel(320, 55, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->overview[2]);
|
||||
name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, Colors::Cornsilk, hero->name);
|
||||
artsText = new CLabel(320, 55, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[2]);
|
||||
|
||||
for (size_t i=0; i<PRIMARY_SKILLS; i++)
|
||||
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,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_PRIMARY_SKILL, hero, i)));
|
||||
|
||||
for (size_t i=0; i<SKILL_PER_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,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_SECONDARY_SKILL, hero, i)));
|
||||
|
||||
|
@ -1,13 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "GUIBase.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CAnimImage;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CResDataBar;
|
||||
@ -65,7 +61,7 @@ private:
|
||||
CLabel * value;
|
||||
CLabel * name;
|
||||
CAnimImage * image;
|
||||
HoverableArea *hover;
|
||||
CHoverableArea *hover;
|
||||
|
||||
public:
|
||||
InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data);
|
||||
@ -104,7 +100,7 @@ public:
|
||||
virtual size_t getImageIndex()=0;
|
||||
|
||||
//TODO: replace with something better
|
||||
virtual bool prepareMessage(std::string &text, SComponent **comp)=0;
|
||||
virtual bool prepareMessage(std::string &text, CComponent **comp)=0;
|
||||
};
|
||||
|
||||
class InfoBoxAbstractHeroData : public IInfoBoxData
|
||||
@ -122,7 +118,7 @@ public:
|
||||
std::string getHoverText();
|
||||
size_t getImageIndex();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
class InfoBoxHeroData : public InfoBoxAbstractHeroData
|
||||
@ -140,7 +136,7 @@ public:
|
||||
std::string getHoverText();
|
||||
std::string getValueText();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
class InfoBoxCustomHeroData : public InfoBoxAbstractHeroData
|
||||
@ -172,7 +168,7 @@ public:
|
||||
std::string getHoverText();
|
||||
size_t getImageIndex();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
//TODO!!!
|
||||
@ -202,7 +198,7 @@ private:
|
||||
struct OwnedObjectInfo
|
||||
{
|
||||
int imageID;
|
||||
unsigned int count;
|
||||
ui32 count;
|
||||
std::string hoverText;
|
||||
};
|
||||
std::vector<OwnedObjectInfo> objects;
|
||||
@ -212,17 +208,17 @@ private:
|
||||
CPicture * background;
|
||||
|
||||
//Main buttons
|
||||
AdventureMapButton *btnTowns;
|
||||
AdventureMapButton *btnHeroes;
|
||||
AdventureMapButton *btnExit;
|
||||
CAdventureMapButton *btnTowns;
|
||||
CAdventureMapButton *btnHeroes;
|
||||
CAdventureMapButton *btnExit;
|
||||
|
||||
//Buttons for scrolling dwellings list
|
||||
AdventureMapButton *dwellUp, *dwellDown;
|
||||
AdventureMapButton *dwellTop, *dwellBottom;
|
||||
CAdventureMapButton *dwellUp, *dwellDown;
|
||||
CAdventureMapButton *dwellTop, *dwellBottom;
|
||||
|
||||
InfoBox * minesBox[7];
|
||||
|
||||
HoverableArea * incomeArea;
|
||||
CHoverableArea * incomeArea;
|
||||
CLabel * incomeAmount;
|
||||
|
||||
CGStatusBar * statusbar;
|
||||
|
@ -1,24 +1,16 @@
|
||||
// CMT.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
#include "../stdafx.h"
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <cmath>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "StdInc.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <SDL_mixer.h>
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "mapHandler.h"
|
||||
#include "../global.h"
|
||||
|
||||
#include "CPreGame.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "../CConsoleHandler.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "../lib/CConsoleHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CPlayerInterface.h"
|
||||
@ -39,18 +31,17 @@
|
||||
#include "../lib/Connection.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../lib/VCMIDirs.h"
|
||||
#include <cstdlib>
|
||||
#include "../lib/NetPacks.h"
|
||||
#include "CMessage.h"
|
||||
#include "../lib/CObjectHandler.h"
|
||||
#include <boost/program_options.hpp>
|
||||
#include "../lib/CArtHandler.h"
|
||||
#include "../lib/CScriptingModule.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "SDL_syswm.h"
|
||||
#endif
|
||||
#include <boost/foreach.hpp>
|
||||
#include "../lib/CDefObjInfoHandler.h"
|
||||
|
||||
#if __MINGW32__
|
||||
@ -70,7 +61,7 @@ namespace po = boost::program_options;
|
||||
*/
|
||||
|
||||
std::string NAME_AFFIX = "client";
|
||||
std::string NAME = NAME_VER + std::string(" (") + NAME_AFFIX + ')'; //application name
|
||||
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
|
||||
CGuiHandler GH;
|
||||
static CClient *client;
|
||||
SDL_Surface *screen = NULL, //main screen surface
|
||||
@ -104,14 +95,14 @@ void startGame(StartInfo * options, CConnection *serv = NULL);
|
||||
|
||||
void init()
|
||||
{
|
||||
timeHandler tmh, pomtime;
|
||||
CStopWatch tmh, pomtime;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff;
|
||||
#else
|
||||
int rmask = 0x000000ff; int gmask = 0x0000ff00; int bmask = 0x00ff0000; int amask = 0xff000000;
|
||||
#endif
|
||||
CSDL_Ext::std32bppSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, rmask, gmask, bmask, amask);
|
||||
tlog0 << "\tInitializing minors: " << pomtime.getDif() << std::endl;
|
||||
tlog0 << "\tInitializing minors: " << pomtime.getDiff() << std::endl;
|
||||
{
|
||||
//read system options
|
||||
CLoadFile settings(GVCMIDirs.UserPath + "/config/sysopts.bin", 727);
|
||||
@ -128,7 +119,7 @@ void init()
|
||||
GDefaultOptions.settingsChanged();
|
||||
}
|
||||
}
|
||||
THC tlog0<<"\tLoading default system settings: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0 << "\tLoading default system settings: " << pomtime.getDiff() << std::endl;
|
||||
|
||||
//initializing audio
|
||||
// Note: because of interface button range, volume can only be a
|
||||
@ -139,43 +130,43 @@ void init()
|
||||
CCS->musich = new CMusicHandler;
|
||||
CCS->musich->init();
|
||||
CCS->musich->setVolume(GDefaultOptions.musicVolume);
|
||||
tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"Initializing screen and sound handling: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tInitializing sound: "<<pomtime.getDiff()<<std::endl;
|
||||
tlog0<<"Initializing screen and sound handling: "<<tmh.getDiff()<<std::endl;
|
||||
|
||||
initDLL(::console,logfile);
|
||||
const_cast<CGameInfo*>(CGI)->setFromLib();
|
||||
CCS->soundh->initCreaturesSounds(CGI->creh->creatures);
|
||||
CCS->soundh->initSpellsSounds(CGI->spellh->spells);
|
||||
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDiff()<<std::endl;
|
||||
|
||||
pomtime.getDif();
|
||||
pomtime.getDiff();
|
||||
CCS->curh = new CCursorHandler;
|
||||
CCS->curh->initCursor();
|
||||
CCS->curh->show();
|
||||
tlog0<<"Screen handler: "<<pomtime.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
tlog0<<"Screen handler: "<<pomtime.getDiff()<<std::endl;
|
||||
pomtime.getDiff();
|
||||
graphics = new Graphics();
|
||||
graphics->loadHeroAnims();
|
||||
tlog0<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tMain graphics: "<<tmh.getDiff()<<std::endl;
|
||||
tlog0<<"Initializing game graphics: "<<tmh.getDiff()<<std::endl;
|
||||
|
||||
CMessage::init();
|
||||
tlog0<<"Message handler: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Message handler: "<<tmh.getDiff()<<std::endl;
|
||||
//CPG = new CPreGame(); //main menu and submenus
|
||||
//tlog0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
static void prog_version(void)
|
||||
{
|
||||
printf("%s\n", NAME_VER);
|
||||
printf(" data directory: %s\n", DATA_DIR);
|
||||
printf(" library directory: %s\n", LIB_DIR);
|
||||
printf(" binary directory: %s\n", BIN_DIR);
|
||||
printf("%s\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf(" data directory: %s\n", GameConstants::DATA_DIR.c_str());
|
||||
printf(" library directory: %s\n", GameConstants::LIB_DIR.c_str());
|
||||
printf(" binary directory: %s\n", GameConstants::BIN_DIR.c_str());
|
||||
}
|
||||
|
||||
static void prog_help(const char *progname)
|
||||
{
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", NAME_VER);
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf("Copyright (C) 2007-2010 VCMI dev team - see AUTHORS file\n");
|
||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
||||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
@ -229,17 +220,17 @@ int main(int argc, char** argv)
|
||||
putenv((char*)"SDL_VIDEO_WINDOW_POS");
|
||||
putenv((char*)"SDL_VIDEO_CENTERED=1");
|
||||
|
||||
timeHandler 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;
|
||||
*console->cb = boost::bind(&processCommand, _1);
|
||||
console->start();
|
||||
atexit(dispose);
|
||||
tlog0 <<"Creating console and logfile: "<<pomtime.getDif() << std::endl;
|
||||
tlog0 <<"Creating console and logfile: "<<pomtime.getDiff() << std::endl;
|
||||
|
||||
conf.init();
|
||||
tlog0 <<"Loading settings: "<<pomtime.getDif() << std::endl;
|
||||
tlog0 <<"Loading settings: "<<pomtime.getDiff() << std::endl;
|
||||
tlog0 << NAME << std::endl;
|
||||
|
||||
srand ( time(NULL) );
|
||||
@ -255,7 +246,7 @@ int main(int argc, char** argv)
|
||||
atexit(SDL_Quit);
|
||||
|
||||
setScreenRes(conf.cc.pregameResx, conf.cc.pregameResy, conf.cc.bpp, conf.cc.fullscreen);
|
||||
tlog0 <<"\tInitializing screen: "<<pomtime.getDif() << std::endl;
|
||||
tlog0 <<"\tInitializing screen: "<<pomtime.getDiff() << std::endl;
|
||||
|
||||
// Initialize video
|
||||
#if defined _M_X64 && defined _WIN32 //Win64 -> cannot load 32-bit DLLs for video handling
|
||||
@ -263,7 +254,7 @@ int main(int argc, char** argv)
|
||||
#else
|
||||
CCS->videoh = new CVideoPlayer;
|
||||
#endif
|
||||
tlog0<<"\tInitializing video: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tInitializing video: "<<pomtime.getDiff()<<std::endl;
|
||||
|
||||
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
|
||||
boost::thread loading(init);
|
||||
@ -274,7 +265,7 @@ int main(int argc, char** argv)
|
||||
SDL_FillRect(screen,NULL,0);
|
||||
CSDL_Ext::update(screen);
|
||||
loading.join();
|
||||
tlog0<<"Initialization of VCMI (together): "<<total.getDif()<<std::endl;
|
||||
tlog0<<"Initialization of VCMI (together): "<<total.getDiff()<<std::endl;
|
||||
|
||||
if(!vm.count("battle"))
|
||||
{
|
||||
@ -441,7 +432,7 @@ void processCommand(const std::string &message)
|
||||
boost::filesystem::create_directory("Extracted_txts");
|
||||
tlog0<<"Command accepted. Opening .lod file...\t";
|
||||
CLodHandler * txth = new CLodHandler;
|
||||
txth->init(std::string(DATA_DIR "/Data/H3bitmap.lod"),"");
|
||||
txth->init(GameConstants::DATA_DIR + "/Data/H3bitmap.lod","");
|
||||
tlog0<<"done.\nScanning .lod file\n";
|
||||
|
||||
BOOST_FOREACH(Entry e, txth->entries)
|
||||
@ -488,7 +479,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);
|
||||
@ -543,8 +534,8 @@ void dispose()
|
||||
static void setScreenRes(int w, int h, int bpp, bool fullscreen)
|
||||
{
|
||||
// VCMI will only work with 2, 3 or 4 bytes per pixel
|
||||
amax(bpp, 16);
|
||||
amin(bpp, 32);
|
||||
vstd::amax(bpp, 16);
|
||||
vstd::amin(bpp, 32);
|
||||
|
||||
// Try to use the best screen depth for the display
|
||||
int suggestedBpp = SDL_VideoModeOK(w, h, bpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user