00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef buildingtypeselectorH
00019 #define buildingtypeselectorH
00020
00021 #include <pgimage.h>
00022 #include "selectionwindow.h"
00023 #include "../buildingtype.h"
00024 #include "../paradialog.h"
00025
00026
00027
00028
00029
00030
00031 class BuildingTypeBaseWidget: public SelectionWidget {
00032 const BuildingType* vt;
00033 static Surface clippingSurface;
00034 Surface& getClippingSurface() { return clippingSurface; };
00035 const Player& actplayer;
00036 public:
00037 BuildingTypeBaseWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, const Player& player );
00038 ASCString getName() const;
00039 const BuildingType* getBuildingType() const { return vt; };
00040 protected:
00041 void display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst );
00042 static int getBuildingHeight( const BuildingType* type );
00043 };
00044
00045 class BuildingTypeResourceWidget: public BuildingTypeBaseWidget {
00046 public:
00047 BuildingTypeResourceWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, int lackingResources, const Resources& cost, const Player& player );
00048 };
00049
00050
00051 class BuildingTypeCountWidget: public BuildingTypeBaseWidget {
00052 public:
00053 BuildingTypeCountWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, const Player& player, int number );
00054 };
00055
00056
00057 class BuildingTypeSelectionItemFactory: public SelectionItemFactory, public SigC::Object {
00058 Resources plantResources;
00059 const Player& actplayer;
00060 public:
00061 typedef vector<const BuildingType*> Container;
00062
00063 protected:
00064 Container::iterator it;
00065 Container items;
00066
00067 virtual void BuildingTypeSelected( const BuildingType* type ) = 0;
00068
00069 virtual Resources getCost( const BuildingType* type );
00070
00071 private:
00072 const Container& original_items;
00073
00074 public:
00075 BuildingTypeSelectionItemFactory( Resources plantResources, const Container& types, const Player& player );
00076
00077 SigC::Signal0<void> reloadAllItems;
00078
00079 void restart();
00080
00081 void setAvailableResource( const Resources& plantResources ) { this->plantResources = plantResources; };
00082
00083
00084 SelectionWidget* spawnNextItem( PG_Widget* parent, const PG_Point& pos );
00085
00086 void itemSelected( const SelectionWidget* widget, bool mouse );
00087 };
00088
00089 bool BuildingComp ( const BuildingType* v1, const BuildingType* v2 );
00090
00091 #endif