| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef _OPENCITY_CITY_H_ |
| 21 |
#define _OPENCITY_CITY_H_ 1 |
| 22 |
|
| 23 |
#include "main.h" |
| 24 |
|
| 25 |
#include "persistence.h" |
| 26 |
#include "ui.h" |
| 27 |
|
| 28 |
#include <deque> |
| 29 |
|
| 30 |
#define OC_MAX_RESSOURCE_RECORD 20 |
| 31 |
|
| 32 |
|
| 33 |
class PathFinder; |
| 34 |
class Vehicle; |
| 35 |
class MovementManager; |
| 36 |
|
| 37 |
class MainSim; |
| 38 |
|
| 39 |
class Layer; |
| 40 |
class BuildingLayer; |
| 41 |
|
| 42 |
class GUIBar; |
| 43 |
class GUIButton; |
| 44 |
class GUILabel; |
| 45 |
class GUIContainer; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
struct Ressource { |
| 52 |
OC_LINT fund; |
| 53 |
uint population; |
| 54 |
uint r, c, i; |
| 55 |
uint w, e, g; |
| 56 |
}; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
class City : public Persistence, public UI |
| 63 |
{ |
| 64 |
public: |
| 65 |
City( |
| 66 |
const uint width = OC_CITY_W, |
| 67 |
const uint length = OC_CITY_L, |
| 68 |
const bool bGUIEnabled = true ); |
| 69 |
|
| 70 |
~City(); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
void SaveTo( std::fstream& rfs ); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
void LoadFrom( std::fstream& rfs ); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
void SetCurrentLayer( OPENCITY_CITY_LAYER enumNewLayer ); |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
void Run(); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
void Display(); |
| 101 |
|
| 102 |
|
| 103 |
Layer* GetLayer( OPENCITY_CITY_LAYER enumLayer ) const; |
| 104 |
|
| 105 |
|
| 106 |
const void GetWL( uint & w, uint & l ) const; |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
void Keyboard( const SDL_KeyboardEvent& rcEvent ); |
| 113 |
void MouseMotion( const SDL_MouseMotionEvent& rcEvent ); |
| 114 |
void MouseButton( const SDL_MouseButtonEvent& rcEvent ); |
| 115 |
void Expose( const SDL_ExposeEvent& rcEvent ); |
| 116 |
void Resize( const SDL_ResizeEvent& rcEvent ); |
| 117 |
|
| 118 |
|
| 119 |
private: |
| 120 |
|
| 121 |
bool _bGUIEnabled; |
| 122 |
bool _bStatusVisible; |
| 123 |
|
| 124 |
uint _uiIncome; |
| 125 |
OC_LINT _liCityFund; |
| 126 |
uint _uiPopulation; |
| 127 |
std::deque<Ressource> _dqRessource; |
| 128 |
|
| 129 |
uint _uiDay; |
| 130 |
uint _uiMonth; |
| 131 |
uint _uiYear; |
| 132 |
|
| 133 |
uint _uiWidth; |
| 134 |
uint _uiLength; |
| 135 |
|
| 136 |
int _iWinWidth; |
| 137 |
int _iWinHeight; |
| 138 |
|
| 139 |
|
| 140 |
bool _bLMBPressed; |
| 141 |
uint _uiMapW1; |
| 142 |
uint _uiMapL1; |
| 143 |
uint _uiMapW2; |
| 144 |
uint _uiMapL2; |
| 145 |
|
| 146 |
|
| 147 |
bool _abKeyPressed[KEY_NUMBER]; |
| 148 |
|
| 149 |
|
| 150 |
OPENCITY_CITY_LAYER _eCurrentLayer; |
| 151 |
|
| 152 |
|
| 153 |
OPENCITY_CITY_SPEED _eSpeed; |
| 154 |
|
| 155 |
|
| 156 |
OPENCITY_TOOL_CODE _eCurrentTool; |
| 157 |
GUIButton* _apbtnCurrentTool[OC_TOOL_NUMBER]; |
| 158 |
|
| 159 |
|
| 160 |
Layer* _apLayer[4]; |
| 161 |
|
| 162 |
|
| 163 |
bool boolPathGo; |
| 164 |
uint uiPathStartW, uiPathStartH; |
| 165 |
uint uiPathStopW, uiPathStopH; |
| 166 |
GUIContainer*_pctrPath; |
| 167 |
GUIButton* pbtnPathStart; |
| 168 |
GUIButton* pbtnPathStop1; |
| 169 |
GUIButton* pbtnPathStop2; |
| 170 |
GUIButton* pbtnTestBuilding; |
| 171 |
Vehicle* pvehicle; |
| 172 |
uint uiVehicleType; |
| 173 |
|
| 174 |
|
| 175 |
GUIContainer*_pctrMAS; |
| 176 |
GUIButton* pbtnMAS; |
| 177 |
GUIButton* pbtnMASPolice; |
| 178 |
GUIButton* pbtnMASDemonstrator; |
| 179 |
GUIButton* pbtnMASRobber; |
| 180 |
|
| 181 |
|
| 182 |
MainSim* _pMSim; |
| 183 |
SDL_Thread* _pthreadMSim; |
| 184 |
|
| 185 |
|
| 186 |
GUIContainer* _pctrMenu; |
| 187 |
GUIButton* _pbtnMenuNew; |
| 188 |
GUIButton* _pbtnMenuLoad; |
| 189 |
GUIButton* _pbtnMenuSave; |
| 190 |
GUIButton* _pbtnMenuQuit; |
| 191 |
|
| 192 |
|
| 193 |
GUIContainer* _pctrStatus; |
| 194 |
GUILabel* _plblFund; |
| 195 |
GUILabel* _plblPopulation; |
| 196 |
GUILabel* _plblDate; |
| 197 |
GUIBar* _pbarResidence; |
| 198 |
GUIBar* _pbarCommerce; |
| 199 |
GUIBar* _pbarIndustry; |
| 200 |
GUIBar* _pbarPower; |
| 201 |
GUIButton* _pbtnPause; |
| 202 |
GUIButton* _pbtnPlay; |
| 203 |
|
| 204 |
|
| 205 |
GUIContainer* _pctr; |
| 206 |
GUIContainer* _pctrMain; |
| 207 |
GUIContainer* _pctrL; |
| 208 |
GUIContainer* _pctrT; |
| 209 |
GUIContainer* _pctrQ; |
| 210 |
GUIContainer* _pctrZ; |
| 211 |
GUIContainer* _pctrG; |
| 212 |
GUIContainer* _pctrN; |
| 213 |
GUIContainer* _pctrS; |
| 214 |
|
| 215 |
|
| 216 |
GUIButton* pbtnZ; |
| 217 |
GUIButton* pbtnS; |
| 218 |
GUIButton* pbtnL; |
| 219 |
GUIButton* pbtnP; |
| 220 |
GUIButton* pbtnX; |
| 221 |
GUIButton* pbtnG; |
| 222 |
|
| 223 |
|
| 224 |
GUIButton* pbtnZB; |
| 225 |
GUIButton* pbtnZR; |
| 226 |
GUIButton* pbtnZC; |
| 227 |
GUIButton* pbtnZI; |
| 228 |
|
| 229 |
|
| 230 |
GUIButton* pbtnLB; |
| 231 |
GUIButton* pbtnLL; |
| 232 |
GUIButton* pbtnLN; |
| 233 |
GUIButton* pbtnLC; |
| 234 |
|
| 235 |
|
| 236 |
GUIButton* pbtnTB; |
| 237 |
GUIButton* pbtnTU; |
| 238 |
GUIButton* pbtnTD; |
| 239 |
GUIButton* pbtnTX; |
| 240 |
GUIButton* pbtnTQ; |
| 241 |
|
| 242 |
|
| 243 |
GUIButton* pbtnGB; |
| 244 |
GUIButton* pbtnGP; |
| 245 |
GUIButton* pbtnGE; |
| 246 |
GUIButton* pbtnGH; |
| 247 |
GUIButton* pbtnGL; |
| 248 |
GUIButton* pbtnGF; |
| 249 |
|
| 250 |
|
| 251 |
GUIButton* pbtnNB; |
| 252 |
GUIButton* pbtnNP; |
| 253 |
GUIButton* pbtnNT; |
| 254 |
|
| 255 |
|
| 256 |
GUIButton* pbtnSB; |
| 257 |
GUIButton* pbtnSS; |
| 258 |
GUIButton* pbtnSL; |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
void _CreateTree(); |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
void _CreateSimulator(); |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
void _DeleteSimulator(); |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
void _CreateGUI(); |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
void _DeleteGUI(); |
| 297 |
|
| 298 |
void _LoadMenu(); |
| 299 |
void _CenterMenu(); |
| 300 |
void _UnloadMenu(); |
| 301 |
|
| 302 |
void _SetCurrentTool( const OPENCITY_TOOL_CODE& tool ); |
| 303 |
void _DoTool( const SDL_MouseButtonEvent& sdlMBEvent ); |
| 304 |
|
| 305 |
bool _HandleKeyPressed(); |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
void _RecordRessource(); |
| 311 |
|
| 312 |
void _DoBill( const OPENCITY_PROPERTY_CODE& ); |
| 313 |
|
| 314 |
void _HandleMenuClick(); |
| 315 |
|
| 316 |
void _HandleStatusClick(); |
| 317 |
|
| 318 |
void _HandleGUIClick(); |
| 319 |
|
| 320 |
void _HandleMouseXY(); |
| 321 |
|
| 322 |
void _TestPathfinding(); |
| 323 |
|
| 324 |
void _BuildPreview(); |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
bool |
| 332 |
_Save( const string& strFilename ); |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
bool |
| 339 |
_Load( const string& strFilename ); |
| 340 |
|
| 341 |
}; |
| 342 |
|
| 343 |
#endif |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|