1 // Crimson Fields -- a game of tactical warfare
2 // Copyright (C) 2000-2007 Jens Granseuer
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
19 ///////////////////////////////////////////////////////////////
20 // mapwindow.h
21 ///////////////////////////////////////////////////////////////
22 
23 #ifndef _INCLUDE_MAPWINDOW_H
24 #define _INCLUDE_MAPWINDOW_H
25 
26 #include "window.h"
27 #include "mapview.h"
28 #include "mapwidget.h"
29 #include "mission.h"
30 #include "misc.h"
31 
32 #define ANIM_SPEED_UNIT		150  // time it takes for a unit to move one hex (ms)
33 #define ANIM_SPEED_CURSOR	40   // speed when moving cursor
34 
35 #define DEFAULT_PANEL_HEIGHT	(20)
36 
37 // the small info panel at the bottom of the map window
38 class Panel : public Window {
39 public:
40   Panel( class MapWindow *mw, View *view );
41 
42   void Draw( void );
43   void Update( MapObject *obj );
44   virtual GUI_Status HandleEvent( const SDL_Event &event );
45   virtual void VideoModeChange( void );
46 
47 private:
48   MapObject *obj;
49   MapWindow *mapwin;
50   Image workshop_icon;
51   Image factory_icon;
52 };
53 
54 
55 class MapWindow : public Window {
56 public:
57   MapWindow( short x, short y, unsigned short w, unsigned short h,
58              unsigned short flags, View *view );
~MapWindow(void)59   ~MapWindow( void ) { delete mview; }
60 
61   virtual GUI_Status HandleEvent( const SDL_Event &event );
62   virtual void Draw( void );
Close(void)63   virtual void Close( void ) { Window::Close(); view->CloseWindow(panel); }
64   virtual void DrawBack( short x, short y, unsigned short w, unsigned short h );
65   virtual void VideoModeChange( void );
66 
GetMapView(void)67   MapView *GetMapView( void ) const { return mview; }
GetPanel(void)68   Panel *GetPanel( void ) const { return panel; }
69 
70   void MoveHex( unsigned short img, const TileSet &tiles, const Point &hex1,
71                 const Point &hex2, unsigned short speed, bool blink = false );
72   Point MoveCursor( Direction dir );
FadeOutUnit(unsigned short img,const Point & hex)73   void FadeOutUnit( unsigned short img, const Point &hex )
74        { FadeHex( img, hex, false, true ); }
FadeInUnit(unsigned short img,const Point & hex)75   void FadeInUnit( unsigned short img, const Point &hex )
76        { FadeHex( img, hex, true, true ); }
FadeInTerrain(unsigned short img,const Point & hex)77   void FadeInTerrain( unsigned short img, const Point &hex )
78        { FadeHex( img, hex, true, false ); }
79   void FlashUnit( const Point &hex, unsigned short times );
80 
81   void DisplayHex( const Point &hex );
82   void BoxAvoidHexes( Rect &rect, const Point &hex1, const Point &hex2 ) const;
83 
84 private:
85   void FadeHex( unsigned short img, const Point &hex, bool in, bool unit );
86 
87   MapView *mview;
88   Panel *panel;
89 };
90 
91 
92 class TacticalWindow : public Window, public WidgetHook {
93 public:
94   TacticalWindow( MapView *mapview, Mission &m, View *view );
95 
96   void Draw( void );
97   GUI_Status WidgetActivated( Widget *widget, Window *win );
98 
99 private:
100   void CalcViewPort( Rect &vp ) const;
101 
102   MapView *mv;
103   MapWidget *mw;
104   Mission &mission;
105   Player &p1;
106   Player &p2;
107 };
108 
109 
110 // window displaying the results of a battle
111 class CombatWindow : public Window {
112 public:
113   CombatWindow( Combat *combat, MapWindow *mapwin, View *view );
114 
115   virtual void Draw( void );
116 
117   ButtonWidget *button;
118 
119 private:
120   void DrawState( void );
121 
122   MapWindow *mapwin;
123 
124   Unit *att;
125   Unit *def;
126   Point apos;
127   Point dpos;
128   short startgroup1;
129   short startgroup2;
130 
131   Rect msgbar1;
132   Rect msgbar2;
133   Rect att_anchor;
134   Rect def_anchor;
135   Rect clock[2][6];
136 };
137 
138 #endif	/* _INCLUDE_MAPWINDOW_H */
139 
140