initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / city-editor-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 CITY_EDITOR_DIALOG_H
20 #define CITY_EDITOR_DIALOG_H
21
22 #include <memory>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25
26
27 class CreateScenarioRandomize;
28 class City;
29 class ArmyProdBase;
30 class Player;
31
32 //! Scenario editor.  Edits a City object.
33 class CityEditorDialog: public sigc::trackable
34 {
35  public:
36     CityEditorDialog(City *city, CreateScenarioRandomize *randomizer);
37     ~CityEditorDialog();
38
39     void set_parent_window(Gtk::Window &parent);
40
41     int run();
42     
43  private:
44     City *city;
45     CreateScenarioRandomize *d_randomizer;
46     Gtk::Dialog* dialog;
47     Gtk::ComboBoxText *player_combobox;
48     Gtk::CheckButton *capital_checkbutton;
49     Gtk::Entry *name_entry;
50     Gtk::SpinButton *income_spinbutton;
51     Gtk::CheckButton *burned_checkbutton;
52
53     Gtk::TreeView *army_treeview;
54     
55     class ArmyColumns: public Gtk::TreeModelColumnRecord {
56     public:
57         ArmyColumns()
58             { add(army); add(image);
59               add(strength); add(moves); add(upkeep); add(duration); add(name);}
60
61         Gtk::TreeModelColumn<const ArmyProdBase *> army;
62         Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > image;
63         Gtk::TreeModelColumn<int> strength, moves, upkeep, duration;
64         Gtk::TreeModelColumn<Glib::ustring> name;
65     };
66     const ArmyColumns army_columns;
67     Glib::RefPtr<Gtk::ListStore> army_list;
68     Gtk::Button *add_button;
69     Gtk::Button *remove_button;
70     Gtk::Button *randomize_armies_button;
71     Gtk::Button *randomize_name_button;
72     Gtk::Button *randomize_income_button;
73     Gtk::CellRendererSpin strength_renderer;
74     Gtk::TreeViewColumn strength_column;
75     Gtk::CellRendererSpin moves_renderer;
76     Gtk::TreeViewColumn moves_column;
77     Gtk::CellRendererSpin duration_renderer;
78     Gtk::TreeViewColumn duration_column;
79     Gtk::CellRendererSpin upkeep_renderer;
80     Gtk::TreeViewColumn upkeep_column;
81
82
83     void on_add_clicked();
84     void on_remove_clicked();
85     void on_randomize_armies_clicked();
86     void on_randomize_name_clicked();
87     void on_randomize_income_clicked();
88     void on_selection_changed();
89     void on_player_changed();
90     Player *get_selected_player();
91     void change_city_ownership();
92
93     void add_army(const ArmyProdBase *a);
94     void set_button_sensitivity();
95     void cell_data_strength(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
96     void on_strength_edited(const Glib::ustring &path, const Glib::ustring &new_text);
97     void cell_data_moves(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
98     void on_moves_edited(const Glib::ustring &path, const Glib::ustring &new_text);
99     void cell_data_turns(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
100     void on_turns_edited(const Glib::ustring &path, const Glib::ustring &new_text);
101     void cell_data_upkeep(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
102     void on_upkeep_edited(const Glib::ustring &path, const Glib::ustring &new_text);
103
104 };
105
106 #endif