diff options
-rw-r--r-- | gui/dialog.cpp | 16 | ||||
-rw-r--r-- | gui/dialog.h | 4 | ||||
-rw-r--r-- | gui/launcher.cpp | 6 | ||||
-rw-r--r-- | gui/message.cpp | 2 | ||||
-rw-r--r-- | gui/widget.cpp | 12 | ||||
-rw-r--r-- | gui/widget.h | 10 | ||||
-rw-r--r-- | scumm/dialogs.cpp | 194 | ||||
-rw-r--r-- | scumm/dialogs.h | 58 | ||||
-rw-r--r-- | sound/mididrv.cpp | 30 |
9 files changed, 191 insertions, 141 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 95df03f1db..31d980f8dd 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -38,6 +38,18 @@ * ... */ +Dialog::~Dialog() +{ + Widget *w = _firstWidget, *next; + while (w) { + next = w->_next; + w->_next = 0; + delete w; + w = next; + } + _firstWidget = 0; +} + void Dialog::open() { Widget *w = _firstWidget; @@ -243,8 +255,8 @@ Widget *Dialog::findWidget(int x, int y) return w; } -Widget *Dialog::addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey) +Widget *Dialog::addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey) { - return new ButtonWidget(this, x, y, w, h, label, cmd, hotkey); + return new ButtonWidget(this, x, y, 54, 16, label, cmd, hotkey); } diff --git a/gui/dialog.h b/gui/dialog.h index 0611b22ead..509ae6d385 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -48,7 +48,7 @@ public: : _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0), _mouseWidget(0), _focusedWidget(0), _visible(false) {} - virtual ~Dialog() {}; + virtual ~Dialog(); virtual void open(); virtual void close(); @@ -70,7 +70,7 @@ public: protected: Widget* findWidget(int x, int y); // Find the widget at pos x,y if any - Widget* addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey); + Widget* addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey); }; #endif diff --git a/gui/launcher.cpp b/gui/launcher.cpp index f602b1bb77..4238fbfc13 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -48,9 +48,9 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector) : Dialog(gui, 0, 0, 320, 200), _detector(detector) { // Add three buttons at the bottom - addButton(1*(_w - 54)/6, _h - 24, 54, 16, "Quit", kQuitCmd, 'Q'); - addButton(3*(_w - 54)/6, _h - 24, 54, 16, "Options", kOptionsCmd, 'O'); - _startButton = addButton(5*(_w - 54)/6, _h - 24, 54, 16, "Start", kStartCmd, 'S'); + addButton(1*(_w - 54)/6, _h - 24, "Quit", kQuitCmd, 'Q'); + addButton(3*(_w - 54)/6, _h - 24, "Options", kOptionsCmd, 'O'); + _startButton = addButton(5*(_w - 54)/6, _h - 24, "Start", kStartCmd, 'S'); _startButton->setEnabled(false); // Add list with game titles diff --git a/gui/message.cpp b/gui/message.cpp index a2b890785c..91c37763f9 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -69,5 +69,5 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message) } // FIXME - the vertical position has to be adjusted - addButton((_w - 54)/2, _h - 24, 54, 16, "OK", kCloseCmd, '\n'); // Confirm dialog + addButton((_w - kButtonWidth)/2, _h - 24, "OK", kCloseCmd, '\n'); // Confirm dialog } diff --git a/gui/widget.cpp b/gui/widget.cpp index 39c2a6b69b..463c0a7b3d 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -103,9 +103,7 @@ void StaticTextWidget::setValue(int value) void StaticTextWidget::drawWidget(bool hilite) { NewGui *gui = _boss->getGui(); - gui->drawString(_label.c_str(), _x, _y, _w, - !isEnabled() ? gui->_color : - hilite ? gui->_textcolorhi : gui->_textcolor, _align); + gui->drawString(_label.c_str(), _x, _y, _w, gui->_textcolor, _align); } @@ -125,6 +123,14 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) sendCommand(_cmd, 0); } +void ButtonWidget::drawWidget(bool hilite) +{ + NewGui *gui = _boss->getGui(); + gui->drawString(_label.c_str(), _x, _y, _w, + !isEnabled() ? gui->_color : + hilite ? gui->_textcolorhi : gui->_textcolor, _align); +} + #pragma mark - diff --git a/gui/widget.h b/gui/widget.h index 066252b0ec..718a50f444 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -47,6 +47,13 @@ enum { kScrollBarWidget = 'SCRB' }; +enum { + kButtonWidth = 54, + kButtonHeight = 16, +}; + + + class CommandReceiver; class CommandSender; @@ -155,6 +162,9 @@ public: void handleMouseUp(int x, int y, int button, int clickCount); void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + +protected: + void drawWidget(bool hilite); }; /* CheckboxWidget */ diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index b6c20139c5..811f104aad 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -34,7 +34,6 @@ # pragma warning( disable : 4068 ) #endif - struct ResString { int num; char string[80]; @@ -284,7 +283,6 @@ const char *ScummDialog::queryCustomString(int stringno) #pragma mark - - enum { kSaveCmd = 'SAVE', kLoadCmd = 'LOAD', @@ -309,11 +307,11 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm) // addResText(10, 7, 240, 16, 2); // addResText(10, 7, 240, 16, 3); - addButton(200, 20, 54, 16, queryResString(4), kSaveCmd, 'S'); // Save - addButton(200, 40, 54, 16, queryResString(5), kLoadCmd, 'L'); // Load - addButton(200, 60, 54, 16, queryResString(6), kPlayCmd, 'P'); // Play - addButton(200, 80, 54, 16, queryCustomString(17), kOptionsCmd, 'O'); // Options - addButton(200, 100, 54, 16, queryResString(8), kQuitCmd, 'Q'); // Quit + addButton(200, 20, queryResString(4), kSaveCmd, 'S'); // Save + addButton(200, 40, queryResString(5), kLoadCmd, 'L'); // Load + addButton(200, 60, queryResString(6), kPlayCmd, 'P'); // Play + addButton(200, 80, queryCustomString(17), kOptionsCmd, 'O'); // Options + addButton(200, 100, queryResString(8), kQuitCmd, 'Q'); // Quit _savegameList = new ListWidget(this, 10, 20, 180, 90); _savegameList->setNumberingMode(kListNumberingZero); @@ -362,7 +360,7 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat _scumm->_system->quit(); break; default: - Dialog::handleCommand(sender, cmd, data); + ScummDialog::handleCommand(sender, cmd, data); } } @@ -370,105 +368,82 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat #pragma mark - enum { - kSoundCmd = 'SOUN', + kMasterVolumeChanged = 'mavc', + kMusicVolumeChanged = 'muvc', + kSfxVolumeChanged = 'sfvc', + kOKCmd = 'ok ', + kCancelCmd = 'cncl', +}; + +enum { kKeysCmd = 'KEYS', kAboutCmd = 'ABOU', - kMiscCmd = 'OPTN' }; OptionsDialog::OptionsDialog(NewGui *gui, Scumm *scumm) - : ScummDialog(gui, scumm, 50, 80, 210, 60) -{ - addButton( 10, 10, 40, 16, queryCustomString(5), kSoundCmd, 'S'); // Sound - addButton( 80, 10, 40, 16, queryCustomString(6), kKeysCmd, 'K'); // Keys - addButton(150, 10, 40, 16, queryCustomString(7), kAboutCmd, 'A'); // About - addButton( 10, 35, 40, 16, queryCustomString(18), kMiscCmd, 'M'); // Misc - addButton(150, 35, 40, 16, queryCustomString(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, queryCustomString(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); -} - -#pragma mark - - -PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm) - : ScummDialog(gui, scumm, 35, 80, 250, 16) -{ - addResText(4, 4, 250-8, 16, 10); -} - -#pragma mark - + // + // Add the buttons + // + addButton(_w-kButtonWidth-8, _h-24, "OK", kOKCmd, 'O'); + addButton(_w-2*kButtonWidth-12, _h-24, "Cancel", kCancelCmd, 'C'); + + addButton(8, _h-24, "About", kAboutCmd, 'A'); +#ifdef _WIN32_WCE + addButton(kButtonWidth+12, _h-24, "Keys", kKeysCmd, 'K'); +#endif -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); + // + // Sound controllers + // + new StaticTextWidget(this, 25, 10, 85, 16, "Master volume:", kTextAlignRight); + new StaticTextWidget(this, 25, 26, 85, 16, "Music volume:", kTextAlignRight); + new StaticTextWidget(this, 25, 42, 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 = new SliderWidget(this, 115, 8, 80, 12, "Volume1", kMasterVolumeChanged); + musicVolumeSlider = new SliderWidget(this, 115, 24, 80, 12, "Volume2", kMusicVolumeChanged); + sfxVolumeSlider = new SliderWidget(this, 115, 40, 80, 12, "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 = new StaticTextWidget(this, 200, 10, 60, 16, "Volume1", kTextAlignLeft); + musicVolumeLabel = new StaticTextWidget(this, 200, 26, 60, 16, "Volume2", kTextAlignLeft); + sfxVolumeLabel = new StaticTextWidget(this, 200, 42, 60, 16, "Volume3", kTextAlignLeft); masterVolumeLabel->setFlags(WIDGET_CLEARBG); musicVolumeLabel->setFlags(WIDGET_CLEARBG); sfxVolumeLabel->setFlags(WIDGET_CLEARBG); + + // + // Some misc options + // + subtitlesCheckbox = new CheckboxWidget(this, 25, 62, 100, 16, "Show subtitles", 0, 'S'); + amigaPalCheckbox = new CheckboxWidget(this, 25, 80, 100, 16, "Amiga palette conversion", 0, 'P'); + + + // + // Finally create the sub dialogs + // + _aboutDialog = new AboutDialog(gui, scumm); +#ifdef _WIN32_WCE + // TODO - create _keysDialog +#endif } -void SoundDialog::open() +OptionsDialog::~OptionsDialog() { - Dialog::open(); + delete _aboutDialog; +} - // get current variables +void OptionsDialog::open() +{ + ScummDialog::open(); + + // display current sound settings _soundVolumeMaster = _scumm->_sound->_sound_volume_master; _soundVolumeMusic = _scumm->_sound->_sound_volume_music; _soundVolumeSfx = _scumm->_sound->_sound_volume_sfx; @@ -480,12 +455,21 @@ void SoundDialog::open() masterVolumeLabel->setValue(_soundVolumeMaster); musicVolumeLabel->setValue(_soundVolumeMusic); sfxVolumeLabel->setValue(_soundVolumeSfx); -} + // update checkboxes, too + subtitlesCheckbox->setState(_scumm->_noSubtitles == false); + amigaPalCheckbox->setState(_scumm->_features & GF_AMIGA); +} -void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) +void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { + case kKeysCmd: + // TODO + break; + case kAboutCmd: + _aboutDialog->open(); + break; case kMasterVolumeChanged: _soundVolumeMaster = masterVolumeSlider->getValue(); masterVolumeLabel->setValue(_soundVolumeMaster); @@ -502,7 +486,7 @@ void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) sfxVolumeLabel->draw(); break; case kOKCmd: { - // FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp + // Update the sound settings _scumm->_sound->_sound_volume_master = _soundVolumeMaster; // Master _scumm->_sound->_sound_volume_music = _soundVolumeMusic; // Music _scumm->_sound->_sound_volume_sfx = _soundVolumeSfx; // SFX @@ -515,12 +499,46 @@ void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) g_config->setInt("master_volume", _soundVolumeMaster); g_config->setInt("music_volume", _soundVolumeMusic); g_config->setInt("sfx_volume", _soundVolumeSfx); + + // Subtitles? + _scumm->_noSubtitles = !subtitlesCheckbox->getState(); + g_config->setBool("nosubtitles", _scumm->_noSubtitles); + + // Amiga palette? + if (amigaPalCheckbox->getState()) + _scumm->_features |= GF_AMIGA; + else + _scumm->_features &= ~GF_AMIGA; + g_config->setBool("amiga", amigaPalCheckbox->getState()); + + // Finally flush the modified config g_config->flush(); } case kCancelCmd: close(); break; default: - Dialog::handleCommand(sender, cmd, data); + ScummDialog::handleCommand(sender, cmd, data); } } + +#pragma mark - + +AboutDialog::AboutDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 30, 20, 260, 124) +{ + addButton(110, 100, queryCustomString(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); +} + +#pragma mark - + +PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm) + : ScummDialog(gui, scumm, 35, 80, 250, 16) +{ + addResText(4, 4, 250-8, 16, 10); +} diff --git a/scumm/dialogs.h b/scumm/dialogs.h index f6f925b988..8f3f752148 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -67,50 +67,14 @@ public: class OptionsDialog : public ScummDialog { protected: Dialog *_aboutDialog; - Dialog *_soundDialog; +#ifdef _WIN32_WCE Dialog *_keysDialog; - Dialog *_miscDialog; +#endif 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); @@ -128,6 +92,24 @@ protected: StaticTextWidget *masterVolumeLabel; StaticTextWidget *musicVolumeLabel; StaticTextWidget *sfxVolumeLabel; + + CheckboxWidget *subtitlesCheckbox; + CheckboxWidget *amigaPalCheckbox; +}; + +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 == ' ') // Close pause dialog if space key is pressed + close(); + else + ScummDialog::handleKeyDown(key, modifiers); + } }; diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index bf5395c2e4..1c6a5b333b 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -815,11 +815,15 @@ void MidiDriver_QT::send(uint32 b) break; case 0xE0:{ // Pitch bend - long theBend = (long)midiCmd[1] | (long)(midiCmd[2] << 8); // QuickTime specifies pitchbend in semitones, using 8.8 fixed point values; - // but iMuse sends us the pitch bend data relative to +/- 12 semitones. Thus - // we have to convert it to the QT format. - theBend = (theBend - 0x4000) * 6 / 128; + // but iMuse sends us the pitch bend data as 0-32768. which has to be mapped + // to +/- 12 semitones. Based on this, we first center the input data, then + // multiply it by a factor. If all was right, the factor would be 3/8, but for + // mysterious reasons the actual factor we have to use is more like 1/32 or 3/64. + // Maybe the QT docs are right, and + long theBend = (long)midiCmd[1] | (long)(midiCmd[2] << 7); + theBend = (theBend - 0x2000) * 2 / 64; + NASetController(qtNoteAllocator, qtNoteChannel[chanID], kControllerPitchBend, theBend); } break; @@ -880,6 +884,9 @@ int MidiDriver_CORE::open(int mode) if (au_output != NULL) return MERR_ALREADY_OPEN; + if (mode == MO_STREAMING) + return MERR_STREAMING_NOT_AVAILABLE; + _mode = mode; int err; @@ -914,6 +921,21 @@ int MidiDriver_CORE::open(int mode) // start the output AudioOutputUnitStart(au_output); +#if 1 + // Send initial pitch bend sensitivity values for +/- 12 semitones. + // For information on control change registered parameters, + // which includes the Pitch Bend sensitivity settings, + // visit http://www.midi.org/about-midi/table3.htm, + // Table 3a. + int chan; + for (chan = 0; chan < 16; ++chan) { + MusicDeviceMIDIEvent(au_MusicDevice, (0xB0 | chan), 101, 0, 0); + MusicDeviceMIDIEvent(au_MusicDevice, (0xB0 | chan), 100, 0, 0); + MusicDeviceMIDIEvent(au_MusicDevice, (0xB0 | chan), 6, 12, 0); + MusicDeviceMIDIEvent(au_MusicDevice, (0xB0 | chan), 38, 0, 0); + } // next for +#endif + return 0; } |