00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <sstream>
00013 #include <pgimage.h>
00014 #include <pglistboxitem.h>
00015 #include <pgpopupmenu.h>
00016
00017
00018 #include "gamedialog.h"
00019
00020 #include "guidimension.h"
00021 #include "sdl/sound.h"
00022 #include "misc.h"
00023 #include "dialogs/selectionwindow.h"
00024 #include "dialogs/fileselector.h"
00025 #include "dialogs/soundsettings.h"
00026 #include "dialogs/newgame.h"
00027 #include "dialogs/editgameoptions.h"
00028 #include "dialog.h"
00029 #include "sigc++/retype.h"
00030 #include "iconrepository.h"
00031 #include "sg.h"
00032 #include "loaders.h"
00033 #include "spfst.h"
00034
00035 #include "networksupervisor.h"
00036
00037 const int GameDialog::xSize = 450;
00038 const int GameDialog::ySize = 550;
00039 const int GameDialog::buttonIndent = 150;
00040 GameDialog* GameDialog::instance = 0;
00041
00042 GameDialog::GameDialog(): ASC_PG_Dialog(NULL, PG_Rect( -1, -1, xSize, ySize ), "Game", SHOW_CLOSE ) {
00043 singlePlayerButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "New Game", 90);
00044 singlePlayerButton->sigClick.connect( SigC::slot( *this, &GameDialog::newGame));
00045
00046 PG_Point p = ScreenToClient(singlePlayerButton->x, singlePlayerButton->y);
00047 multiPlayerButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Continue Mail Game", 90);
00048 multiPlayerButton->sigClick.connect( SigC::slot( *this, &GameDialog::multiGame));
00049
00050 p = ScreenToClient(multiPlayerButton->x, multiPlayerButton->y);
00051 loadGameButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Load Game", 90);
00052 loadGameButton->sigClick.connect( SigC::slot( *this, &GameDialog::loadGame));
00053
00054 p = ScreenToClient(loadGameButton->x, loadGameButton->y);
00055 saveGameButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Save Game", 90);
00056 saveGameButton->sigClick.connect( SigC::slot( *this, &GameDialog::saveGame));
00057
00058 p = ScreenToClient(loadGameButton->x, saveGameButton->y);
00059 PG_Button* superViseButton= new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Supervise Net Game", 90);
00060 superViseButton->sigClick.connect( SigC::slot( *this, &GameDialog::supervise));
00061
00062
00063 p = ScreenToClient(superViseButton->x, superViseButton->y);
00064 optionsButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Options", 90);
00065 optionsButton->sigClick.connect( SigC::slot( *this, &GameDialog::showOptions));
00066
00067
00068 p = ScreenToClient(optionsButton->x, optionsButton->y);
00069 exitButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Quit Game", 90);
00070 exitButton->sigClick.connect( SigC::slot( *this, &GameDialog::exitGame));
00071
00072 if ( actmap ) {
00073 p = ScreenToClient(exitButton->x, exitButton->y);
00074 continueButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + 2 * GuiDimension::getTopOffSet() , 150, GuiDimension::getButtonHeight()), "Return to Game", 90);
00075 continueButton->sigClick.connect( SigC::slot( *this, &GameDialog::closeWindow ));
00076 }
00077
00078 sigClose.connect( SigC::slot( *this, &GameDialog::closeWindow ));
00079 SetInputFocus();
00080 }
00081
00082
00083
00084 GameDialog::~GameDialog() {
00085 }
00086 bool GameDialog::handleEventKeyDown (const SDL_KeyboardEvent *key) {
00087 if(key->keysym.sym == SDLK_ESCAPE) {
00088 closeWindow();
00089 }
00090 return true;
00091 }
00092
00093
00094
00095 bool GameDialog::closeWindow() {
00096 quitModalLoop(1);
00097
00098 return true;
00099 }
00100
00101 bool GameDialog::exitGame(PG_Button* button) {
00102 Hide();
00103 if (choice_dlg( "do you really want to quit ?", "~y~es","~n~o") == 1) {
00104 getPGApplication().Quit();
00105 }
00106 quitModalLoop(1);
00107 return true;
00108 }
00109
00110
00111 bool GameDialog::supervise(PG_Button* button) {
00112 networksupervisor();
00113 return true;
00114 }
00115
00116
00117
00118
00119 bool GameDialog::showOptions(PG_Button* button) {
00120 Hide();
00121 OptionsDialog::optionsDialog(this);
00122 Show();
00123 return true;
00124 }
00125
00126 bool GameDialog::saveGame(PG_Button* button) {
00127 Hide();
00128 ::saveGame(true);
00129 Show();
00130 return true;
00131 }
00132
00133 bool GameDialog::loadGame(PG_Button* button) {
00134 if ( ::loadGame(false))
00135 QuitModal();
00136
00137 return true;
00138 }
00139
00140 bool GameDialog::newGame(PG_Button* button)
00141 {
00142 Hide();
00143 if ( startMultiplayerGame() ) {
00144 hookGuiToMap(actmap);
00145 QuitModal();
00146
00147 } else
00148 Show();
00149 return true;
00150 }
00151
00152
00153 bool GameDialog::singleGame(PG_Button* button) {
00154 Hide();
00155 SinglePlayerDialog::singlePlayerDialog(this);
00156 Show();
00157 return true;
00158 }
00159
00160 bool GameDialog::multiGame(PG_Button* button) {
00161 Hide();
00162
00163 if ( continueAndStartMultiplayerGame( false ) ) {
00164 QuitModal();
00165 } else
00166 Show();
00167 return true;
00168 }
00169
00170
00171 bool GameDialog::gameDialog() {
00172 GameDialog gd;
00173 gd.Show();
00174 gd.RunModal();
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 return true;
00185 }
00186
00187
00188
00189 const int ConfirmExitDialog::xSize = 450;
00190 const int ConfirmExitDialog::ySize = 120;
00191
00192
00193 ConfirmExitDialog::ConfirmExitDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "End Game", MODAL ) {
00194
00195 okButton = new PG_Button(this, PG_Rect(80, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "OK", 90);
00196 okButton->sigClick.connect( SigC::slot( *this, &ConfirmExitDialog::exitGame ));
00197
00198 PG_Point p = ScreenToClient(okButton->x, okButton->y);
00199 cancelButton = new PG_Button(this, PG_Rect(p.x + 150 + 10, p.y, 150, GuiDimension::getButtonHeight()), "Cancel", 90);
00200 cancelButton->sigClick.connect( SigC::slot( *this, &ConfirmExitDialog::closeWindow ));
00201 }
00202
00203
00204 ConfirmExitDialog::~ConfirmExitDialog() {
00205 }
00206
00207 bool ConfirmExitDialog::closeWindow() {
00208 quitModalLoop(1);
00209
00210 return true;
00211 }
00212
00213 bool ConfirmExitDialog::exitGame(PG_Button* button) {
00214
00215 quitModalLoop(1);
00216 getPGApplication().Quit();
00217 return true;
00218 }
00219
00220 void ConfirmExitDialog::confirmExitDialog(PG_MessageObject* caller) {
00221 ConfirmExitDialog ced(caller);
00222 ced.Show();
00223 ced.RunModal();
00224 }
00225
00226
00227
00228 const int SinglePlayerDialog::xSize = 450;
00229 const int SinglePlayerDialog::ySize = 250;
00230 const int SinglePlayerDialog::buttonIndent = 150;
00231 SinglePlayerDialog* SinglePlayerDialog::instance = 0;
00232
00233 SinglePlayerDialog::SinglePlayerDialog( PG_MessageObject * c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Single Player", SHOW_CLOSE ) {
00234
00235 campaignButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "Campaign", 90);
00236 campaignButton->sigClick.connect( SigC::slot( *this, &SinglePlayerDialog::campaign ));
00237
00238 PG_Point p = ScreenToClient(campaignButton->x, campaignButton->y);
00239 singleLevelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), 150, GuiDimension::getButtonHeight()), "Single Level", 90);
00240 singleLevelButton->sigClick.connect( SigC::slot( *this, &SinglePlayerDialog::singleLevel ));
00241
00242 p = ScreenToClient(singleLevelButton->x, singleLevelButton->y);
00243 cancelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, 150, GuiDimension::getButtonHeight()), "Cancel", 90);
00244 cancelButton->sigClick.connect( SigC::slot( *this, &SinglePlayerDialog::closeWindow ));
00245
00246 sigClose.connect( SigC::slot( *this, &SinglePlayerDialog::closeWindow ));
00247 caller = c;
00248 SetInputFocus();
00249 }
00250
00251
00252 SinglePlayerDialog::~SinglePlayerDialog() {
00253 }
00254
00255 bool SinglePlayerDialog::closeWindow() {
00256 quitModalLoop(1);
00257 caller->SetInputFocus();
00258 return true;
00259 }
00260
00261 bool SinglePlayerDialog::campaign(PG_Button* button) {
00262 Hide();
00263
00264 Show();
00265 return true;
00266 }
00267
00268 bool SinglePlayerDialog::singleLevel(PG_Button* button) {
00269 Hide();
00270
00271 Show();
00272 return true;
00273 }
00274
00275
00276 void SinglePlayerDialog::singlePlayerDialog(PG_MessageObject* caller) {
00277 if(SinglePlayerDialog::instance == 0) {
00278 SinglePlayerDialog* spd = new SinglePlayerDialog(caller);
00279 SinglePlayerDialog::instance = spd;
00280 spd->Show();
00281 spd->RunModal();
00282 delete spd;
00283 SinglePlayerDialog::instance = 0;
00284 }
00285 }
00286
00287
00288
00289 const int MultiPlayerDialog::xSize = 450;
00290 const int MultiPlayerDialog::ySize = 350;
00291 const int MultiPlayerDialog::buttonIndent = 140;
00292
00293 MultiPlayerDialog::MultiPlayerDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Multi Player", SHOW_CLOSE ) {
00294
00295 continueGameButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Continue Network Game", 90);
00296 continueGameButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::continueGame ));
00297
00298 PG_Point p = ScreenToClient(continueGameButton->x, continueGameButton->y);
00299 superViseButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Supervise Network Game", 90);
00300 superViseButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::superVise ));
00301
00302 p = ScreenToClient(superViseButton->x, superViseButton->y);
00303 setupNWButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Setup Network Game", 90);
00304 setupNWButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::closeWindow ));
00305
00306 p = ScreenToClient(setupNWButton->x, setupNWButton->y);
00307 changeMapPasswordButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Change Password", 90);
00308 changeMapPasswordButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::changeMapPassword ));
00309
00310 p = ScreenToClient(changeMapPasswordButton->x, changeMapPasswordButton->y);
00311 cancelButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
00312 cancelButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::closeWindow ));
00313
00314 cancelButton->sigClick.connect( SigC::slot( *this, &MultiPlayerDialog::closeWindow ));
00315
00316 sigClose.connect( SigC::slot( *this, &MultiPlayerDialog::closeWindow ));
00317
00318 caller = c;
00319 SetInputFocus();
00320 }
00321
00322
00323 MultiPlayerDialog::~MultiPlayerDialog() {
00324 }
00325
00326 bool MultiPlayerDialog::closeWindow() {
00327 quitModalLoop(1);
00328 caller->SetInputFocus();
00329 return true;
00330 }
00331
00332 bool MultiPlayerDialog::continueGame(PG_Button* button) {
00333 Hide();
00334
00335 Show();
00336 return true;
00337 }
00338
00339 bool MultiPlayerDialog::changeMapPassword(PG_Button* button) {
00340 Hide();
00341 ChangeMapPasswordDialog::changeMapPasswordDialog(this);
00342 Show();
00343 return true;
00344 }
00345
00346 bool MultiPlayerDialog::superVise(PG_Button* button) {
00347 Hide();
00348 Show();
00349 return true;
00350 }
00351
00352
00353 void MultiPlayerDialog::multiPlayerDialog(PG_MessageObject* c) {
00354 MultiPlayerDialog spd(c);
00355 spd.Show();
00356 spd.RunModal();
00357 }
00358
00359
00360
00361 const int OptionsDialog::xSize = 450;
00362 const int OptionsDialog::ySize = 400;
00363 const int OptionsDialog::buttonIndent = 150;
00364
00365 OptionsDialog::OptionsDialog(PG_MessageObject* c ): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Options", SHOW_CLOSE ) {
00366
00367 soundButton = new PG_Button(this, PG_Rect(buttonIndent, GuiDimension::getTopOffSet()*2, 150, GuiDimension::getButtonHeight()), "Sound Options", 90);
00368 soundButton->sigClick.connect( SigC::slot( *this, &OptionsDialog::showSoundOptions ));
00369
00370 PG_Point p = ScreenToClient(soundButton->x, soundButton->y);
00371 otherButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet(), 150, GuiDimension::getButtonHeight()), "Game Options", 90);
00372 otherButton->sigClick.connect( SigC::slot( *this, &OptionsDialog::showOtherOptions ));
00373
00374 p = ScreenToClient(otherButton->x, otherButton->y);
00375 PG_Button* okButton = new PG_Button(this, PG_Rect(p.x, p.y + GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet() * 2, 150, GuiDimension::getButtonHeight()), "Back", 90);
00376 okButton->sigClick.connect( SigC::slot( *this, &OptionsDialog::closeWindow ));
00377
00378 sigClose.connect( SigC::slot( *this, &OptionsDialog::closeWindow ));
00379
00380 caller = c;
00381 SetInputFocus();
00382 }
00383
00384
00385 OptionsDialog::~OptionsDialog() {
00386 }
00387
00388 bool OptionsDialog::closeWindow() {
00389 quitModalLoop(1);
00390 caller->SetInputFocus();
00391 return true;
00392 }
00393
00394 bool OptionsDialog::showSoundOptions(PG_Button* button) {
00395 Hide();
00396 soundSettings(this);
00397 Show();
00398 return true;
00399 }
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 bool OptionsDialog::showOtherOptions(PG_Button* button) {
00410 Hide();
00411 editGameOptions();
00412 Show();
00413 return true;
00414 }
00415
00416 void OptionsDialog::optionsDialog(PG_MessageObject* caller) {
00417 OptionsDialog od(caller);
00418 od.Show();
00419 od.RunModal();
00420 }
00421
00422
00423
00424 const int GameOptionsDialog::xSize = 450;
00425 const int GameOptionsDialog::ySize = 320;
00426 const int GameOptionsDialog::buttonIndent = 60;
00427
00428 GameOptionsDialog::GameOptionsDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Game Options",
00429 SHOW_CLOSE ) {
00430
00431 autoAmmunitionLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), static_cast<int>(GuiDimension::getTopOffSet() * 1.5), 10, GetTextHeight() * 2), "Auto Ammunition");
00432 autoAmmunitionLabel->SetSizeByText();
00433
00434 PG_Point p = ScreenToClient(autoUnitTrainingLabel->x, autoUnitTrainingLabel->y);
00435 promptEndOfTurnLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), p.y + GuiDimension::getTopOffSet() + GetTextHeight() * 2 , 10, GetTextHeight() * 2), "Prompt End of Turn");
00436 promptEndOfTurnLabel->SetSizeByText();
00437
00438 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));
00439 if(CGameOptions::Instance()->CGameOptions::Instance()->endturnquestion){
00440 promptEndOfTurnCButton->SetPressed();
00441 }
00442
00443 p = ScreenToClient(promptEndOfTurnLabel->x, promptEndOfTurnLabel->y);
00444 changePasswordButton = new PG_Button(this, PG_Rect((xSize - GuiDimension::getButtonWidth())/2, p.y + GuiDimension::getTopOffSet() + GetTextHeight() * 2 , GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Change Password");
00445 changePasswordButton->sigClick.connect( SigC::slot( *this, &GameOptionsDialog::changePassword ));
00446
00447 okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
00448 okButton->sigClick.connect( SigC::slot( *this, &GameOptionsDialog::ok ));
00449
00450 p = ScreenToClient(okButton->x, okButton->y);
00451 cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
00452 cancelButton->sigClick.connect( SigC::slot( *this, &GameOptionsDialog::closeWindow ));
00453
00454 sigClose.connect( SigC::slot( *this, &GameOptionsDialog::closeWindow ));
00455
00456 caller = c;
00457 SetInputFocus();
00458 }
00459
00460
00461 GameOptionsDialog::~GameOptionsDialog() {
00462 }
00463
00464 bool GameOptionsDialog::closeWindow() {
00465 quitModalLoop(1);
00466 caller->SetInputFocus();
00467 return true;
00468 }
00469
00470 bool GameOptionsDialog::changePassword(PG_Button* button){
00471 Hide();
00472 ChangeDefaultPasswordDialog::changeDefaultPasswordDialog(this);
00473 Show();
00474 return true;
00475 }
00476 bool GameOptionsDialog::ok(PG_Button* button) {
00477 CGameOptions::Instance()->CGameOptions::Instance()->endturnquestion = promptEndOfTurnCButton->GetPressed();
00478 quitModalLoop(1);
00479 return true;
00480 }
00481
00482 void GameOptionsDialog::gameOptionsDialog(PG_MessageObject* caller) {
00483 GameOptionsDialog god(caller);
00484 god.Show();
00485 god.RunModal();
00486 }
00487
00488
00489
00490 const int ChangePasswordDialog::xSize = 450;
00491 const int ChangePasswordDialog::ySize = 220;
00492 const int ChangePasswordDialog::buttonIndent = 60;
00493
00494 ChangePasswordDialog::ChangePasswordDialog(PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Change Password",
00495 SHOW_CLOSE ) {
00496
00497 passwordLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), static_cast<int>(GuiDimension::getTopOffSet() * 1.5), 10, GetTextHeight() * 2), "New Password: ");
00498 passwordLabel->SetSizeByText();
00499
00500 PG_Point p = ScreenToClient(passwordLabel->x, passwordLabel->y);
00501 passwordValue = new PG_LineEdit(this, PG_Rect((xSize - xSize/2)/2, p.y + GuiDimension::getTopOffSet(), xSize/2, GetTextHeight() * 2));
00502 passwordValue->SetText(CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword);
00503
00504
00505 okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
00506 okButton->sigClick.connect( SigC::slot( *this, &ChangePasswordDialog::ok ));
00507
00508 p = ScreenToClient(okButton->x, okButton->y);
00509 cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
00510 cancelButton->sigClick.connect( SigC::slot( *this, &ChangePasswordDialog::closeWindow ));
00511
00512 sigClose.connect( SigC::slot( *this, &ChangePasswordDialog::closeWindow ));
00513
00514 caller = c;
00515 SetInputFocus();
00516 }
00517
00518 ChangePasswordDialog::~ChangePasswordDialog(){
00519
00520 }
00521
00522
00523 bool ChangePasswordDialog::ok(PG_Button* button){
00524 CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword = passwordValue->GetText();
00525 quitModalLoop(1);
00526 caller->SetInputFocus();
00527 return true;
00528 }
00529
00530
00531
00532 ChangeDefaultPasswordDialog::ChangeDefaultPasswordDialog(PG_MessageObject* c) : ChangePasswordDialog(c){
00533
00534
00535 }
00536
00537 ChangeDefaultPasswordDialog::~ChangeDefaultPasswordDialog() {
00538
00539
00540 }
00541
00542 bool ChangeDefaultPasswordDialog::ok(PG_Button* button){
00543 CGameOptions::Instance()->CGameOptions::Instance()->defaultPassword = passwordValue->GetText();
00544 quitModalLoop(1);
00545 caller->SetInputFocus();
00546 return true;
00547 }
00548
00549
00550 void ChangeDefaultPasswordDialog::changeDefaultPasswordDialog(PG_MessageObject* caller) {
00551 ChangeDefaultPasswordDialog cdpd(caller);
00552 cdpd.Show();
00553 cdpd.RunModal();
00554 }
00555
00556
00557 #if 0
00558 const int MousePreferencesDialog::xSize = 450;
00559 const int MousePreferencesDialog::ySize = 220;
00560
00561 MousePreferencesDialog::MousePreferencesDialog(PG_MessageObject* c) : ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), "Mouse Options",
00562 SHOW_CLOSE ) {
00563
00564 sigClose.connect( SigC::slot( *this, &MousePreferencesDialog::closeWindow ));
00565
00566 caller = c;
00567 SetInputFocus();
00568 }
00569
00570
00571 MousePreferencesDialog::~MousePreferencesDialog(){
00572
00573
00574 }
00575
00576
00577
00578 bool MousePreferencesDialog::ok(PG_Button* button){
00579 return true;
00580 }
00581
00582 void MousePreferencesDialog::mousePreferencesDialog(PG_MessageObject* caller){
00583 MousePreferencesDialog mpd(caller);
00584 mpd.Show();
00585 mpd.RunModal();
00586 }
00587 #endif
00588
00589
00590
00591 ChangeMapPasswordDialog::ChangeMapPasswordDialog(PG_MessageObject* c) : ChangePasswordDialog(c){
00592
00593
00594 }
00595
00596 ChangeMapPasswordDialog::~ChangeMapPasswordDialog() {
00597
00598
00599 }
00600
00601 bool ChangeMapPasswordDialog::ok(PG_Button* button){
00602 actmap->player[actmap->actplayer].passwordcrc.setUnencoded(passwordValue->GetText());
00603 quitModalLoop(1);
00604 caller->SetInputFocus();
00605 return true;
00606 }
00607
00608
00609 void ChangeMapPasswordDialog::changeMapPasswordDialog(PG_MessageObject* caller) {
00610 ChangeMapPasswordDialog cdpd(caller);
00611 cdpd.Show();
00612 cdpd.RunModal();
00613 }
00614
00615
00616
00617
00618 const int SaveGameBaseDialog::xSize = 450;
00619 const int SaveGameBaseDialog::ySize = 360;
00620 const int SaveGameBaseDialog::buttonIndent = 60;
00621
00622 SaveGameBaseDialog::SaveGameBaseDialog(const ASCString& title, PG_MessageObject* c): ASC_PG_Dialog(NULL, PG_Rect( 200, 100, xSize, ySize ), title.c_str(), SHOW_CLOSE ) {
00623
00624
00625 fileList = new PG_ListBox(this, PG_Rect(GuiDimension::getLeftIndent(), GuiDimension::getTopOffSet(), xSize - (2 *GuiDimension::getLeftIndent() + GuiDimension::getSliderWidth()), 200));
00626
00627 for(int i=0; i<17; i++) {
00628 PG_ListBoxItem* item = new PG_ListBoxItem(fileList, 25, "");
00629 item->SetTextFormat("Item %i", i+1);
00630 }
00631 fileList->EnableScrollBar(true, PG_ScrollBar::VERTICAL);
00632 fileList->Update();
00633 #if 0
00634
00635 tfindfile ff ( "*.sav" );
00636
00637 ASCString location;
00638 string fileName = ff.getnextname(NULL, NULL, &location );
00639 PG_ListBoxItem* item;
00640 while( !fileName.empty() ) {
00641 item = new PG_ListBoxItem(fileList, 20, fileName.c_str());
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661 #endif
00662 PG_Point p = ScreenToClient(fileList->x, fileList->y);
00663
00664
00665
00666
00667
00668 fileNameLabel = new PG_Label(this, PG_Rect(GuiDimension::getLeftIndent(), p.y + fileList->Height() + GuiDimension::getTopOffSet(), 10, 10), "Filename: ");
00669 fileNameLabel->SetSizeByText();
00670
00671 p = ScreenToClient(fileNameLabel->x, fileNameLabel->y);
00672 fileNameValue = new PG_LineEdit(this, PG_Rect(p.x + fileNameLabel->Width(), p.y, xSize - (GuiDimension::getLeftIndent()*2 + fileNameLabel->Width()), GetTextHeight()*2));
00673
00674 p = ScreenToClient(fileNameValue->x, fileNameValue->y);
00675 sortNameButton = new PG_RadioButton(this, PG_Rect(p.x , p.y + + GuiDimension::getTopOffSet(), 20, 20), "by name");
00676 sortNameButton->SetSizeByText();
00677
00678 sortDateButton = new PG_RadioButton(this, PG_Rect(p.x + sortNameButton->Width() + GuiDimension::getLineOffset() , p.y + + GuiDimension::getTopOffSet(), 20, 20), "by date");
00679 sortDateButton->SetSizeByText();
00680
00681
00682
00683
00684 okButton = new PG_Button(this, PG_Rect( buttonIndent, ySize - (GuiDimension::getButtonHeight() + GuiDimension::getTopOffSet()), GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "OK", 90);
00685 okButton->sigClick.connect( SigC::slot( *this, &SaveGameBaseDialog::ok ));
00686
00687 p = ScreenToClient(okButton->x, okButton->y);
00688 cancelButton = new PG_Button(this, PG_Rect(p.x + GuiDimension::getButtonWidth() + 10, p.y, GuiDimension::getButtonWidth(), GuiDimension::getButtonHeight()), "Cancel", 90);
00689 cancelButton->sigClick.connect( SigC::slot( *this, &SaveGameBaseDialog::closeWindow ));
00690
00691 sigClose.connect( SigC::slot( *this, &SaveGameBaseDialog::closeWindow ));
00692
00693 caller = c;
00694 SetInputFocus();
00695 }
00696
00697
00698 SaveGameBaseDialog::~SaveGameBaseDialog() {
00699 }
00700
00701 bool SaveGameBaseDialog::closeWindow() {
00702 quitModalLoop(1);
00703 caller->SetInputFocus();
00704 return true;
00705 }
00706
00707 bool SaveGameBaseDialog::handleSlider(long data) {
00708
00709 return true;
00710 }
00711
00712
00713
00714 SaveGameDialog::SaveGameDialog(PG_MessageObject* c):SaveGameBaseDialog("Save Game", c) {
00715 }
00716
00717 SaveGameDialog::~SaveGameDialog() {
00718 }
00719 bool SaveGameDialog::ok(PG_Button* button) {
00720 savegame( fileNameValue->GetText().c_str());
00721 quitModalLoop(1);
00722 return true;
00723 }
00724
00725 void SaveGameDialog::saveGameDialog(PG_MessageObject* c) {
00726 SaveGameDialog sgd(c);
00727 sgd.Show();
00728 sgd.RunModal();
00729 }
00730
00731
00732 #if 0
00733 LoadGameDialog::LoadGameDialog(PG_MessageObject* c):SaveGameBaseDialog("Load Game", c) {
00734 }
00735
00736 LoadGameDialog::~LoadGameDialog() {
00737 }
00738 bool LoadGameDialog::ok(PG_Button* button) {
00739 vector<PG_ListBoxBaseItem*> selectedFileList;
00740 PG_ListBoxItem* fileName = dynamic_cast<PG_ListBoxItem*>(selectedFileList.front());
00741
00742 quitModalLoop(1);
00743 return true;
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768 void LoadGameDialog::loadGameDialog(PG_MessageObject* caller) {
00769
00770 ItemSelectorWindow isw ( NULL, PG_Rect( 10,10,500,500) , "choose file", new FileSelectionItemFactory( "*.foo" )) ;
00771
00772 isw.Show();
00773 isw.RunModal();
00774 }
00775
00776 #endif
00777
00778