common.h

Go to the documentation of this file.
00001 /*
00002      This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003      Copyright (C) 1994-2010  Martin Bickel  
00004 
00005      This program is free software; you can redistribute it and/or modify
00006      it under the terms of the GNU General Public License as published by
00007      the Free Software Foundation; either version 2 of the License, or
00008      (at your option) any later version.
00009 
00010      This program is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013      GNU General Public License for more details.
00014 
00015      You should have received a copy of the GNU General Public License
00016      along with this program; see the file COPYING. If not, write to the
00017      Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00018      Boston, MA  02111-1307  USA
00019 */
00020 
00021 
00022 #ifndef commonH
00023 #define commonH
00024 
00025 #include "../typen.h"
00026 
00027 #include "../paradialog.h"
00028 
00029 class GameMap;
00030 class ObjectType;
00031 class BuildingType;
00032 class VehicleType;
00033 class TerrainType;
00034 
00035 extern GameMap* getActiveMap();
00036 
00037 extern const ObjectType* getObjectType( int id );
00038 extern const BuildingType* getBuildingType( int id );
00039 extern const VehicleType* getUnitType( int id );
00040 extern const TerrainType* getTerrainType( int id );
00041 
00042 class StringArray {
00043    public:
00044       vector<ASCString> values;
00045       StringArray(){};
00046       void add( const ASCString& s ) { values.push_back( s ); };
00047       ASCString getItem( int n ) 
00048       {
00049          return (n> 0 && n <= values.size()) ? values[n-1] : ASCString();
00050       }
00051       int size() { return values.size(); }; //
00052 };
00053 
00054 class PropertyDialog : public ASC_PG_Dialog {
00055    private:
00056       PG_PropertyEditor* propertyEditor;
00057       bool result;
00058    
00059       bool ok();
00060       bool cancel();
00061       
00062       map<ASCString,bool> boolValues;
00063       map<ASCString,int>  intValues;
00064       map<ASCString,ASCString> stringValues;
00065       
00066       void setup();
00067       
00068    public:
00069       PropertyDialog( const ASCString& title );
00070       PropertyDialog( const ASCString& title, const PG_Rect& size );
00071       void addBool( const ASCString& name, bool defaultValue );
00072       void addInteger( const ASCString& name, int defaultValue );
00073       void addIntDropdown ( const ASCString& name, const StringArray& names, int defaultValue );
00074       void addString( const ASCString& name, const ASCString& defaultValue );
00075       
00076       std::string getString( const ASCString& name );
00077       int getInteger( const ASCString& name );
00078       bool getBool( const ASCString& name );
00079       bool run();
00080 };
00081 
00082 extern int selectString ( const ASCString& title, const StringArray& entries, int defaultEntry = -1 );
00083 
00084 extern GameMap* getLoadingMap();
00085 
00086 extern void setLocalizedEventMessage( GameMap* map, int eventID, const ASCString& message );
00087 extern void setLocalizedContainerName( GameMap* map, const MapCoordinate& pos, const std::string& name );
00088 
00089 extern MapCoordinate getCursorPosition( const GameMap* gamemap );
00090 
00091 extern void setCursorPosition( const GameMap* gamemap, const MapCoordinate& pos );
00092 
00093 extern void assertSuccess( const ActionResult& result );
00094 
00095 #endif
00096 

Generated on Mon May 21 01:26:30 2012 for Advanced Strategic Command by  doxygen 1.5.1