1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
%module asc
%include "std_vector.i"
%include "std_string.i"
%{
#include <string>
#include "../gamemap.h"
#include "../mapalgorithms.h"
#include "../util/messaginghub.h"
#include "../textfiletags.h"
#include "common.h"
%}
class Resources {
public:
%immutable;
int energy;
int material;
int fuel;
%mutable;
Resources();
Resources( int energy, int material, int fuel );
};
class MapCoordinate {
protected:
MapCoordinate();
public:
MapCoordinate(int x, int y );
bool valid();
};
class MapCoordinate3D : public MapCoordinate {
protected:
MapCoordinate3D();
public:
MapCoordinate3D(int x, int y, int bitmappedHeight );
bool valid();
};
GameMap* getActiveMap();
const ObjectType* getObjectType( int id );
const BuildingType* getBuildingType( int id );
const Vehicletype* getUnitType( int id );
const TerrainType* getTerrainType( int id );
void errorMessage ( std::string s );
void warningMessage ( std::string s );
void infoMessage ( std::string s );
class ContainerBaseType {
public:
int getID() const;
int getHeight() const;
%extend
{
bool hasProperty ( std::string bitName ) // see textfiletags.cpp for value
{
for ( int i = 0; i < ContainerBaseType::functionNum; ++i )
if ( containerFunctionTags[i] == bitName )
return $self->hasFunction( (ContainerBaseType::ContainerFunctions) i);
return false;
}
}
protected:
ContainerBaseType();
};
class BuildingType : public ContainerBaseType {
};
class Vehicletype : public ContainerBaseType {
};
class TerrainType {
protected:
TerrainType();
public:
int getID() const;
};
class ContainerBase {
public:
void deleteProductionLine( const Vehicletype* type );
void deleteAllProductionLines();
void addProductionLine( const Vehicletype* type );
int getCargoCount();
// warning: the cargo may have items which are NULL
Vehicle* getCargo( int i );
std::string getName();
void setName( const std::string& name );
int getOwner();
int getHeight();
Resources getStorageCapacity() const;
protected:
ContainerBase();
};
class Building : public ContainerBase {
protected:
Building();
public:
const BuildingType* getType();
};
class Vehicle : public ContainerBase {
protected:
Vehicle();
public:
const Vehicletype* getType();
Resources getTank() const;
};
class Object {
public:
ObjectType* getType();
int getDir();
void setDir( int dir );
};
class ObjectType {
public:
int getID();
std::string getName();
};
class tfield {
public:
Building* getBuildingEntrance();
Vehicle* getVehicle();
int getWeather();
int getMineralMaterial() const;
int getMineralFuel() const;
void setMineralMaterial( int material );
void setMineralFuel( int material );
%extend
{
bool hasProperty ( std::string bitName ) // see textfiletags.cpp for value
{
for ( int i = 0; i < terrainPropertyNum; ++i )
if ( terrainProperties[i] == bitName )
return $self->bdt.test(i);
return false;
}
}
#ifdef mapeditor
void setWeather( int weather );
bool removeObject ( const ObjectType* obj, bool force = false );
#endif
Object* checkForObject ( const ObjectType* o );
%extend
{
int getObjectCount()
{
return $self->objects.size();
}
Object* getObject( int num ) // zero based!
{
if ( num >= 0 && num < $self->objects.size() )
return &($self->objects[num]);
else
return NULL;
}
}
protected:
tfield();
};
class Properties {
public:
std::string getValue( const std::string& key );
void setValue( const std::string& key, const std::string& value );
};
class GameMap {
public:
#ifdef mapeditor
// in ASC, the scripts are not able to access all fields, as they are running in a user context
tfield* getField( int x, int y );
tfield* getField( const MapCoordinate& pos );
#endif
int width() const;
int height() const;
Player& getPlayer( int p );
Properties& getProperties();
};
class Player {
protected:
Player();
public:
int getPosition();
bool exist() const;
bool isHuman() const;
#ifdef mapeditor
void setName( const char* name );
#endif
Research& getResearch();
};
class Research {
protected:
Research();
public:
#ifdef mapeditor
void addPredefinedTechAdapter( const std::string& techAdapter );
#endif
};
class StringArray {
public:
StringArray();
void add( const std::string& s );
std::string getItem( int n ); //!< 1 based, in best LUA tradition
int size(); //
};
class PropertyDialog {
public:
PropertyDialog( const std::string& title );
void addBool( const std::string& name, bool defaultValue );
void addInteger( const std::string& name, int defaultValue );
// returns and integer, so query result with getInteger
void addIntDropdown ( const std::string& name, const StringArray& names, int defaultValue );
void addString( const std::string& name, const std::string& defaultValue );
std::string getString( const std::string& name );
int getInteger( const std::string& name );
bool getBool( const std::string& name );
bool run();
};
int selectString ( const std::string& title, const StringArray& entries, int defaultEntry = -1 );
/* this is a very special function for usage in conjunction with setLocalizedEventMessage , to get the map that
is being loaded before it is set active. Only for translation scripts */
GameMap* getLoadingMap();
void setLocalizedEventMessage( GameMap* map, int eventID, const std::string& message );
void setLocalizedContainerName( GameMap* map, const MapCoordinate& pos, const std::string& name );
MapCoordinate getCursorPosition( const GameMap* gamemap );
|