diff options
author | Max Horn | 2002-09-19 17:44:41 +0000 |
---|---|---|
committer | Max Horn | 2002-09-19 17:44:41 +0000 |
commit | 859ef578dc6faa881cab115fd0059a88b6a5899a (patch) | |
tree | c79215a60053ab0fe7d2966ddfbf7d5511389708 | |
parent | f644bea112becce051fb7faa85d2c1bb47c8eee5 (diff) | |
download | scummvm-rg350-859ef578dc6faa881cab115fd0059a88b6a5899a.tar.gz scummvm-rg350-859ef578dc6faa881cab115fd0059a88b6a5899a.tar.bz2 scummvm-rg350-859ef578dc6faa881cab115fd0059a88b6a5899a.zip |
moved the Scumm specific dialogs to scumm/dialogs.*
svn-id: r4973
-rw-r--r-- | Makefile.common | 2 | ||||
-rw-r--r-- | gui/dialog.cpp | 249 | ||||
-rw-r--r-- | gui/dialog.h | 96 | ||||
-rw-r--r-- | gui/newgui.cpp | 88 | ||||
-rw-r--r-- | gui/newgui.h | 9 | ||||
-rw-r--r-- | scumm/dialogs.cpp | 431 | ||||
-rw-r--r-- | scumm/dialogs.h | 137 |
7 files changed, 602 insertions, 410 deletions
diff --git a/Makefile.common b/Makefile.common index 0e0b3fb805..164539d04e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -21,7 +21,7 @@ SCUMM_OBJS = scumm/actor.o scumm/akos.o scumm/boxes.o scumm/bundle.o \ scumm/object.o scumm/resource.o scumm/resource_v2.o scumm/resource_v3.o \ scumm/resource_v4.o scumm/saveload.o scumm/script.o \ scumm/script_v1.o scumm/script_v2.o scumm/scummvm.o scumm/sound.o \ - scumm/string.o scumm/vars.o scumm/verbs.o \ + scumm/string.o scumm/vars.o scumm/verbs.o scumm/dialogs.o \ # scumm/insane.o SIMON_OBJS = simon/debug.o simon/items.o simon/midi.o simon/res.o simon/simon.o \ diff --git a/gui/dialog.cpp b/gui/dialog.cpp index e1886af83d..d9c25d15bb 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -24,13 +24,6 @@ #include "newgui.h" #include "dialog.h" #include "widget.h" -#include "ListWidget.h" -#include "config-file.h" - -#include "scumm/sound.h" -#include "sound/mididrv.h" -#include "scumm/scumm.h" -#include "scumm/imuse.h" /* * TODO list @@ -250,250 +243,8 @@ Widget *Dialog::findWidget(int x, int y) return w; } -void Dialog::addResText(int x, int y, int w, int h, int resID) -{ - // Get the string - const char *str = _gui->queryResString(resID); - if (!str) - str = "Dummy!"; - new StaticTextWidget(this, x, y, w, h, str, kTextAlignLeft); -} - void Dialog::addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey) { new ButtonWidget(this, x, y, w, h, label, cmd, hotkey); } -#pragma mark - - - -enum { - kSaveCmd = 'SAVE', - kLoadCmd = 'LOAD', - kPlayCmd = 'PLAY', - kOptionsCmd = 'OPTN', - kQuitCmd = 'QUIT' -}; - -/* - * TODO - * - Maybe go back to the old way of differentiating between the save and the load mode? - * This would include that in the load mode the list is not editable. - * - Currently the savegame list is only loaded once when the dialog is created. Instead, - * it should be loaded whenever the dialog is opened. Might want to add an open() - * method to Dialog for that. - */ - -SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm) - : Dialog (gui, 30, 20, 260, 124), _scumm(scumm) -{ - addResText(10, 7, 240, 16, 1); -// addResText(10, 7, 240, 16, 2); -// addResText(10, 7, 240, 16, 3); - - addButton(200, 20, 54, 16, RES_STRING(4), kSaveCmd, 'S'); // Save - addButton(200, 40, 54, 16, RES_STRING(5), kLoadCmd, 'L'); // Load - addButton(200, 60, 54, 16, RES_STRING(6), kPlayCmd, 'P'); // Play - addButton(200, 80, 54, 16, CUSTOM_STRING(17), kOptionsCmd, 'O'); // Options - addButton(200, 100, 54, 16, RES_STRING(8), kQuitCmd, 'Q'); // Quit - - _savegameList = new ListWidget(this, 10, 20, 180, 90); - _savegameList->setNumberingMode(kListNumberingZero); - - // Get savegame names - ScummVM::StringList l; - char name[32]; - - for (int i = 0; i <= 80; i++) { // 80 - got this value from the old GUI - _scumm->getSavegameName(i, name); - l.push_back(name); - } - - _savegameList->setList(l); -} - -void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) -{ - switch (cmd) { - case kListItemChangedCmd: - case kSaveCmd: - if (_savegameList->getSelected() >= 1 && !_savegameList->getSelectedString().isEmpty()) { - Scumm *s = _scumm; - s->_saveLoadSlot = _savegameList->getSelected(); - s->_saveLoadCompatible = false; - s->_saveLoadFlag = 1; // 1 for save, I assume (Painelf) - strcpy(s->_saveLoadName, _savegameList->getSelectedString().c_str()); - close(); - } - break; - case kListItemDoubleClickedCmd: - case kLoadCmd: - if (_savegameList->getSelected() >= 0 && !_savegameList->getSelectedString().isEmpty()) { - Scumm *s = _scumm; - s->_saveLoadSlot = _savegameList->getSelected(); - s->_saveLoadCompatible = false; - s->_saveLoadFlag = 2; // 2 for load. Magic number anyone? - close(); - } - break; - case kPlayCmd: - close(); - break; - case kOptionsCmd: - _gui->optionsDialog(); - break; - case kQuitCmd: { - _scumm->_system->quit(); - } - break; - default: - Dialog::handleCommand(sender, cmd, data); - } -} - - -#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, 16, CUSTOM_STRING(5), kSoundCmd, 'S'); // Sound - addButton( 80, 10, 40, 16, CUSTOM_STRING(6), kKeysCmd, 'K'); // Keys - addButton(150, 10, 40, 16, CUSTOM_STRING(7), kAboutCmd, 'A'); // About - addButton( 10, 35, 40, 16, CUSTOM_STRING(18), kMiscCmd, 'M'); // Misc - addButton(150, 35, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME -} - -void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) -{ - switch (cmd) { - case kSoundCmd: - _gui->soundDialog(); - break; - case kKeysCmd: - break; - case kAboutCmd: - _gui->aboutDialog(); - break; - case kMiscCmd: - break; - default: - Dialog::handleCommand(sender, cmd, data); - } -} - - -#pragma mark - - -AboutDialog::AboutDialog(NewGui *gui) - : Dialog (gui, 30, 20, 260, 124) -{ - addButton(110, 100, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME - new StaticTextWidget(this, 10, 10, 240, 16, "ScummVM " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", kTextAlignCenter); - new StaticTextWidget(this, 10, 30, 240, 16, "http://scummvm.sourceforge.net", kTextAlignCenter); - new StaticTextWidget(this, 10, 50, 240, 16, "All games (c) LucasArts", kTextAlignCenter); - new StaticTextWidget(this, 10, 64, 240, 16, "Except", kTextAlignCenter); - new StaticTextWidget(this, 10, 78, 240, 16, "Simon the Sorcerer (c) Adventuresoft", kTextAlignCenter); -} - -PauseDialog::PauseDialog(NewGui *gui) - : Dialog (gui, 50, 80, 220, 16) -{ - addResText(4, 4, 220, 16, 10); -} - -SoundDialog::SoundDialog(NewGui *gui, Scumm *scumm) - : Dialog (gui, 30, 20, 260, 110), _scumm(scumm) -{ - - // set up dialog - addButton(70, 90, 54, 16, "OK", kOKCmd, 'O'); // Confirm dialog - addButton(136, 90, 54, 16, "Cancel", kCancelCmd, 'C'); // Abort dialog - new StaticTextWidget(this, 20, 17, 85, 16, "Master volume:", kTextAlignRight); - new StaticTextWidget(this, 20, 37, 85, 16, "Music volume:", kTextAlignRight); - new StaticTextWidget(this, 20, 57, 85, 16, "SFX volume:", kTextAlignRight); - - masterVolumeSlider = new SliderWidget(this, 110, 13, 80, 16, "Volume1", kMasterVolumeChanged); - musicVolumeSlider = new SliderWidget(this, 110, 33, 80, 16, "Volume2", kMusicVolumeChanged); - sfxVolumeSlider = new SliderWidget(this, 110, 53, 80, 16, "Volume3", kSfxVolumeChanged); - - masterVolumeSlider->setMinValue(0); masterVolumeSlider->setMaxValue(256); - musicVolumeSlider->setMinValue(0); musicVolumeSlider->setMaxValue(256); - sfxVolumeSlider->setMinValue(0); sfxVolumeSlider->setMaxValue(256); - - masterVolumeLabel = new StaticTextWidget(this, 195, 17, 60, 16, "Volume1", kTextAlignLeft); - musicVolumeLabel = new StaticTextWidget(this, 195, 37, 60, 16, "Volume2", kTextAlignLeft); - sfxVolumeLabel = new StaticTextWidget(this, 195, 57, 60, 16, "Volume3", kTextAlignLeft); - - masterVolumeLabel->setFlags(WIDGET_CLEARBG); - musicVolumeLabel->setFlags(WIDGET_CLEARBG); - sfxVolumeLabel->setFlags(WIDGET_CLEARBG); -} - -void SoundDialog::open() -{ - Dialog::open(); - - // get current variables - _soundVolumeMaster = _scumm->_sound->_sound_volume_master; - _soundVolumeMusic = _scumm->_sound->_sound_volume_music; - _soundVolumeSfx = _scumm->_sound->_sound_volume_sfx; - - masterVolumeSlider->setValue(_soundVolumeMaster); - musicVolumeSlider->setValue(_soundVolumeMusic); - sfxVolumeSlider->setValue(_soundVolumeSfx); - - masterVolumeLabel->setValue(_soundVolumeMaster); - musicVolumeLabel->setValue(_soundVolumeMusic); - sfxVolumeLabel->setValue(_soundVolumeSfx); -} - - -void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) -{ - switch (cmd) { - case kMasterVolumeChanged: - _soundVolumeMaster = masterVolumeSlider->getValue(); - masterVolumeLabel->setValue(_soundVolumeMaster); - masterVolumeLabel->draw(); - break; - case kMusicVolumeChanged: - _soundVolumeMusic = musicVolumeSlider->getValue(); - musicVolumeLabel->setValue(_soundVolumeMusic); - musicVolumeLabel->draw(); - break; - case kSfxVolumeChanged: - _soundVolumeSfx = sfxVolumeSlider->getValue(); - sfxVolumeLabel->setValue(_soundVolumeSfx); - sfxVolumeLabel->draw(); - break; - case kOKCmd: { - // FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp - _scumm->_sound->_sound_volume_master = _soundVolumeMaster; // Master - _scumm->_sound->_sound_volume_music = _soundVolumeMusic; // Music - _scumm->_sound->_sound_volume_sfx = _soundVolumeSfx; // SFX - - _scumm->_imuse->set_music_volume(_soundVolumeMusic); - _scumm->_imuse->set_master_volume(_soundVolumeMaster); - _scumm->_mixer->setVolume(_soundVolumeSfx); - _scumm->_mixer->setMusicVolume(_soundVolumeMusic); - - scummcfg->setInt("master_volume", _soundVolumeMaster); - scummcfg->setInt("music_volume", _soundVolumeMusic); - scummcfg->setInt("sfx_volume", _soundVolumeSfx); - scummcfg->flush(); - } - case kCancelCmd: - close(); - break; - default: - Dialog::handleCommand(sender, cmd, data); - } -} diff --git a/gui/dialog.h b/gui/dialog.h index 3d1577b9e3..a530a79075 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -22,14 +22,9 @@ #define DIALOG_H #include "scummsys.h" -#include "widget.h" -#include "ListWidget.h" +#include "widget.h" // For CommandReceiver class NewGui; -class Scumm; - -#define RES_STRING(id) _gui->queryResString(id) -#define CUSTOM_STRING(id) _gui->queryCustomString(id) // Some "common" commands sent to handleCommand() enum { @@ -75,96 +70,7 @@ public: protected: Widget* findWidget(int x, int y); // Find the widget at pos x,y if any - void addResText(int x, int y, int w, int h, int resID); void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey); }; - -class SaveLoadDialog : public Dialog { -public: - SaveLoadDialog(NewGui *gui, Scumm *scumm); - - virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); - -protected: - Scumm *_scumm; - ListWidget *_savegameList; -}; - - -class AboutDialog : public Dialog { -public: - AboutDialog(NewGui *gui); -}; - -class SoundDialog; -class KeysDialog; -class MiscDialog; - -class OptionsDialog : public Dialog { -protected: - SoundDialog *_soundDialog; - KeysDialog *_keysDialog; - MiscDialog *_miscDialog; - -public: - OptionsDialog(NewGui *gui); - - virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); -}; - -class PauseDialog : public Dialog { -public: - PauseDialog(NewGui *gui); - - virtual void handleMouseDown(int x, int y, int button, int clickCount) - { close(); } - virtual void handleKeyDown(char key, int modifiers) - { - if (key == 32) - close(); - else - Dialog::handleKeyDown(key, modifiers); - } - - // Enforce no transparency! - virtual void setupScreenBuf() {} - virtual void teardownScreenBuf() {} - -}; - - -class SoundDialog : public Dialog { -public: - SoundDialog(NewGui *gui, Scumm *scumm); - - enum { - kMasterVolumeChanged = 'mavc', - kMusicVolumeChanged = 'muvc', - kSfxVolumeChanged = 'sfvc', - kOKCmd = 'ok ', - kCancelCmd = 'cncl', - }; - - virtual void open(); - - virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); - -protected: - Scumm *_scumm; - - int _soundVolumeMaster; - int _soundVolumeMusic; - int _soundVolumeSfx; - - SliderWidget *masterVolumeSlider; - SliderWidget *musicVolumeSlider; - SliderWidget *sfxVolumeSlider; - - StaticTextWidget *masterVolumeLabel; - StaticTextWidget *musicVolumeLabel; - StaticTextWidget *sfxVolumeLabel; -}; - - #endif diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 5485895855..08d51b7c83 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -23,8 +23,8 @@ #include "scumm/scumm.h" #include "scumm/sound.h" #include "newgui.h" -#include "guimaps.h" #include "dialog.h" +#include "scumm/dialogs.h" /* * TODO list @@ -38,7 +38,35 @@ * - ... */ - +// Built-in font +static byte guifont[] = {0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7, +7,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,8,5,8,8,7,7,7,6,7,7,7,7,7,5,6,7,5,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,3,5,0,8,7,7,7,7,7,7,0,6,7,7,7,5,5,5,7,0,6,8,8,7,7,7,7,7,0,7,7,0,0, +0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,1,3,6,12, +24,62,3,0,128,192,96,48,24,124,192,0,0,3,62,24,12,6,3,1,0,192,124,24,48,96,192,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,74,72,0,0,0,0,0,128,128,128,0,0,0,0,0,0,0,0,0,0,0,0,0,60,66,153,161,161,153,66,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,96,96,96,96,0,0,96,0,102,102,102,0,0,0,0,0,102,102,255,102,255,102,102,0,24,62,96,60,6,124,24,0,98,102,12,24,48,102,70,0,60,102,60,56,103,102,63,0,96,48,16,0,0,0,0,0,24,48,96,96,96,48,24,0,96,48,24,24,24,48,96,0, +0,102,60,255,60,102,0,0,0,24,24,126,24,24,0,0,0,0,0,0,0,48,48,96,0,0,0,126,0,0,0,0,0,0,0,0,0,96,96,0,0,3,6,12,24,48,96,0,60,102,102,102,102,102,60,0,24,24,56,24,24,24,126,0,60,102,6,12,48,96,126,0,60,102,6,28,6,102,60,0,6, +14,30,102,127,6,6,0,126,96,124,6,6,102,60,0,60,102,96,124,102,102,60,0,126,102,12,24,24,24,24,0,60,102,102,60,102,102,60,0,60,102,102,62,6,102,60,0,0,0,96,0,0,96,0,0,0,0,48,0,0,48,48,96,14,24,48,96,48,24,14,0,0,0,120,0,120,0,0,0,112,24, +12,6,12,24,112,0,60,102,6,12,24,0,24,0,0,0,0,255,255,0,0,0,24,60,102,126,102,102,102,0,124,102,102,124,102,102,124,0,60,102,96,96,96,102,60,0,120,108,102,102,102,108,120,0,126,96,96,120,96,96,126,0,126,96,96,120,96,96,96,0,60,102,96,110,102,102,60,0,102,102,102, +126,102,102,102,0,120,48,48,48,48,48,120,0,30,12,12,12,12,108,56,0,102,108,120,112,120,108,102,0,96,96,96,96,96,96,126,0,99,119,127,107,99,99,99,0,102,118,126,126,110,102,102,0,60,102,102,102,102,102,60,0,124,102,102,124,96,96,96,0,60,102,102,102,102,60,14,0,124,102,102,124, +120,108,102,0,60,102,96,60,6,102,60,0,126,24,24,24,24,24,24,0,102,102,102,102,102,102,60,0,102,102,102,102,102,60,24,0,99,99,99,107,127,119,99,0,102,102,60,24,60,102,102,0,102,102,102,60,24,24,24,0,126,6,12,24,48,96,126,0,120,96,96,96,96,96,120,0,3,6,12,24,48, +96,192,0,120,24,24,24,24,24,120,0,0,0,0,0,0,219,219,0,0,0,0,0,0,0,0,255,102,102,102,0,0,0,0,0,0,0,60,6,62,102,62,0,0,96,96,124,102,102,124,0,0,0,60,96,96,96,60,0,0,6,6,62,102,102,62,0,0,0,60,102,126,96,60,0,0,14,24,62,24,24, +24,0,0,0,62,102,102,62,6,124,0,96,96,124,102,102,102,0,0,48,0,112,48,48,120,0,0,12,0,12,12,12,12,120,0,96,96,108,120,108,102,0,0,112,48,48,48,48,120,0,0,0,102,127,127,107,99,0,0,0,124,102,102,102,102,0,0,0,60,102,102,102,60,0,0,0,124,102,102,124,96, +96,0,0,62,102,102,62,6,6,0,0,124,102,96,96,96,0,0,0,62,96,60,6,124,0,0,24,126,24,24,24,14,0,0,0,102,102,102,102,62,0,0,0,102,102,102,60,24,0,0,0,99,107,127,62,54,0,0,0,102,60,24,60,102,0,0,0,102,102,102,62,12,120,0,0,126,12,24,48,126,0, +24,48,48,96,48,48,24,0,96,96,96,0,96,96,96,0,96,48,48,24,48,48,96,0,0,0,0,0,0,0,0,0,8,12,14,255,255,14,12,8,60,102,96,96,102,60,24,56,102,0,102,102,102,102,62,0,12,24,60,102,126,96,60,0,24,36,60,6,62,102,62,0,102,0,60,6,62,102,62,0,48, +24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,60,96,96,96,60,24,56,24,36,60,102,126,96,60,0,102,0,60,102,126,96,60,0,48,24,60,102,126,96,60,0,0,216,0,112,48,48,120,0,48,72,0,112,48,48,120,0,96,48,0,112,48,48,120,0,102,24,60,102,126,102,102,0,0,0, +0,0,0,0,0,0,24,48,124,96,120,96,124,0,0,0,108,26,126,216,110,0,30,40,40,126,72,136,142,0,24,36,60,102,102,102,60,0,102,0,60,102,102,102,60,0,48,24,60,102,102,102,60,0,24,36,0,102,102,102,62,0,48,24,102,102,102,102,62,0,0,0,0,0,0,0,0,0,102,60,102, +102,102,102,60,0,102,0,102,102,102,102,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,28,54,54,124,102,102,124,64,0,0,0}; + +// Constructor NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0), _use_alpha_blending(true), _need_redraw(false),_prepare_for_gui(true), _pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0), @@ -49,7 +77,7 @@ NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0), void NewGui::pauseDialog() { if (!_pauseDialog) - _pauseDialog = new PauseDialog(this); + _pauseDialog = new PauseDialog(this, _s); _pauseDialog->open(); } @@ -60,27 +88,13 @@ void NewGui::saveloadDialog() _saveLoadDialog->open(); } -void NewGui::aboutDialog() -{ - if (!_aboutDialog) - _aboutDialog = new AboutDialog(this); - _aboutDialog->open(); -} - void NewGui::optionsDialog() { if (!_optionsDialog) - _optionsDialog = new OptionsDialog(this); + _optionsDialog = new OptionsDialog(this, _s); _optionsDialog->open(); } -void NewGui::soundDialog() -{ - if (!_soundDialog) - _soundDialog = new SoundDialog(this, _s); - _soundDialog->open(); -} - void NewGui::loop() { Dialog *activeDialog = _dialogStack.top(); @@ -266,44 +280,6 @@ void NewGui::closeTopDialog() _need_redraw = true; } -#pragma mark - - -const char *NewGui::queryResString(int stringno) -{ - char *result; - int string; - - if (stringno == 0) - return NULL; - - if (_s->_features & GF_AFTER_V7) - string = _s->_vars[string_map_table_v7[stringno - 1].num]; - else if (_s->_features & GF_AFTER_V6) - string = _s->_vars[string_map_table_v6[stringno - 1].num]; - else - string = string_map_table_v5[stringno - 1].num; - - result = (char *)_s->getStringAddress(string); - if (result && *result == '/') { - _s->translateText((char*)result, (char*)&_s->transText); - strcpy((char*)result, (char*)&_s->transText); - } - - if (!result) { // Gracelessly degrade to english :) - if (_s->_features & GF_AFTER_V6) - return string_map_table_v6[stringno - 1].string; - else - return string_map_table_v5[stringno - 1].string; - } - - return result; -} - -const char *NewGui::queryCustomString(int stringno) -{ - return string_map_table_custom[stringno]; -} - #pragma mark - diff --git a/gui/newgui.h b/gui/newgui.h index f8e085f18a..bf60f3ed6b 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -71,9 +71,7 @@ public: // Dialogs void pauseDialog(); void saveloadDialog(); - void aboutDialog(); void optionsDialog(); - void soundDialog(); void loop(); @@ -145,13 +143,6 @@ public: void drawString(const char *str, int x, int y, int w, int16 color, int align = kTextAlignLeft); void drawBitmap(uint32 bitmap[8], int x, int y, int16 color); - - // 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 diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp new file mode 100644 index 0000000000..3777fd45fc --- /dev/null +++ b/scumm/dialogs.cpp @@ -0,0 +1,431 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + */ + +#include "stdafx.h" +#include "dialogs.h" +#include "sound.h" +#include "sound/mididrv.h" +#include "scumm.h" +#include "imuse.h" + +#include "gui/newgui.h" +#include "gui/ListWidget.h" +#include "common/config-file.h" + + +struct ResString { + int num; + char string[80]; +}; + +// String maps +static const char* string_map_table_custom[] = { + "Master Volume :", //0 + "Music Volume :", //1 + "SFX Volume :", //2 + "+", //3 + "-", //4 + "Sound", //5 + "Keys", //6 + "About", //7 + "Pocket ScummVM", //8 + "Build " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", //9 + "ScummVM http://scummvm.sourceforge.net", //10 + "All games (c) LucasArts", //11 + "Quit", //12 + "Pause", //13 + "Save", //14 + "Skip", //15 + "Hide", //16 + "Options", //17 + "Misc", //18 + "Show speech subtitles", //19 + "Amiga palette conversion", //20 + "Except:", //21 + "Simon the Sorcerer (c) Adventuresoft", //22 + "Close" //23 +}; + +static ResString string_map_table_v7[] = { + {96, "game name and version"}, //that's how it's supposed to be + {77, "Select a game to LOAD"}, + {76, "Name your SAVE game"}, + {70, "save"}, //boot8 + {71, "load"}, //boot9 + {72, "play"}, //boot10 + {73, "cancel"}, //boot11 + {74, "quit"}, //boot12 + {75, "ok"}, //boot13 + {85, "game paused"}, // boot3 + + /* this is the almost complete string map for v7 + {63, "how may I serve you?"}, + {64, "the dig v1.0"}, //(game name/version) + {67, "text display only"}, + {68, "c:\\dig"}, //boot007 (save path ?) + {69, "the dig"}, //boot21 (game name) + {70, "save"}, //boot8 + {71, "load"}, //boot9 + {72, "play"}, //boot10 + {73, "cancel"}, //boot11 + {74, "quit"}, //boot12 + {75, "ok"}, //boot13 + {76, "name your save game"}, //boot19 + {77, "select a game to load"}, //boot20 + {78, "you must enter a name"},//boot14 + {79, "saving '%s'"}, //boot17 + {80, "loading '%s'"}, //boot18 + {81, "the game was NOT saved"}, //boot15 + {82, "the game was NOT loaded"}, //boot16 + {83, "how may I serve you?"}, + {84, "how may I serve you?"}, + {85, "game paused"}, // boot3 + {86, "Are you sure you want to restart"}, + {87, "Are you sure you want to quit?"}, //boot05 + {89, "how may I serve you?"}, + {90, "music"}, //boot22 + {91, "voice"}, //boot23 + {92, "sfx"}, //boot24 + {93, "disabled"}, //boot25 + {94, "text speed"}, //boot26 + {95, "text display"}, //boot27 + {96, "the dig v1.0"},*/ + +}; + +static ResString string_map_table_v6[] = { + {117, "How may I serve you?"}, + {109, "Select a game to LOAD"}, + {108, "Name your SAVE game"}, + {96, "Save"}, + {97, "Load"}, + {98, "Play"}, + {99, "Cancel"}, + {100, "Quit"}, + {101, "Ok"}, + {93, "Game paused"}, +}; + +static ResString string_map_table_v5[] = { + {28, "How may I serve you?"}, + {20, "Select a game to LOAD"}, + {19, "Name your SAVE game"}, + {7, "Save"}, + {8, "Load"}, + {9, "Play"}, + {10, "Cancel"}, + {11, "Quit"}, + {12, "Ok"}, + {4, "Game paused"} +}; + + +#pragma mark - + + +void ScummDialog::addResText(int x, int y, int w, int h, int resID) +{ + // Get the string + const char *str = queryResString(resID); + if (!str) + str = "Dummy!"; + new StaticTextWidget(this, x, y, w, h, str, kTextAlignLeft); +} + + +const char *ScummDialog::queryResString(int stringno) +{ + char *result; + int string; + + if (stringno == 0) + return NULL; + + if (_scumm->_features & GF_AFTER_V7) + string = _scumm->_vars[string_map_table_v7[stringno - 1].num]; + else if (_scumm->_features & GF_AFTER_V6) + string = _scumm->_vars[string_map_table_v6[stringno - 1].num]; + else + string = string_map_table_v5[stringno - 1].num; + + result = (char *)_scumm->getStringAddress(string); + if (result && *result == '/') { + _scumm->translateText((char*)result, (char*)&_scumm->transText); + strcpy((char*)result, (char*)&_scumm->transText); + } + + if (!result) { // Gracelessly degrade to english :) + if (_scumm->_features & GF_AFTER_V6) + return string_map_table_v6[stringno - 1].string; + else + return string_map_table_v5[stringno - 1].string; + } + + return result; +} + +const char *ScummDialog::queryCustomString(int stringno) +{ + return string_map_table_custom[stringno]; +} + + +#pragma mark - + + +enum { + kSaveCmd = 'SAVE', + kLoadCmd = 'LOAD', + kPlayCmd = 'PLAY', + kOptionsCmd = 'OPTN', + kQuitCmd = 'QUIT' +}; + +/* + * TODO + * - Maybe go back to the old way of differentiating between the save and the load mode? + * This would include that in the load mode the list is not editable. + * - Currently the savegame list is only loaded once when the dialog is created. Instead, + * it should be loaded whenever the dialog is opened. Might want to add an open() + * method to Dialog for that. + */ + +SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 30, 20, 260, 124) +{ + addResText(10, 7, 240, 16, 1); +// addResText(10, 7, 240, 16, 2); +// addResText(10, 7, 240, 16, 3); + + addButton(200, 20, 54, 16, RES_STRING(4), kSaveCmd, 'S'); // Save + addButton(200, 40, 54, 16, RES_STRING(5), kLoadCmd, 'L'); // Load + addButton(200, 60, 54, 16, RES_STRING(6), kPlayCmd, 'P'); // Play + addButton(200, 80, 54, 16, CUSTOM_STRING(17), kOptionsCmd, 'O'); // Options + addButton(200, 100, 54, 16, RES_STRING(8), kQuitCmd, 'Q'); // Quit + + _savegameList = new ListWidget(this, 10, 20, 180, 90); + _savegameList->setNumberingMode(kListNumberingZero); + + // Get savegame names + ScummVM::StringList l; + char name[32]; + + for (int i = 0; i <= 80; i++) { // 80 - got this value from the old GUI + _scumm->getSavegameName(i, name); + l.push_back(name); + } + + _savegameList->setList(l); +} + +void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) +{ + switch (cmd) { + case kListItemChangedCmd: + case kSaveCmd: + if (_savegameList->getSelected() >= 1 && !_savegameList->getSelectedString().isEmpty()) { + Scumm *s = _scumm; + s->_saveLoadSlot = _savegameList->getSelected(); + s->_saveLoadCompatible = false; + s->_saveLoadFlag = 1; // 1 for save, I assume (Painelf) + strcpy(s->_saveLoadName, _savegameList->getSelectedString().c_str()); + close(); + } + break; + case kListItemDoubleClickedCmd: + case kLoadCmd: + if (_savegameList->getSelected() >= 0 && !_savegameList->getSelectedString().isEmpty()) { + Scumm *s = _scumm; + s->_saveLoadSlot = _savegameList->getSelected(); + s->_saveLoadCompatible = false; + s->_saveLoadFlag = 2; // 2 for load. Magic number anyone? + close(); + } + break; + case kPlayCmd: + close(); + break; + case kOptionsCmd: + _gui->optionsDialog(); + break; + case kQuitCmd: { + _scumm->_system->quit(); + } + break; + default: + Dialog::handleCommand(sender, cmd, data); + } +} + + +#pragma mark - + +enum { + kSoundCmd = 'SOUN', + kKeysCmd = 'KEYS', + kAboutCmd = 'ABOU', + kMiscCmd = 'OPTN' +}; + +OptionsDialog::OptionsDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 50, 80, 210, 60) +{ + addButton( 10, 10, 40, 16, CUSTOM_STRING(5), kSoundCmd, 'S'); // Sound + addButton( 80, 10, 40, 16, CUSTOM_STRING(6), kKeysCmd, 'K'); // Keys + addButton(150, 10, 40, 16, CUSTOM_STRING(7), kAboutCmd, 'A'); // About + addButton( 10, 35, 40, 16, CUSTOM_STRING(18), kMiscCmd, 'M'); // Misc + addButton(150, 35, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME + + _aboutDialog = new AboutDialog(gui, scumm); + _soundDialog = new SoundDialog(gui, scumm); +} + +OptionsDialog::~OptionsDialog() +{ + delete _aboutDialog; + delete _soundDialog; +} + +void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) +{ + switch (cmd) { + case kSoundCmd: + _soundDialog->open(); + break; + case kKeysCmd: + break; + case kAboutCmd: + _aboutDialog->open(); + break; + case kMiscCmd: + break; + default: + Dialog::handleCommand(sender, cmd, data); + } +} + + +#pragma mark - + +AboutDialog::AboutDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 30, 20, 260, 124) +{ + addButton(110, 100, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME + new StaticTextWidget(this, 10, 10, 240, 16, "ScummVM " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", kTextAlignCenter); + new StaticTextWidget(this, 10, 30, 240, 16, "http://scummvm.sourceforge.net", kTextAlignCenter); + new StaticTextWidget(this, 10, 50, 240, 16, "All games (c) LucasArts", kTextAlignCenter); + new StaticTextWidget(this, 10, 64, 240, 16, "Except", kTextAlignCenter); + new StaticTextWidget(this, 10, 78, 240, 16, "Simon the Sorcerer (c) Adventuresoft", kTextAlignCenter); +} + +PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 50, 80, 220, 16) +{ + addResText(4, 4, 220, 16, 10); +} + +SoundDialog::SoundDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 30, 20, 260, 110) +{ + + // set up dialog + addButton(70, 90, 54, 16, "OK", kOKCmd, 'O'); // Confirm dialog + addButton(136, 90, 54, 16, "Cancel", kCancelCmd, 'C'); // Abort dialog + new StaticTextWidget(this, 20, 17, 85, 16, "Master volume:", kTextAlignRight); + new StaticTextWidget(this, 20, 37, 85, 16, "Music volume:", kTextAlignRight); + new StaticTextWidget(this, 20, 57, 85, 16, "SFX volume:", kTextAlignRight); + + masterVolumeSlider = new SliderWidget(this, 110, 13, 80, 16, "Volume1", kMasterVolumeChanged); + musicVolumeSlider = new SliderWidget(this, 110, 33, 80, 16, "Volume2", kMusicVolumeChanged); + sfxVolumeSlider = new SliderWidget(this, 110, 53, 80, 16, "Volume3", kSfxVolumeChanged); + + masterVolumeSlider->setMinValue(0); masterVolumeSlider->setMaxValue(256); + musicVolumeSlider->setMinValue(0); musicVolumeSlider->setMaxValue(256); + sfxVolumeSlider->setMinValue(0); sfxVolumeSlider->setMaxValue(256); + + masterVolumeLabel = new StaticTextWidget(this, 195, 17, 60, 16, "Volume1", kTextAlignLeft); + musicVolumeLabel = new StaticTextWidget(this, 195, 37, 60, 16, "Volume2", kTextAlignLeft); + sfxVolumeLabel = new StaticTextWidget(this, 195, 57, 60, 16, "Volume3", kTextAlignLeft); + + masterVolumeLabel->setFlags(WIDGET_CLEARBG); + musicVolumeLabel->setFlags(WIDGET_CLEARBG); + sfxVolumeLabel->setFlags(WIDGET_CLEARBG); +} + +void SoundDialog::open() +{ + Dialog::open(); + + // get current variables + _soundVolumeMaster = _scumm->_sound->_sound_volume_master; + _soundVolumeMusic = _scumm->_sound->_sound_volume_music; + _soundVolumeSfx = _scumm->_sound->_sound_volume_sfx; + + masterVolumeSlider->setValue(_soundVolumeMaster); + musicVolumeSlider->setValue(_soundVolumeMusic); + sfxVolumeSlider->setValue(_soundVolumeSfx); + + masterVolumeLabel->setValue(_soundVolumeMaster); + musicVolumeLabel->setValue(_soundVolumeMusic); + sfxVolumeLabel->setValue(_soundVolumeSfx); +} + + +void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) +{ + switch (cmd) { + case kMasterVolumeChanged: + _soundVolumeMaster = masterVolumeSlider->getValue(); + masterVolumeLabel->setValue(_soundVolumeMaster); + masterVolumeLabel->draw(); + break; + case kMusicVolumeChanged: + _soundVolumeMusic = musicVolumeSlider->getValue(); + musicVolumeLabel->setValue(_soundVolumeMusic); + musicVolumeLabel->draw(); + break; + case kSfxVolumeChanged: + _soundVolumeSfx = sfxVolumeSlider->getValue(); + sfxVolumeLabel->setValue(_soundVolumeSfx); + sfxVolumeLabel->draw(); + break; + case kOKCmd: { + // FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp + _scumm->_sound->_sound_volume_master = _soundVolumeMaster; // Master + _scumm->_sound->_sound_volume_music = _soundVolumeMusic; // Music + _scumm->_sound->_sound_volume_sfx = _soundVolumeSfx; // SFX + + _scumm->_imuse->set_music_volume(_soundVolumeMusic); + _scumm->_imuse->set_master_volume(_soundVolumeMaster); + _scumm->_mixer->setVolume(_soundVolumeSfx); + _scumm->_mixer->setMusicVolume(_soundVolumeMusic); + + scummcfg->setInt("master_volume", _soundVolumeMaster); + scummcfg->setInt("music_volume", _soundVolumeMusic); + scummcfg->setInt("sfx_volume", _soundVolumeSfx); + scummcfg->flush(); + } + case kCancelCmd: + close(); + break; + default: + Dialog::handleCommand(sender, cmd, data); + } +} diff --git a/scumm/dialogs.h b/scumm/dialogs.h new file mode 100644 index 0000000000..61260ac6ca --- /dev/null +++ b/scumm/dialogs.h @@ -0,0 +1,137 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + */ + +#ifndef SCUMM_DIALOGS_H +#define SCUMM_DIALOGS_H + +#include "gui/dialog.h" + +class ListWidget; +class Scumm; + +#define RES_STRING(id) queryResString(id) +#define CUSTOM_STRING(id) queryCustomString(id) + +class ScummDialog : public Dialog { +public: + ScummDialog(NewGui *gui, Scumm *scumm, int x, int y, int w, int h) + : Dialog(gui, x, y, w, h), _scumm(scumm) {} + +protected: + Scumm *_scumm; + + void addResText(int x, int y, int w, int h, int resID); + + // 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); +}; + +class SaveLoadDialog : public ScummDialog { +public: + SaveLoadDialog(NewGui *gui, Scumm *scumm); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + +protected: + ListWidget *_savegameList; +}; + + +class AboutDialog : public ScummDialog { +public: + AboutDialog(NewGui *gui, Scumm *scumm); +}; + +class SoundDialog; +class KeysDialog; +class MiscDialog; + +class OptionsDialog : public ScummDialog { +protected: + AboutDialog *_aboutDialog; + SoundDialog *_soundDialog; + KeysDialog *_keysDialog; + MiscDialog *_miscDialog; + +public: + OptionsDialog(NewGui *gui, Scumm *scumm); + ~OptionsDialog(); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); +}; + +class PauseDialog : public ScummDialog { +public: + PauseDialog(NewGui *gui, Scumm *scumm); + + virtual void handleMouseDown(int x, int y, int button, int clickCount) + { close(); } + virtual void handleKeyDown(char key, int modifiers) + { + if (key == 32) + close(); + else + Dialog::handleKeyDown(key, modifiers); + } + + // Enforce no transparency! + virtual void setupScreenBuf() {} + virtual void teardownScreenBuf() {} + +}; + + +class SoundDialog : public ScummDialog { +public: + SoundDialog(NewGui *gui, Scumm *scumm); + + enum { + kMasterVolumeChanged = 'mavc', + kMusicVolumeChanged = 'muvc', + kSfxVolumeChanged = 'sfvc', + kOKCmd = 'ok ', + kCancelCmd = 'cncl', + }; + + virtual void open(); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + +protected: + + int _soundVolumeMaster; + int _soundVolumeMusic; + int _soundVolumeSfx; + + SliderWidget *masterVolumeSlider; + SliderWidget *musicVolumeSlider; + SliderWidget *sfxVolumeSlider; + + StaticTextWidget *masterVolumeLabel; + StaticTextWidget *musicVolumeLabel; + StaticTextWidget *sfxVolumeLabel; +}; + + +#endif |