initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / network-game-selector-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 NETWORK_GAME_SELECTOR_DIALOG_H
19 #define NETWORK_GAME_SELECTOR_DIALOG_H
20
21 #include <memory>
22 #include <string>
23 #include <sigc++/trackable.h>
24 #include <gtkmm.h>
25
26 class RecentlyPlayedNetworkedGame;
27 #include "decorated.h"
28 // dialog for joining remote games
29 class NetworkGameSelectorDialog: public Decorated
30 {
31  public:
32     NetworkGameSelectorDialog();
33     ~NetworkGameSelectorDialog();
34
35     sigc::signal<void, std::string /*ip*/, unsigned short /*port*/> game_selected;
36
37     void set_parent_window(Gtk::Window &parent);
38
39     void hide();
40     bool run();
41     
42  private:
43     Gtk::Dialog* dialog;
44     Gtk::Entry *hostname_entry;
45     Gtk::SpinButton *port_spinbutton;
46     Gtk::Button *connect_button;
47     Gtk::Button *clear_button;
48
49     void on_hostname_changed();
50
51     Gtk::TreeView *recent_treeview;
52
53     class RecentlyJoinedGamesColumns: public Gtk::TreeModelColumnRecord {
54     public:
55         RecentlyJoinedGamesColumns() 
56         { add(name); add(turn);
57           add(number_of_players); add(number_of_cities); add(host); add(port);}
58         
59         Gtk::TreeModelColumn<Glib::ustring> name;
60         Gtk::TreeModelColumn<unsigned int> turn;
61         Gtk::TreeModelColumn<unsigned int> number_of_players;
62         Gtk::TreeModelColumn<unsigned int> number_of_cities;
63         Gtk::TreeModelColumn<Glib::ustring> host;
64         Gtk::TreeModelColumn<unsigned int> port;
65     };
66     const RecentlyJoinedGamesColumns recently_joined_games_columns;
67     Glib::RefPtr<Gtk::ListStore> recently_joined_games_list;
68     void addRecentlyJoinedGame(RecentlyPlayedNetworkedGame*);
69
70     void on_recent_game_selected();
71     void on_clear_clicked();
72 };
73
74 #endif