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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
|
%module asc
%include "std_vector.i"
%include "std_string.i"
%{
#include <string>
#include "../gamemap.h"
#include "../spfst.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();
std::string toString();
%immutable;
int x;
int y;
};
class MapCoordinate3D : public MapCoordinate {
protected:
MapCoordinate3D();
public:
MapCoordinate3D(int x, int y, int bitmappedHeight );
bool valid();
};
GameMap* getActiveMap();
void repaintMap();
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:
#ifdef mapeditor
void deleteProductionLine( const VehicleType* type );
void deleteAllProductionLines();
void addProductionLine( const VehicleType* type );
#endif
int getCargoCount();
// warning: the cargo may have items which are NULL
Vehicle* getCargo( int i );
#ifdef mapeditor
// removes a unit from the cargo. The unit will still be registered as containing to the map
// It must then be placed into another Container or onto a field
bool removeUnitFromCargo( Vehicle* veh, bool recursive = false );
bool removeUnitFromCargo( int nwid, bool recursive = false );
void addToCargo( Vehicle* v );
//! The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all
void setInternalResourcePlus( const Resources& res );
//! The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all
void setInternalResourceMaxPlus( const Resources& res );
#endif
//! The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all
Resources getInternalResourcePlus() const;
//! The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all
Resources getInternalResourceMaxPlus() const;
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();
#ifdef mapeditor
void convert ( int player );
#endif
};
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 MapField {
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 ) {
ASCString t = terrainProperties[i];
if ( t.compare_ci( bitName ) == 0 )
return $self->bdt.test(i);
}
return false;
}
}
#ifdef mapeditor
void setWeather( int weather );
bool removeObject ( const ObjectType* obj, bool force = false );
void changeTerrainType( const TerrainType* terrain );
void removeBuilding();
void removeUnit();
#endif
TerrainType* getTerrainType();
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:
MapField();
};
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
MapField* getField( int x, int y );
MapField* getField( const MapCoordinate& pos );
void setServerMapID( int id );
void setTitle( const std::string& title );
#endif
int getServerMapID() const;
std::string getTitle() const;
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 std::string& name );
void setPlayerID( int id );
#endif
int getPlayerID() const;
std::string getName() const;
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(); //
};
/** a rectangle for specifying the size and position of dialogs, widgets, etc */
class PG_Rect {
public:
PG_Rect( int xpos, int ypos, int width, int heigth );
};
class PropertyDialog {
public:
PropertyDialog( const std::string& title );
PropertyDialog( const std::string& title, const PG_Rect& size );
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 );
#ifdef mapeditor
void setCursorPosition( const GameMap* gamemap, const MapCoordinate& pos );
#endif
|