initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / new-random-map-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 NEW_RANDOM_MAP_DIALOG_H
20 #define NEW_RANDOM_MAP_DIALOG_H
21
22 #include <memory>
23 #include <vector>
24 #include <sigc++/signal.h>
25 #include <gtkmm.h>
26
27 #include "Tile.h"
28 #include "game-parameters.h"
29 #include "decorated.h"
30
31 //! A dialog to let the user create a new random map.
32 class NewRandomMapDialog: public Decorated
33 {
34  public:
35     NewRandomMapDialog();
36     ~NewRandomMapDialog();
37
38     void set_parent_window(Gtk::Window &parent);
39
40     int run();
41
42     std::string getRandomMapFilename() const {return d_filename;};
43
44     //std::string create_and_dump_scenario(const std::string &file, const GameParameters &g);
45 static std::string create_and_dump_scenario(const std::string &file,
46                                                          const GameParameters &g, sigc::slot<void> *pulse);
47     
48  private:
49
50     void pulse();
51     GameParameters getParams();
52     struct Map
53     {
54         int width, height;
55         int grass, water, swamp, forest, hills, mountains;
56         int cities, ruins, temples;
57         int signposts;
58         std::string tileset;
59         std::string shieldset;
60         std::string cityset;
61         std::string armyset;
62     };
63
64     Map map;
65     Gtk::Dialog* dialog;
66
67     Gtk::VBox *dialog_vbox;
68     Gtk::HButtonBox *dialog_action_area;
69     Gtk::ComboBox *map_size_combobox;
70     Gtk::ProgressBar *progressbar;
71     Gtk::Widget *random_map_container;
72     Gtk::ComboBoxText *tile_size_combobox;
73     Gtk::ComboBoxText *tile_theme_combobox;
74     Gtk::ComboBoxText *city_theme_combobox;
75     Gtk::ComboBoxText *army_theme_combobox;
76     Gtk::ComboBoxText *shield_theme_combobox;
77     Gtk::Scale *grass_scale;
78     Gtk::Scale *water_scale;
79     Gtk::Scale *swamp_scale;
80     Gtk::Scale *forest_scale;
81     Gtk::Scale *hills_scale;
82     Gtk::Scale *mountains_scale;
83     Gtk::Scale *cities_scale;
84     Gtk::Scale *ruins_scale;
85     Gtk::Scale *temples_scale;
86     Gtk::Scale *signposts_scale;
87     Gtk::Button *accept_button;
88     Gtk::Button *cancel_button;
89     Gtk::ToggleButton *grass_random_togglebutton;
90     Gtk::ToggleButton *water_random_togglebutton;
91     Gtk::ToggleButton *swamp_random_togglebutton;
92     Gtk::ToggleButton *forest_random_togglebutton;
93     Gtk::ToggleButton *hills_random_togglebutton;
94     Gtk::ToggleButton *mountains_random_togglebutton;
95     Gtk::ToggleButton *cities_random_togglebutton;
96
97     Gtk::CheckButton *cities_can_produce_allies_checkbutton;
98
99     enum { MAP_SIZE_NORMAL = 0, MAP_SIZE_SMALL, MAP_SIZE_TINY };
100
101     void on_map_size_changed();
102
103     void on_grass_random_toggled();
104     void on_water_random_toggled();
105     void on_swamp_random_toggled();
106     void on_forest_random_toggled();
107     void on_hills_random_toggled();
108     void on_mountains_random_toggled();
109     void on_cities_random_toggled();
110     void on_accept_clicked();
111     void on_cancel_clicked();
112
113     guint32 get_active_tile_size();
114     void on_tile_size_changed();
115     void on_grass_changed();
116     int dialog_response;
117     std::string d_filename;
118 };
119
120 #endif