1 // Copyright (C) 2007, 2008, 2009, 2010, 2014, 2015, 2020 Ben Asselstine 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Library General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 // 02110-1301, USA. 17 18 #pragma once 19 #ifndef GUI_ARMYSET_WINDOW_H 20 #define GUI_ARMYSET_WINDOW_H 21 22 #include <memory> 23 #include <vector> 24 #include <sigc++/signal.h> 25 #include <sigc++/trackable.h> 26 #include <gtkmm.h> 27 28 #include "armyproto.h" 29 #include "armyset.h" 30 #include "shield.h" 31 32 //! Armyset Editor. Edit an Armyset. 33 class ArmySetWindow: public sigc::trackable 34 { 35 public: 36 ArmySetWindow(Glib::ustring load_filename = ""); 37 ~ArmySetWindow(); 38 show()39 void show() {window->show();} hide()40 void hide() {window->hide();} 41 get_window()42 Gtk::Window &get_window() { return *window; } 43 44 sigc::signal<void, guint32> armyset_saved; 45 46 private: 47 Gtk::Window* window; 48 Glib::ustring current_save_filename; 49 Armyset *d_armyset; //current armyset 50 ArmyProto *d_army; //current army 51 bool needs_saving; 52 bool inhibit_needs_saving; 53 bool inhibit_updates; 54 Gtk::Image *white_image; 55 Gtk::Image *green_image; 56 Gtk::Image *yellow_image; 57 Gtk::Image *light_blue_image; 58 Gtk::Image *red_image; 59 Gtk::Image *dark_blue_image; 60 Gtk::Image *orange_image; 61 Gtk::Image *black_image; 62 Gtk::Image *neutral_image; 63 Gtk::Entry *name_entry; 64 Gtk::ScrolledWindow *armies_scrolledwindow; 65 Gtk::TreeView *armies_treeview; 66 Gtk::TextView *description_textview; 67 Gtk::Button *white_image_button; 68 Gtk::Button *green_image_button; 69 Gtk::Button *yellow_image_button; 70 Gtk::Button *light_blue_image_button; 71 Gtk::Button *red_image_button; 72 Gtk::Button *dark_blue_image_button; 73 Gtk::Button *orange_image_button; 74 Gtk::Button *black_image_button; 75 Gtk::Button *neutral_image_button; 76 Gtk::SpinButton *production_spinbutton; 77 Gtk::SpinButton *cost_spinbutton; 78 Gtk::SpinButton *new_cost_spinbutton; 79 Gtk::SpinButton *upkeep_spinbutton; 80 Gtk::SpinButton *strength_spinbutton; 81 Gtk::SpinButton *moves_spinbutton; 82 Gtk::SpinButton *exp_spinbutton; 83 Gtk::SpinButton *id_spinbutton; 84 Gtk::ComboBox *hero_combobox; 85 Gtk::Switch *awardable_switch; 86 Gtk::Switch *defends_ruins_switch; 87 Gtk::SpinButton *sight_spinbutton; 88 Gtk::Switch *move_forests_switch; 89 Gtk::Switch *move_marshes_switch; 90 Gtk::Switch *move_hills_switch; 91 Gtk::Switch *move_mountains_switch; 92 Gtk::Switch *can_fly_switch; 93 Gtk::Switch *add1strinopen_switch; 94 Gtk::Switch *add2strinopen_switch; 95 Gtk::Switch *add1strinforest_switch; 96 Gtk::Switch *add2strinforest_switch; 97 Gtk::Switch *add1strinhills_switch; 98 Gtk::Switch *add2strinhills_switch; 99 Gtk::Switch *add1strincity_switch; 100 Gtk::Switch *add2strincity_switch; 101 Gtk::Switch *add1stackinhills_switch; 102 Gtk::Switch *suballcitybonus_switch; 103 Gtk::Switch *sub1enemystack_switch; 104 Gtk::Switch *sub2enemystack_switch; 105 Gtk::Switch *add1stack_switch; 106 Gtk::Switch *add2stack_switch; 107 Gtk::Switch *suballnonherobonus_switch; 108 Gtk::Switch *suballherobonus_switch; 109 Gtk::Button *add_army_button; 110 Gtk::Button *remove_army_button; 111 Gtk::Box *army_vbox; 112 Gtk::MenuItem *new_armyset_menuitem; 113 Gtk::MenuItem *load_armyset_menuitem; 114 Gtk::MenuItem *save_armyset_menuitem; 115 Gtk::MenuItem *save_as_menuitem; 116 Gtk::MenuItem *validate_armyset_menuitem; 117 Gtk::MenuItem *edit_armyset_info_menuitem; 118 Gtk::MenuItem *edit_ship_picture_menuitem; 119 Gtk::MenuItem *edit_standard_picture_menuitem; 120 Gtk::MenuItem *edit_bag_picture_menuitem; 121 Gtk::MenuItem *quit_menuitem; 122 Gtk::MenuItem *help_about_menuitem; 123 Gtk::MenuItem *tutorial_menuitem; 124 Gtk::Button *make_same_button; 125 Gtk::Notebook *notebook; 126 127 class ArmiesColumns: public Gtk::TreeModelColumnRecord { 128 public: ArmiesColumns()129 ArmiesColumns() 130 { add(name); add(army);} 131 132 Gtk::TreeModelColumn<Glib::ustring> name; 133 Gtk::TreeModelColumn<ArmyProto *> army; 134 }; 135 const ArmiesColumns armies_columns; 136 Glib::RefPtr<Gtk::ListStore> armies_list; 137 bool inhibit_scrolldown; 138 139 void addArmyType(guint32 army_type); 140 void update_army_panel(); 141 void update_armyset_buttons(); 142 143 void on_new_armyset_activated(); 144 void on_load_armyset_activated(); 145 void on_save_armyset_activated(); 146 void on_save_as_activated(); 147 void on_validate_armyset_activated(); 148 void on_quit_activated(); 149 bool on_window_closed(GdkEventAny*); 150 bool quit(); 151 void on_edit_armyset_info_activated(); 152 void on_edit_standard_picture_activated(); 153 void on_edit_bag_picture_activated(); 154 void on_edit_ship_picture_activated(); 155 void on_help_about_activated(); 156 void on_tutorial_video_activated(); 157 void on_army_selected(); 158 void fill_army_image(Gtk::Button *button, Gtk::Image *image, Shield::Colour c, ArmyProto *army); 159 void fill_army_info(ArmyProto *army); 160 161 //callbacks 162 void on_name_changed(); 163 void on_description_changed(); 164 void on_image_changed(Shield::Colour c); 165 void on_production_changed(); 166 void on_production_text_changed(); 167 void on_cost_changed(); 168 void on_cost_text_changed(); 169 void on_new_cost_changed(); 170 void on_new_cost_text_changed(); 171 void on_upkeep_changed(); 172 void on_upkeep_text_changed(); 173 void on_strength_changed(); 174 void on_strength_text_changed(); 175 void on_moves_changed(); 176 void on_moves_text_changed(); 177 void on_exp_changed(); 178 void on_exp_text_changed(); 179 void on_sight_changed(); 180 void on_sight_text_changed(); 181 void on_id_changed(); 182 void on_id_text_changed(); 183 void on_hero_combobox_changed(); 184 void on_awardable_toggled(); 185 void on_defends_ruins_toggled(); 186 void on_movebonus_toggled(Gtk::Switch *button, guint32 val); 187 void on_armybonus_toggled(Gtk::Switch *button, guint32 val); 188 void on_add_army_clicked(); 189 void on_remove_army_clicked(); 190 191 void on_white_all_checked(); 192 193 bool load_armyset(Glib::ustring filename); 194 void update_window_title(); 195 void on_make_same_clicked(); 196 197 void show_add_file_error(Armyset *a, Gtk::Window &d, Glib::ustring file); 198 void show_remove_file_error(Armyset *a, Gtk::Window &d, Glib::ustring file); 199 void refresh_armies(); 200 201 bool make_new_armyset (); 202 bool load_armyset (); 203 bool save_current_armyset_file (Glib::ustring filename = ""); 204 bool save_current_armyset_file_as (); 205 206 bool check_discard (Glib::ustring msg); 207 bool check_save_valid (bool existing); 208 bool check_name_valid (bool existing); 209 bool isValidName (); 210 Gtk::Button *lookup_button_by_colour (Shield::Colour s); 211 void fill_army_images (ArmyProto *army); 212 void sync_armies (); 213 void instantiateOthers (ArmyProto *a, Shield::Colour c, Glib::ustring f); 214 void on_army_moved (); 215 }; 216 217 #endif 218