initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / game-preferences-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 GAME_PREFERENCES_DIALOG_H
20 #define GAME_PREFERENCES_DIALOG_H
21
22 #include <memory>
23 #include <vector>
24 #include <sigc++/signal.h>
25 #include <gtkmm.h>
26
27 #include "game-parameters.h"
28 #include "game-options-dialog.h"
29 #include "GameScenario.h"
30
31 #include "decorated.h"
32 class XML_Helper;
33
34 // dialog for choosing parameters for starting a new game
35 class GamePreferencesDialog: public Decorated
36 {
37  public:
38     GamePreferencesDialog(std::string filename, GameScenario::PlayMode mode);
39     ~GamePreferencesDialog();
40
41     void set_title(std::string title);
42
43     void set_parent_window(Gtk::Window &parent);
44
45     sigc::signal<void, GameParameters> game_started;
46     
47     bool run(std::string nickname = "guest");
48     void hide();
49     
50  private:
51     void init(std::string filename);
52     Gtk::Dialog* dialog;
53     GameScenario::PlayMode mode;
54
55     Gtk::VBox *dialog_vbox;
56     Gtk::ProgressBar *progressbar;
57     Gtk::Button *start_game_button;
58     Gtk::Button *edit_options_button;
59     Gtk::Label *game_name_label;
60     Gtk::Entry *game_name_entry;
61     Gtk::Label *difficulty_label;
62     Gtk::ComboBox *difficulty_combobox;
63
64     enum { BEGINNER = 0, INTERMEDIATE, ADVANCED, I_AM_THE_GREATEST, CUSTOM};
65
66     Gtk::VBox *players_vbox;
67
68     typedef std::vector<Glib::ustring> player_name_seq;
69     
70     std::list<Gtk::ComboBoxText *> player_types;
71     std::list<Gtk::Entry *> player_names;
72     std::list<Gtk::Image *> player_shields;
73
74     GameOptionsDialog *game_options_dialog;
75
76     void add_player(GameParameters::Player::Type type,
77                                        const Glib::ustring &name);
78     void on_difficulty_changed();
79     void on_start_game_clicked();
80     void on_edit_options_clicked();
81     void on_player_type_changed();
82     bool is_beginner();
83     bool is_intermediate();
84     bool is_advanced();
85     bool is_greatest();
86     void update_difficulty_combobox();
87     void update_difficulty_rating();
88     void update_shields();
89     Glib::RefPtr<Gdk::Pixbuf> getShieldPic(guint32 type, guint32 owner);
90     std::string d_filename;
91     guint32 d_shieldset;
92 };
93
94 #endif