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