1 // Copyright (C) 2007 Ole Laursen 2 // Copyright (C) 2007, 2008, 2009, 2014, 2020 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 #pragma once 20 #ifndef NEW_RANDOM_MAP_DIALOG_H 21 #define NEW_RANDOM_MAP_DIALOG_H 22 23 #include <gtkmm.h> 24 25 #include "Tile.h" 26 #include "game-parameters.h" 27 #include "lw-dialog.h" 28 29 //! A dialog to let the user create a new random map. 30 class NewRandomMapDialog: public LwDialog 31 { 32 public: 33 NewRandomMapDialog(Gtk::Window &parent); 34 ~NewRandomMapDialog(); 35 36 int run(); 37 getRandomMapFilename()38 Glib::ustring getRandomMapFilename() const {return d_filename;}; 39 40 static Glib::ustring create_and_dump_scenario(const Glib::ustring &file, 41 const GameParameters &g, 42 sigc::slot<void> *pulse); 43 44 private: 45 46 void pulse(); 47 GameParameters getParams(); 48 struct Map 49 { 50 int width, height; 51 int grass, water, swamp, forest, hills, mountains; 52 int cities, ruins, temples; 53 int signposts; 54 Glib::ustring tileset; 55 Glib::ustring shieldset; 56 Glib::ustring cityset; 57 Glib::ustring armyset; 58 }; 59 60 Map map; 61 62 Gtk::Box *dialog_vbox; 63 Gtk::ButtonBox *dialog_action_area; 64 Gtk::ComboBox *map_size_combobox; 65 Gtk::ComboBoxText *tile_size_combobox; 66 Gtk::ComboBoxText *tile_theme_combobox; 67 Gtk::ComboBoxText *city_theme_combobox; 68 Gtk::ComboBoxText *army_theme_combobox; 69 Gtk::ComboBoxText *shield_theme_combobox; 70 Gtk::Scale *grass_scale; 71 Gtk::Scale *water_scale; 72 Gtk::Scale *swamp_scale; 73 Gtk::Scale *forest_scale; 74 Gtk::Scale *hills_scale; 75 Gtk::Scale *mountains_scale; 76 Gtk::Scale *cities_scale; 77 Gtk::Button *accept_button; 78 Gtk::Button *cancel_button; 79 Gtk::CheckButton *grass_random_checkbutton; 80 Gtk::CheckButton *water_random_checkbutton; 81 Gtk::CheckButton *swamp_random_checkbutton; 82 Gtk::CheckButton *forest_random_checkbutton; 83 Gtk::CheckButton *hills_random_checkbutton; 84 Gtk::CheckButton *mountains_random_checkbutton; 85 Gtk::CheckButton *cities_random_checkbutton; 86 Gtk::CheckButton *cities_can_produce_allies_checkbutton; 87 Gtk::Notebook *notebook; 88 Gtk::TreeView *progress_treeview; 89 90 class ProgressModelColumns : public Gtk::TreeModel::ColumnRecord 91 { 92 public: ProgressModelColumns()93 ProgressModelColumns () 94 { add (perc);} 95 Gtk::TreeModelColumn<int> perc; 96 }; 97 ProgressModelColumns progress_columns; 98 Glib::RefPtr<Gtk::ListStore> progress_liststore; 99 Gtk::TreeModel::Row row; 100 101 enum { MAP_SIZE_NORMAL = 0, MAP_SIZE_SMALL, MAP_SIZE_TINY }; 102 103 enum ActiveTerrainType { NONE, GRASS, WATER, FOREST, HILLS, MOUNTAINS, 104 SWAMP, MAX_TERRAINS }; 105 106 //callbacks 107 void on_map_size_changed(); 108 void on_grass_random_toggled(); 109 void on_water_random_toggled(); 110 void on_swamp_random_toggled(); 111 void on_forest_random_toggled(); 112 void on_hills_random_toggled(); 113 void on_mountains_random_toggled(); 114 void on_cities_random_toggled(); 115 void on_accept_clicked(); 116 void on_cancel_clicked(); 117 void on_value_changed (ActiveTerrainType type); 118 void on_tile_size_changed(); 119 120 //helpers 121 void alter_grass (); 122 void alter_terrain (ActiveTerrainType type); 123 guint32 get_active_tile_size(); 124 void take_percentages (); 125 void augment_scale_value_by_type (ActiveTerrainType type, double amt); 126 void assign_random_terrain (GameParameters &g); 127 128 int dialog_response; 129 Glib::ustring d_filename; 130 double percentages[MAX_TERRAINS]; 131 ActiveTerrainType d_active_terrain; 132 bool d_inhibit_scales; 133 static int cmp (std::pair<int,double> const &a, std::pair<int,double> const &b); 134 }; 135 136 #endif 137