Ticket #8238: helpDialog.diff
File helpDialog.diff, 5.4 KB (added by , 21 years ago) |
---|
-
scumm/dialogs.h
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.h,v retrieving revision 1.17 diff -u -r1.17 dialogs.h
23 23 24 24 #include "common/str.h" 25 25 #include "gui/dialog.h" 26 #include "help.h" 26 27 27 28 class ListWidget; 28 29 class Scumm; … … 37 38 38 39 Scumm *_scumm; 39 40 41 Dialog *_helpDialog; 42 40 43 void addResText(int x, int y, int w, int h, int resID); 41 44 42 45 // Query a string from the resources … … 50 53 class SaveLoadDialog : public ScummDialog { 51 54 public: 52 55 SaveLoadDialog(NewGui *gui, Scumm *scumm); 56 ~SaveLoadDialog(); 53 57 virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); 54 58 virtual void open(); 55 59 virtual void close(); 56 60 57 61 protected: 58 ListWidget 62 ListWidget *_savegameList; 59 63 60 64 PushButtonWidget *_saveButton; 61 65 PushButtonWidget *_loadButton; … … 72 76 class AboutDialog : public ScummDialog { 73 77 public: 74 78 AboutDialog(NewGui *gui, Scumm *scumm); 79 }; 80 81 class HelpDialog : public ScummDialog { 82 public: 83 HelpDialog(NewGui *gui, Scumm *scumm); 84 virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); 85 86 protected: 87 typedef ScummVM::String String; 88 89 PushButtonWidget *_nextButton; 90 PushButtonWidget *_prevButton; 91 92 StaticTextWidget *_title; 93 StaticTextWidget *_key[HELP_NUM_LINES]; 94 StaticTextWidget *_dsc[HELP_NUM_LINES]; 95 96 int _page; 97 int _numPages; 98 99 byte _gameId; 100 101 void displayKeyBindings(); 75 102 }; 76 103 77 104 class OptionsDialog : public ScummDialog { -
scumm/dialogs.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.cpp,v retrieving revision 1.49 diff -u -r1.49 dialogs.cpp
25 25 #include "scumm.h" 26 26 #include "imuse.h" 27 27 #include "verbs.h" 28 #include "help.h" 28 29 29 30 #include "gui/newgui.h" 30 31 #include "gui/ListWidget.h" … … 78 79 "Map", //24 79 80 "Choose an action to map", //25 80 81 "Press the key to associate", //26 81 "Please select an action" //27 82 "Please select an action", //27 83 "Help" //28 82 84 }; 83 85 84 86 #ifdef __PALM_OS__ … … 219 221 kLoadCmd = 'LOAD', 220 222 kPlayCmd = 'PLAY', 221 223 kOptionsCmd = 'OPTN', 222 kQuitCmd = 'QUIT' 224 kQuitCmd = 'QUIT', 225 kHelpCmd = 'HELP', 223 226 }; 224 227 225 228 SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm) … … 234 237 _loadButton = addPushButton(x, 40, queryResString(5), kLoadCmd, 'L'); 235 238 addButton(x, 60, queryResString(6), kPlayCmd, 'P'); // Play 236 239 addButton(x, 80, queryCustomString(17), kOptionsCmd, 'O'); // Options 237 addButton(x, 100, queryResString(8), kQuitCmd, 'Q'); // Quit 240 addButton(x, 100, queryCustomString(28), kHelpCmd, 'H'); // Help 241 addButton(x, 120, queryResString(8), kQuitCmd, 'Q'); // Quit 238 242 239 243 // The save game list 240 244 _savegameList = new ListWidget(this, 8, 20, x - 14, 134); 245 246 _helpDialog = new HelpDialog(gui, scumm); 247 } 248 249 SaveLoadDialog::~SaveLoadDialog() { 250 delete _helpDialog; 241 251 } 242 252 243 253 void SaveLoadDialog::open() { … … 296 306 case kOptionsCmd: 297 307 _scumm->optionsDialog(); 298 308 break; 309 case kHelpCmd: 310 _helpDialog->runModal(); 311 break; 299 312 case kQuitCmd: 300 313 #ifdef __PALM_OS__ 301 314 close(); … … 553 566 new StaticTextWidget(this, 10, 50, 240, 16, "All games (c) LucasArts", kTextAlignCenter); 554 567 new StaticTextWidget(this, 10, 64, 240, 16, "Except", kTextAlignCenter); 555 568 new StaticTextWidget(this, 10, 78, 240, 16, "Simon the Sorcerer (c) Adventuresoft", kTextAlignCenter); 569 } 570 571 #pragma mark - 572 573 enum { 574 kNextCmd = 'NEXT', 575 kPrevCmd = 'PREV' 576 }; 577 578 HelpDialog::HelpDialog(NewGui *gui, Scumm *scumm) 579 : ScummDialog(gui, scumm, 20, 10, 280, 184) { 580 581 _page = 1; 582 _gameId = scumm->_gameId; 583 _numPages = ScummHelp::numPages(_gameId); 584 585 _prevButton = addPushButton(10, 160, "Previous", kPrevCmd, 'P'); 586 _nextButton = addPushButton(90, 160, "Next", kNextCmd, 'N'); 587 addButton(200, 160, "Close", kCloseCmd, 'C'); 588 _prevButton->clearFlags(WIDGET_ENABLED); 589 590 _title = new StaticTextWidget(this, 10, 5, 260, 16, "", kTextAlignCenter); 591 for (int i = 0; i < HELP_NUM_LINES; i++) { 592 _key[i] = new StaticTextWidget(this, 10, 20 + (10 * i), 70, 16, "", kTextAlignLeft); 593 _dsc[i] = new StaticTextWidget(this, 80, 20 + (10 * i), 190, 16, "", kTextAlignLeft); 594 } 595 596 displayKeyBindings(); 597 } 598 599 void HelpDialog::displayKeyBindings() { 600 String titleStr, *keyStr, *dscStr; 601 602 ScummHelp::updateStrings(_gameId, _page, titleStr, keyStr, dscStr); 603 604 _title->setLabel(titleStr); 605 for (int i = 0; i < HELP_NUM_LINES; i++) { 606 _key[i]->setLabel(keyStr[i]); 607 _dsc[i]->setLabel(dscStr[i]); 608 } 609 610 delete [] keyStr; 611 delete [] dscStr; 612 } 613 614 void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { 615 switch (cmd) { 616 case kNextCmd: 617 _page++; 618 if (_page >= _numPages) { 619 _nextButton->clearFlags(WIDGET_ENABLED); 620 } 621 if (_page >= 2) { 622 _prevButton->setFlags(WIDGET_ENABLED); 623 } 624 displayKeyBindings(); 625 draw(); 626 break; 627 case kPrevCmd: 628 _page--; 629 if (_page <= _numPages) { 630 _nextButton->setFlags(WIDGET_ENABLED); 631 } 632 if (_page <= 1) { 633 _prevButton->clearFlags(WIDGET_ENABLED); 634 } 635 displayKeyBindings(); 636 draw(); 637 break; 638 default: 639 ScummDialog::handleCommand(sender, cmd, data); 640 } 556 641 } 557 642 558 643 #pragma mark -