Ticket #8664: subtitles-settings2.patch

File subtitles-settings2.patch, 3.5 KB (added by fingolfin, 17 years ago)

Slightly revised patch

  • engines/scumm/input.cpp

     
    414414
    415415void ScummEngine_v6::processKeyboard(int lastKeyHit) {
    416416        if (lastKeyHit == 20) {
    417                 // FIXME: What key is '20' supposed to indicate? I can't trigger
    418                 // it with my keyboard, it seems...
    419                 char buf[256];
     417                // FIXME: The 20 seems to indicate Ctrl-T. Of course this is a
     418                // rather ugly way to detect it -- modifier + ascii code would
     419                // be a *lot* cleaner...
    420420
    421                 _voiceMode++;
    422                 if (_voiceMode == 3)
    423                         _voiceMode = 0;
     421                SubtitleSettingsDialog dialog(this, _voiceMode);
     422                _voiceMode = runDialog(dialog);
    424423
    425424                switch (_voiceMode) {
    426425                case 0:
    427                         sprintf(buf, "Speech Only");
    428426                        ConfMan.setBool("speech_mute", false);
    429427                        ConfMan.setBool("subtitles", false);
    430428                        break;
    431429                case 1:
    432                         sprintf(buf, "Speech and Subtitles");
    433430                        ConfMan.setBool("speech_mute", false);
    434431                        ConfMan.setBool("subtitles", true);
    435432                        break;
    436433                case 2:
    437                         sprintf(buf, "Subtitles Only");
    438434                        ConfMan.setBool("speech_mute", true);
    439435                        ConfMan.setBool("subtitles", true);
    440436                        break;
     
    443439                if (VAR_VOICE_MODE != 0xFF)
    444440                        VAR(VAR_VOICE_MODE) = _voiceMode;
    445441
    446                 GUI::TimedMessageDialog dialog(buf, 1500);
    447                 runDialog(dialog);
    448442                return;
    449443        }
    450444
  • engines/scumm/dialogs.cpp

     
    2727#include "common/config-manager.h"
    2828#include "common/savefile.h"
    2929#include "common/system.h"
     30#include "common/events.h"
    3031
    3132#include "graphics/scaler.h"
    3233
     
    920921        _timer = getMillis() + kDisplayDelay;
    921922}
    922923
     924SubtitleSettingsDialog::SubtitleSettingsDialog(ScummEngine *scumm, int value)
     925        : InfoDialog(scumm, ""), _value(value) {
     926
     927}
     928
     929void SubtitleSettingsDialog::handleTickle() {
     930        InfoDialog::handleTickle();
     931        if (getMillis() > _timer)
     932                close();
     933}
     934
     935void SubtitleSettingsDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
     936        if (keycode == 't' && modifiers == Common::KBD_CTRL) {
     937                cycleValue();
     938
     939                reflowLayout();
     940                draw();
     941        } else {
     942                close();
     943        }
     944}
     945
     946void SubtitleSettingsDialog::open() {
     947        cycleValue();
     948        InfoDialog::open();
     949}
     950
     951void SubtitleSettingsDialog::cycleValue() {
     952        static const char* subtitleDesc[] = {
     953                "Speech Only",
     954                "Speech and Subtitles",
     955                "Subtitles Only"
     956        };
     957       
     958        _value = (_value + 1) % 3;
     959
     960        setInfoText(subtitleDesc[_value]);
     961
     962        setResult(_value);
     963        _timer = getMillis() + 1500;
     964}
     965
    923966Indy3IQPointsDialog::Indy3IQPointsDialog(ScummEngine *scumm, char* text)
    924967        : InfoDialog(scumm, text) {
    925968}
  • engines/scumm/dialogs.h

     
    236236        uint32 _timer;
    237237};
    238238
     239/**
     240 * A dialog used to display and cycle subtitle settings.
     241 * Automatically closes after a brief time has passed.
     242 */
     243class SubtitleSettingsDialog : public InfoDialog {
     244public:
     245        SubtitleSettingsDialog(ScummEngine *scumm, int value);
    239246
     247        virtual void open();
     248        virtual void handleTickle();
     249        virtual void handleMouseDown(int x, int y, int button, int clickCount) {
     250                close();
     251        }
     252        virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
     253protected:
     254        int _value;
     255        uint32 _timer;
     256       
     257        void cycleValue();
     258};
     259
    240260//The Indy IQ dialog
    241261class Indy3IQPointsDialog : public InfoDialog {
    242262public: