Advanced Strategic Command
gamedialog.cpp
Go to the documentation of this file.
1 //
2 // C++ Implementation: gamedialog
3 //
4 // Description:
5 //
6 //
7 // Author: Kevin Hirschmann <hirsch@dhcppc0>, (C) 2005
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #include <sstream>
13 #include <pgimage.h>
14 #include <pglistboxitem.h>
15 #include <pgpopupmenu.h>
16 
17 
18 #include "gamedialog.h"
19 // #include "gamedlg.h"
20 #include "guidimension.h"
21 #include "sdl/sound.h"
22 #include "misc.h"
24 #include "dialogs/fileselector.h"
25 #include "dialogs/soundsettings.h"
26 #include "dialogs/newgame.h"
28 #include "dialog.h"
29 #include "sigc++/adaptors/retype.h"
30 #include "iconrepository.h"
31 #include "sg.h"
32 #include "loaders.h"
33 #include "spfst.h"
34 #include "spfst-legacy.h"
35 #include "networksupervisor.h"
36 
37 const int GameDialog::xSize = 450;
38 const int GameDialog::ySize = 550;
39 const int GameDialog::buttonIndent = 150;
40 GameDialog* GameDialog::instance = 0;
41 
42 GameDialog::GameDialog(): ASC_PG_Dialog(NULL, PG_Rect( -1, -1, xSize, ySize ), "Game", SHOW_CLOSE ) {
43  singlePlayerButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "New Game", 90);
44  singlePlayerButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::newGame));
45 
46  PG_Point p = ScreenToClient(singlePlayerButton->x, singlePlayerButton->y);
47  multiPlayerButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Continue Mail Game", 90);
48  multiPlayerButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::multiGame));
49 
50  p = ScreenToClient(multiPlayerButton->x, multiPlayerButton->y);
51  loadGameButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Load Game", 90);
52  loadGameButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::loadGame));
53 
54  p = ScreenToClient(loadGameButton->x, loadGameButton->y);
55  saveGameButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Save Game", 90);
56  saveGameButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::saveGame));
57 
58  p = ScreenToClient(loadGameButton->x, saveGameButton->y);
59  PG_Button* superViseButton= new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Supervise Net Game", 90);
60  superViseButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::supervise));
61 
62 
63  p = ScreenToClient(superViseButton->x, superViseButton->y);
64  optionsButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Options", 90);
65  optionsButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::showOptions));
66 
67 
68  p = ScreenToClient(optionsButton->x, optionsButton->y);
69  exitButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Quit Game", 90);
70  exitButton->sigClick.connect( sigc::mem_fun( *this, &GameDialog::exitGame));
71 
72  if ( actmap ) {
73  p = ScreenToClient(exitButton->x, exitButton->y);
74  continueButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + 2 * GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Return to Game", 90);
75  continueButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &GameDialog::closeWindow )));
76  }
77 
78  sigClose.connect( sigc::mem_fun( *this, &GameDialog::closeWindow ));
79  SetInputFocus();
80 }
81 
82 
83 
85 }
86 bool GameDialog::eventKeyDown (const SDL_KeyboardEvent *key) {
87 
88  int mod = SDL_GetModState() & ~(KMOD_NUM | KMOD_CAPS | KMOD_MODE);
89 
90  if(key->keysym.sym == SDLK_ESCAPE) {
91  closeWindow();
92  }
93 
94  if ( mod == 0 ) {
95  switch ( key->keysym.sym ) {
96  case SDLK_F3:
98  QuitModal();
99  return true;
100 
101  case SDLK_F4:
103  QuitModal();
104  return true;
105  default:;
106  }
107  }
108 
109 
110  if ( (mod & KMOD_SHIFT) && (mod & KMOD_CTRL)) {
111  switch ( key->keysym.sym ) {
112  case SDLK_l:
114  QuitModal();
115  return true;
116  default:;
117  }
118  }
119 
120 
121 
122  if ( mod & KMOD_CTRL ) {
123  switch ( key->keysym.sym ) {
124  case SDLK_l:
126  QuitModal();
127  return true;
128  default:;
129  }
130  }
131 
132  if ( mod & KMOD_SHIFT ) {
133  switch ( key->keysym.sym ) {
134  case SDLK_F3:
136  QuitModal();
137  return true;
138  default:;
139  }
140  }
141 
142 
143  return true;
144 }
145 
146 
147 
148 bool GameDialog::closeWindow() {
149  quitModalLoop(1);
150 
151  return true;
152 }
153 
154 bool GameDialog::exitGame(PG_Button* button) {
155  Hide();
156  if (choice_dlg( "do you really want to quit ?", "~y~es","~n~o") == 1) {
158  }
159  quitModalLoop(1);
160  return true;
161 }
162 
163 
164 bool GameDialog::supervise(PG_Button* button) {
166  return true;
167 }
168 
169 
170 
171 
172 bool GameDialog::showOptions(PG_Button* button) {
173  Hide();
175  Show();
176  return true;
177 }
178 
179 bool GameDialog::saveGame(PG_Button* button) {
180  Hide();
181  ::saveGame(true);
182  Show();
183  return true;
184 }
185 
186 bool GameDialog::loadGame(PG_Button* button) {
187  if ( ::loadGame(false))
188  QuitModal();
189 
190  return true;
191 }
192 
193 bool GameDialog::newGame(PG_Button* button)
194 {
195  Hide();
196  if ( startMultiplayerGame() ) {
198  QuitModal();
199 
200  } else
201  Show();
202  return true;
203 }
204 
205 
206 bool GameDialog::singleGame(PG_Button* button) {
207  Hide();
209  Show();
210  return true;
211 }
212 
213 bool GameDialog::multiGame(PG_Button* button) {
214  Hide();
215  // MultiPlayerDialog::multiPlayerDialog(this);
216  if ( continueAndStartMultiplayerGame( false ) ) {
217  QuitModal();
218  } else
219  Show();
220  return true;
221 }
222 
223 
225  GameDialog gd;
226  gd.Show();
227  gd.RunModal();
228  /*
229  GameDialog* gd = new GameDialog();
230  instance = gd;
231  gd->Show();
232  gd->RunModal();
233  delete gd;
234  GameDialog::instance = 0;
235  }
236  */
237  return true;
238 }
239 
240 
241 //*******************************************************************************************************************+
242 const int ConfirmExitDialog::xSize = 450;
243 const int ConfirmExitDialog::ySize = 120;
244 
245 
246 ConfirmExitDialog::ConfirmExitDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "End Game", MODAL ) {
247 
248  okButton = new PG_Button(this, PG_Rect(80, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "OK", 90);
249  okButton->sigClick.connect( sigc::mem_fun( *this, &ConfirmExitDialog::exitGame ));
250 
251  PG_Point p = ScreenToClient(okButton->x, okButton->y);
252  cancelButton = new PG_Button(this, PG_Rect(p.x + 150 + 10, p.y, 150, GuiDimension::getButtonHeight()), "Cancel", 90);
253  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &ConfirmExitDialog::closeWindow )));
254 }
255 
256 
258 }
259 
260 bool ConfirmExitDialog::closeWindow() {
261  quitModalLoop(1);
262 
263  return true;
264 }
265 
266 bool ConfirmExitDialog::exitGame(PG_Button* button) {
267  // throw ThreadExitException();
268  quitModalLoop(1);
270  return true;
271 }
272 
273 void ConfirmExitDialog::confirmExitDialog(PG_MessageObject* caller) {
274  ConfirmExitDialog ced(caller);
275  ced.Show();
276  ced.RunModal();
277 }
278 
279 //*******************************************************************************************************************+
280 
281 const int SinglePlayerDialog::xSize = 450;
282 const int SinglePlayerDialog::ySize = 250;
283 const int SinglePlayerDialog::buttonIndent = 150;
284 SinglePlayerDialog* SinglePlayerDialog::instance = 0;
285 
286 SinglePlayerDialog::SinglePlayerDialog( PG_MessageObject * c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Single Player", SHOW_CLOSE ) {
287 
288  campaignButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "Campaign", 90);
289  campaignButton->sigClick.connect( sigc::mem_fun( *this, &SinglePlayerDialog::campaign ));
290 
291  PG_Point p = ScreenToClient(campaignButton->x, campaignButton->y);
292  singleLevelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), 150, GuiDimension::getButtonHeight()), "Single Level", 90);
293  singleLevelButton->sigClick.connect( sigc::mem_fun( *this, &SinglePlayerDialog::singleLevel ));
294 
295  p = ScreenToClient(singleLevelButton->x, singleLevelButton->y);
296  cancelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, 150, GuiDimension::getButtonHeight()), "Cancel", 90);
297  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &SinglePlayerDialog::closeWindow )));
298 
299  sigClose.connect( sigc::mem_fun( *this, &SinglePlayerDialog::closeWindow ));
300  caller = c;
301  SetInputFocus();
302 }
303 
304 
306 }
307 
308 bool SinglePlayerDialog::closeWindow() {
309  quitModalLoop(1);
310  caller->SetInputFocus();
311  return true;
312 }
313 
314 bool SinglePlayerDialog::campaign(PG_Button* button) {
315  Hide();
316 
317  Show();
318  return true;
319 }
320 
321 bool SinglePlayerDialog::singleLevel(PG_Button* button) {
322  Hide();
323 
324  Show();
325  return true;
326 }
327 
328 
329 void SinglePlayerDialog::singlePlayerDialog(PG_MessageObject* caller) {
330  if(SinglePlayerDialog::instance == 0) {
331  SinglePlayerDialog* spd = new SinglePlayerDialog(caller);
332  SinglePlayerDialog::instance = spd;
333  spd->Show();
334  spd->RunModal();
335  delete spd;
336  SinglePlayerDialog::instance = 0;
337  }
338 }
339 
340 //*******************************************************************************************************************+
341 
342 const int MultiPlayerDialog::xSize = 450;
343 const int MultiPlayerDialog::ySize = 350;
344 const int MultiPlayerDialog::buttonIndent = 140;
345 
346 MultiPlayerDialog::MultiPlayerDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Multi Player", SHOW_CLOSE ) {
347 
348  continueGameButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Continue Network Game", 90);
349  continueGameButton->sigClick.connect( sigc::mem_fun( *this, &MultiPlayerDialog::continueGame ));
350 
351  PG_Point p = ScreenToClient(continueGameButton->x, continueGameButton->y);
352  superViseButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Supervise Network Game", 90);
353  superViseButton->sigClick.connect( sigc::mem_fun( *this, &MultiPlayerDialog::superVise ));
354 
355  p = ScreenToClient(superViseButton->x, superViseButton->y);
356  setupNWButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Setup Network Game", 90);
357  setupNWButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &MultiPlayerDialog::closeWindow )));
358 
359  p = ScreenToClient(setupNWButton->x, setupNWButton->y);
360  changeMapPasswordButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Change Password", 90);
361  changeMapPasswordButton->sigClick.connect( sigc::mem_fun( *this, &MultiPlayerDialog::changeMapPassword ));
362 
363  p = ScreenToClient(changeMapPasswordButton->x, changeMapPasswordButton->y);
364  cancelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
365  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &MultiPlayerDialog::closeWindow )));
366 
367  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &MultiPlayerDialog::closeWindow )));
368 
369  sigClose.connect( sigc::mem_fun( *this, &MultiPlayerDialog::closeWindow ));
370 
371  caller = c;
372  SetInputFocus();
373 }
374 
375 
377 }
378 
379 bool MultiPlayerDialog::closeWindow() {
380  quitModalLoop(1);
381  caller->SetInputFocus();
382  return true;
383 }
384 
385 bool MultiPlayerDialog::continueGame(PG_Button* button) {
386  Hide();
387 
388  Show();
389  return true;
390 }
391 
392 bool MultiPlayerDialog::changeMapPassword(PG_Button* button) {
393  Hide();
395  Show();
396  return true;
397 }
398 
399 bool MultiPlayerDialog::superVise(PG_Button* button) {
400  Hide();
401  Show();
402  return true;
403 }
404 
405 
406 void MultiPlayerDialog::multiPlayerDialog(PG_MessageObject* c) {
407  MultiPlayerDialog spd(c);
408  spd.Show();
409  spd.RunModal();
410 }
411 
412 
413 //*******************************************************************************************************************+
414 const int OptionsDialog::xSize = 450;
415 const int OptionsDialog::ySize = 400;
416 const int OptionsDialog::buttonIndent = 150;
417 
418 OptionsDialog::OptionsDialog(PG_MessageObject* c ): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Options", SHOW_CLOSE ) {
419 
420  soundButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "Sound Options", 90);
421  soundButton->sigClick.connect( sigc::mem_fun( *this, &OptionsDialog::showSoundOptions ));
422 
423  PG_Point p = ScreenToClient(soundButton->x, soundButton->y);
424  otherButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), 150, GuiDimension::getButtonHeight()), "Game Options", 90);
425  otherButton->sigClick.connect( sigc::mem_fun( *this, &OptionsDialog::showOtherOptions ));
426 
427  p = ScreenToClient(otherButton->x, otherButton->y);
428  PG_Button* okButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, 150, GuiDimension::getButtonHeight()), "Back", 90);
429  okButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &OptionsDialog::closeWindow )));
430 
431  sigClose.connect( sigc::mem_fun( *this, &OptionsDialog::closeWindow ));
432 
433  caller = c;
434  SetInputFocus();
435 }
436 
437 
439 }
440 
441 bool OptionsDialog::closeWindow() {
442  quitModalLoop(1);
443  caller->SetInputFocus();
444  return true;
445 }
446 
447 bool OptionsDialog::showSoundOptions(PG_Button* button) {
448  Hide();
449  soundSettings(this);
450  Show();
451  return true;
452 }
453 /*
454 bool OptionsDialog::showMouseOptions(PG_Button* button) {
455  Hide();
456  MousePreferencesDialog::mousePreferencesDialog(this);
457  Show();
458  return true;
459 }
460 */
461 
462 bool OptionsDialog::showOtherOptions(PG_Button* button) {
463  Hide();
464  editGameOptions();
465  Show();
466  return true;
467 }
468 
469 void OptionsDialog::optionsDialog(PG_MessageObject* caller) {
470  OptionsDialog od(caller);
471  od.Show();
472  od.RunModal();
473 }
474 
475 
476 //*******************************************************************************************************************+
477 const int GameOptionsDialog::xSize = 450;
478 const int GameOptionsDialog::ySize = 320;
479 const int GameOptionsDialog::buttonIndent = 60;
480 
481 GameOptionsDialog::GameOptionsDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Game Options",
482  SHOW_CLOSE ) {
483 
484  autoAmmunitionLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), static_cast<int>(GuiDimension::getTopOffSet() * 1.5), 10, GetTextHeight() * 2), "Auto Ammunition");
485  autoAmmunitionLabel->SetSizeByText();
486 
487  PG_Point p = ScreenToClient(autoUnitTrainingLabel->x, autoUnitTrainingLabel->y);
488  promptEndOfTurnLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), p.y + GuiDimension::getTopOffSet() + GetTextHeight() * 2 , 10, GetTextHeight() * 2), "Prompt End of Turn");
489  promptEndOfTurnLabel->SetSizeByText();
490 
491  promptEndOfTurnCButton = new PG_CheckButton(this, PG_Rect(xSize - (GuiDimension::getLineEditWidth() + GuiDimension::getLeftIndent()), p.y + GuiDimension::getTopOffSet() + static_cast<int>(GetTextHeight() * 1.5), GuiDimension::getLineEditWidth(), GetTextHeight() * 2));
492  if(CGameOptions::Instance()->CGameOptions::Instance()->endturnquestion){
493  promptEndOfTurnCButton->SetPressed();
494  }
495 
496  p = ScreenToClient(promptEndOfTurnLabel->x, promptEndOfTurnLabel->y);
497  changePasswordButton = new PG_Button(this, PG_Rect((xSize - GuiDimension::getButtonWidth())/2, p.y + GuiDimension::getTopOffSet() + GetTextHeight() * 2 , GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Change Password");
498  changePasswordButton->sigClick.connect( sigc::mem_fun( *this, &GameOptionsDialog::changePassword ));
499 
500  okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
501  okButton->sigClick.connect( sigc::mem_fun( *this, &GameOptionsDialog::ok ));
502 
503  p = ScreenToClient(okButton->x, okButton->y);
504  cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
505  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &GameOptionsDialog::closeWindow )));
506 
507  sigClose.connect( sigc::mem_fun( *this, &GameOptionsDialog::closeWindow ));
508 
509  caller = c;
510  SetInputFocus();
511 }
512 
513 
515 }
516 
517 bool GameOptionsDialog::closeWindow() {
518  quitModalLoop(1);
519  caller->SetInputFocus();
520  return true;
521 }
522 
523 bool GameOptionsDialog::changePassword(PG_Button* button){
524  Hide();
526  Show();
527  return true;
528 }
529 bool GameOptionsDialog::ok(PG_Button* button) {
530  CGameOptions::Instance()->CGameOptions::Instance()->endturnquestion = promptEndOfTurnCButton->GetPressed();
531  quitModalLoop(1);
532  return true;
533 }
534 
535 void GameOptionsDialog::gameOptionsDialog(PG_MessageObject* caller) {
536  GameOptionsDialog god(caller);
537  god.Show();
538  god.RunModal();
539 }
540 
541 
542 //*******************************************************************************************************************+
543 const int ChangePasswordDialog::xSize = 450;
544 const int ChangePasswordDialog::ySize = 220;
545 const int ChangePasswordDialog::buttonIndent = 60;
546 
547 ChangePasswordDialog::ChangePasswordDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Change Password",
548  SHOW_CLOSE ) {
549 
550  passwordLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), static_cast<int>(GuiDimension::getTopOffSet() * 1.5), 10, GetTextHeight() * 2), "New Password: ");
551  passwordLabel->SetSizeByText();
552 
553  PG_Point p = ScreenToClient(passwordLabel->x, passwordLabel->y);
554  passwordValue = new PG_LineEdit(this, PG_Rect((xSize - xSize/2)/2, p.y + GuiDimension::getTopOffSet(), xSize/2, GetTextHeight() * 2));
555  passwordValue->SetText(CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword);
556 
557 
558  okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
559  okButton->sigClick.connect( sigc::mem_fun( *this, &ChangePasswordDialog::ok ));
560 
561  p = ScreenToClient(okButton->x, okButton->y);
562  cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
563  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &ChangePasswordDialog::closeWindow )));
564 
565  sigClose.connect( sigc::mem_fun( *this, &ChangePasswordDialog::closeWindow ));
566 
567  caller = c;
568  SetInputFocus();
569 }
570 
572 
573 }
574 
575 
576 bool ChangePasswordDialog::ok(PG_Button* button){
577  CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword = passwordValue->GetText();
578  quitModalLoop(1);
579  caller->SetInputFocus();
580  return true;
581 }
582 
583 //*******************************************************************************************************************+
584 
585 ChangeDefaultPasswordDialog::ChangeDefaultPasswordDialog(PG_MessageObject* c) : ChangePasswordDialog(c){
586 
587 
588 }
589 
591 
592 
593 }
594 
595 bool ChangeDefaultPasswordDialog::ok(PG_Button* button){
596  CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword = passwordValue->GetText();
597  quitModalLoop(1);
598  caller->SetInputFocus();
599  return true;
600 }
601 
602 
604  ChangeDefaultPasswordDialog cdpd(caller);
605  cdpd.Show();
606  cdpd.RunModal();
607 }
608 
609 //*******************************************************************************************************************
610 #if 0
611  const int MousePreferencesDialog::xSize = 450;
612  const int MousePreferencesDialog::ySize = 220;
613 
614  MousePreferencesDialog::MousePreferencesDialog(PG_MessageObject* c) : ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Mouse Options",
615  SHOW_CLOSE ) {
616 
617  sigClose.connect( sigc::mem_fun( *this, &MousePreferencesDialog::closeWindow ));
618 
619  caller = c;
620  SetInputFocus();
621  }
622 
623 
624  MousePreferencesDialog::~MousePreferencesDialog(){
625 
626 
627  }
628 
629 
630 
631  bool MousePreferencesDialog::ok(PG_Button* button){
632  return true;
633  }
634 
635  void MousePreferencesDialog::mousePreferencesDialog(PG_MessageObject* caller){
636  MousePreferencesDialog mpd(caller);
637  mpd.Show();
638  mpd.RunModal();
639  }
640 #endif
641 //*******************************************************************************************************************
642 
643 
644 ChangeMapPasswordDialog::ChangeMapPasswordDialog(PG_MessageObject* c) : ChangePasswordDialog(c){
645 
646 
647 }
648 
650 
651 
652 }
653 
654 bool ChangeMapPasswordDialog::ok(PG_Button* button){
656  quitModalLoop(1);
657  caller->SetInputFocus();
658  return true;
659 }
660 
661 
662 void ChangeMapPasswordDialog::changeMapPasswordDialog(PG_MessageObject* caller) {
663  ChangeMapPasswordDialog cdpd(caller);
664  cdpd.Show();
665  cdpd.RunModal();
666 }
667 
668 
669 
670 //*******************************************************************************************************************+
671 const int SaveGameBaseDialog::xSize = 450;
672 const int SaveGameBaseDialog::ySize = 360;
673 const int SaveGameBaseDialog::buttonIndent = 60;
674 
675 SaveGameBaseDialog::SaveGameBaseDialog(const ASCString& title, PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), title.c_str(), SHOW_CLOSE ) {
676 
677 
679 
680  for(int i=0; i<17; i++) {
681  PG_ListBoxItem* item = new PG_ListBoxItem(fileList, 25, "");
682  item->SetTextFormat("Item %i", i+1);
683  }
684  fileList->EnableScrollBar(true, PG_ScrollBar::VERTICAL);
685  fileList->Update();
686 #if 0
687 
688  tfindfile ff ( "*.sav" ); //wildcard
689 
690  ASCString location;
691  string fileName = ff.getnextname(NULL, NULL, &location );
692  PG_ListBoxItem* item;
693  while( !fileName.empty() ) {
694  item = new PG_ListBoxItem(fileList, 20, fileName.c_str());
695  /*tfiledata f;
696  f.name = filename.c_str();
697 
698  time_t tdate = get_filetime( filename.c_str() );
699  f.time = tdate;
700  if ( tdate != -1 )
701  f.sdate = ctime ( &tdate );
702 
703  f.location = location;
704 
705  fileList->
706  //files.push_back ( f );
707 
708  numberoffiles++;
709 
710  fileName = ff.getnextname(NULL, NULL, &location );
711  }
712  fileList->EnableScrollBar(true, PG_ScrollBar::VERTICAL);
713  */
714 #endif
715  PG_Point p = ScreenToClient(fileList->x, fileList->y);
716  /* slider = new PG_ScrollBar(this, PG_Rect(xSize - (GuiDimension::getLeftIndent() + GuiDimension::getSliderWidth()) , p.y, GuiDimension::getSliderWidth(), fileList->Height()), PG_ScrollBar::VERTICAL);
717  slider->SetRange(0,fileList->GetWidgetCount());
718  slider->sigScrollTrack.connect( sigc::mem_fun( *this, &SaveGameBaseDialog::handleSlider));*/
719 
720 
721  fileNameLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), p.y + fileList->Height() + GuiDimension::getTopOffSet(), 10, 10), "Filename: ");
722  fileNameLabel->SetSizeByText();
723 
724  p = ScreenToClient(fileNameLabel->x, fileNameLabel->y);
725  fileNameValue = new PG_LineEdit(this, PG_Rect(p.x + fileNameLabel->Width(), p.y, xSize - (GuiDimension::getLeftIndent()*2 + fileNameLabel->Width()), GetTextHeight()*2));
726 
727  p = ScreenToClient(fileNameValue->x, fileNameValue->y);
728  sortNameButton = new PG_RadioButton(this, PG_Rect(p.x , p.y + + GuiDimension::getTopOffSet(), 20, 20), "by name");
729  sortNameButton->SetSizeByText();
730 
731  sortDateButton = new PG_RadioButton(this, PG_Rect(p.x + sortNameButton->Width() + GuiDimension::getLineOffset() , p.y + + GuiDimension::getTopOffSet(), 20, 20), "by date");
732  sortDateButton->SetSizeByText();
733 
734 
735 
736 
737  okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
738  okButton->sigClick.connect( sigc::mem_fun( *this, &SaveGameBaseDialog::ok ));
739 
740  p = ScreenToClient(okButton->x, okButton->y);
741  cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
742  cancelButton->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &SaveGameBaseDialog::closeWindow )));
743 
744  sigClose.connect( sigc::mem_fun( *this, &SaveGameBaseDialog::closeWindow ));
745 
746  caller = c;
747  SetInputFocus();
748 }
749 
750 
752 }
753 
754 bool SaveGameBaseDialog::closeWindow() {
755  quitModalLoop(1);
756  caller->SetInputFocus();
757  return true;
758 }
759 
760 bool SaveGameBaseDialog::handleSlider(long data) {
761 
762  return true;
763 }
764 
765 //*************************************************************************************************************************
766 
767 SaveGameDialog::SaveGameDialog(PG_MessageObject* c):SaveGameBaseDialog("Save Game", c) {
768 }
769 
771 }
772 bool SaveGameDialog::ok(PG_Button* button) {
773  savegame( fileNameValue->GetText(), actmap );
774  quitModalLoop(1);
775  return true;
776 }
777 
778 void SaveGameDialog::saveGameDialog(PG_MessageObject* c) {
779  SaveGameDialog sgd(c);
780  sgd.Show();
781  sgd.RunModal();
782 }
783 
784 //*************************************************************************************************************************
785 #if 0
786 LoadGameDialog::LoadGameDialog(PG_MessageObject* c):SaveGameBaseDialog("Load Game", c) {
787 }
788 
789 LoadGameDialog::~LoadGameDialog() {
790 }
791 bool LoadGameDialog::ok(PG_Button* button) {
792  vector<PG_ListBoxBaseItem*> selectedFileList;
793  PG_ListBoxItem* fileName = dynamic_cast<PG_ListBoxItem*>(selectedFileList.front());
794  // loadgame(fileName->GetText().c_str());
795  quitModalLoop(1);
796  return true;
797 }
798 /*
799 void LoadGameDialog::loadGameDialog(PG_MessageObject* caller) {
800 
801  ItemSelectorWindow isw ( NULL, PG_Rect( 10,10,500,500) , new ) ;
802 
803  File
804 
805  LoadGameDialog lgd(caller);
806  lgd.Show();
807  lgd.RunModal();
808 }
809 */
810 //*************************************************************************************************************************
811 
812 
813 
814 //*******************************************************************************************************************+
815 
816 
817 
818 //*******************************************************************************************************************+
819 
820 
821 void LoadGameDialog::loadGameDialog(PG_MessageObject* caller) {
822 
823  ItemSelectorWindow isw ( NULL, PG_Rect( 10,10,500,500) , "choose file", new FileSelectionItemFactory( "*.foo" )) ;
824 
825  isw.Show();
826  isw.RunModal();
827 }
828 
829 #endif
830 
831 
static void changeDefaultPasswordDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:603
map accessing and usage routines used by ASC and the mapeditor
miscellaneous functions which are used by ASC and all its tools
static void gameOptionsDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:535
ASCString getnextname(int *loc=NULL, bool *inContainer=NULL, ASCString *location=NULL)
Returns the next entry of the internal file list.
Definition: basestrm.cpp:2211
ASCString defaultPassword
Definition: gameoptions.h:236
static int getLineOffset()
static void saveGameDialog(PG_MessageObject *caller)
Definition: gamedialog.cpp:778
PG_LineEdit * passwordValue
Definition: gamedialog.h:194
void soundSettings(PG_MessageObject *caller)
PG_MessageObject * caller
Definition: paradialog.h:131
Definition: sg.h:36
bool endturnquestion
question "do you want to end your turn"
Definition: gameoptions.h:69
static int getButtonWidth()
void setUnencoded(const string &s)
Definition: password.cpp:27
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
static void multiPlayerDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:406
static void confirmExitDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:273
PG_ListBox * fileList
Definition: gamedialog.h:251
virtual ~ChangePasswordDialog()
Definition: gamedialog.cpp:571
static bool gameDialog()
Definition: gamedialog.cpp:224
Interface for various global functions and variables.
ASC_PG_App & getPGApplication()
Definition: paradialog.cpp:294
static void singlePlayerDialog(PG_MessageObject *caller)
Definition: gamedialog.cpp:329
bool startMultiplayerGame()
Definition: newgame.cpp:921
bool quitModalLoop(int value)
Definition: paradialog.cpp:545
void Quit()
Definition: paradialog.cpp:223
void editGameOptions(bool mainApp)
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
virtual ~SaveGameBaseDialog()
Definition: gamedialog.cpp:751
Searching for files.
Definition: basestrm.h:484
ChangePasswordDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:547
virtual ~ChangeMapPasswordDialog()
Definition: gamedialog.cpp:649
bool eventKeyDown(const SDL_KeyboardEvent *key)
Definition: gamedialog.cpp:86
virtual bool closeWindow()
Definition: paradialog.cpp:580
static int getButtonHeight()
virtual ~SaveGameDialog()
Definition: gamedialog.cpp:770
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
static int getLeftIndent()
PG_LineEdit * fileNameValue
Definition: gamedialog.h:249
static void changeMapPasswordDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:662
static int getLineEditWidth()
Player player[9]
Definition: gamemap.h:253
static CGameOptions * Instance()
returns the only Instance
Definition: gameoptions.cpp:38
Interface for all the dialog boxes used by the game and the mapeditor.
procedure for loading and writing savegames, maps etc.
GameMap * actmap
Definition: spfst.cpp:64
void hookGuiToMap(GameMap *map)
Definition: sg.cpp:287
Password passwordcrc
the Password required for playing this player
Definition: player.h:160
static int getTopOffSet()
int choice_dlg(const ASCString &title, const ASCString &leftButton, const ASCString &rightButton)
Definition: dialog.cpp:616
static void optionsDialog(PG_MessageObject *c)
Definition: gamedialog.cpp:469
bool continueAndStartMultiplayerGame(bool mostRecent=false)
Definition: sg.cpp:610
void executeUserAction(tuseractions action)
Definition: sg.cpp:759
virtual ~ChangeDefaultPasswordDialog()
Definition: gamedialog.cpp:590
void networksupervisor(void)
static int getSliderWidth()
SaveGameBaseDialog(const ASCString &title, PG_MessageObject *c)
Definition: gamedialog.cpp:675
void savegame(const ASCString &name, GameMap *gamemap)
saves the game located in actmap to the savegame file name
Definition: loaders.cpp:1456