diff options
author | Max Horn | 2002-07-07 22:44:30 +0000 |
---|---|---|
committer | Max Horn | 2002-07-07 22:44:30 +0000 |
commit | 10d86be56456b57392cca05d5a2135408289223c (patch) | |
tree | ca7d19195a38b260fbd625e9f634a71843c1c4bf | |
parent | c90ade1f10d3ff0c2f7e429ec5d688b7db8637c9 (diff) | |
download | scummvm-rg350-10d86be56456b57392cca05d5a2135408289223c.tar.gz scummvm-rg350-10d86be56456b57392cca05d5a2135408289223c.tar.bz2 scummvm-rg350-10d86be56456b57392cca05d5a2135408289223c.zip |
added options dialog; added NewGui TODO list;
svn-id: r4485
-rw-r--r-- | gui/dialog.cpp | 73 | ||||
-rw-r--r-- | gui/dialog.h | 19 | ||||
-rw-r--r-- | guimaps.h | 3 | ||||
-rw-r--r-- | newgui.cpp | 30 | ||||
-rw-r--r-- | newgui.h | 13 |
5 files changed, 114 insertions, 24 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 36694ab8ff..a4491d0c07 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -56,6 +56,15 @@ void Dialog::handleMouseMoved(int x, int y, int button) } +void Dialog::handleCommand(uint32 cmd) +{ + switch (cmd) { + case kCloseCmd: + close(); + break; + } +} + /* * Determine the widget at location (x,y) if any. Assumes the coordinates are * in the local coordinate system, i.e. relative to the top left of the dialog. @@ -80,7 +89,7 @@ void Dialog::close() void Dialog::addResText(int x, int y, int w, int h, int resID) { // Get the string - const char *str = _gui->queryString(resID); + const char *str = _gui->queryResString(resID); if (!str) str = "Dummy!"; new StaticTextWidget(this, x, y, w, h, str); @@ -92,17 +101,9 @@ void Dialog::addButton(int x, int y, int w, int h, char hotkey, const char *labe // TODO - handle hotkey } -void Dialog::addButton(int x, int y, int w, int h, char hotkey, int resID, uint32 cmd) -{ - // Get the string - const char *label = _gui->queryString(resID); - if (!label) - label = "Dummy!"; - addButton(x, y, w, h, hotkey, label, cmd); -} - #pragma mark - + enum { kSaveCmd = 'SAVE', kLoadCmd = 'LOAD', @@ -118,11 +119,11 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui) // addResText(10, 7, 240, 16, 2); // addResText(10, 7, 240, 16, 3); - addButton(200, 20, 54, 16, 'S', 4, kSaveCmd); // Save - addButton(200, 40, 54, 16, 'L', 5, kLoadCmd); // Load - addButton(200, 60, 54, 16, 'P', 6, kPlayCmd); // Play - addButton(200, 80, 54, 16, 'O', 17, kOptionsCmd); // Options - addButton(200, 100, 54, 16, 'Q', 8, kQuitCmd); // Quit + addButton(200, 20, 54, 16, 'S', RES_STRING(4), kSaveCmd); // Save + addButton(200, 40, 54, 16, 'L', RES_STRING(5), kLoadCmd); // Load + addButton(200, 60, 54, 16, 'P', RES_STRING(6), kPlayCmd); // Play + addButton(200, 80, 54, 16, 'O', CUSTOM_STRING(17), kOptionsCmd); // Options + addButton(200, 100, 54, 16, 'Q', RES_STRING(8), kQuitCmd); // Quit } void SaveLoadDialog::handleCommand(uint32 cmd) @@ -131,17 +132,55 @@ void SaveLoadDialog::handleCommand(uint32 cmd) case kSaveCmd: break; case kLoadCmd: - // FIXME HACK - just to demo the nesting ability - _gui->pauseDialog(); break; case kPlayCmd: close(); break; case kOptionsCmd: + _gui->optionsDialog(); break; case kQuitCmd: exit(1); break; + default: + Dialog::handleCommand(cmd); + } +} + + +#pragma mark - + +enum { + kSoundCmd = 'SOUN', + kKeysCmd = 'KEYS', + kAboutCmd = 'ABOU', + kMiscCmd = 'OPTN' +}; + +OptionsDialog::OptionsDialog(NewGui *gui) + : Dialog (gui, 50, 80, 210, 60) +{ + addButton( 10, 10, 40, 15, 'S', CUSTOM_STRING(5), kSoundCmd); // Sound + addButton( 80, 10, 40, 15, 'K', CUSTOM_STRING(6), kKeysCmd); // Keys + addButton(150, 10, 40, 15, 'A', CUSTOM_STRING(7), kAboutCmd); // About + addButton( 10, 35, 40, 15, 'M', CUSTOM_STRING(18), kMiscCmd); // Misc + addButton(150, 35, 40, 15, 'C', CUSTOM_STRING(23), kCloseCmd); // Close dialog - FIXME +} + +void OptionsDialog::handleCommand(uint32 cmd) +{ + switch (cmd) { + case kSoundCmd: + break; + case kKeysCmd: + break; + case kAboutCmd: + _gui->aboutDialog(); + break; + case kMiscCmd: + break; + default: + Dialog::handleCommand(cmd); } } diff --git a/gui/dialog.h b/gui/dialog.h index a164cc0185..9d7756a2c4 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -27,6 +27,14 @@ class Widget; class NewGui; +#define RES_STRING(id) _gui->queryResString(id) +#define CUSTOM_STRING(id) _gui->queryCustomString(id) + +// Some "common" commands sent to handleCommand() +enum { + kCloseCmd = 'clos' +}; + class Dialog { friend class Widget; friend class StaticTextWidget; @@ -48,8 +56,7 @@ public: virtual void handleKey(char key, int modifiers) // modifiers = alt/shift/ctrl etc. { if (key == 27) close(); } virtual void handleMouseMoved(int x, int y, int button); - virtual void handleCommand(uint32 cmd) - {} + virtual void handleCommand(uint32 cmd); protected: Widget* findWidget(int x, int y); // Find the widget at pos x,y if any @@ -57,7 +64,6 @@ protected: void addResText(int x, int y, int w, int h, int resID); void addButton(int x, int y, int w, int h, char hotkey, const char *label, uint32 cmd); - void addButton(int x, int y, int w, int h, char hotkey, int resID, uint32 cmd); }; class SaveLoadDialog : public Dialog { @@ -67,6 +73,13 @@ public: virtual void handleCommand(uint32 cmd); }; +class OptionsDialog : public Dialog { +public: + OptionsDialog(NewGui *gui); + + virtual void handleCommand(uint32 cmd); +}; + class PauseDialog : public Dialog { public: PauseDialog(NewGui *gui); @@ -50,7 +50,8 @@ static const char* string_map_table_custom[] = { "Show speech subtitles", //19 "Amiga pallette conversion", //20 "Except:", //21 - "Simon the Sorcerer (c) Adventuresoft" //22 + "Simon the Sorcerer (c) Adventuresoft", //22 + "Close" //23 }; static ResString string_map_table_v7[] = { diff --git a/newgui.cpp b/newgui.cpp index f660673304..4a9828bb26 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -28,10 +28,23 @@ #define vline(x, y, y2, color) line(x, y, x, y2, color); +/* + * TODO list + * - add more widgets + * - implement hotkeys + * - add "close" widget to all dialogs (with a flag to turn it off) ? + * - make dialogs "moveable" ? + * - implement the missing / incomplete dialogs + * - come up with a new look&feel / theme for the GUI + * - ... + */ + NewGui::NewGui(Scumm *s) : _s(s), _need_redraw(false) { _pauseDialog = new PauseDialog(this); _saveLoadDialog = new SaveLoadDialog(this); +// _aboutDialog = new AboutDialog(this); + _optionsDialog = new OptionsDialog(this); } void NewGui::pauseDialog() @@ -44,6 +57,16 @@ void NewGui::saveloadDialog() openDialog(_saveLoadDialog); } +void NewGui::aboutDialog() +{ +// openDialog(_aboutDialog); +} + +void NewGui::optionsDialog() +{ + openDialog(_optionsDialog); +} + void NewGui::loop() { Dialog *activeDialog = _dialogStack.top(); @@ -124,7 +147,7 @@ void NewGui::closeTopDialog() #pragma mark - -const char *NewGui::queryString(int stringno) +const char *NewGui::queryResString(int stringno) { char *result; int string; @@ -151,6 +174,11 @@ const char *NewGui::queryString(int stringno) return result; } +const char *NewGui::queryCustomString(int stringno) +{ + return string_map_table_custom[stringno]; +} + #pragma mark - byte *NewGui::getBasePtr(int x, int y) @@ -52,6 +52,9 @@ public: // Dialogs void pauseDialog(); void saveloadDialog(); + void aboutDialog(); + void optionsDialog(); + void loop(); bool isActive() { return ! _dialogStack.empty(); } @@ -65,6 +68,8 @@ protected: Dialog *_pauseDialog; Dialog *_saveLoadDialog; + Dialog *_aboutDialog; + Dialog *_optionsDialog; // sound state bool _old_soundsPaused; @@ -94,8 +99,12 @@ public: void drawChar(const char c, int x, int y); void drawString(const char *str, int x, int y, int w, byte color); - // - const char *queryString(int string); + // Query a string from the resources + const char *queryResString(int stringno); + + // Query a custom string. This is in a seperate method so that we + // can easily localize the messages in the future if we want to. + const char *queryCustomString(int stringno); }; #endif |