00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _OPENCITY_CITY_H_
00021 #define _OPENCITY_CITY_H_ 1
00022
00023 #include "main.h"
00024
00025 #include "persistence.h"
00026 #include "ui.h"
00027
00028
00029 class PathFinder;
00030 class Vehicle;
00031 class MovementManager;
00032
00033 class MainSim;
00034
00035 class Layer;
00036 class BuildingLayer;
00037
00038 class GUIButton;
00039 class GUIContainer;
00040
00041
00044 class City : public Persistence, public UI
00045 {
00046 public:
00047 City(
00048 const uint width = OC_CITY_W,
00049 const uint length = OC_CITY_L,
00050 const OC_DATE foundedDate = 0,
00051 const int difficulty = 2 );
00052
00053 ~City();
00054
00055
00056
00060 void
00061 SaveTo( std::fstream& rfs );
00062
00063
00064
00068 void
00069 LoadFrom( std::fstream& rfs );
00070
00071
00072
00073
00074
00075 void
00076 uiKeyboard( const SDL_KeyboardEvent & rcsSDLKeyboardEvent );
00077
00078 void
00079 uiMouseMotion( const SDL_MouseMotionEvent & rcsSDLMouseMotionEvent );
00080
00081 void
00082 uiMouseButton( const SDL_MouseButtonEvent & rcsSDLMouseButtonEvent );
00083
00084 void
00085 uiExpose( const SDL_ExposeEvent & rcsSDLExposeEvent );
00086
00087 void
00088 uiResize( const SDL_ResizeEvent & rcsSDLResizeEvent );
00089
00090
00091 void
00092 SetCurrentLayer( OPENCITY_CITY_LAYER enumNewLayer );
00093
00094 void
00095 Run( OPENCITY_CITY_SPEED enumSpeed = LAST_SPEED );
00096
00097 Layer*
00098 GetLayer( OPENCITY_CITY_LAYER enumLayer ) const;
00099
00100
00101 const void GetWL(
00102 uint & w, uint & l ) const;
00103
00104
00105 private:
00106
00107 string strCityName;
00108 int iDifficulty;
00109 string strFileName;
00110 OC_DATE cityFoundedDate;
00111 OC_LINT _liCityFund;
00112 bool boolModified;
00113
00114
00115
00116
00117
00118
00119 uint _uiDay;
00120 uint _uiMonth;
00121 uint _uiYear;
00122
00123 OC_CHAR _cTool;
00124
00125 uint _uiWidth;
00126 uint _uiLength;
00127
00128 int iWinWidth;
00129 int iWinHeight;
00130
00131
00132 bool boolLMBPressed;
00133 uint uiMapW1;
00134 uint uiMapL1;
00135 uint uiMapW2;
00136 uint uiMapL2;
00137
00138
00139 bool booltabKeyPressed [KEY_NUMBER];
00140
00141
00142 OPENCITY_CITY_LAYER enumCurrentLayer;
00143
00144
00145 OPENCITY_CITY_SPEED enumCurrentSpeed;
00146
00147
00148 OPENCITY_TOOL_CODE enumCurrentTool;
00149
00150
00151
00152 Layer* ptabLayer [4];
00153
00154
00155 bool boolPathGo;
00156 uint uiPathStartW, uiPathStartH;
00157 uint uiPathStopW, uiPathStopH;
00158 GUIContainer* pctrPath;
00159 GUIButton* pbtnPathStart;
00160 GUIButton* pbtnPathStop1;
00161 GUIButton* pbtnPathStop2;
00162 GUIButton* pbtnTestBuilding;
00163 Vehicle* pvehicle;
00164 uint uiVehicleType;
00165
00166
00167 GUIContainer* pctrMAS;
00168 GUIButton* pbtnMAS;
00169 GUIButton* pbtnMASPolice;
00170 GUIButton* pbtnMASDemonstrator;
00171 GUIButton* pbtnMASRobber;
00172
00173
00174 MainSim* _pMSim;
00175 SDL_Thread* _pthreadMSim;
00176
00177
00178
00179 GUIButton* pbtnSplash;
00180
00181
00182 GUIContainer* pctr;
00183 GUIContainer* pctrMain;
00184 GUIContainer* pctrL;
00185 GUIContainer* pctrT;
00186 GUIContainer* pctrQ;
00187 GUIContainer* pctrZ;
00188 GUIContainer* pctrG;
00189 GUIContainer* pctrN;
00190 GUIContainer* pctrS;
00191
00192
00193 GUIButton* pbtnZ;
00194 GUIButton* pbtnS;
00195 GUIButton* pbtnL;
00196 GUIButton* pbtnP;
00197 GUIButton* pbtnX;
00198 GUIButton* pbtnG;
00199
00200
00201 GUIButton* pbtnZB;
00202 GUIButton* pbtnZR;
00203 GUIButton* pbtnZC;
00204 GUIButton* pbtnZI;
00205
00206
00207 GUIButton* pbtnLB;
00208 GUIButton* pbtnLL;
00209 GUIButton* pbtnLE;
00210
00211
00212 GUIButton* pbtnTB;
00213 GUIButton* pbtnTU;
00214 GUIButton* pbtnTD;
00215 GUIButton* pbtnTX;
00216 GUIButton* pbtnTQ;
00217
00218
00219 GUIButton* pbtnGB;
00220 GUIButton* pbtnGP;
00221 GUIButton* pbtnGE;
00222 GUIButton* pbtnGH;
00223 GUIButton* pbtnGL;
00224 GUIButton* pbtnGF;
00225
00226
00227 GUIButton* pbtnNB;
00228 GUIButton* pbtnNP;
00229 GUIButton* pbtnNT;
00230
00231
00232 GUIButton* pbtnSB;
00233 GUIButton* pbtnSS;
00234 GUIButton* pbtnSL;
00235
00236
00237
00238
00239
00240
00244 void _CreateSimulator();
00245
00246
00247
00251 void _DeleteSimulator();
00252
00253
00254
00258 void _CreateGUI();
00259
00260
00264 void _DeleteGUI();
00265
00266 void _DoTool(
00267 const SDL_MouseButtonEvent & sdlMBEvent );
00268
00269 bool _HandleKeyPressed();
00270
00271 void _DoBill( const OPENCITY_PROPERTY_CODE & );
00272
00273 void _HandleGUIClick();
00274
00275 void _HandleMouseXY();
00276
00277 void _TestPathfinding();
00278
00279 void _BuildPreview();
00280
00281
00282
00286 bool
00287 _Save( const string& strFilename );
00288
00289
00293 bool
00294 _Load( const string& strFilename );
00295
00296 };
00297
00298 #endif
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317