1 //  Copyright (C) 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_CITYSET_WINDOW_H
20 #define GUI_CITYSET_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 "cityset.h"
29 
30 //! Cityset Editor.  Edit an cityset.
31 class CitySetWindow: public sigc::trackable
32 {
33  public:
34     CitySetWindow(Glib::ustring load_filename = "");
35     ~CitySetWindow();
36 
get_window()37     Gtk::Window &get_window() { return *window; }
show()38     void show() {window->show();};
hide()39     void hide() {window->hide();};
40 
41     sigc::signal<void, guint32> cityset_saved;
42 
43  private:
44     Gtk::Window* window;
45     Glib::ustring current_save_filename;
46     Cityset *d_cityset; //current cityset
47     bool needs_saving;
48     Gtk::MenuItem *new_cityset_menuitem;
49     Gtk::MenuItem *load_cityset_menuitem;
50     Gtk::MenuItem *save_cityset_menuitem;
51     Gtk::MenuItem *save_as_menuitem;
52     Gtk::MenuItem *validate_cityset_menuitem;
53     Gtk::MenuItem *edit_cityset_info_menuitem;
54     Gtk::MenuItem *quit_menuitem;
55     Gtk::MenuItem *help_about_menuitem;
56     Gtk::MenuItem *tutorial_menuitem;
57     Gtk::Button *change_citypics_button;
58     Gtk::Button *change_razedcitypics_button;
59     Gtk::Button *change_portpic_button;
60     Gtk::Button *change_signpostpic_button;
61     Gtk::Button *change_ruinpics_button;
62     Gtk::Button *change_templepic_button;
63     Gtk::Button *change_towerpics_button;
64     Gtk::SpinButton *city_tile_width_spinbutton;
65     Gtk::SpinButton *ruin_tile_width_spinbutton;
66     Gtk::SpinButton *temple_tile_width_spinbutton;
67     Gtk::Alignment *cityset_alignment;
68     Gtk::Notebook *notebook;
69 
70     void update_cityset_panel();
71 
72     bool load_cityset(Glib::ustring filename);
73     bool save_current_cityset();
74 
75     //callbacks
76     void on_new_cityset_activated();
77     void on_load_cityset_activated();
78     void on_save_cityset_activated();
79     void on_save_as_activated();
80     void on_validate_cityset_activated();
81     void on_quit_activated();
82     bool on_window_closed(GdkEventAny*);
83     bool quit();
84     void on_edit_cityset_info_activated();
85     void on_help_about_activated();
86     void on_tutorial_video_activated();
87     void on_city_tile_width_changed();
88     void on_city_tile_width_text_changed();
89     void on_ruin_tile_width_changed();
90     void on_ruin_tile_width_text_changed();
91     void on_temple_tile_width_changed();
92     void on_temple_tile_width_text_changed();
93     void on_change_citypics_clicked();
94     void on_change_razedcitypics_clicked();
95     void on_change_portpic_clicked();
96     void on_change_signpostpic_clicked();
97     void on_change_ruinpics_clicked();
98     void on_change_templepic_clicked();
99     void on_change_towerpics_clicked();
100     Glib::ustring change_image (Glib::ustring m, Glib::ustring i, int num, std::vector<PixMask *> frames, bool &cleared, int tile_width);
101     void update_window_title();
102     void show_add_file_error(Gtk::Dialog &d, Glib::ustring file);
103     void show_remove_file_error(Gtk::Dialog &d, Glib::ustring file);
104 
105     bool make_new_cityset ();
106     bool load_cityset ();
107     bool save_current_cityset_file (Glib::ustring filename = "");
108     bool save_current_cityset_file_as ();
109 
110     bool check_discard (Glib::ustring msg);
111     bool check_save_valid (bool existing);
112     bool check_name_valid (bool existing);
113     bool isValidName ();
114 };
115 
116 #endif
117