00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef mapedmainscreenH
00027 #define mapedmainscreenH
00028
00029 #include "paradialog.h"
00030 #include "edselfnt.h"
00031 #include "graphics/surface.h"
00032 #include "widgets/dropdownselector.h"
00033 #include "mainscreenwidget.h"
00034
00035 class Menu;
00036 class NewGuiHost;
00037 class MapDisplayPG;
00038 class UnitWeaponRangeLayer;
00039
00040 class SelectionItemWidget : public PG_Widget {
00041 const Placeable* it;
00042 static const int labelHeight = 15;
00043 public:
00044 SelectionItemWidget( PG_Widget* parent, const PG_Rect& pos ) : PG_Widget( parent, pos, true ), it(NULL)
00045 {
00046 }
00047
00048 void set( const Placeable* item) { it = item; Redraw(true); };
00049 protected:
00050 void eventDraw (SDL_Surface *surface, const PG_Rect &rect)
00051 {
00052 Surface s = Surface::Wrap( surface );
00053 s.Fill( s.GetPixelFormat().MapRGB( DI_Color( 0x73b16a ) ));
00054
00055 if ( it ) {
00056 const MapComponent* mc = dynamic_cast<const MapComponent*>(it);
00057 if ( mc ) {
00058 SPoint pos ( (Width() - mc->displayWidth()) / 2, (Height() - mc->displayHeight())/2 );
00059 mc->display( s, pos );
00060 }
00061 }
00062 };
00063
00064 };
00065
00066
00067 class ContextAction {
00068 public:
00069 virtual bool available( const MapCoordinate& pos ) = 0;
00070 virtual ASCString getText( const MapCoordinate& pos ) = 0;
00071 virtual int getActionID() = 0;
00072 virtual ~ContextAction() {};
00073 };
00074
00075 class Maped_MainScreenWidget : public MainScreenWidget {
00076 PG_Window* vehicleSelector;
00077 PG_Window* buildingSelector;
00078 PG_Window* objectSelector;
00079 PG_Window* terrainSelector;
00080 PG_Window* mineSelector;
00081 DropDownSelector* weatherSelector;
00082 DropDownSelector* playerSelector;
00083 DropDownSelector* brushSelector;
00084 PG_Label* selectionName;
00085 PG_Label* selectionName2;
00086 PG_Label* coordinateDisplay;
00087 SelectionItemWidget* currentSelectionWidget;
00088 deallocating_vector<ContextAction*> contextActions;
00089 PG_PopupMenu* contextMenu;
00090 public:
00091 Maped_MainScreenWidget( PG_Application& application );
00092
00093 bool clearSelection();
00094 bool selectVehicle();
00095 bool selectBuilding();
00096 bool selectObject();
00097 bool selectObjectList();
00098 bool selectTerrain();
00099 bool selectTerrainList();
00100 bool selectMine();
00101 bool selectLuaBrush();
00102 void updateStatusBar();
00103
00104 void addContextAction( ContextAction* contextAction );
00105
00106
00107 void showWeaponRange( GameMap* gamemap, const MapCoordinate& pos );
00108
00109 protected:
00110
00111 bool clickOnMap( const MapCoordinate& field, const SPoint& pos, bool changed, int button, int prio);
00112
00113 NewGuiHost* guiHost;
00114 Menu* menu;
00115
00116 void brushChanged( int i );
00117 void selectionChanged( const Placeable* item );
00118 bool eventKeyUp(const SDL_KeyboardEvent* key);
00119 bool eventKeyDown(const SDL_KeyboardEvent* key);
00120 void setupStatusBar();
00121
00122 void playerChanged( int player );
00123
00124 ASCString getBackgroundImageFilename() { return "mapeditor-background.png"; };
00125
00126 bool eventMouseButtonDown (const SDL_MouseButtonEvent *button);
00127
00128 ~Maped_MainScreenWidget() { };
00129 private:
00130 bool runContextAction (PG_PopupMenu::MenuItem* menuItem );
00131 UnitWeaponRangeLayer* weaponRangeLayer;
00132
00133 };
00134
00136 extern void displaymessage2( const char* formatstring, ... );
00137
00138 extern Maped_MainScreenWidget* mainScreenWidget ;
00139
00140 #endif
00141