Ticket #8599: AGI_SavegameMouseWithButtons.patch
File AGI_SavegameMouseWithButtons.patch, 3.4 KB (added by , 18 years ago) |
---|
-
engines/agi/savegame.cpp
458 458 sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), num); 459 459 return saveLoadSlot; 460 460 } 461 461 462 462 int AgiEngine::selectSlot() { 463 463 int i, key, active = 0; 464 464 int rc = -1; 465 465 int hm = 2, vm = 3; /* box margins */ 466 int xmin, xmax, slotClicked; 466 467 char desc[NUM_SLOTS][40]; 468 int textCentre, buttonLength, buttonX[2], buttonY; 469 const char *buttonText[] = { " OK ", "Cancel", NULL }; 467 470 468 471 for (i = 0; i < NUM_SLOTS; i++) { 469 472 char fileName[MAX_PATH]; 470 473 Common::InSaveFile *in; 471 474 472 debugC(4, kDebugLevelMain | kDebugLevelSavegame, " Game id seems to be%s", _targetName.c_str());475 debugC(4, kDebugLevelMain | kDebugLevelSavegame, "Current game id is %s", _targetName.c_str()); 473 476 sprintf(fileName, "%s", getSavegameFilename(i)); 474 477 if (!(in = _saveFileMan->openForLoading(fileName))) { 475 478 debugC(4, kDebugLevelMain | kDebugLevelSavegame, "File %s does not exist", fileName); … … 489 492 } 490 493 } 491 494 495 textCentre = GFX_WIDTH / CHAR_LINES / 2; 496 buttonLength = 6; 497 buttonX[0] = (textCentre - 3 * buttonLength / 2) * CHAR_COLS; 498 buttonX[1] = (textCentre + buttonLength / 2) * CHAR_COLS; 499 buttonY = (vm + 17) * CHAR_LINES; 500 501 for (i = 0; i < 2; i++) 502 _gfx->drawButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); 503 492 504 for (;;) { 493 505 char dstr[64]; 494 506 for (i = 0; i < NUM_SLOTS; i++) { … … 496 508 printText(dstr, 0, hm + 1, vm + 4 + i, 497 509 (40 - 2 * hm) - 1, i == active ? MSG_BOX_COLOUR : MSG_BOX_TEXT, 498 510 i == active ? MSG_BOX_TEXT : MSG_BOX_COLOUR); 499 500 511 } 501 512 502 513 _gfx->pollTimer(); /* msdos driver -> does nothing */ 503 514 key = doPollKeyboard(); 504 515 switch (key) { … … 510 521 rc = -1; 511 522 goto getout; 512 523 case BUTTON_LEFT: 524 if (_gfx->testButton(buttonX[0], buttonY, buttonText[0])) { 525 rc = active; 526 strncpy(_game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN); 527 goto press; 528 } 529 if (_gfx->testButton(buttonX[1], buttonY, buttonText[1])) { 530 rc = -1; 531 goto getout; 532 } 533 xmin = (hm + 1) * CHAR_COLS; 534 xmax = xmin + CHAR_COLS * 34; 535 if ((int)g_mouse.x >= xmin && (int)g_mouse.x <= xmax) { 536 slotClicked = ((int)g_mouse.y-1)/CHAR_COLS-(vm+4); 537 if (slotClicked >= 0 && slotClicked < NUM_SLOTS) 538 active = slotClicked; 539 } 513 540 break; 514 541 case KEY_DOWN: 515 542 active++; … … 552 579 drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp); 553 580 printText("Select a slot in which you wish to save the game:", 554 581 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); 555 printText("Press ENTER to select, ESC cancels",556 0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);557 582 558 583 slot = selectSlot(); 559 584 if (slot < 0) … … 568 593 _gfx->flushBlock(3 * CHAR_COLS, 11 * CHAR_LINES - 1, 569 594 37 * CHAR_COLS, 12 * CHAR_LINES); 570 595 571 getString(2, 11, 3 3, MAX_STRINGS);596 getString(2, 11, 31, MAX_STRINGS); 572 597 _gfx->printCharacter(3, 11, _game.cursorChar, MSG_BOX_COLOUR, MSG_BOX_TEXT); 573 598 do { 574 599 mainCycle(); … … 625 650 drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp); 626 651 printText("Select a game which you wish to\nrestore:", 627 652 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); 628 printText("Press ENTER to select, ESC cancels",629 0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);630 653 631 654 slot = selectSlot(); 632 655