Map.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 **
00004 ** Copyright (C) 2006-2010 The TBT Team.
00005 **
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 **
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 **
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef GAMEFIELD_HH_
00018 # define GAMEFIELD_HH_
00019 
00020 # include "Constants.hh"
00021 # include "GameButton.hh"
00022 # include "Sprite.hh"
00023 # include "VirtualScrollableSurface.hh"
00024 
00025 class TextSurface;
00026 
00027 BEGIN_NS(sdlvisu);
00028 
00029 class Game;
00030 class VisuPlayer;
00031 
00033   enum eMapZone {
00034     MZ_EJECTED = 0,
00035     MZ_OUT,
00036     MZ_KO,
00037     MZ_RESERVE,
00038     MZ_FIELD
00039   };
00040 
00046 enum eMapChildsZ {
00047   MCZ_BG = -2,
00048   MCZ_RBG = -1,
00049   MCZ_VPLAYER = 1,
00050   MCZ_VPACIRCLE,
00051   MCZ_VPSCIRCLE,
00052   MCZ_VPNUM,
00053   MCZ_VPSTATUS,
00054   MCZ_BALL,
00055   MCZ_MOVE,
00056   MCZ_DIFFICULTY,
00057   MCZ_BLOCKPUSH
00058 };
00059 
00066 class Map : public VirtualScrollableSurface
00067 {
00068 public:
00069   Map(Game& g);
00070   virtual ~Map();
00071 
00074   bool mouseInsideMap() const;
00077   bool mouseInsideField() const;
00080   Coordinates mouseToSquare() const;
00084   Point squareToMap(const Coordinates& coord, const Point& adjust = Point(0, 0)) const;
00085 
00086   void setMarker(const Point& square, int type);
00087   void removeMarker();
00088   
00089   void setBallCoord(const Coordinates& coord);
00090   void removeBall();
00091 
00100   void addPlayer(VisuPlayer* vp);
00109   void movePlayer(enum eStatus old_status, enum eStatus new_status, int team_id, int player_id);
00110 
00112   const VisuPlayer* getSelectedPlayer() const;
00114   void setSelectedPlayer(VisuPlayer* vp);
00116   void unselectPlayer();
00117 
00119   void drawPath();
00121   void clearPath(unsigned int from_step = 0);
00122 
00124   void drawBlock();
00126   void clearBlock();
00127 
00129   void drawThrow();
00131   void clearThrow();
00132 
00134   void centerViewTo(const Point& pos);
00135 
00136   bool getDrawTicks() const;
00137   void setDrawTicks(bool enable);
00138   
00139   virtual void update();
00140 
00141 private:
00143   enum eMapZone statusToZone(enum eStatus status);
00145   void movePlayer(enum eMapZone from, enum eMapZone to, int team_id, int player_id);
00147   void scrollDugout(enum eMapZone dugout, int team_id, unsigned int page_index);
00149   void updateDugout(enum eMapZone dugout, int team_id, int player_id);
00150 
00152   void scrollDugouts(bool forth);
00153 
00155   void drawTicks();
00156 
00157   Game&         g_;
00158   
00159   Surface       bg_;
00160   Surface       reserve_bg_;
00161   Sprite        ball_;
00162   Sprite        cross_black_;
00163   Sprite        cross_red_;
00164 
00165   Coordinates                prev_dest_;
00166   std::vector<Sprite*>      path_steps_;
00167   std::vector<TextSurface*> path_scores_;
00168   TextSurface*              block_diff_;
00169   TextSurface*              throw_diff_;
00170 
00171   bool          draw_ticks_;
00172 
00173   Surface       red_highlight_;
00174   Surface       blue_highlight_;
00175 
00176   unsigned int  dugouts_page_index_[4][2];
00177   VisuPlayer*   players_by_zone_[5][2][MAX_PLAYER];
00178   VisuPlayer*   selected_vplayer_;
00179 
00180   class DugoutsCallback : public GameButtonCallback
00181   {
00182     public:
00183     DugoutsCallback(Map* map, bool forth)
00184       : map_(map), forth_(forth) {}
00185     private:
00186       virtual void clicked();
00187       Map* map_;
00188       bool forth_;
00189   };
00190   GameButton    dugouts_back_, dugouts_forth_;
00191 };
00192 
00193 END_NS(sdlvisu);
00194 
00195 #endif /* !GAMEFIELD_HH_ */
Generated on Mon Apr 5 21:17:12 2010 for Stechec/TBT by  doxygen 1.6.3