Advanced Strategic Command
buildingtypeselector.h
Go to the documentation of this file.
1 /***************************************************************************
2  cargodialog.cpp - description
3  -------------------
4  begin : Tue Oct 24 2000
5  copyright : (C) 2000 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef buildingtypeselectorH
19 #define buildingtypeselectorH
20 
21 #include <pgimage.h>
22 #include "selectionwindow.h"
23 #include "../buildingtype.h"
24 #include "../paradialog.h"
25 
26 
27 
28 
29 
30 
32  const BuildingType* vt;
33  static Surface clippingSurface;
34  Surface& getClippingSurface() { return clippingSurface; };
35  const Player& actplayer;
36  public:
37  BuildingTypeBaseWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, const Player& player );
38  ASCString getName() const;
39  const BuildingType* getBuildingType() const { return vt; };
40  protected:
41  void display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst );
42  static int getBuildingHeight( const BuildingType* type );
43 };
44 
46  public:
47  BuildingTypeResourceWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, int lackingResources, const Resources& cost, const Player& player );
48 };
49 
50 
52  public:
53  BuildingTypeCountWidget( PG_Widget* parent, const PG_Point& pos, int width, const BuildingType* BuildingType, const Player& player, int number );
54 };
55 
56 
57 class BuildingTypeSelectionItemFactory: public SelectionItemFactory, public sigc::trackable {
58  Resources plantResources;
59  const Player& actplayer;
60  public:
61  typedef vector<const BuildingType*> Container;
62 
63  protected:
64  Container::iterator it;
66 
67  virtual void BuildingTypeSelected( const BuildingType* type ) = 0;
68 
69  virtual Resources getCost( const BuildingType* type );
70 
71  private:
72  const Container& original_items;
73 
74  public:
75  BuildingTypeSelectionItemFactory( Resources plantResources, const Container& types, const Player& player );
76 
77  sigc::signal<void> reloadAllItems;
78 
79  void restart();
80 
81  void setAvailableResource( const Resources& plantResources ) { this->plantResources = plantResources; };
82 
83 
84  SelectionWidget* spawnNextItem( PG_Widget* parent, const PG_Point& pos );
85 
86  void itemSelected( const SelectionWidget* widget, bool mouse );
87 };
88 
89 bool BuildingComp ( const BuildingType* v1, const BuildingType* v2 );
90 
91 #endif
bool BuildingComp(const BuildingType *v1, const BuildingType *v2)
void setAvailableResource(const Resources &plantResources)
void display(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
void itemSelected(const SelectionWidget *widget, bool mouse)
virtual Resources getCost(const BuildingType *type)
virtual void BuildingTypeSelected(const BuildingType *type)=0
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
BuildingTypeResourceWidget(PG_Widget *parent, const PG_Point &pos, int width, const BuildingType *BuildingType, int lackingResources, const Resources &cost, const Player &player)
The class describing properties that are common to all buildings of a certain kind.
Definition: buildingtype.h:35
const BuildingType * getBuildingType() const
BuildingTypeSelectionItemFactory(Resources plantResources, const Container &types, const Player &player)
SelectionWidget * spawnNextItem(PG_Widget *parent, const PG_Point &pos)
vector< const BuildingType * > Container
BuildingTypeCountWidget(PG_Widget *parent, const PG_Point &pos, int width, const BuildingType *BuildingType, const Player &player, int number)
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99
Resources are basically the currency of ASC.
Definition: typen.h:97
static int getBuildingHeight(const BuildingType *type)
BuildingTypeBaseWidget(PG_Widget *parent, const PG_Point &pos, int width, const BuildingType *BuildingType, const Player &player)