Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

city.h

00001 /***************************************************************************
00002                             city.h    -  description
00003                                 -------------------
00004     begin                : mer mai 28 2003
00005     copyright            : (C) 2003-2006 by Duong-Khang NGUYEN
00006     email                : neoneurone @ users sourceforge net
00007     
00008     $Id: city.h 60 2006-10-09 21:28:49Z neoneurone $
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   any later version.                                                    *
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;       // testing pathfinding
00030 class Vehicle;
00031 class MovementManager;
00032 
00033 class MainSim;          // main simulator which handles the micro simulators
00034 
00035 class Layer;
00036 class BuildingLayer;
00037 
00038 class GUIButton;        // GUI, toolcircle
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    // Inherited methods from UI
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 // Current city's informations
00107     string      strCityName;        
00108     int         iDifficulty;        
00109     string      strFileName;        
00110     OC_DATE     cityFoundedDate;
00111     OC_LINT     _liCityFund;        
00112     bool        boolModified;
00113 /* not used
00114     uint        uiPoliceDpt;
00115     uint        uiFireDpt;
00116     uint        uiPark;
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 // Dragging mode and mouse click
00132     bool        boolLMBPressed;
00133     uint        uiMapW1;
00134     uint        uiMapL1;
00135     uint        uiMapW2;
00136     uint        uiMapL2;
00137 
00138 // Handle pressed keyboards
00139     bool        booltabKeyPressed [KEY_NUMBER];
00140 
00141 // Current city's layer
00142     OPENCITY_CITY_LAYER enumCurrentLayer;
00143 
00144 // Current city's speed
00145     OPENCITY_CITY_SPEED enumCurrentSpeed;
00146 
00147 // Current active tool
00148     OPENCITY_TOOL_CODE enumCurrentTool;
00149 
00150 
00151 // Others classes
00152     Layer*      ptabLayer [4];          // table of our 4 differents layer
00153 
00154 // Testing pathfinder, TODO maybe we need to move it to main.cpp
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;       // Used by graphists
00163     Vehicle*    pvehicle;
00164     uint        uiVehicleType;
00165 
00166 // Testing MAS
00167     GUIContainer* pctrMAS;
00168     GUIButton*  pbtnMAS;
00169     GUIButton*  pbtnMASPolice;
00170     GUIButton*  pbtnMASDemonstrator;
00171     GUIButton*  pbtnMASRobber;
00172 
00173 // Simulator
00174     MainSim*    _pMSim;
00175     SDL_Thread* _pthreadMSim;
00176 
00177 // GUI Splash screen
00178 //debug, test
00179     GUIButton*  pbtnSplash;
00180 
00181 // GUI containers for main, zone, eLectric and Terrain toolcircles
00182     GUIContainer* pctr;
00183     GUIContainer* pctrMain;
00184     GUIContainer* pctrL;        // electricic tool
00185     GUIContainer* pctrT;        // terrain tool
00186     GUIContainer* pctrQ;        // query tool
00187     GUIContainer* pctrZ;        // zone tool
00188     GUIContainer* pctrG;        // Government tool circle
00189     GUIContainer* pctrN;        // Nature tool circle
00190     GUIContainer* pctrS;        // Save tool circle
00191 
00192 // Main container, Z, LPX buttons
00193     GUIButton* pbtnZ;       // RCI zoning tools
00194     GUIButton* pbtnS;       // save/load tools
00195     GUIButton* pbtnL;       // electric Line
00196     GUIButton* pbtnP;       // Path
00197     GUIButton* pbtnX;       // Xestroy
00198     GUIButton* pbtnG;       // Government tool
00199 
00200 // RCI buttons
00201     GUIButton* pbtnZB;      // Back button
00202     GUIButton* pbtnZR;      // Residential
00203     GUIButton* pbtnZC;      // Commercial
00204     GUIButton* pbtnZI;      // Industrial
00205 
00206 // EL buttons
00207     GUIButton* pbtnLB;      // Back button
00208     GUIButton* pbtnLL;      // Electric lines
00209     GUIButton* pbtnLE;      // Electric plant
00210 
00211 // (U)p / (D)own buttons
00212     GUIButton* pbtnTB;      // Back button
00213     GUIButton* pbtnTU;      // Raise terrain
00214     GUIButton* pbtnTD;      // Lower terrain
00215     GUIButton* pbtnTX;      // Destroy tool
00216     GUIButton* pbtnTQ;      // query button
00217 
00218 // (P)ark buttons
00219     GUIButton* pbtnGB;      // Back button
00220     GUIButton* pbtnGP;      // Build a park
00221     GUIButton* pbtnGE;      // Education department
00222     GUIButton* pbtnGH;      // Hospital
00223     GUIButton* pbtnGL;      // Police department
00224     GUIButton* pbtnGF;      // Fire department
00225 
00226 // Nature buttons
00227     GUIButton* pbtnNB;      // Back button
00228     GUIButton* pbtnNP;      // Park
00229     GUIButton* pbtnNT;      // Tree
00230 
00231 // Save buttons
00232     GUIButton* pbtnSB;      // Back button
00233     GUIButton* pbtnSS;      // Save
00234     GUIButton* pbtnSL;      // Load
00235 
00236 
00237    /*=====================================================================*/
00238    /*                        PRIVATE     METHODS                          */
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 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2