30
30
#include <gtkmm/stock.h>
32
32
#include "splash-window.h"
33
#include "game-window.h"
35
35
#include "game-preferences-dialog.h"
36
36
#include "load-scenario-dialog.h"
37
#include "new-campaign-dialog.h"
37
38
#include "glade-helpers.h"
38
#include "../Configuration.h"
42
#include "../GameScenario.h"
43
#include "../playerlist.h"
44
#include "game-lobby-dialog.h"
39
#include "Configuration.h"
43
#include "GameScenario.h"
44
#include "playerlist.h"
45
45
#include "network-game-selector-dialog.h"
46
//#include "../netggz.h"
47
47
#include "gtksdl.h"
48
#include "main-preferences-dialog.h"
49
#include "timed-message-dialog.h"
67
70
Gtk::Window *w = 0;
68
71
xml->get_widget("window", w);
73
decorate(window.get(), File::getMiscFile("various/back.bmp"));
74
window_closed.connect(sigc::mem_fun(this, &SplashWindow::on_window_closed));
71
76
xml->get_widget("sdl_container", sdl_container);
72
77
w->signal_delete_event().connect(
85
90
sigc::mem_fun(*this, &SplashWindow::on_new_game_clicked));
86
91
xml->connect_clicked("load_game_button",
87
92
sigc::mem_fun(*this, &SplashWindow::on_load_game_clicked));
93
xml->connect_clicked("new_campaign_button",
94
sigc::mem_fun(*this, &SplashWindow::on_new_campaign_clicked));
88
95
xml->connect_clicked("load_scenario_button",
89
96
sigc::mem_fun(*this, &SplashWindow::on_load_scenario_clicked));
90
97
xml->connect_clicked("quit_button",
93
100
xml->connect_clicked("new_network_game_button",
94
101
sigc::mem_fun(*this, &SplashWindow::on_new_network_game_clicked));
102
xml->connect_clicked("new_pbm_game_button",
103
sigc::mem_fun(*this, &SplashWindow::on_new_pbm_game_clicked));
104
xml->connect_clicked("preferences_button",
105
sigc::mem_fun(*this, &SplashWindow::on_preferences_clicked));
95
106
Sound::getInstance()->playMusic("intro");
97
108
if (Configuration::s_autosave_policy == 1)
166
184
void SplashWindow::on_new_game_clicked()
168
GamePreferencesDialog d;
186
GamePreferencesDialog d(GameScenario::HOTSEAT);
170
188
d.set_parent_window(*window.get());
171
189
d.game_started.connect(sigc::mem_fun(*this, &SplashWindow::on_game_started));
209
227
xml->get_widget("client_radiobutton", client_radiobutton);
210
228
dialog->set_transient_for(*window.get());
229
Gtk::Entry *nick_entry;
230
xml->get_widget("nick_entry", nick_entry);
233
nick = getenv("USER");
234
else if (network_game_nickname != "")
235
nick = network_game_nickname;
238
nick_entry->set_text(nick);
239
nick_entry->set_activates_default(true);
211
240
int response = dialog->run();
212
242
if (response == 0) //we hit okay
244
network_game_nickname = nick_entry->get_text();
214
245
if (client_radiobutton->get_active() == true)
216
Gtk::MessageDialog mdialog(*window.get(), "not implemented yet.");
219
247
NetworkGameSelectorDialog ngsd;
220
248
ngsd.game_selected.connect(sigc::mem_fun(*this, &SplashWindow::on_network_game_selected));
222
//okay, we're a client.
225
//std::string filename;
226
//launch lobby.. emit something?
227
//GameLobbyDialog gld(filename, false);
232
Gtk::MessageDialog mdialog(*window.get(), "not implemented yet.");
235
253
//okay, we're a server.
236
GamePreferencesDialog gpd;
254
GamePreferencesDialog gpd(GameScenario::NETWORKED);
238
256
gpd.set_parent_window(*window.get());
257
gpd.set_title(_("New Networked Game"));
239
258
gpd.game_started.connect(sigc::mem_fun(*this, &SplashWindow::on_network_game_created));
259
gpd.run(network_game_nickname);
267
void SplashWindow::on_new_pbm_game_clicked()
269
GamePreferencesDialog gpd(GameScenario::PLAY_BY_MAIL);
271
gpd.set_parent_window(*window.get());
272
gpd.set_title(_("New Play By Mail game"));
273
gpd.game_started.connect(sigc::mem_fun(*this, &SplashWindow::on_pbm_game_created));
247
278
void SplashWindow::on_load_scenario_clicked()
249
280
LoadScenarioDialog d;
255
286
std::string filename = d.get_scenario_filename();
256
287
if (!filename.empty())
258
290
GamePreferencesDialog gp(filename);
259
291
gp.set_parent_window(*window.get());
260
292
gp.game_started.connect(sigc::mem_fun(*this, &SplashWindow::on_game_started));
264
296
//load_requested.emit(filename);
299
void SplashWindow::on_new_campaign_clicked()
303
d.set_parent_window(*window.get());
307
std::string filename = d.get_campaign_filename();
308
if (!filename.empty())
311
GamePreferencesDialog gp(filename, true);
312
gp.set_parent_window(*window.get());
313
gp.game_started.connect(sigc::mem_fun(*this, &SplashWindow::on_campaign_started));
317
//load_requested.emit(filename);
267
320
void SplashWindow::on_network_game_selected(std::string ip, unsigned short port)
270
//download it into a file called network.sav, and then:
271
std::string filename = File::getSavePath() + "network.sav";
272
new_network_game_requested.emit(filename, false);
275
void SplashWindow::on_network_game_created(GameParameters g)
277
std::string filename;
278
if (g.map_path.empty())
280
// construct new random scenario if we're not going to load the game
281
std::string path = GameWindow::create_and_dump_scenario("random.map", g);
286
GameScenario* game_scenario = new GameScenario(g.map_path, broken);
290
//on_message_requested("Corrupted saved game file.");
294
if (game_scenario->getRound() == 0)
296
Playerlist::getInstance()->syncPlayers(g.players);
297
game_scenario->setupFog(g.hidden_map);
298
game_scenario->setupCities(g.quick_start);
299
game_scenario->setupDiplomacy(g.diplomacy);
300
game_scenario->nextRound();
303
filename = File::getSavePath() + "network.sav";
304
game_scenario->saveGame(filename);
305
delete game_scenario;
306
new_network_game_requested.emit(filename, true);
322
new_remote_network_game_requested.emit(ip, port, network_game_nickname);
309
325
void SplashWindow::on_game_started(GameParameters g)
311
new_game_requested.emit(g);
327
new_game_requested.emit(g);
330
void SplashWindow::on_campaign_started(GameParameters g)
332
new_campaign_requested.emit(g);
489
510
sdl_initialized.emit();
514
void SplashWindow::on_network_game_created(GameParameters g)
516
new_hosted_network_game_requested.emit(g, LORDSAWAR_PORT,
517
network_game_nickname);
520
void SplashWindow::on_pbm_game_created(GameParameters g)
522
new_pbm_game_requested.emit(g);
525
void SplashWindow::on_preferences_clicked()
527
bool saved = Configuration::s_decorated;
528
MainPreferencesDialog d;
529
d.set_parent_window(*window.get());
532
if (saved != Configuration::s_decorated)
534
TimedMessageDialog dialog(*window.get(), _("Please exit the program and restart it for the changes to take effect."), 30);