SCUMM: Add setting for the Loom Overture tempo on the Engine tab

It's hard to make this appear only on EGA Loom, so the tooltip has to
document the fact that it's only useful there. The setting is made
relative to the default tempo, which I feel is a much more sensible way
of presenting it to the user than the raw ticks value.
This commit is contained in:
Torbjörn Andersson 2022-02-03 16:36:00 +01:00 committed by Torbjörn Andersson
parent c63786022d
commit c80adc3e8b
19 changed files with 136 additions and 6 deletions

View File

@ -699,4 +699,69 @@ void LoomTownsDifficultyDialog::handleCommand(GUI::CommandSender *sender, uint32
}
}
EgaLoomOptionsWidget::EgaLoomOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
OptionsContainerWidget(boss, name, "EgaLoomOptionsDialog", false, domain) {
new GUI::StaticTextWidget(widgetsBoss(), "EgaLoomOptionsDialog.OvertureTicksHeader", _("Overture Timing:"));
_overtureTicksSlider = new GUI::SliderWidget(widgetsBoss(), "EgaLoomOptionsDialog.OvertureTicks", _("Adjusts how quickly the Overture transition happens when using replacement audio tracks."), kOvertureTicksChanged);
// Each step of the slider changes the assumed length of the Loom
// Overture by ten SCUMM ticks. When I timed it, I was able to set the
// transition to happen anywhere between approximately 1:30 and 2:20,
// which should be more than enough. I think it's nice if the interval
// is small enough that you can set the slider back to 0 at reasonable
// screen resolutions.
_overtureTicksSlider->setMinValue(-200);
_overtureTicksSlider->setMaxValue(200);
_overtureTicksLabel = new GUI::StaticTextWidget(widgetsBoss(), "EgaLoomOptionsDialog.OvertureTicksLabel", Common::U32String());
_overtureTicksLabel->setFlags(GUI::WIDGET_CLEARBG);
}
void EgaLoomOptionsWidget::load() {
int loomOvertureTicks = DEFAULT_LOOM_OVERTURE_TICKS;
if (ConfMan.hasKey("loom_overture_ticks", _domain))
loomOvertureTicks = ConfMan.getInt("loom_overture_ticks", _domain);
_overtureTicksSlider->setValue(loomOvertureTicks);
updateOvertureTicksLabel();
}
bool EgaLoomOptionsWidget::save() {
ConfMan.setInt("loom_overture_ticks", _overtureTicksSlider->getValue(), _domain);
return true;
}
void EgaLoomOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
layouts.addDialog(layoutName, overlayedLayout)
.addLayout(GUI::ThemeLayout::kLayoutHorizontal)
.addPadding(16, 16, 16, 16)
.addWidget("OvertureTicksHeader", "OptionsLabel")
.addWidget("OvertureTicks", "WideSlider")
.addSpace(8)
.addWidget("OvertureTicksLabel", "SmallLabel")
.closeLayout()
.closeDialog();
}
void EgaLoomOptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kOvertureTicksChanged:
updateOvertureTicksLabel();
break;
default:
GUI::OptionsContainerWidget::handleCommand(sender, cmd, data);
break;
}
}
void EgaLoomOptionsWidget::updateOvertureTicksLabel() {
_overtureTicksLabel->setValue(_overtureTicksSlider->getValue());
_overtureTicksLabel->markAsDirty();
}
} // End of namespace Scumm

View File

@ -209,6 +209,31 @@ private:
int _difficulty;
};
/**
* Options widget for EGA Loom
*/
class EgaLoomOptionsWidget : public GUI::OptionsContainerWidget {
public:
EgaLoomOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
~EgaLoomOptionsWidget() override {};
void load() override;
bool save() override;
private:
enum {
kOvertureTicksChanged = 'OTCH'
};
void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
GUI::SliderWidget *_overtureTicksSlider;
GUI::StaticTextWidget *_overtureTicksLabel;
void updateOvertureTicksLabel();
};
} // End of namespace Scumm
#endif

View File

@ -32,6 +32,7 @@
#include "scumm/he/intern_he.h"
#include "scumm/scumm_v0.h"
#include "scumm/scumm_v8.h"
#include "scumm/dialogs.h"
#include "scumm/resource.h"
// Files related for detection.
@ -522,6 +523,26 @@ SaveStateDescriptor ScummMetaEngine::querySaveMetaInfos(const char *target, int
return desc;
}
GUI::OptionsContainerWidget *ScummMetaEngine::buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
if (ConfMan.get("gameid", target) != "loom")
return nullptr;
// These Loom settings are only relevant for the EGA version, so
// exclude non-DOS versions. If the game was added a long time ago,
// the platform may still be listed as unknown.
Common::Platform platform = Common::parsePlatform(ConfMan.get("platform", target));
if (platform != Common::kPlatformUnknown && platform != Common::kPlatformDOS)
return nullptr;
if (ConfMan.get("extra", target) == "Steam")
return nullptr;
// And yet, after all this, we still can't be sure that it's not the
// VGA version or a demo...
return new Scumm::EgaLoomOptionsWidget(boss, name, target);
}
#if PLUGIN_ENABLED_DYNAMIC(SCUMM)
REGISTER_PLUGIN_DYNAMIC(SCUMM, PLUGIN_TYPE_ENGINE, ScummMetaEngine);
#else

View File

@ -35,6 +35,8 @@ class ScummMetaEngine : public MetaEngine {
int getMaximumSaveSlot() const override;
void removeSaveState(const char *target, int slot) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
GUI::OptionsContainerWidget *buildEngineOptionsWidgetDynamic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
};
#endif // SCUMM_METAENGINE_H

View File

@ -1541,6 +1541,7 @@ void ScummEngine::setupScumm(const Common::String &macResourceFile) {
bool useReplacementAudioTracks = (_game.id == GID_LOOM && !(_game.features & GF_AUDIOTRACKS));
if (useReplacementAudioTracks) {
ConfMan.registerDefault("loom_overture_ticks", DEFAULT_LOOM_OVERTURE_TICKS);
_system->getAudioCDManager()->open();
}

View File

@ -98,6 +98,7 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer, bool useReplacementAudioT
_loomSteamCD.balance = 0;
_isLoomSteam = _vm->_game.id == GID_LOOM && Common::File::exists("CDDA.SOU");
_loomOvertureTicks = DEFAULT_LOOM_OVERTURE_TICKS + 10 * ConfMan.getInt("loom_overture_ticks");
_loomSteamCDAudioHandle = new Audio::SoundHandle();
_talkChannelHandle = new Audio::SoundHandle();
@ -127,8 +128,8 @@ bool Sound::isRolandLoom() const {
// Ozawa version of No. 10 Scène (Moderato). Good enough for now, but maybe it
// needs to be configurable to accommodate for different recordings?
#define TICKS_TO_TIMER(x) ((((x) * 278) / 8940) + 1)
#define TIMER_TO_TICKS(x) ((((x) - 1) * 8940) / 278)
#define TICKS_TO_TIMER(x) ((((x) * 278) / _loomOvertureTicks) + 1)
#define TIMER_TO_TICKS(x) ((((x) - 1) * _loomOvertureTicks) / 278)
void Sound::updateMusicTimer(int ticks) {
bool isLoomOverture = (isRolandLoom() && _currentCDSound == 56 && !(_vm->_game.features & GF_DEMO));

View File

@ -29,6 +29,8 @@
#include "backends/audiocd/audiocd.h"
#include "scumm/file.h"
#define DEFAULT_LOOM_OVERTURE_TICKS 8940
namespace Audio {
class Mixer;
class SoundHandle;
@ -94,6 +96,7 @@ protected:
bool _useReplacementAudioTracks;
int _musicTimer;
uint32 _scummTicks;
uint32 _loomOvertureTicks;
public:
Audio::SoundHandle *_talkChannelHandle; // Handle of mixer channel actor is talking on

View File

@ -103,6 +103,9 @@
<widget name = 'Slider'
size = '128, 18'
/>
<widget name = 'WideSlider'
size = '-1, 18'
/>
<widget name = 'PopUp'
size = '-1, 19'
/>

View File

@ -96,6 +96,9 @@
<widget name = 'Slider'
size = '85, 12'
/>
<widget name = 'WideSlider'
size = '-1, 12'
/>
<widget name = 'PopUp'
size = '-1, 15'
/>

Binary file not shown.

View File

@ -1,3 +1,3 @@
[SCUMMVM_STX0.9.1:ResidualVM Modern Theme Remastered:No Author]
[SCUMMVM_STX0.9.2:ResidualVM Modern Theme Remastered:No Author]
%using ../common
%using ../common-svg

Binary file not shown.

View File

@ -1 +1 @@
[SCUMMVM_STX0.9.1:ScummVM Classic Theme:No Author]
[SCUMMVM_STX0.9.2:ScummVM Classic Theme:No Author]

View File

@ -87,6 +87,9 @@
<widget name = 'Slider'
size = '128, 18'
/>
<widget name = 'WideSlider'
size = '-1, 18'
/>
<widget name = 'PopUp'
size = '-1, 19'
/>

View File

@ -84,6 +84,9 @@
<widget name = 'Slider'
size = '85, 12'
/>
<widget name = 'WideSlider'
size = '-1, 12'
/>
<widget name = 'PopUp'
size = '-1, 15'
/>

Binary file not shown.

View File

@ -1,2 +1,2 @@
[SCUMMVM_STX0.9.1:ScummVM Modern Theme:No Author]
[SCUMMVM_STX0.9.2:ScummVM Modern Theme:No Author]
%using ../common

Binary file not shown.

View File

@ -1,3 +1,3 @@
[SCUMMVM_STX0.9.1:ScummVM Modern Theme Remastered:No Author]
[SCUMMVM_STX0.9.2:ScummVM Modern Theme Remastered:No Author]
%using ../common
%using ../common-svg