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 CITY_EDITOR_DIALOG_H
21 #define CITY_EDITOR_DIALOG_H
22 
23 #include <gtkmm.h>
24 #include "lw-editor-dialog.h"
25 
26 class CreateScenarioRandomize;
27 class City;
28 class ArmyProdBase;
29 class Player;
30 
31 //! Scenario editor.  Edits a City object.
32 class CityEditorDialog: public LwEditorDialog
33 {
34  public:
35     CityEditorDialog(Gtk::Window &parent, City *city, CreateScenarioRandomize *randomizer);
36     ~CityEditorDialog();
37 
38     int run();
39 
40  private:
41     City *city;
42     CreateScenarioRandomize *d_randomizer;
43     Gtk::ComboBoxText *player_combobox;
44     Gtk::Switch *capital_switch;
45     Gtk::Entry *name_entry;
46     Gtk::SpinButton *income_spinbutton;
47     Gtk::Switch *burned_switch;
48     Gtk::Switch *build_production_switch;
49 
50     Gtk::TreeView *army_treeview;
51 
52     class ArmyColumns: public Gtk::TreeModelColumnRecord {
53     public:
ArmyColumns()54 	ArmyColumns()
55 	    { add(army); add(image);
56 	      add(strength); add(moves); add(upkeep); add(duration); add(name);}
57 
58 	Gtk::TreeModelColumn<const ArmyProdBase *> army;
59 	Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > image;
60 	Gtk::TreeModelColumn<int> strength, moves, upkeep, duration;
61 	Gtk::TreeModelColumn<Glib::ustring> name;
62     };
63     const ArmyColumns army_columns;
64     Glib::RefPtr<Gtk::ListStore> army_list;
65     Gtk::Button *add_button;
66     Gtk::Button *remove_button;
67     Gtk::Button *randomize_armies_button;
68     Gtk::Button *randomize_name_button;
69     Gtk::Button *randomize_income_button;
70     Gtk::CellRendererSpin strength_renderer;
71     Gtk::TreeViewColumn strength_column;
72     Gtk::CellRendererSpin moves_renderer;
73     Gtk::TreeViewColumn moves_column;
74     Gtk::CellRendererSpin duration_renderer;
75     Gtk::TreeViewColumn duration_column;
76     Gtk::CellRendererSpin upkeep_renderer;
77     Gtk::TreeViewColumn upkeep_column;
78 
79 
80     void on_add_clicked();
81     void on_remove_clicked();
82     void on_randomize_armies_clicked();
83     void on_randomize_name_clicked();
84     void on_randomize_income_clicked();
85     void on_selection_changed();
86     void on_player_changed();
87     Player *get_selected_player();
88     void change_city_ownership();
89 
90     void add_army(const ArmyProdBase *a);
91     void set_button_sensitivity();
92     void cell_data_strength(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
93     void on_strength_edited(const Glib::ustring &path, const Glib::ustring &new_text);
94     void cell_data_moves(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
95     void on_moves_edited(const Glib::ustring &path, const Glib::ustring &new_text);
96     void cell_data_turns(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
97     void on_turns_edited(const Glib::ustring &path, const Glib::ustring &new_text);
98     void cell_data_upkeep(Gtk::CellRenderer *renderer, const Gtk::TreeIter& i);
99     void on_upkeep_edited(const Glib::ustring &path, const Glib::ustring &new_text);
100     void update_buttons();
101     void on_burned_changed ();
102     void on_capital_changed ();
103     void on_name_changed ();
104     void on_income_changed ();
105     void on_income_text_changed ();
106     void on_build_production_changed ();
107 
108     void update_armies ();
109 
110 };
111 
112 #endif
113