ebc9ab2f2a1090c60e7041df4e48c36abc3af5ad
[lordsawar] / src / gui / buy-production-dialog.h
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #ifndef BUY_PRODUCTION_DIALOG_H
20 #define BUY_PRODUCTION_DIALOG_H
21
22 #include <memory>
23 #include <vector>
24 #include <sigc++/trackable.h>
25 #include <gtkmm.h>
26
27 #include "army-info-tip.h"
28
29 #include "armyproto.h"
30 class City;
31
32 #include "decorated.h"
33 // dialog for buying a production slot for a city
34 class BuyProductionDialog: public Decorated
35 {
36  public:
37     BuyProductionDialog(City *city);
38     ~BuyProductionDialog();
39
40     void set_parent_window(Gtk::Window &parent);
41
42     void run();
43     void hide();
44
45     enum { NO_ARMY_SELECTED = -1 };
46     int get_selected_army() { return selected_army == NO_ARMY_SELECTED ? NO_ARMY_SELECTED : purchasables[selected_army]->getTypeId(); }
47     
48  private:
49     Gtk::Dialog* dialog;
50     ArmyInfoTip* army_info_tip;
51     Gtk::Label *production_info_label1;
52     Gtk::Label *production_info_label2;
53     Gtk::Button *buy_button;
54
55     City *city;
56     int selected_army;
57
58     std::vector<Gtk::ToggleButton *> production_toggles;
59     bool ignore_toggles;
60     std::vector<const ArmyProto*> purchasables;
61
62     void on_production_toggled(Gtk::ToggleButton *toggle);
63     bool on_production_button_event(GdkEventButton *e, Gtk::ToggleButton *toggle);
64     void fill_in_production_info();
65     void set_buy_button_state();
66     const ArmyProto *army_id_to_army();
67 };
68
69 #endif