27
27
#define gameeventsystemH
29
29
#include <sigc++/sigc++.h>
30
#include "loki/Singleton.h"
32
#include "libs/loki/Singleton.h"
33
#include "util/factory.h"
35
35
#include "mapdisplayinterface.h"
36
#include "util/factorywithnames.h"
37
38
class MapDisplayInterface;
44
45
cconnection_areaentered_specificunit = 32 };
47
extern bool checkevents( MapDisplayInterface* md );
49
extern void checktimedevents( MapDisplayInterface* md );
51
extern void eventReady();
48
extern bool checkevents( GameMap* gamemap, MapDisplayInterface* md );
50
extern void checktimedevents( GameMap* gamemap, MapDisplayInterface* md );
52
extern void eventReady( GameMap* gamemap );
53
54
typedef int EventTriggerID;
54
55
typedef int EventActionID;
101
101
virtual void writeData ( tnstream& stream ) = 0;
102
102
virtual ASCString getName() const = 0;
104
virtual ASCString getLocalizationString() const { return ""; };
105
virtual void setLocalizationString( const ASCString& s ) {};
104
107
virtual void execute( MapDisplayInterface* md ) = 0;
105
108
virtual void setup() = 0;
106
109
void setMap( GameMap* gamemap_ ) { gamemap = gamemap_; };
165
template < class AbstractProduct, typename IdentifierType, typename ObjectCreatorCallBack = AbstractProduct*(*)(), typename NameType = ASCString >
166
class FactoryWithNames : protected Factory<AbstractProduct, IdentifierType>
169
typedef std::map<NameType, IdentifierType> NameMap;
172
vector<NameType> getNames(){
173
vector<NameType> nameList;
175
for ( typename NameMap::iterator i = names.begin(); i != names.end(); ++i )
176
nameList.push_back( i->first );
180
IdentifierType getID( const ASCString& name )
185
bool registerClass( IdentifierType id, typename FactoryWithNames<AbstractProduct, IdentifierType, typename FactoryWithNames::ObjectCreatorCallBack, NameType>::ObjectCreatorCallBack createFn, Loki::Functor<NameType, TYPELIST_1(const IdentifierType&)> nameProvider )
187
return registerClass( id, createFn, nameProvider(id) );
190
bool registerClass( IdentifierType id, typename FactoryWithNames<AbstractProduct, IdentifierType, typename FactoryWithNames::ObjectCreatorCallBack, NameType>::ObjectCreatorCallBack createFn, NameType name )
192
if ( Factory<AbstractProduct, IdentifierType>::registerClass ( id, createFn )) {
199
AbstractProduct* createObject( IdentifierType id ) {
200
return Factory<AbstractProduct, IdentifierType>::createObject( id );
205
typedef Loki::SingletonHolder< FactoryWithNames< EventTrigger, EventTriggerID > > triggerFactory;
206
typedef Loki::SingletonHolder< FactoryWithNames< EventAction , EventActionID > > actionFactory;
168
typedef Loki::SingletonHolder< FactoryWithNames< EventTrigger, EventTriggerID > > eventTriggerFactory;
169
typedef Loki::SingletonHolder< FactoryWithNames< EventAction , EventActionID > > eventActionFactory;