src/tron/cockpit/cMap.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 ***************************************************************************
00025 
00026 */
00027 
00033 
00034 #ifndef ARMAGETRON_CMAP_H
00035 #define ARMAGETRON_CMAP_H
00036 
00037 #include "cockpit/cWidgetBase.h"
00038 
00039 #ifndef DEDICATED
00040 
00041 #include "tList.h"
00042 #include "gWall.h"
00043 #include "ePlayer.h"
00044 #include <deque>
00045 #include <vector>
00046 
00047 namespace cWidget {
00048 
00050 class Map : public WithCoordinates, public WithBackground, public WithForeground {
00051     void DrawRimWalls( tList<eWallRim> &list ); 
00052     void DrawWalls(tList<gNetPlayerWall> &list); 
00053 
00054     void DrawObjects(tCoord scale); 
00055 
00056     /*
00057     * rimWalls    draw rim walls?
00058     * cycleWalls  draw cycle walls?
00059     * cycles      draw cycles?
00060     * cycleSize   size of cycles in real-world units
00061     * border      border around bounds (in grid units)
00062     * x y w h     the map will always fit in this rectangle (in OpenGL units)
00063     * rw rh       width and height of the rectangle in real-world units
00064     * ix iy       position where inside? (range [0, 1], used if there's room left due to nonmatching aspect ratio)
00065     */
00066     void DrawMap(bool rimWalls, bool cycleWalls,
00067                  double cycleSize, double border,
00068                  double x, double y, double w, double h,
00069                  double rw, double rh, double ix, double iy); 
00070 
00071     //
00073     typedef enum {
00074         MODE_STD, 
00075         MODE_ZONE, 
00076         MODE_CYCLE 
00077     } mode_t;
00079     typedef enum {
00080         ROTATION_FIXED, 
00081         ROTATION_SPAWN, 
00082         ROTATION_CYCLE, 
00083         ROTATION_CAMERA 
00084     } rotation_t;
00085     mode_t m_mode;
00086     tCoord m_centre; // minimap center position on overall map
00087     float m_zoom; // vars to store zoom factor
00088     rotation_t m_rotation;
00089 
00090     int m_toggleKey; //key to toggle the mode
00091 
00092     void ToggleMode(void); 
00093 
00094     class Clipper {
00095     public:
00096         virtual ~Clipper(){}
00097         virtual void Begin(Map &map, tCoord const &e1, tCoord const &e2) = 0;
00098         virtual void End() = 0;
00099     };
00100 class ClipperRect : public Clipper {
00101     public:
00102         static Clipper *create() {return new ClipperRect;}
00103         void Begin(Map &map, tCoord const &e1, tCoord const &e2);
00104         void End();
00105     };
00106     friend class ClipperRect;
00107 class ClipperCircle : public Clipper {
00108         int m_edges;
00109         void Clip(int i, tCoord const &u, tCoord const &v);
00110     public:
00111         static Clipper *create() {return new ClipperCircle;}
00112         ClipperCircle();
00113         void Begin(Map &map, tCoord const &e1, tCoord const &e2);
00114         void End();
00115     };
00116     friend class ClipperCircle;
00117     std::auto_ptr<Clipper> m_clipper;
00118 
00119     class Mode {
00120     public:
00121         mode_t m_mode;
00122         rotation_t m_rotation;
00123         float m_zoom;
00124         Clipper *(*m_clipper)(void);
00125         Mode(tXmlParser::node cur);
00126     };
00127     std::vector<Mode> m_modes;
00128     int m_currentMode;
00129     void Apply(Mode const &mode);
00130 public:
00131     void HandleEvent(bool state, int id);
00132     void Render(); 
00133     virtual bool Process(tXmlParser::node cur); 
00134 
00135     Map(); 
00136 };
00137 
00138 }
00139 
00140 #endif
00141 #endif

Generated on Sat Mar 15 22:56:05 2008 for Armagetron Advanced by  doxygen 1.5.4