Advanced Strategic Command
maped-mainscreen.h
Go to the documentation of this file.
1 
5 /*
6  This file is part of Advanced Strategic Command; http://www.asc-hq.de
7  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING. If not, write to the
21  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22  Boston, MA 02111-1307 USA
23 */
24 
25 
26 #ifndef mapedmainscreenH
27  #define mapedmainscreenH
28 
29 #include "paradialog.h"
30 #include "edselfnt.h"
31 #include "graphics/surface.h"
33 #include "mainscreenwidget.h"
34 
35 class Menu;
36 class NewGuiHost;
37 class MapDisplayPG;
39 
40 class SelectionItemWidget : public PG_Widget {
41  const Placeable* it;
42  static const int labelHeight = 15;
43  public:
44  SelectionItemWidget( PG_Widget* parent, const PG_Rect& pos ) : PG_Widget( parent, pos, true ), it(NULL)
45  {
46  }
47 
48  void set( const Placeable* item) { it = item; Redraw(true); };
49  protected:
50  void eventDraw (SDL_Surface *surface, const PG_Rect &rect)
51  {
52  Surface s = Surface::Wrap( surface );
53  s.Fill( s.GetPixelFormat().MapRGB( DI_Color( 0x73b16a ) ));
54 
55  if ( it ) {
56  const MapComponent* mc = dynamic_cast<const MapComponent*>(it);
57  if ( mc ) {
58  SPoint pos ( (Width() - mc->displayWidth()) / 2, (Height() - mc->displayHeight())/2 );
59  mc->display( s, pos );
60  }
61  }
62  };
63 
64 };
65 
66 
67  class ContextAction {
68  public:
69  virtual bool available( const MapCoordinate& pos ) = 0;
70  virtual ASCString getText( const MapCoordinate& pos ) = 0;
71  virtual int getActionID() = 0;
72  virtual ~ContextAction() {};
73  };
74 
76  PG_Window* vehicleSelector;
77  PG_Window* buildingSelector;
78  PG_Window* objectSelector;
79  PG_Window* terrainSelector;
80  PG_Window* mineSelector;
81  DropDownSelector* weatherSelector;
82  DropDownSelector* playerSelector;
83  DropDownSelector* brushSelector;
84  PG_Label* selectionName;
85  PG_Label* selectionName2;
86  PG_Label* coordinateDisplay;
87  SelectionItemWidget* currentSelectionWidget;
89  PG_PopupMenu* contextMenu;
90 public:
91  Maped_MainScreenWidget( PG_Application& application );
92 
93  bool clearSelection();
94  bool selectVehicle();
95  bool selectBuilding();
96  bool selectObject();
97  bool selectObjectList();
98  bool selectTerrain();
99  bool selectTerrainList();
100  bool selectMine();
101  bool selectLuaBrush();
102  void updateStatusBar();
103 
104  void addContextAction( ContextAction* contextAction );
105 
106 
107  void showWeaponRange( GameMap* gamemap, const MapCoordinate& pos );
108 
109 protected:
110 
111  bool clickOnMap( const MapCoordinate& field, const SPoint& pos, bool changed, int button, int prio);
112 
115 
116  void brushChanged( int i );
117  void selectionChanged( const Placeable* item );
118  bool eventKeyUp(const PG_MessageObject* o, const SDL_KeyboardEvent* key);
119  bool eventKeyDown(const PG_MessageObject* o, const SDL_KeyboardEvent* key);
120  void setupStatusBar();
121 
122  void playerChanged( int player );
123 
124  ASCString getBackgroundImageFilename() { return "mapeditor-background.png"; };
125 
126  bool eventMouseButtonDown (const SDL_MouseButtonEvent *button);
127 
129  private:
130  bool runContextAction (PG_PopupMenu::MenuItem* menuItem );
131  UnitWeaponRangeLayer* weaponRangeLayer;
132 
133 };
134 
136 extern void displaymessage2( const char* formatstring, ... );
137 
139 
140 #endif
141 
virtual ~ContextAction()
A Device Independent color. Shamelessly pinched from Paragui to reduce coupling.
Definition: surface.h:30
void eventDraw(SDL_Surface *surface, const PG_Rect &rect)
bool eventKeyUp(const PG_MessageObject *o, const SDL_KeyboardEvent *key)
bool eventMouseButtonDown(const SDL_MouseButtonEvent *button)
void playerChanged(int player)
virtual bool available(const MapCoordinate &pos)=0
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void displaymessage2(const char *formatstring,...)
displays a message in the status line of ASC
Maped_MainScreenWidget * mainScreenWidget
Maped_MainScreenWidget(PG_Application &application)
ASCString getBackgroundImageFilename()
void showWeaponRange(GameMap *gamemap, const MapCoordinate &pos)
A MapComponent represents any kind of item that can be placed on the map by the user.
void selectionChanged(const Placeable *item)
void set(const Placeable *item)
Coordinate on the twodimensional map.
Definition: typen.h:202
Dialog classes based on the Paragui library.
SelectionItemWidget(PG_Widget *parent, const PG_Rect &pos)
void addContextAction(ContextAction *contextAction)
virtual int displayHeight() const =0
bool clickOnMap(const MapCoordinate &field, const SPoint &pos, bool changed, int button, int prio)
SDLmm::SPoint SPoint
Definition: surface.h:27
bool eventKeyDown(const PG_MessageObject *o, const SDL_KeyboardEvent *key)
virtual int displayWidth() const =0
virtual ASCString getText(const MapCoordinate &pos)=0
virtual void display(Surface &s, const SPoint &pos) const =0
static Surface Wrap(SDL_Surface *surface)
Definition: surface.h:76
virtual int getActionID()=0
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182