MOHAWK (Myst): Allow fuzzy matching in the space ship puzzle

Enabling this new option can make it easier for hearing impaired
users to solve that puzzle
This commit is contained in:
AspireONE-zz 2021-06-12 20:07:18 +02:00 committed by GitHub
parent 9382979b68
commit fdbfb6160f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 5 deletions

View File

@ -99,6 +99,7 @@ MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name
_zipModeCheckbox(nullptr), _zipModeCheckbox(nullptr),
_transitionsCheckbox(nullptr), _transitionsCheckbox(nullptr),
_mystFlyByCheckbox(nullptr), _mystFlyByCheckbox(nullptr),
_spaceshipFuzzyLogicCheckbox(nullptr),
_languagePopUp(nullptr), _languagePopUp(nullptr),
_dropPageButton(nullptr), _dropPageButton(nullptr),
_showMapButton(nullptr), _showMapButton(nullptr),
@ -119,6 +120,18 @@ MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name
_("The Myst fly by movie was not played by the original engine.")); _("The Myst fly by movie was not played by the original engine."));
} }
if (!isDemo) {
/**
* I18N:
* This Option is for hard-of-hearing.
* It makes it easier to solve the spaceship puzzle.
* Normally game uses strict binary logic here.
* We change it to use fuzzy logic.
* By default the option is off.
*/
_spaceshipFuzzyLogicCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystGameOptionsDialog.FuzzyMode", _("~F~uzzy Logic in SpaceShip Active"));
}
if (isInGame()) { if (isInGame()) {
MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine); MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
assert(vm); assert(vm);
@ -161,6 +174,7 @@ void MystOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Stri
.addWidget("ZipMode", "Checkbox") .addWidget("ZipMode", "Checkbox")
.addWidget("Transistions", "Checkbox") .addWidget("Transistions", "Checkbox")
.addWidget("PlayMystFlyBy", "Checkbox") .addWidget("PlayMystFlyBy", "Checkbox")
.addWidget("FuzzyMode", "Checkbox")
.addLayout(GUI::ThemeLayout::kLayoutHorizontal) .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
.addPadding(0, 0, 0, 0) .addPadding(0, 0, 0, 0)
.addWidget("LanguageDesc", "OptionsLabel") .addWidget("LanguageDesc", "OptionsLabel")
@ -193,6 +207,10 @@ void MystOptionsWidget::load() {
_mystFlyByCheckbox->setState(ConfMan.getBool("playmystflyby", _domain)); _mystFlyByCheckbox->setState(ConfMan.getBool("playmystflyby", _domain));
} }
if (_spaceshipFuzzyLogicCheckbox) {
_spaceshipFuzzyLogicCheckbox->setState(ConfMan.getBool("fuzzy_logic", _domain));
}
if (_languagePopUp) { if (_languagePopUp) {
Common::Language language = Common::parseLanguage(ConfMan.get("language", _domain)); Common::Language language = Common::parseLanguage(ConfMan.get("language", _domain));
const MystLanguage *languageDesc = MohawkEngine_Myst::getLanguageDesc(language); const MystLanguage *languageDesc = MohawkEngine_Myst::getLanguageDesc(language);
@ -229,6 +247,10 @@ bool MystOptionsWidget::save() {
ConfMan.setBool("playmystflyby", _mystFlyByCheckbox->getState(), _domain); ConfMan.setBool("playmystflyby", _mystFlyByCheckbox->getState(), _domain);
} }
if (_spaceshipFuzzyLogicCheckbox) {
ConfMan.setBool("fuzzy_logic", _spaceshipFuzzyLogicCheckbox->getState(), _domain);
}
if (_languagePopUp) { if (_languagePopUp) {
MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine); MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
assert(vm); assert(vm);

View File

@ -100,6 +100,8 @@ private:
GUI::CheckboxWidget *_zipModeCheckbox; GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_transitionsCheckbox; GUI::CheckboxWidget *_transitionsCheckbox;
GUI::CheckboxWidget *_mystFlyByCheckbox; GUI::CheckboxWidget *_mystFlyByCheckbox;
GUI::CheckboxWidget *_spaceshipFuzzyLogicCheckbox;
GUI::PopUpWidget *_languagePopUp; GUI::PopUpWidget *_languagePopUp;
GUI::ButtonWidget *_dropPageButton; GUI::ButtonWidget *_dropPageButton;

View File

@ -26,6 +26,7 @@ void Mohawk::MohawkMetaEngine_Myst::registerDefaultSettings() {
ConfMan.registerDefault("playmystflyby", false); ConfMan.registerDefault("playmystflyby", false);
ConfMan.registerDefault("zip_mode", false); ConfMan.registerDefault("zip_mode", false);
ConfMan.registerDefault("transition_mode", false); ConfMan.registerDefault("transition_mode", false);
ConfMan.registerDefault("fuzzy_logic", false);
} }
const Mohawk::MystLanguage *Mohawk::MohawkMetaEngine_Myst::listLanguages() { const Mohawk::MystLanguage *Mohawk::MohawkMetaEngine_Myst::listLanguages() {

View File

@ -30,6 +30,7 @@
#include "mohawk/video.h" #include "mohawk/video.h"
#include "mohawk/myst_stacks/myst.h" #include "mohawk/myst_stacks/myst.h"
#include "common/config-manager.h"
#include "common/events.h" #include "common/events.h"
#include "common/math.h" #include "common/math.h"
#include "common/system.h" #include "common/system.h"
@ -2292,6 +2293,17 @@ uint16 Myst::rocketSliderGetSound(uint16 pos) {
return (uint16)(9530 + (pos - 216) * 35.0 / 61.0); return (uint16)(9530 + (pos - 216) * 35.0 / 61.0);
} }
uint16 Myst::rocketCheckIfSoundMatches(uint16 sound1, uint16 sound2) {
debugN("rocketCheckIfSoundMatches: %i %i (diff:% 3i) ", sound1, sound2, sound1 - sound2);
if (!ConfMan.getBool("fuzzy_logic")) {
debugN("strict\n");
return sound1 == sound2;
} else {
debugN("fuzzy\n");
return abs(sound1 - sound2) < 5;
}
}
void Myst::rocketCheckSolution() { void Myst::rocketCheckSolution() {
_vm->_cursor->hideCursor(); _vm->_cursor->hideCursor();
@ -2302,35 +2314,35 @@ void Myst::rocketCheckSolution() {
_vm->_sound->playEffect(soundId); _vm->_sound->playEffect(soundId);
_rocketSlider1->drawConditionalDataToScreen(2); _rocketSlider1->drawConditionalDataToScreen(2);
_vm->wait(250); _vm->wait(250);
if (soundId != 9558) if (!rocketCheckIfSoundMatches(soundId, 9558))
solved = false; solved = false;
soundId = rocketSliderGetSound(_rocketSlider2->_pos.y); soundId = rocketSliderGetSound(_rocketSlider2->_pos.y);
_vm->_sound->playEffect(soundId); _vm->_sound->playEffect(soundId);
_rocketSlider2->drawConditionalDataToScreen(2); _rocketSlider2->drawConditionalDataToScreen(2);
_vm->wait(250); _vm->wait(250);
if (soundId != 9546) if (!rocketCheckIfSoundMatches(soundId, 9546))
solved = false; solved = false;
soundId = rocketSliderGetSound(_rocketSlider3->_pos.y); soundId = rocketSliderGetSound(_rocketSlider3->_pos.y);
_vm->_sound->playEffect(soundId); _vm->_sound->playEffect(soundId);
_rocketSlider3->drawConditionalDataToScreen(2); _rocketSlider3->drawConditionalDataToScreen(2);
_vm->wait(250); _vm->wait(250);
if (soundId != 9543) if (!rocketCheckIfSoundMatches(soundId, 9543))
solved = false; solved = false;
soundId = rocketSliderGetSound(_rocketSlider4->_pos.y); soundId = rocketSliderGetSound(_rocketSlider4->_pos.y);
_vm->_sound->playEffect(soundId); _vm->_sound->playEffect(soundId);
_rocketSlider4->drawConditionalDataToScreen(2); _rocketSlider4->drawConditionalDataToScreen(2);
_vm->wait(250); _vm->wait(250);
if (soundId != 9553) if (!rocketCheckIfSoundMatches(soundId, 9553))
solved = false; solved = false;
soundId = rocketSliderGetSound(_rocketSlider5->_pos.y); soundId = rocketSliderGetSound(_rocketSlider5->_pos.y);
_vm->_sound->playEffect(soundId); _vm->_sound->playEffect(soundId);
_rocketSlider5->drawConditionalDataToScreen(2); _rocketSlider5->drawConditionalDataToScreen(2);
_vm->wait(250); _vm->wait(250);
if (soundId != 9560) if (!rocketCheckIfSoundMatches(soundId, 9560))
solved = false; solved = false;
_vm->_sound->stopEffect(); _vm->_sound->stopEffect();

View File

@ -312,6 +312,7 @@ protected:
void rocketSliderMove(); void rocketSliderMove();
uint16 rocketSliderGetSound(uint16 pos); uint16 rocketSliderGetSound(uint16 pos);
uint16 rocketCheckIfSoundMatches(uint16 sound1, uint16 sound2);
void rocketCheckSolution(); void rocketCheckSolution();
void libraryBookPageTurnLeft(); void libraryBookPageTurnLeft();