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
00039 class SelectionItemWidget : public PG_Widget {
00040 const MapComponent* it;
00041 static const int labelHeight = 15;
00042 public:
00043 SelectionItemWidget( PG_Widget* parent, const PG_Rect& pos ) : PG_Widget( parent, pos, true ), it(NULL)
00044 {
00045 }
00046
00047 void set( const MapComponent* item) { it = item; Redraw(true); };
00048 protected:
00049 void eventDraw (SDL_Surface *surface, const PG_Rect &rect)
00050 {
00051 Surface s = Surface::Wrap( surface );
00052 s.Fill( s.GetPixelFormat().MapRGB( DI_Color( 0x73b16a ) ));
00053 if ( it ) {
00054 SPoint pos ( (Width() - it->displayWidth()) / 2, (Height() - it->displayHeight())/2 );
00055 it->display( s, pos );
00056 }
00057 };
00058
00059 };
00060
00061
00062 class ContextAction {
00063 public:
00064 virtual bool available( const MapCoordinate& pos ) = 0;
00065 virtual ASCString getText( const MapCoordinate& pos ) = 0;
00066 virtual int getActionID() = 0;
00067 virtual ~ContextAction() {};
00068 };
00069
00070 class Maped_MainScreenWidget : public MainScreenWidget {
00071 PG_Window* vehicleSelector;
00072 PG_Window* buildingSelector;
00073 PG_Window* objectSelector;
00074 PG_Window* terrainSelector;
00075 PG_Window* mineSelector;
00076 DropDownSelector* weatherSelector;
00077 DropDownSelector* playerSelector;
00078 DropDownSelector* brushSelector;
00079 PG_Label* selectionName;
00080 PG_Label* selectionName2;
00081 PG_Label* coordinateDisplay;
00082 SelectionItemWidget* currentSelectionWidget;
00083 deallocating_vector<ContextAction*> contextActions;
00084 PG_PopupMenu* contextMenu;
00085 public:
00086 Maped_MainScreenWidget( PG_Application& application );
00087
00088 bool clearSelection();
00089 bool selectVehicle();
00090 bool selectBuilding();
00091 bool selectObject();
00092 bool selectObjectList();
00093 bool selectTerrain();
00094 bool selectTerrainList();
00095 bool selectMine();
00096 void updateStatusBar();
00097
00098 void addContextAction( ContextAction* contextAction );
00099
00100 protected:
00101
00102 bool clickOnMap( const MapCoordinate& field, const SPoint& pos, bool changed, int button, int prio);
00103
00104 NewGuiHost* guiHost;
00105 Menu* menu;
00106
00107 void brushChanged( int i );
00108 void selectionChanged( const MapComponent* item );
00109 bool eventKeyUp(const SDL_KeyboardEvent* key);
00110 bool eventKeyDown(const SDL_KeyboardEvent* key);
00111 void setupStatusBar();
00112
00113 void playerChanged( int player );
00114
00115 ASCString getBackgroundImageFilename() { return "mapeditor-background.png"; };
00116
00117 bool eventMouseButtonDown (const SDL_MouseButtonEvent *button);
00118
00119 ~Maped_MainScreenWidget() { };
00120 private:
00121 bool runContextAction (PG_PopupMenu::MenuItem* menuItem );
00122 };
00123
00125 extern void displaymessage2( const char* formatstring, ... );
00126
00127 extern Maped_MainScreenWidget* mainScreenWidget ;
00128
00129 #endif
00130