initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / itemlist-dialog.h
1 //  Copyright (C) 2008, 2009 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 #ifndef GUI_ITEMLIST_DIALOG_H
19 #define GUI_ITEMLIST_DIALOG_H
20
21 #include <memory>
22 #include <vector>
23 #include <sigc++/signal.h>
24 #include <sigc++/trackable.h>
25 #include <gtkmm.h>
26
27 #include "Itemlist.h"
28
29 //! Scenario editor.  Edits the global list of Item objects in the scenario.
30 class ItemlistDialog: public sigc::trackable
31 {
32  public:
33     ItemlistDialog();
34     ~ItemlistDialog();
35
36     void set_parent_window(Gtk::Window &parent);
37
38     int run();
39
40     void show();
41     void hide();
42
43     Gtk::Dialog &get_dialog() { return *dialog; }
44
45  private:
46     Gtk::Dialog* dialog;
47     std::string current_save_filename;
48     Itemlist *d_itemlist; //current itemlist
49     ItemProto *d_item; //current item
50     Gtk::Entry *name_entry;
51     Gtk::TreeView *items_treeview;
52     Gtk::Button *add_item_button;
53     Gtk::Button *remove_item_button;
54     Gtk::VBox *item_vbox;
55     Gtk::CheckButton *add1str_checkbutton;
56     Gtk::CheckButton *add2str_checkbutton;
57     Gtk::CheckButton *add3str_checkbutton;
58     Gtk::CheckButton *add1stack_checkbutton;
59     Gtk::CheckButton *add2stack_checkbutton;
60     Gtk::CheckButton *add3stack_checkbutton;
61     Gtk::CheckButton *flystack_checkbutton;
62     Gtk::CheckButton *doublemovestack_checkbutton;
63     Gtk::CheckButton *add2goldpercity_checkbutton;
64     Gtk::CheckButton *add3goldpercity_checkbutton;
65     Gtk::CheckButton *add4goldpercity_checkbutton;
66     Gtk::CheckButton *add5goldpercity_checkbutton;
67
68     class ItemsColumns: public Gtk::TreeModelColumnRecord {
69     public:
70         ItemsColumns() 
71         { add(name); add(item);}
72         
73         Gtk::TreeModelColumn<Glib::ustring> name;
74         Gtk::TreeModelColumn<ItemProto *> item;
75     };
76     const ItemsColumns items_columns;
77     Glib::RefPtr<Gtk::ListStore> items_list;
78
79     bool on_delete_event(GdkEventAny *e);
80
81     void addItemProto(ItemProto *itemproto);
82     void update_item_panel();
83     void update_itemlist_buttons();
84
85     void fill_item_info(ItemProto *item);
86
87     //callbacks
88     void on_name_changed();
89     void on_add_item_clicked();
90     void on_remove_item_clicked();
91     void on_item_selected();
92
93
94     void on_checkbutton_toggled(Gtk::CheckButton *checkbutton, 
95                                 ItemProto::Bonus bonus);
96     void on_add1str_toggled();
97     void on_add2str_toggled();
98     void on_add3str_toggled();
99     void on_add1stack_toggled();
100     void on_add2stack_toggled();
101     void on_add3stack_toggled();
102     void on_flystack_toggled();
103     void on_doublemovestack_toggled();
104     void on_add2goldpercity_toggled();
105     void on_add3goldpercity_toggled();
106     void on_add4goldpercity_toggled();
107     void on_add5goldpercity_toggled();
108 };
109
110 #endif