initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / players-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 PLAYERS_DIALOG_H
20 #define PLAYERS_DIALOG_H
21
22 #include <memory>
23 #include <vector>
24 #include <sigc++/signal.h>
25 #include <gtkmm.h>
26
27 class Player;
28 class CreateScenarioRandomize;
29
30 //! Scenario editor.  Edit Player objects in the scenario.
31 class PlayersDialog
32 {
33  public:
34     PlayersDialog(CreateScenarioRandomize *randomizer, int width, int height);
35     ~PlayersDialog();
36
37     void set_parent_window(Gtk::Window &parent);
38
39     int run();
40     
41  private:
42     Gtk::Dialog* dialog;
43
44     Gtk::TreeView *player_treeview;
45     
46     class PlayerColumns: public Gtk::TreeModelColumnRecord {
47     public:
48         PlayerColumns()
49             { add(type); add(name); add(gold); add(player); }
50         
51         Gtk::TreeModelColumn<Glib::ustring> type, name;
52         Gtk::TreeModelColumn<int> gold;
53         Gtk::TreeModelColumn<Player *> player;
54     };
55     const PlayerColumns player_columns;
56     Glib::RefPtr<Gtk::ListStore> player_list;
57     
58     Gtk::CellRendererCombo type_renderer;
59     Gtk::TreeViewColumn type_column;
60     Gtk::CellRendererSpin gold_renderer;
61     Gtk::TreeViewColumn gold_column;
62     Gtk::CellRendererText name_renderer;
63     Gtk::TreeViewColumn name_column;
64     
65     class PlayerTypeColumns: public Gtk::TreeModelColumnRecord {
66     public:
67         PlayerTypeColumns()
68             { add(type); }
69         
70         Gtk::TreeModelColumn<Glib::ustring> type;
71     };
72     const PlayerTypeColumns player_type_columns;
73     Glib::RefPtr<Gtk::ListStore> player_type_list;
74
75     typedef std::vector<Glib::ustring> player_name_seq;
76     player_name_seq default_player_names;
77     
78     void cell_data_type(Gtk::CellRenderer *renderer, const Gtk::TreeIter &i);
79     void on_type_edited(const Glib::ustring &path,
80                         const Glib::ustring &new_text);
81     void cell_data_gold(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
82     void on_gold_edited(const Glib::ustring &path, const Glib::ustring &new_text);
83     void cell_data_name(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
84     void on_name_edited(const Glib::ustring &path, const Glib::ustring &new_text);
85     
86     void add_player(const Glib::ustring &type, const Glib::ustring &name,
87                     int gold, Player *player);
88     int d_width;
89     int d_height;
90 };
91
92 #endif