[Scummvm-git-logs] scummvm master -> 1d731aeef9025e3213ad67e60160898fbe3c00cc
bgK
bastien.bouclet at gmail.com
Sat Mar 28 06:38:51 UTC 2020
This automated email contains information about 12 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9bd6d9ee08 GUI: Do not reflow layout attached widgets in the constructor
8ae288c52f GUI: Allow defining layouts programmatically with a chaining syntax
c8f2d8a1d3 GUI: Introduce OptionsContainerWidget, a container for settings widgets
f6bb3af12a KEYMAPPER: Use OptionsContainerWidget for the remap widget
bcfb7145fa GUI: Allow engines to define a fully custom tab in the edit game dialog
0d895ec2f9 ENGINES: Allow showing the engine options in the in-game options dialog
1be3c3c7c4 MOHAWK: MYST: Configuration dialog changes
1f5d4d1fdd MOHAWK: RIVEN: Configuration dialog changes
195d593405 MOHAWK: RIVEN: Allow changing the game language at run-time
bfe7aad96a ENGINES: Return a const reference for DetectedGame::getGUIOptions
c9476543e0 MOHAWK: MYST: Allow changing the game language while on the main menu
1d731aeef9 MOHAWK: Simplify retrieving game features
Commit: 9bd6d9ee08a59ee6e0dcb1fb791781a26740cc3e
https://github.com/scummvm/scummvm/commit/9bd6d9ee08a59ee6e0dcb1fb791781a26740cc3e
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
GUI: Do not reflow layout attached widgets in the constructor
The parent widget they are attached to may not have been layed-out at the
moment of their construction.
Changed paths:
gui/widget.cpp
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 3c1f44ff8c..1dc338cf88 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -45,7 +45,6 @@ Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
Widget::Widget(GuiObject *boss, const Common::String &name, const char *tooltip)
: GuiObject(name), _type(0), _boss(boss), _tooltip(tooltip),
_id(0), _flags(0), _hasFocus(false), _state(ThemeEngine::kStateDisabled) {
- reflowLayout();
init();
}
@@ -546,12 +545,6 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx, int statenum) {
return;
}
-
- if (gfx->w > _w || gfx->h > _h) {
- warning("PicButtonWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h);
- return;
- }
-
_gfx[statenum].copyFrom(*gfx);
}
@@ -815,11 +808,6 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
return;
}
- if (gfx->w > _w || gfx->h > _h) {
- warning("GraphicsWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h);
- return;
- }
-
_gfx.copyFrom(*gfx);
}
Commit: 8ae288c52f99bbc62fe1e0691ace62487a278f3d
https://github.com/scummvm/scummvm/commit/8ae288c52f99bbc62fe1e0691ace62487a278f3d
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
GUI: Allow defining layouts programmatically with a chaining syntax
Changed paths:
gui/ThemeEval.cpp
gui/ThemeEval.h
gui/ThemeLayout.h
gui/ThemeParser.cpp
gui/ThemeParser.h
gui/widget.cpp
gui/widget.h
diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp
index 9a37a1b9d3..76264e5d10 100644
--- a/gui/ThemeEval.cpp
+++ b/gui/ThemeEval.cpp
@@ -80,7 +80,7 @@ Graphics::TextAlign ThemeEval::getWidgetTextHAlign(const Common::String &widget)
return _layouts[dialogName]->getWidgetTextHAlign(widgetName);
}
-void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled, Graphics::TextAlign align) {
+ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String &type, int w, int h, Graphics::TextAlign align) {
int typeW = -1;
int typeH = -1;
Graphics::TextAlign typeAlign = Graphics::kTextAlignInvalid;
@@ -105,13 +105,14 @@ void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign);
_curLayout.top()->addChild(widget);
- setVar("Dialog." + _curDialog + "." + name + ".Enabled", enabled ? 1 : 0);
+
+ return *this;
}
-void ThemeEval::addDialog(const Common::String &name, const Common::String &overlays, int16 width, int16 height, bool enabled, int inset) {
+ThemeEval &ThemeEval::addDialog(const Common::String &name, const Common::String &overlays, int16 width, int16 height, int inset) {
Common::String var = "Dialog." + name;
- ThemeLayout *layout = new ThemeLayoutMain(name, overlays, width, height, enabled, inset);
+ ThemeLayout *layout = new ThemeLayoutMain(name, overlays, width, height, inset);
if (_layouts.contains(var))
delete _layouts[var];
@@ -127,10 +128,11 @@ void ThemeEval::addDialog(const Common::String &name, const Common::String &over
_curLayout.push(layout);
_curDialog = name;
- setVar(var + ".Enabled", enabled ? 1 : 0);
+
+ return *this;
}
-void ThemeEval::addLayout(ThemeLayout::LayoutType type, int spacing, ThemeLayout::ItemAlign itemAlign) {
+ThemeEval &ThemeEval::addLayout(ThemeLayout::LayoutType type, int spacing, ThemeLayout::ItemAlign itemAlign) {
ThemeLayout *layout = nullptr;
if (spacing == -1)
@@ -149,11 +151,25 @@ void ThemeEval::addLayout(ThemeLayout::LayoutType type, int spacing, ThemeLayout
_curLayout.top()->addChild(layout);
_curLayout.push(layout);
+
+ return *this;
}
-void ThemeEval::addSpace(int size) {
+ThemeEval &ThemeEval::addSpace(int size) {
ThemeLayout *space = new ThemeLayoutSpacing(_curLayout.top(), size);
_curLayout.top()->addChild(space);
+
+ return *this;
+}
+
+bool ThemeEval::hasDialog(const Common::String &name) {
+ Common::StringTokenizer tokenizer(name, ".");
+
+ if (name.hasPrefix("Dialog."))
+ tokenizer.nextToken();
+
+ Common::String dialogName = "Dialog." + tokenizer.nextToken();
+ return _layouts.contains(dialogName);
}
void ThemeEval::reflowDialogLayout(const Common::String &name, Widget *widgetChain) {
@@ -165,12 +181,13 @@ void ThemeEval::reflowDialogLayout(const Common::String &name, Widget *widgetCha
_layouts["Dialog." + name]->reflowLayout(widgetChain);
}
-bool ThemeEval::addImportedLayout(const Common::String &name) {
- if (!_layouts.contains(name))
- return false;
+ThemeEval &ThemeEval::addImportedLayout(const Common::String &name) {
+ ThemeLayout *importedLayout = _layouts[name];
+ assert(importedLayout);
+
+ _curLayout.top()->importLayout(importedLayout);
- _curLayout.top()->importLayout(_layouts[name]);
- return true;
+ return *this;
}
} // End of namespace GUI
diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h
index bc6eb1dc11..cb36c139aa 100644
--- a/gui/ThemeEval.h
+++ b/gui/ThemeEval.h
@@ -74,16 +74,18 @@ public:
bool hasVar(const Common::String &name) { return _vars.contains(name) || _builtin.contains(name); }
- void addDialog(const Common::String &name, const Common::String &overlays, int16 maxWidth = -1, int16 maxHeight = -1, bool enabled = true, int inset = 0);
- void addLayout(ThemeLayout::LayoutType type, int spacing, ThemeLayout::ItemAlign itemAlign);
- void addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled = true, Graphics::TextAlign align = Graphics::kTextAlignLeft);
- bool addImportedLayout(const Common::String &name);
- void addSpace(int size);
+ ThemeEval &addDialog(const Common::String &name, const Common::String &overlays, int16 maxWidth = -1, int16 maxHeight = -1, int inset = 0);
+ ThemeEval &addLayout(ThemeLayout::LayoutType type, int spacing = -1, ThemeLayout::ItemAlign itemAlign = ThemeLayout::kItemAlignStart);
+ ThemeEval &addWidget(const Common::String &name, const Common::String &type, int w = -1, int h = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft);
+ ThemeEval &addImportedLayout(const Common::String &name);
+ ThemeEval &addSpace(int size = -1);
- void addPadding(int16 l, int16 r, int16 t, int16 b) { _curLayout.top()->setPadding(l, r, t, b); }
+ ThemeEval &addPadding(int16 l, int16 r, int16 t, int16 b) { _curLayout.top()->setPadding(l, r, t, b); return *this; }
- void closeLayout() { _curLayout.pop(); }
- void closeDialog() { _curLayout.pop(); _curDialog.clear(); }
+ ThemeEval &closeLayout() { _curLayout.pop(); return *this; }
+ ThemeEval &closeDialog() { _curLayout.pop(); _curDialog.clear(); return *this; }
+
+ bool hasDialog(const Common::String &name);
void reflowDialogLayout(const Common::String &name, Widget *widgetChain);
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h);
diff --git a/gui/ThemeLayout.h b/gui/ThemeLayout.h
index e17def4e2d..ccf44d1f1a 100644
--- a/gui/ThemeLayout.h
+++ b/gui/ThemeLayout.h
@@ -139,11 +139,10 @@ protected:
class ThemeLayoutMain : public ThemeLayout {
public:
- ThemeLayoutMain(const Common::String &name, const Common::String &overlays, int16 width, int16 height, bool enabled, int inset) :
+ ThemeLayoutMain(const Common::String &name, const Common::String &overlays, int16 width, int16 height, int inset) :
ThemeLayout(nullptr),
_name(name),
_overlays(overlays),
- _enabled(enabled),
_inset(inset) {
_w = _defaultW = width;
_h = _defaultH = height;
@@ -169,7 +168,6 @@ protected:
Common::String _name;
Common::String _overlays;
- bool _enabled;
int _inset;
};
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 872642f051..9b9885bff5 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -684,12 +684,6 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
var = node->values["name"];
int width = -1;
int height = -1;
- bool enabled = true;
-
- if (node->values.contains("enabled")) {
- if (!Common::parseBool(node->values["enabled"], enabled))
- return parserError("Invalid value for Widget enabling (expecting true/false)");
- }
if (node->values.contains("width")) {
if (_theme->getEvaluator()->hasVar(node->values["width"]) == true)
@@ -714,7 +708,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
return parserError("Invalid value for text alignment.");
}
- _theme->getEvaluator()->addWidget(var, width, height, node->values["type"], enabled, alignH);
+ _theme->getEvaluator()->addWidget(var, node->values["type"], width, height, alignH);
}
return true;
@@ -722,7 +716,6 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
bool ThemeParser::parserCallback_dialog(ParserNode *node) {
Common::String name = node->values["name"];
- bool enabled = true;
int inset = 0;
if (resolutionCheck(node->values["resolution"]) == false) {
@@ -730,11 +723,6 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) {
return true;
}
- if (node->values.contains("enabled")) {
- if (!Common::parseBool(node->values["enabled"], enabled))
- return parserError("Invalid value for Dialog enabling (expecting true/false)");
- }
-
if (node->values.contains("inset")) {
if (!parseIntegerKey(node->values["inset"], 1, &inset))
return false;
@@ -757,7 +745,7 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) {
return false;
}
- _theme->getEvaluator()->addDialog(name, overlays, width, height, enabled, inset);
+ _theme->getEvaluator()->addDialog(name, overlays, width, height, inset);
if (node->values.contains("shading")) {
int shading = 0;
@@ -774,9 +762,13 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) {
}
bool ThemeParser::parserCallback_import(ParserNode *node) {
+ Common::String importedName = node->values["layout"];
+
+ if (!_theme->getEvaluator()->hasDialog(importedName))
+ return parserError("Imported layout was not found: " + importedName);
+
+ _theme->getEvaluator()->addImportedLayout(importedName);
- if (!_theme->getEvaluator()->addImportedLayout(node->values["layout"]))
- return parserError("Error importing external layout");
return true;
}
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index 3faa89a1a1..661bccccf2 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -185,7 +185,6 @@ protected:
XML_PROP(overlays, true)
XML_PROP(size, false)
XML_PROP(shading, false)
- XML_PROP(enabled, false)
XML_PROP(resolution, false)
XML_PROP(inset, false)
XML_KEY(layout)
@@ -203,7 +202,6 @@ protected:
XML_PROP(width, false)
XML_PROP(height, false)
XML_PROP(type, false)
- XML_PROP(enabled, false)
XML_PROP(textalign, false)
KEY_END()
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 1dc338cf88..6244372c6a 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -33,18 +33,19 @@
#include "gui/dialog.h"
#include "gui/widgets/popup.h"
+#include "gui/widgets/scrollcontainer.h"
namespace GUI {
Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
: GuiObject(x, y, w, h), _type(0), _boss(boss), _tooltip(tooltip),
- _id(0), _flags(0), _hasFocus(false), _state(ThemeEngine::kStateEnabled) {
+ _flags(0), _hasFocus(false), _state(ThemeEngine::kStateEnabled) {
init();
}
Widget::Widget(GuiObject *boss, const Common::String &name, const char *tooltip)
: GuiObject(name), _type(0), _boss(boss), _tooltip(tooltip),
- _id(0), _flags(0), _hasFocus(false), _state(ThemeEngine::kStateDisabled) {
+ _flags(0), _hasFocus(false), _state(ThemeEngine::kStateDisabled) {
init();
}
@@ -192,9 +193,6 @@ void Widget::setEnabled(bool e) {
}
bool Widget::isEnabled() const {
- if (g_gui.xmlEval()->getVar("Dialog." + _name + ".Enabled", 1) == 0) {
- return false;
- }
return ((_flags & WIDGET_ENABLED) != 0);
}
diff --git a/gui/widget.h b/gui/widget.h
index 7b4b19b888..5a7d2f119c 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -99,7 +99,6 @@ protected:
uint32 _type;
GuiObject *_boss;
Widget *_next;
- uint16 _id;
bool _hasFocus;
ThemeEngine::WidgetStateInfo _state;
Common::String _tooltip;
Commit: c8f2d8a1d3b3986417ed63de8a083e97ad595c88
https://github.com/scummvm/scummvm/commit/c8f2d8a1d3b3986417ed63de8a083e97ad595c88
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
GUI: Introduce OptionsContainerWidget, a container for settings widgets
OptionsContainerWidget is a GUI widgets container that is meant to be
used for configuration dialogs tabs. It provides an interface subclasses
can implement for loading and saving settings from a configuration domain.
Changed paths:
gui/widget.cpp
gui/widget.h
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 6244372c6a..d11316d075 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -889,4 +889,68 @@ void ContainerWidget::drawWidget() {
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
}
+#pragma mark -
+
+OptionsContainerWidget::OptionsContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogLayout,
+ bool scrollable, const Common::String &domain) :
+ Widget(boss, name),
+ _domain(domain),
+ _dialogLayout(dialogLayout),
+ _parentDialog(nullptr),
+ _scrollContainer(nullptr) {
+
+ if (scrollable) {
+ _scrollContainer = new ScrollContainerWidget(this, 0, 0, 0, 0, kReflowCmd);
+ _scrollContainer->setTarget(this);
+ _scrollContainer->setBackgroundType(GUI::ThemeEngine::kWidgetBackgroundNo);
+ }
+}
+
+OptionsContainerWidget::~OptionsContainerWidget() {
+}
+
+void OptionsContainerWidget::reflowLayout() {
+ Widget::reflowLayout();
+
+ if (!_dialogLayout.empty()) {
+ if (!g_gui.xmlEval()->hasDialog(_dialogLayout)) {
+ defineLayout(*g_gui.xmlEval(), _dialogLayout, _name);
+ }
+
+ g_gui.xmlEval()->reflowDialogLayout(_dialogLayout, _firstWidget);
+ }
+
+ if (_scrollContainer) {
+ _scrollContainer->resize(_x, _y, _w, _h);
+ }
+
+ Widget *w = _firstWidget;
+ while (w) {
+ w->reflowLayout();
+ w = w->next();
+ }
+}
+
+bool OptionsContainerWidget::containsWidget(Widget *widget) const {
+ return containsWidgetInChain(_firstWidget, widget);
+}
+
+Widget *OptionsContainerWidget::findWidget(int x, int y) {
+ // Iterate over all child widgets and find the one which was clicked
+ return Widget::findWidgetInChain(_firstWidget, x, y);
+}
+
+void OptionsContainerWidget::removeWidget(Widget *widget) {
+ _boss->removeWidget(widget);
+ Widget::removeWidget(widget);
+}
+
+GuiObject *OptionsContainerWidget::widgetsBoss() {
+ if (_scrollContainer) {
+ return _scrollContainer;
+ }
+
+ return this;
+}
+
} // End of namespace GUI
diff --git a/gui/widget.h b/gui/widget.h
index 5a7d2f119c..52bc71cb54 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -37,6 +37,8 @@
namespace GUI {
+class ScrollContainerWidget;
+
enum {
WIDGET_ENABLED = 1 << 0,
WIDGET_INVISIBLE = 1 << 1,
@@ -444,6 +446,64 @@ protected:
ThemeEngine::WidgetBackground _backgroundType;
};
+/* OptionsContainerWidget */
+class OptionsContainerWidget : public Widget {
+public:
+ /**
+ * @param widgetsBoss parent widget for the container widget
+ * @param name name of the container widget in the layout system
+ * @param dialogLayout name of the layout used by the contained widgets, empty string for manually layed out widgets
+ * @param scrollable whether the container is made scrollable through a ScrollContainerWidget
+ * @param domain the configuration manager domain this widget is meant to edit
+ */
+ OptionsContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogLayout,
+ bool scrollable, const Common::String &domain);
+ ~OptionsContainerWidget() override;
+
+ /** Implementing classes should (re)initialize their widgets with state from the configuration domain */
+ virtual void load() = 0;
+
+ /**
+ * Implementing classes should save their widget's state to the configuration domain
+ *
+ * @return true if changes were made to the configuration since the last call to load()
+ */
+ virtual bool save() = 0;
+
+ void setParentDialog(Dialog *parentDialog) { _parentDialog = parentDialog; }
+
+protected:
+ enum {
+ /** The command that gets sent when the scroll container needs to reflow its contents */
+ kReflowCmd = 'REFL'
+ };
+
+ // Widget API
+ void reflowLayout() override;
+ void drawWidget() override {}
+ bool containsWidget(Widget *widget) const override;
+ Widget *findWidget(int x, int y) override;
+ void removeWidget(Widget *widget) override;
+
+ /** The pareent object to use when creating child widgets */
+ GuiObject *widgetsBoss();
+
+ /**
+ * Child classes can override this method to define the layout used by the contained widgets in the layout system
+ *
+ * This is called only when the layout was not found in the theme definition files.
+ */
+ virtual void defineLayout(ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {}
+
+ const Common::String _domain;
+ const Common::String _dialogLayout;
+
+ Dialog *_parentDialog;
+
+private:
+ ScrollContainerWidget *_scrollContainer;
+};
+
ButtonWidget *addClearButton(GuiObject *boss, const Common::String &name, uint32 cmd, int x=0, int y=0, int w=0, int h=0);
} // End of namespace GUI
Commit: f6bb3af12afe60183afdf1d1d12401674b2552e6
https://github.com/scummvm/scummvm/commit/f6bb3af12afe60183afdf1d1d12401674b2552e6
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
KEYMAPPER: Use OptionsContainerWidget for the remap widget
Changed paths:
backends/keymapper/remap-widget.cpp
backends/keymapper/remap-widget.h
diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp
index dd5f291040..f86cf44eef 100644
--- a/backends/keymapper/remap-widget.cpp
+++ b/backends/keymapper/remap-widget.cpp
@@ -41,12 +41,11 @@ enum {
kClearCmd = 'CLER',
kResetActionCmd = 'RTAC',
kResetKeymapCmd = 'RTKM',
- kCloseCmd = 'CLOS',
- kReflowCmd = 'REFL'
+ kCloseCmd = 'CLOS'
};
RemapWidget::RemapWidget(GuiObject *boss, const Common::String &name, const KeymapArray &keymaps) :
- Widget(boss, name),
+ OptionsContainerWidget(boss, name, "", true, ""),
_keymapTable(keymaps),
_remapKeymap(nullptr),
_remapAction(nullptr),
@@ -57,10 +56,6 @@ RemapWidget::RemapWidget(GuiObject *boss, const Common::String &name, const Keym
EventDispatcher *eventDispatcher = g_system->getEventManager()->getEventDispatcher();
_remapInputWatcher = new InputWatcher(eventDispatcher, keymapper);
-
- _scrollContainer = new GUI::ScrollContainerWidget(this, 0, 0, 0, 0, kReflowCmd);
- _scrollContainer->setTarget(this);
- _scrollContainer->setBackgroundType(GUI::ThemeEngine::kWidgetBackgroundNo);
}
RemapWidget::~RemapWidget() {
@@ -70,8 +65,8 @@ RemapWidget::~RemapWidget() {
delete _remapInputWatcher;
}
-void RemapWidget::build() {
- debug(3, "RemapWidget::build keymaps: %d", _keymapTable.size());
+void RemapWidget::load() {
+ debug(3, "RemapWidget::load keymaps: %d", _keymapTable.size());
_changes = false;
@@ -167,7 +162,7 @@ void RemapWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 d
} else if (cmd == kReflowCmd) {
reflowActionWidgets();
} else {
- Widget::handleCommand(sender, cmd, data);
+ OptionsContainerWidget::handleCommand(sender, cmd, data);
}
}
@@ -242,7 +237,7 @@ void RemapWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (_remapInputWatcher->isWatching())
stopRemapping();
else
- Widget::handleMouseDown(x, y, button, clickCount);
+ OptionsContainerWidget::handleMouseDown(x, y, button, clickCount);
}
void RemapWidget::handleTickle() {
@@ -257,7 +252,7 @@ void RemapWidget::handleTickle() {
if (_remapInputWatcher->isWatching() && g_system->getMillis() > _remapTimeout)
stopRemapping();
- Widget::handleTickle();
+ OptionsContainerWidget::handleTickle();
}
void RemapWidget::loadKeymap() {
@@ -279,10 +274,10 @@ void RemapWidget::refreshKeymap() {
ActionRow &row = _actions[i];
if (!row.actionText) {
- row.actionText = new GUI::StaticTextWidget(_scrollContainer, 0, 0, 0, 0, "", Graphics::kTextAlignLeft, nullptr, GUI::ThemeEngine::kFontStyleNormal);
+ row.actionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, "", Graphics::kTextAlignLeft, nullptr, GUI::ThemeEngine::kFontStyleNormal);
row.actionText->setLabel(row.action->description);
- row.keyButton = new GUI::DropdownButtonWidget(_scrollContainer, 0, 0, 0, 0, "", nullptr, kRemapCmd + i);
+ row.keyButton = new GUI::DropdownButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kRemapCmd + i);
row.keyButton->appendEntry(_("Reset to defaults"), kResetActionCmd + i);
row.keyButton->appendEntry(_("Clear mapping"), kClearCmd + i);
}
@@ -308,8 +303,8 @@ void RemapWidget::refreshKeymap() {
KeymapTitleRow &keymapTitle = _keymapSeparators[row.keymap];
if (!keymapTitle.descriptionText) {
- keymapTitle.descriptionText = new GUI::StaticTextWidget(_scrollContainer, 0, 0, 0, 0, row.keymap->getDescription(), Graphics::kTextAlignLeft);
- keymapTitle.resetButton = new GUI::ButtonWidget(_scrollContainer, 0, 0, 0, 0, "", nullptr, kResetKeymapCmd + i);
+ keymapTitle.descriptionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, row.keymap->getDescription(), Graphics::kTextAlignLeft);
+ keymapTitle.resetButton = new GUI::ButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kResetKeymapCmd + i);
// I18N: Button to reset keymap mappings to defaults
keymapTitle.resetButton->setLabel(_("Reset"));
@@ -318,21 +313,4 @@ void RemapWidget::refreshKeymap() {
}
}
-void RemapWidget::reflowLayout() {
- Widget::reflowLayout();
-
- _scrollContainer->resize(_x, _y, _w, _h);
-
- Widget *w = _firstWidget;
- while (w) {
- w->reflowLayout();
- w = w->next();
- }
-}
-
-GUI::Widget *RemapWidget::findWidget(int x, int y) {
- // Iterate over all child widgets and find the one which was clicked
- return Widget::findWidgetInChain(_firstWidget, x, y);
-}
-
} // End of namespace Common
diff --git a/backends/keymapper/remap-widget.h b/backends/keymapper/remap-widget.h
index cbcbfb2c37..3076b45633 100644
--- a/backends/keymapper/remap-widget.h
+++ b/backends/keymapper/remap-widget.h
@@ -43,14 +43,14 @@ class Keymap;
class Keymapper;
class InputWatcher;
-class RemapWidget : public GUI::Widget {
+class RemapWidget : public GUI::OptionsContainerWidget {
public:
typedef Common::Array<Keymap *> KeymapArray;
RemapWidget(GuiObject *boss, const Common::String &name, const KeymapArray &keymaps);
~RemapWidget() override;
- void build();
- bool save();
+ void load() override;
+ bool save() override;
void handleInputChanged();
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
void handleMouseDown(int x, int y, int button, int clickCount) override;
@@ -74,10 +74,6 @@ protected:
KeymapTitleRow() : descriptionText(nullptr), resetButton(nullptr) {}
};
- void drawWidget() override {}
- void reflowLayout() override;
- Widget *findWidget(int x, int y) override;
-
void loadKeymap();
void refreshKeymap();
void reflowActionWidgets();
@@ -94,8 +90,6 @@ protected:
Action *_remapAction;
uint32 _remapTimeout;
- GUI::ScrollContainerWidget *_scrollContainer;
-
static const uint32 kRemapTimeoutDelay = 3000;
bool _changes;
Commit: bcfb7145fac9a712595e81efd5eaf2bd1230ddac
https://github.com/scummvm/scummvm/commit/bcfb7145fac9a712595e81efd5eaf2bd1230ddac
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
GUI: Allow engines to define a fully custom tab in the edit game dialog
By implementing MetaEngine::buildEngineOptionsWidget, engines can
instantiate a container widget that will be shown in the Engine tab of
the edit game dialog. The default implementation retains the existing
behavior and shows the extra GUI options.
Changed paths:
base/main.cpp
engines/dialogs.cpp
engines/dialogs.h
engines/metaengine.cpp
engines/metaengine.h
gui/ThemeEngine.h
gui/dialog.cpp
gui/dialog.h
gui/editgamedialog.cpp
gui/editgamedialog.h
gui/options.cpp
gui/options.h
gui/themes/default.inc
gui/themes/scummclassic.zip
gui/themes/scummclassic/THEMERC
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
gui/themes/scummmodern.zip
gui/themes/scummmodern/THEMERC
gui/themes/scummmodern/scummmodern_layout.stx
gui/themes/scummmodern/scummmodern_layout_lowres.stx
gui/themes/scummremastered.zip
gui/themes/scummremastered/THEMERC
gui/themes/scummremastered/remastered_layout.stx
gui/themes/scummremastered/remastered_layout_lowres.stx
diff --git a/base/main.cpp b/base/main.cpp
index 8ab43d0e12..063da86bd3 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -185,10 +185,7 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
// Set default values for all of the custom engine options
// Apparently some engines query them in their constructor, thus we
// need to set this up before instance creation.
- const ExtraGuiOptions engineOptions = metaEngine.getExtraGuiOptions(Common::String());
- for (uint i = 0; i < engineOptions.size(); i++) {
- ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
- }
+ metaEngine.registerDefaultSettings(target);
err = metaEngine.createInstance(&system, &engine);
}
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index aaf30c8abf..cc22223d9f 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -358,4 +358,59 @@ void ConfigDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32
}
}
+ExtraGuiOptionsWidget::ExtraGuiOptionsWidget(GuiObject *containerBoss, const Common::String &name, const Common::String &domain, const ExtraGuiOptions &options) :
+ OptionsContainerWidget(containerBoss, name, dialogLayout(domain), false, domain),
+ _options(options) {
+
+ // Note: up to 7 engine options can currently fit on screen (the most that
+ // can fit in a 320x200 screen with the classic theme).
+ // TODO: Increase this number by including the checkboxes inside a scroll
+ // widget. The appropriate number of checkboxes will need to be added to
+ // the theme files.
+
+ uint i = 1;
+ ExtraGuiOptions::const_iterator iter;
+ for (iter = _options.begin(); iter != _options.end(); ++iter, ++i) {
+ Common::String id = Common::String::format("%d", i);
+ _checkboxes.push_back(new CheckboxWidget(widgetsBoss(),
+ _dialogLayout + ".customOption" + id + "Checkbox", _(iter->label), _(iter->tooltip)));
+ }
+}
+
+ExtraGuiOptionsWidget::~ExtraGuiOptionsWidget() {
+}
+
+Common::String ExtraGuiOptionsWidget::dialogLayout(const Common::String &domain) {
+ if (ConfMan.getActiveDomainName().equals(domain)) {
+ return "GlobalConfig_Engine_Container";
+ } else {
+ return "GameOptions_Engine_Container";
+ }
+}
+
+void ExtraGuiOptionsWidget::load() {
+ // Set the state of engine-specific checkboxes
+ for (uint j = 0; j < _options.size(); ++j) {
+ // The default values for engine-specific checkboxes are not set when
+ // ScummVM starts, as this would require us to load and poll all of the
+ // engine plugins on startup. Thus, we set the state of each custom
+ // option checkbox to what is specified by the engine plugin, and
+ // update it only if a value has been set in the configuration of the
+ // currently selected game.
+ bool isChecked = _options[j].defaultState;
+ if (ConfMan.hasKey(_options[j].configOption, _domain))
+ isChecked = ConfMan.getBool(_options[j].configOption, _domain);
+ _checkboxes[j]->setState(isChecked);
+ }
+}
+
+bool ExtraGuiOptionsWidget::save() {
+ // Set the state of engine-specific checkboxes
+ for (uint i = 0; i < _options.size(); i++) {
+ ConfMan.setBool(_options[i].configOption, _checkboxes[i]->getState(), _domain);
+ }
+
+ return true;
+}
+
} // End of namespace GUI
diff --git a/engines/dialogs.h b/engines/dialogs.h
index cfe3349f28..85105854f5 100644
--- a/engines/dialogs.h
+++ b/engines/dialogs.h
@@ -25,6 +25,7 @@
#include "gui/dialog.h"
#include "gui/options.h"
+#include "gui/widget.h"
class Engine;
@@ -95,6 +96,24 @@ public:
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
};
+class ExtraGuiOptionsWidget : public OptionsContainerWidget {
+public:
+ ExtraGuiOptionsWidget(GuiObject *widgetsBoss, const Common::String &name, const Common::String &domain, const ExtraGuiOptions &options);
+ ~ExtraGuiOptionsWidget() override;
+
+ // OptionsContainerWidget API
+ void load() override;
+ bool save() override;
+
+private:
+ typedef Common::Array<CheckboxWidget *> CheckboxWidgetList;
+
+ static Common::String dialogLayout(const Common::String &domain);
+
+ ExtraGuiOptions _options;
+ CheckboxWidgetList _checkboxes;
+};
+
} // End of namespace GUI
#endif
diff --git a/engines/metaengine.cpp b/engines/metaengine.cpp
index 02275308e5..a46faf29e4 100644
--- a/engines/metaengine.cpp
+++ b/engines/metaengine.cpp
@@ -30,6 +30,8 @@
#include "common/system.h"
#include "common/translation.h"
+#include "engines/dialogs.h"
+
#include "graphics/palette.h"
#include "graphics/scaler.h"
#include "graphics/managed_surface.h"
@@ -336,6 +338,21 @@ SaveStateList MetaEngine::listSaves(const char *target, bool saveMode) const {
return saveList;
}
+void MetaEngine::registerDefaultSettings(const Common::String &target) const {
+ const ExtraGuiOptions engineOptions = getExtraGuiOptions(target);
+ for (uint i = 0; i < engineOptions.size(); i++) {
+ ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
+ }
+}
+
+GUI::OptionsContainerWidget *MetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
+ const ExtraGuiOptions engineOptions = getExtraGuiOptions(target);
+ if (engineOptions.empty()) {
+ return nullptr;
+ }
+
+ return new GUI::ExtraGuiOptionsWidget(boss, name, target, engineOptions);
+}
void MetaEngine::removeSaveState(const char *target, int slot) const {
if (!hasFeature(kSavesUseExtendedFormat))
diff --git a/engines/metaengine.h b/engines/metaengine.h
index 5f5c2b8c1c..5775a67c6a 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -48,6 +48,11 @@ namespace Graphics {
struct Surface;
}
+namespace GUI {
+class GuiObject;
+class OptionsContainerWidget;
+}
+
/**
* Per-game extra GUI options structure.
* Currently, this can only be used for options with checkboxes.
@@ -190,6 +195,30 @@ public:
return ExtraGuiOptions();
}
+ /**
+ * Register the default values for the settings the engine uses into the
+ * configuration manager.
+ *
+ * @param target name of a config manager target
+ */
+ virtual void registerDefaultSettings(const Common::String &target) const;
+
+ /**
+ * Return a GUI widget container for configuring the specified target options.
+ *
+ * The returned widget is shown in the Engine tab in the edit game dialog.
+ * Engines can build custom options dialogs, but by default a simple widget
+ * allowing to configure the extra GUI options is used.
+ *
+ * Engines that don't want to have an Engine tab in the edit game dialog
+ * can return nullptr.
+ *
+ * @param boss the widget / dialog the returned widget is a child of
+ * @param name the name the returned widget must use
+ * @param target name of a config manager target
+ */
+ virtual GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const;
+
/**
* Return the maximum save slot that the engine supports.
*
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index fd71734deb..a852bfcbe1 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -37,7 +37,7 @@
#include "graphics/pixelformat.h"
-#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.35"
+#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.36"
class OSystem;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 8ca61a676e..1cea4a6f81 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -358,6 +358,10 @@ void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
case kCloseCmd:
close();
break;
+ case kCloseWithResultCmd:
+ setResult(data);
+ close();
+ break;
default:
break;
}
diff --git a/gui/dialog.h b/gui/dialog.h
index eac99746ee..bd9fb36f4e 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -42,8 +42,9 @@ class Widget;
// Some "common" commands sent to handleCommand()
enum {
- kCloseCmd = 'clos',
- kOKCmd = 'ok '
+ kCloseWithResultCmd = 'clsr',
+ kCloseCmd = 'clos',
+ kOKCmd = 'ok '
};
class Dialog : public GuiObject {
diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp
index a141fa105c..2aa6ec3d86 100644
--- a/gui/editgamedialog.cpp
+++ b/gui/editgamedialog.cpp
@@ -105,15 +105,13 @@ EditGameDialog::EditGameDialog(const String &domain)
: OptionsDialog(domain, "GameOptions") {
EngineMan.upgradeTargetIfNecessary(domain);
- // Retrieve all game specific options.
+ _engineOptions = nullptr;
// Retrieve the plugin, since we need to access the engine's MetaEngine
// implementation.
const Plugin *plugin = nullptr;
QualifiedGameDescriptor qgd = EngineMan.findTarget(domain, &plugin);
- if (plugin) {
- _engineOptions = plugin->get<MetaEngine>().getExtraGuiOptions(domain);
- } else {
+ if (!plugin) {
warning("Plugin for target \"%s\" not found! Game specific settings might be missing", domain.c_str());
}
@@ -175,12 +173,21 @@ EditGameDialog::EditGameDialog(const String &domain)
}
//
- // 2) The engine tab (shown only if there are custom engine options)
+ // 2) The engine tab (shown only if the engine implements one or there are custom engine options)
//
- if (_engineOptions.size() > 0) {
- tab->addTab(_("Engine"), "GameOptions_Engine");
- addEngineControls(tab, "GameOptions_Engine.", _engineOptions);
+ if (plugin) {
+ int tabId = tab->addTab(_("Engine"), "GameOptions_Engine");
+
+ const MetaEngine &metaEngine = plugin->get<MetaEngine>();
+ metaEngine.registerDefaultSettings(_domain);
+ _engineOptions = metaEngine.buildEngineOptionsWidget(tab, "GameOptions_Engine.Container", _domain);
+
+ if (_engineOptions) {
+ _engineOptions->setParentDialog(this);
+ } else {
+ tab->removeTab(tabId);
+ }
}
//
@@ -404,18 +411,8 @@ void EditGameDialog::open() {
_langPopUp->setEnabled(false);
}
- // Set the state of engine-specific checkboxes
- for (uint j = 0; j < _engineOptions.size(); ++j) {
- // The default values for engine-specific checkboxes are not set when
- // ScummVM starts, as this would require us to load and poll all of the
- // engine plugins on startup. Thus, we set the state of each custom
- // option checkbox to what is specified by the engine plugin, and
- // update it only if a value has been set in the configuration of the
- // currently selected game.
- bool isChecked = _engineOptions[j].defaultState;
- if (ConfMan.hasKey(_engineOptions[j].configOption, _domain))
- isChecked = ConfMan.getBool(_engineOptions[j].configOption, _domain);
- _engineCheckboxes[j]->setState(isChecked);
+ if (_engineOptions) {
+ _engineOptions->load();
}
const Common::PlatformDescription *p = Common::g_platforms;
@@ -459,9 +456,8 @@ void EditGameDialog::apply() {
else
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);
- // Set the state of engine-specific checkboxes
- for (uint i = 0; i < _engineOptions.size(); i++) {
- ConfMan.setBool(_engineOptions[i].configOption, _engineCheckboxes[i]->getState(), _domain);
+ if (_engineOptions) {
+ _engineOptions->save();
}
OptionsDialog::apply();
diff --git a/gui/editgamedialog.h b/gui/editgamedialog.h
index 8832865e51..47df4c6478 100644
--- a/gui/editgamedialog.h
+++ b/gui/editgamedialog.h
@@ -26,6 +26,7 @@
#include "engines/game.h"
#include "gui/dialog.h"
#include "gui/options.h"
+#include "gui/widget.h"
namespace GUI {
@@ -90,7 +91,7 @@ protected:
CheckboxWidget *_globalMT32Override;
CheckboxWidget *_globalVolumeOverride;
- ExtraGuiOptions _engineOptions;
+ OptionsContainerWidget *_engineOptions;
};
} // End of namespace GUI
diff --git a/gui/options.cpp b/gui/options.cpp
index 8e62b71d06..7ce11c557c 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -269,7 +269,7 @@ void OptionsDialog::build() {
// Keymapper options
if (_keymapperWidget) {
- _keymapperWidget->build();
+ _keymapperWidget->load();
}
// Graphic options
@@ -1404,22 +1404,6 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &pre
_enableVolumeSettings = true;
}
-void OptionsDialog::addEngineControls(GuiObject *boss, const Common::String &prefix, const ExtraGuiOptions &engineOptions) {
- // Note: up to 7 engine options can currently fit on screen (the most that
- // can fit in a 320x200 screen with the classic theme).
- // TODO: Increase this number by including the checkboxes inside a scroll
- // widget. The appropriate number of checkboxes will need to be added to
- // the theme files.
-
- uint i = 1;
- ExtraGuiOptions::const_iterator iter;
- for (iter = engineOptions.begin(); iter != engineOptions.end(); ++iter, ++i) {
- Common::String id = Common::String::format("%d", i);
- _engineCheckboxes.push_back(new CheckboxWidget(boss,
- prefix + "customOption" + id + "Checkbox", _(iter->label), _(iter->tooltip)));
- }
-}
-
bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType) {
if (!popup || !popup->isEnabled())
return true;
diff --git a/gui/options.h b/gui/options.h
index 2ec441df3e..0d97bd7a9d 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -61,8 +61,6 @@ class RadiobuttonGroup;
class RadiobuttonWidget;
class OptionsDialog : public Dialog {
- typedef Common::Array<CheckboxWidget *> CheckboxWidgetList;
-
public:
OptionsDialog(const Common::String &domain, int x, int y, int w, int h);
OptionsDialog(const Common::String &domain, const Common::String &name);
@@ -105,7 +103,6 @@ protected:
// The default value is the launcher's non-scaled talkspeed value. When SCUMM uses the widget,
// it uses its own scale
void addSubtitleControls(GuiObject *boss, const Common::String &prefix, int maxSliderVal = 255);
- void addEngineControls(GuiObject *boss, const Common::String &prefix, const ExtraGuiOptions &engineOptions);
void setGraphicSettingsState(bool enabled);
void setShaderSettingsState(bool enabled);
@@ -243,11 +240,6 @@ protected:
//
Common::String _guioptions;
Common::String _guioptionsString;
-
- //
- // Engine-specific controls
- //
- CheckboxWidgetList _engineCheckboxes;
};
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 7e36996d45..4f831dd7ae 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1969,7 +1969,12 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"</layout>"
"</layout>"
"</dialog>"
-"<dialog name='GameOptions_Engine' overlays='Dialog.GameOptions.TabWidget' shading='dim'>"
+"<dialog name='GameOptions_Engine' overlays='Dialog.GameOptions.TabWidget'>"
+"<layout type='vertical' padding='0,0,0,0'>"
+"<widget name='Container'/>"
+"</layout>"
+"</dialog>"
+"<dialog name='GameOptions_Engine_Container' overlays='GameOptions_Engine.Container'>"
"<layout type='vertical' padding='16,16,16,16'>"
"<widget name='customOption1Checkbox' "
"type='Checkbox' "
@@ -2060,6 +2065,16 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"</layout>"
"</layout>"
"</dialog>"
+"<dialog name='GlobalConfig_Engine' overlays='Dialog.GlobalConfig.TabWidget'>"
+"<layout type='vertical' padding='0,0,0,0'>"
+"<widget name='Container'/>"
+"</layout>"
+"</dialog>"
+"<dialog name='GlobalConfig_Engine_Container' overlays='Dialog.GlobalConfig_Engine.Container'>"
+"<layout type='vertical' padding='16,16,16,16'>"
+"<import layout='Dialog.GameOptions_Engine_Container' />"
+"</layout>"
+"</dialog>"
"<dialog name='GlobalConfig_Audio' overlays='Dialog.GlobalConfig.TabWidget'>"
"<layout type='vertical' padding='8,8,8,8' spacing='8'>"
"<layout type='horizontal' padding='0,0,0,0'>"
@@ -3772,7 +3787,12 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"</layout>"
"</layout>"
"</dialog>"
-"<dialog name='GameOptions_Engine' overlays='Dialog.GameOptions.TabWidget' shading='dim'>"
+"<dialog name='GameOptions_Engine' overlays='Dialog.GameOptions.TabWidget'>"
+"<layout type='vertical' padding='0,0,0,0'>"
+"<widget name='Container'/>"
+"</layout>"
+"</dialog>"
+"<dialog name='GameOptions_Engine_Container' overlays='GameOptions_Engine.Container'>"
"<layout type='vertical' padding='8,8,8,8'>"
"<widget name='customOption1Checkbox' "
"type='Checkbox' "
@@ -3864,6 +3884,16 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"</layout>"
"</layout>"
"</dialog>"
+"<dialog name='GlobalConfig_Engine' overlays='Dialog.GlobalConfig.TabWidget'>"
+"<layout type='vertical' padding='0,0,0,0'>"
+"<widget name='Container'/>"
+"</layout>"
+"</dialog>"
+"<dialog name='GlobalConfig_Engine_Container' overlays='Dialog.GlobalConfig_Engine.Container'>"
+"<layout type='vertical' padding='8,8,8,8'>"
+"<import layout='Dialog.GameOptions_Engine_Container' />"
+"</layout>"
+"</dialog>"
"<dialog name='GlobalConfig_Audio' overlays='Dialog.GlobalConfig.TabWidget'>"
"<layout type='vertical' padding='8,8,8,8'>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 15040dfe63..f51df566aa 100644
Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
diff --git a/gui/themes/scummclassic/THEMERC b/gui/themes/scummclassic/THEMERC
index 2bea7c2a2a..4b1ab88179 100644
--- a/gui/themes/scummclassic/THEMERC
+++ b/gui/themes/scummclassic/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.35:ScummVM Classic Theme:No Author]
+[SCUMMVM_STX0.8.36:ScummVM Classic Theme:No Author]
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index ddd246e64e..31193b6206 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -1124,7 +1124,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '16, 16, 16, 16'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1218,6 +1224,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0'>
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index 9b7aaca79c..0516162449 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -1134,7 +1134,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1229,6 +1235,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 55845bb851..b015aa9b90 100644
Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
diff --git a/gui/themes/scummmodern/THEMERC b/gui/themes/scummmodern/THEMERC
index 0d3fa6cec0..7de065a176 100644
--- a/gui/themes/scummmodern/THEMERC
+++ b/gui/themes/scummmodern/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.35:ScummVM Modern Theme:No Author]
+[SCUMMVM_STX0.8.36:ScummVM Modern Theme:No Author]
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index 6b89f2c57a..f1d18251f2 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -1137,7 +1137,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '16, 16, 16, 16'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1231,6 +1237,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0'>
diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
index f85df8647c..854e673136 100644
--- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx
+++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -1133,7 +1133,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1227,6 +1233,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip
index 7907630550..2e795a9578 100644
Binary files a/gui/themes/scummremastered.zip and b/gui/themes/scummremastered.zip differ
diff --git a/gui/themes/scummremastered/THEMERC b/gui/themes/scummremastered/THEMERC
index 20c006fb4e..aab05190ef 100644
--- a/gui/themes/scummremastered/THEMERC
+++ b/gui/themes/scummremastered/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.35:ScummVM Modern Theme Remastered:No Author]
+[SCUMMVM_STX0.8.36:ScummVM Modern Theme Remastered:No Author]
diff --git a/gui/themes/scummremastered/remastered_layout.stx b/gui/themes/scummremastered/remastered_layout.stx
index 5a98890188..eff0392a63 100644
--- a/gui/themes/scummremastered/remastered_layout.stx
+++ b/gui/themes/scummremastered/remastered_layout.stx
@@ -1137,7 +1137,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '16, 16, 16, 16'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1231,6 +1237,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0'>
diff --git a/gui/themes/scummremastered/remastered_layout_lowres.stx b/gui/themes/scummremastered/remastered_layout_lowres.stx
index 99b3063625..f1ab411db5 100644
--- a/gui/themes/scummremastered/remastered_layout_lowres.stx
+++ b/gui/themes/scummremastered/remastered_layout_lowres.stx
@@ -1133,7 +1133,13 @@
</layout>
</dialog>
- <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget' shading = 'dim'>
+ <dialog name = 'GameOptions_Engine' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GameOptions_Engine_Container' overlays = 'GameOptions_Engine.Container'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<widget name = 'customOption1Checkbox'
type = 'Checkbox'
@@ -1227,6 +1233,18 @@
</layout>
</dialog>
+ <dialog name = 'GlobalConfig_Engine' overlays = 'Dialog.GlobalConfig.TabWidget'>
+ <layout type = 'vertical' padding = '0, 0, 0, 0'>
+ <widget name = 'Container'/>
+ </layout>
+ </dialog>
+
+ <dialog name = 'GlobalConfig_Engine_Container' overlays = 'Dialog.GlobalConfig_Engine.Container'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <import layout = 'Dialog.GameOptions_Engine_Container' />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalConfig_Audio' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
Commit: 0d895ec2f981d954906a746368f22c5d39f51afe
https://github.com/scummvm/scummvm/commit/0d895ec2f981d954906a746368f22c5d39f51afe
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
ENGINES: Allow showing the engine options in the in-game options dialog
Changed paths:
engines/dialogs.cpp
engines/dialogs.h
engines/engine.cpp
engines/engine.h
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index cc22223d9f..07442c40d8 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -121,7 +121,7 @@ void MainMenuDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint3
save();
break;
case kOptionsCmd: {
- GUI::ConfigDialog configDialog(_engine->hasFeature(Engine::kSupportsSubtitleOptions));
+ GUI::ConfigDialog configDialog;
configDialog.runModal();
break;
}
@@ -270,18 +270,37 @@ namespace GUI {
// These changes will achieve two things at once: Allow us to get rid of using
// "" as value for the domain, and in fact provide a somewhat better user
// experience at the same time.
-ConfigDialog::ConfigDialog(bool subtitleControls) : GUI::OptionsDialog("", "GlobalConfig") {
- init(subtitleControls);
-}
+ConfigDialog::ConfigDialog() :
+ GUI::OptionsDialog("", "GlobalConfig"),
+ _engineOptions(nullptr) {
+ assert(g_engine);
-ConfigDialog::ConfigDialog() : GUI::OptionsDialog("", "GlobalConfig") {
- init(g_engine->hasFeature(Engine::kSupportsSubtitleOptions));
-}
+ const Common::String &gameDomain = ConfMan.getActiveDomainName();
+ const MetaEngine &metaEngine = g_engine->getMetaEngine();
-void ConfigDialog::init(bool subtitleControls) {
// GUI: Add tab widget
GUI::TabWidget *tab = new GUI::TabWidget(this, "GlobalConfig.TabWidget");
+ //
+ // The game specific options tab
+ //
+
+ int tabId = tab->addTab(_("Game"), "GlobalConfig_Engine");
+
+ if (g_engine->hasFeature(Engine::kSupportsChangingOptionsDuringRuntime)) {
+ _engineOptions = metaEngine.buildEngineOptionsWidget(tab, "GlobalConfig_Engine.Container", gameDomain);
+ }
+
+ if (_engineOptions) {
+ _engineOptions->setParentDialog(this);
+ } else {
+ tab->removeTab(tabId);
+ }
+
+ //
+ // The Audio / Subtitles tab
+ //
+
tab->addTab(_("Audio"), "GlobalConfig_Audio");
//
@@ -295,7 +314,7 @@ void ConfigDialog::init(bool subtitleControls) {
// Subtitle speed and toggle controllers
//
- if (subtitleControls) {
+ if (g_engine->hasFeature(Engine::kSupportsSubtitleOptions)) {
// Global talkspeed range of 0-255
addSubtitleControls(tab, "GlobalConfig_Audio.", 255);
setSubtitleSettingsState(true); // could disable controls by GUI options
@@ -304,14 +323,8 @@ void ConfigDialog::init(bool subtitleControls) {
//
// The Keymap tab
//
- const Common::String &gameDomain = ConfMan.getActiveDomainName();
- const Plugin *plugin = EngineMan.findPlugin(ConfMan.get("engineid"));
-
- Common::KeymapArray keymaps;
- if (plugin) {
- keymaps = plugin->get<MetaEngine>().initKeymaps(gameDomain.c_str());
- }
+ Common::KeymapArray keymaps = metaEngine.initKeymaps(gameDomain.c_str());
if (!keymaps.empty()) {
tab->addTab(_("Keymaps"), "GlobalConfig_KeyMapper");
addKeyMapperControls(tab, "GlobalConfig_KeyMapper.", keymaps, gameDomain);
@@ -339,6 +352,23 @@ ConfigDialog::~ConfigDialog() {
#endif
}
+void ConfigDialog::build() {
+ OptionsDialog::build();
+
+ // Engine options
+ if (_engineOptions) {
+ _engineOptions->load();
+ }
+}
+
+void ConfigDialog::apply() {
+ if (_engineOptions) {
+ _engineOptions->save();
+ }
+
+ OptionsDialog::apply();
+}
+
void ConfigDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kKeysCmd:
diff --git a/engines/dialogs.h b/engines/dialogs.h
index 85105854f5..5a8e941b5a 100644
--- a/engines/dialogs.h
+++ b/engines/dialogs.h
@@ -81,19 +81,22 @@ protected:
namespace GUI {
class ConfigDialog : public OptionsDialog {
-private:
- void init(bool subtitleControls);
-protected:
-#ifdef GUI_ENABLE_KEYSDIALOG
- Dialog *_keysDialog;
-#endif
-
public:
- ConfigDialog(bool subtitleControls);
ConfigDialog();
~ConfigDialog() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
+
+ // OptionsDialog API
+ void build() override;
+ void apply() override;
+
+private:
+ OptionsContainerWidget *_engineOptions;
+
+#ifdef GUI_ENABLE_KEYSDIALOG
+ Dialog *_keysDialog;
+#endif
};
class ExtraGuiOptionsWidget : public OptionsContainerWidget {
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 80e5613f3c..54da3cc610 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -580,6 +580,7 @@ void Engine::openMainMenuDialog() {
}
}
+ applyGameSettings();
syncSoundSettings();
#ifdef USE_TTS
ttsMan->popState();
diff --git a/engines/engine.h b/engines/engine.h
index f28cfb0f1e..63432583ce 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -149,7 +149,14 @@ public:
* If this feature is supported, then the corresponding MetaEngine *must*
* support the kSupportsListSaves feature.
*/
- kSupportsSavingDuringRuntime
+ kSupportsSavingDuringRuntime,
+
+ /**
+ * Changing the game settings during runtime is supported. This enables
+ * showing the engine options tab in the config dialog accessed through
+ * the Global Main Menu.
+ */
+ kSupportsChangingOptionsDuringRuntime
};
@@ -209,8 +216,6 @@ public:
*/
virtual bool hasFeature(EngineFeature f) const { return false; }
-// virtual EnginePlugin *getMetaEnginePlugin() const;
-
/**
* Notify the engine that the sound settings in the config manager may have
* changed and that it hence should adjust any internal volume etc. values
@@ -228,6 +233,13 @@ public:
*/
virtual void syncSoundSettings();
+ /**
+ * Notify the engine that the settings editable from the game tab in the
+ * in-game options dialog may have changed and that they need to be applied
+ * if necessary.
+ */
+ virtual void applyGameSettings() {}
+
/**
* Flip mute all sound option.
*/
Commit: 1be3c3c7c42aa49e06d427fd22d656b1a1b98cdc
https://github.com/scummvm/scummvm/commit/1be3c3c7c42aa49e06d427fd22d656b1a1b98cdc
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
MOHAWK: MYST: Configuration dialog changes
* Unify the custom options dialog (previously accessed through F5), the
engine options tab and the in-game options dialog accessed through the
Global Main Menu.
* Change the default keybinding for F5 to show the GMM for the non-25th
anniversary editions of the game. This allows easy access to
the load and save functionality. With the 25th anniversary edition,
the main menu accessed through ESC should be used instead.
* Change the Quit button in the Global Main Menu to show the credits
before quitting. This is to reproduce the original game behavior.
Changed paths:
A engines/mohawk/myst_actions.h
engines/mohawk/detection.cpp
engines/mohawk/detection_tables.h
engines/mohawk/dialogs.cpp
engines/mohawk/dialogs.h
engines/mohawk/mohawk.h
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_state.cpp
engines/mohawk/myst_state.h
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index 80e7bf2fa6..f974f96d3f 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -32,6 +32,7 @@
#include "common/textconsole.h"
#include "common/translation.h"
+#include "mohawk/dialogs.h"
#include "mohawk/livingbooks.h"
#ifdef ENABLE_CSTIME
@@ -120,8 +121,9 @@ Common::String MohawkEngine::getDatafileLanguageName(const char *prefix) const {
bool MohawkEngine_Myst::hasFeature(EngineFeature f) const {
return
MohawkEngine::hasFeature(f)
- || (f == kSupportsLoadingDuringRuntime)
- || (f == kSupportsSavingDuringRuntime);
+ || (f == kSupportsLoadingDuringRuntime)
+ || (f == kSupportsSavingDuringRuntime)
+ || (f == kSupportsChangingOptionsDuringRuntime);
}
#endif
@@ -182,23 +184,9 @@ static const char *directoryGlobs[] = {
nullptr
};
-static const ADExtraGuiOptionsMap optionsList[] = {
- {
- GAMEOPTION_PLAY_MYST_FLYBY,
- {
- _s("Play the Myst fly by movie"),
- _s("The Myst fly by movie was not played by the original engine."),
- "playmystflyby",
- false
- }
- },
-
- AD_EXTRA_GUI_OPTIONS_TERMINATOR
-};
-
class MohawkMetaEngine : public AdvancedMetaEngine {
public:
- MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames, optionsList) {
+ MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames) {
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
@@ -227,6 +215,8 @@ public:
void removeSaveState(const char *target, int slot) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
Common::KeymapArray initKeymaps(const char *target) const override;
+ void registerDefaultSettings(const Common::String &target) const override;
+ GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
};
bool MohawkMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -348,6 +338,30 @@ Common::KeymapArray MohawkMetaEngine::initKeymaps(const char *target) const {
return AdvancedMetaEngine::initKeymaps(target);
}
+void MohawkMetaEngine::registerDefaultSettings(const Common::String &target) const {
+ Common::String gameId = ConfMan.get("gameid", target);
+
+#ifdef ENABLE_MYST
+ if (gameId == "myst" || gameId == "makingofmyst") {
+ return Mohawk::MohawkEngine_Myst::registerDefaultSettings();
+ }
+#endif
+
+ return AdvancedMetaEngine::registerDefaultSettings(target);
+}
+
+GUI::OptionsContainerWidget *MohawkMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
+ Common::String gameId = ConfMan.get("gameid", target);
+
+#ifdef ENABLE_MYST
+ if (gameId == "myst" || gameId == "makingofmyst") {
+ return new Mohawk::MystOptionsWidget(boss, name, target);
+ }
+#endif
+
+ return AdvancedMetaEngine::buildEngineOptionsWidget(boss, name, target);
+}
+
bool MohawkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Mohawk::MohawkGameDescription *gd = (const Mohawk::MohawkGameDescription *)desc;
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h
index 791726366d..f09376b2fd 100644
--- a/engines/mohawk/detection_tables.h
+++ b/engines/mohawk/detection_tables.h
@@ -23,9 +23,9 @@
namespace Mohawk {
#define GUI_OPTIONS_MYST GUIO4(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI)
-#define GUI_OPTIONS_MYST_ME GUIO5(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI, GAMEOPTION_PLAY_MYST_FLYBY)
-#define GUI_OPTIONS_MYST_ME_25TH GUIO6(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI, GAMEOPTION_PLAY_MYST_FLYBY, GAMEOPTION_25TH)
-#define GUI_OPTIONS_MYST_DEMO GUIO4(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOMIDI, GUIO_NOLAUNCHLOAD)
+#define GUI_OPTIONS_MYST_ME GUIO5(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI, GAMEOPTION_ME)
+#define GUI_OPTIONS_MYST_ME_25TH GUIO6(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI, GAMEOPTION_ME, GAMEOPTION_25TH)
+#define GUI_OPTIONS_MYST_DEMO GUIO5(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOMIDI, GUIO_NOLAUNCHLOAD, GAMEOPTION_DEMO)
#define GUI_OPTIONS_MYST_MAKING_OF GUIO5(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI, GUIO_NOLAUNCHLOAD)
#define GUI_OPTIONS_RIVEN GUIO4(GUIO_NOASPECT, GUIO_NOSUBTITLES, GUIO_NOSPEECH, GUIO_NOMIDI)
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index e12e7d5f73..507e81e7e2 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -25,13 +25,17 @@
#include "gui/gui-manager.h"
#include "gui/saveload.h"
+#include "gui/ThemeEval.h"
#include "gui/widget.h"
#include "gui/widgets/popup.h"
+
+#include "common/gui_options.h"
#include "common/system.h"
#include "common/translation.h"
#ifdef ENABLE_MYST
#include "mohawk/myst.h"
+#include "mohawk/myst_actions.h"
#include "mohawk/myst_scripts.h"
#endif
@@ -128,161 +132,164 @@ void MohawkOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd,
#ifdef ENABLE_MYST
-MystOptionsDialog::MystOptionsDialog(MohawkEngine_Myst* vm) :
- MohawkOptionsDialog(),
- _vm(vm),
- _canDropPage(false),
- _canShowMap(false),
- _canReturnToMenu(false),
- _loadSlot(-1),
- _saveSlot(-1) {
+MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
+ OptionsContainerWidget(boss, name, "MystOptionsDialog", false, domain),
+ _zipModeCheckbox(nullptr),
+ _transitionsCheckbox(nullptr),
+ _mystFlyByCheckbox(nullptr),
+ _dropPageButton(nullptr),
+ _showMapButton(nullptr),
+ _returnToMenuButton(nullptr) {
+
+ if (!checkGameGUIOption(GAMEOPTION_DEMO, ConfMan.get("guioptions", _domain))) {
+ // I18N: Option for fast scene switching
+ _zipModeCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.ZipMode", _("~Z~ip Mode Activated"));
+ }
- _loadButton = new GUI::ButtonWidget(this, 245, 25, 100, 25, _("~L~oad"), nullptr, kLoadCmd);
- _saveButton = new GUI::ButtonWidget(this, 245, 60, 100, 25, _("~S~ave"), nullptr, kSaveCmd);
- _quitButton = new GUI::ButtonWidget(this, 245, 95, 100, 25, _("~Q~uit"), nullptr, kQuitCmd);
+ _transitionsCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.Transistions", _("~T~ransitions Enabled"));
- // I18N: Option for fast scene switching
- _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 220, 15, _("~Z~ip Mode Activated"), nullptr, kZipCmd);
- _transitionsCheckbox = new GUI::CheckboxWidget(this, 15, 30, 220, 15, _("~T~ransitions Enabled"), nullptr, kTransCmd);
- // I18N: Drop book page
- _dropPageButton = new GUI::ButtonWidget(this, 15, 60, 100, 25, _("~D~rop Page"), nullptr, kDropCmd);
+ if (checkGameGUIOption(GAMEOPTION_ME, ConfMan.get("guioptions", _domain))) {
+ _mystFlyByCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.PlayMystFlyBy", _("Play the Myst fly by movie"),
+ _("The Myst fly by movie was not played by the original engine."));
+ }
- // Myst ME only has maps
- if (_vm->getFeatures() & GF_ME)
- _showMapButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("Show ~M~ap"), nullptr, kMapCmd);
- else
- _showMapButton = nullptr;
+ if (isInGame()) {
+ MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
+ assert(vm);
- // Myst demo only has a menu
- if (_vm->getFeatures() & GF_DEMO)
- _returnToMenuButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("Main Men~u~"), nullptr, kMenuCmd);
- else
- _returnToMenuButton = nullptr;
+ // I18N: Drop book page
+ _dropPageButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.DropPage", _("~D~rop Page"), nullptr, kDropCmd);
- _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
- _saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
-}
+ // Myst ME only has maps
+ if (vm->getFeatures() & GF_ME) {
+ _showMapButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.ShowMap", _("Show ~M~ap"), nullptr, kMapCmd);
+ }
-MystOptionsDialog::~MystOptionsDialog() {
- delete _loadDialog;
- delete _saveDialog;
+ // Myst demo only has a menu
+ if (vm->getFeatures() & GF_DEMO) {
+ _returnToMenuButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.MainMenu", _("Main Men~u~"), nullptr, kMenuCmd);
+ }
+ }
}
-void MystOptionsDialog::open() {
- MohawkOptionsDialog::open();
+MystOptionsWidget::~MystOptionsWidget() {
+}
- _dropPageButton->setEnabled(_canDropPage);
+void MystOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
+ layouts.addDialog(layoutName, overlayedLayout)
+ .addLayout(GUI::ThemeLayout::kLayoutVertical)
+ .addPadding(16, 16, 16, 16)
+ .addWidget("ZipMode", "Checkbox")
+ .addWidget("Transistions", "Checkbox")
+ .addWidget("PlayMystFlyBy", "Checkbox")
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 16, 0)
+ .addSpace()
+ .addWidget("DropPage", "Button")
+ .addWidget("ShowMap", "Button")
+ .addWidget("MainMenu", "Button")
+ .addSpace()
+ .closeLayout()
+ .closeLayout()
+ .closeDialog();
+}
- if (_showMapButton) {
- _showMapButton->setEnabled(_canShowMap);
- }
+bool MystOptionsWidget::isInGame() const {
+ return _domain.equals(ConfMan.getActiveDomainName());
+}
- if (_returnToMenuButton) {
- // Return to menu button is not enabled on the menu
- _returnToMenuButton->setEnabled(_canReturnToMenu);
+void MystOptionsWidget::load() {
+ if (_zipModeCheckbox) {
+ _zipModeCheckbox->setState(ConfMan.getBool("zip_mode", _domain));
}
- // Zip mode is disabled in the demo
- if (_vm->getFeatures() & GF_DEMO)
- _zipModeCheckbox->setEnabled(false);
+ _transitionsCheckbox->setState(ConfMan.getBool("transition_mode", _domain));
- if (_vm->getFeatures() & GF_25TH) {
- // The 25th anniversary version has a main menu, no need to show these buttons here
- _loadButton->setVisible(false);
- _saveButton->setVisible(false);
- _quitButton->setVisible(false);
+ if (_mystFlyByCheckbox) {
+ _mystFlyByCheckbox->setState(ConfMan.getBool("playmystflyby", _domain));
}
- _loadSlot = -1;
- _saveSlot = -1;
- _loadButton->setEnabled(_vm->canLoadGameStateCurrently());
- _saveButton->setEnabled(_vm->canSaveGameStateCurrently());
-}
+ if (isInGame()) {
+ MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
+ assert(vm);
-void MystOptionsDialog::save() {
- _saveSlot = _saveDialog->runModalWithCurrentTarget();
+ _dropPageButton->setEnabled(vm->canDoAction(kMystActionDropPage));
- if (_saveSlot >= 0) {
- _saveDescription = _saveDialog->getResultString();
- if (_saveDescription.empty()) {
- // If the user was lazy and entered no save name, come up with a default name.
- _saveDescription = _saveDialog->createDefaultSaveDescription(_saveSlot);
+ if (_showMapButton) {
+ _showMapButton->setEnabled(vm->canDoAction(kMystActionShowMap));
}
- close();
+ if (_returnToMenuButton) {
+ // Return to menu button is not enabled on the menu
+ _returnToMenuButton->setEnabled(vm->canDoAction(kMystActionOpenMainMenu));
+ }
}
}
-void MystOptionsDialog::load() {
- // Do not load the game state from insite the dialog loop to
- // avoid mouse cursor glitches (see bug #7164). Instead store
- // the slot to load and let the code exectuting the dialog do
- // the load after the dialog finished running.
- _loadSlot = _loadDialog->runModalWithCurrentTarget();
+bool MystOptionsWidget::save() {
+ if (_zipModeCheckbox) {
+ ConfMan.setBool("zip_mode", _zipModeCheckbox->getState(), _domain);
+ }
- if (_loadSlot >= 0)
- close();
+ ConfMan.setBool("transition_mode", _transitionsCheckbox->getState(), _domain);
+
+ if (_mystFlyByCheckbox) {
+ ConfMan.setBool("playmystflyby", _mystFlyByCheckbox->getState(), _domain);
+ }
+
+ return true;
}
-void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+void MystOptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ assert(_parentDialog);
+
+ GUI::CommandSender dialog(_parentDialog);
+
switch (cmd) {
- case kLoadCmd:
- load();
- break;
- case kSaveCmd:
- save();
- break;
case kDropCmd:
- setResult(kActionDropPage);
- close();
+ dialog.sendCommand(GUI::kCloseWithResultCmd, kMystActionDropPage);
break;
case kMapCmd:
- setResult(kActionShowMap);
- close();
+ dialog.sendCommand(GUI::kCloseWithResultCmd, kMystActionShowMap);
break;
case kMenuCmd:
- setResult(kActionGoToMenu);
- close();
- break;
- case kQuitCmd:
- setResult(kActionShowCredits);
- close();
- break;
- case GUI::kOKCmd:
- setResult(kActionSaveSettings);
- close();
+ dialog.sendCommand(GUI::kCloseWithResultCmd, kMystActionOpenMainMenu);
break;
default:
- MohawkOptionsDialog::handleCommand(sender, cmd, data);
+ OptionsContainerWidget::handleCommand(sender, cmd, data);
}
}
-void MystOptionsDialog::setCanDropPage(bool canDropPage) {
- _canDropPage = canDropPage;
-}
-
-void MystOptionsDialog::setCanShowMap(bool canShowMap) {
- _canShowMap = canShowMap;
-}
-
-void MystOptionsDialog::setCanReturnToMenu(bool canReturnToMenu) {
- _canReturnToMenu = canReturnToMenu;
-}
-
-bool MystOptionsDialog::getZipMode() const {
- return _zipModeCheckbox->getState();
+MystMenuDialog::MystMenuDialog(Engine *engine) :
+ MainMenuDialog(engine) {
}
-void MystOptionsDialog::setZipMode(bool enabled) {
- _zipModeCheckbox->setState(enabled);
+MystMenuDialog::~MystMenuDialog() {
}
-bool MystOptionsDialog::getTransitions() const {
- return _transitionsCheckbox->getState();
-}
+void MystMenuDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(_engine);
+ assert(vm);
-void MystOptionsDialog::setTransitions(bool enabled) {
- _transitionsCheckbox->setState(enabled);
+ switch (cmd) {
+ case kOptionsCmd: {
+ GUI::ConfigDialog configDialog;
+ int result = configDialog.runModal();
+ if (result > kMystActionNone && result <= kMystActionLast) {
+ close();
+ MystEventAction action = static_cast<MystEventAction>(result);
+ vm->scheduleAction(action);
+ }
+ break;
+ }
+ case kQuitCmd:
+ close();
+ vm->runCredits();
+ break;
+ default:
+ MainMenuDialog::handleCommand(sender, cmd, data);
+ break;
+ }
}
#endif
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index b7fcdab98c..e67da6c331 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -27,7 +27,11 @@
#include "common/events.h"
#include "common/str.h"
+
+#include "engines/dialogs.h"
+
#include "gui/dialog.h"
+#include "gui/widget.h"
namespace GUI {
class SaveLoadChooser;
@@ -87,66 +91,42 @@ public:
#ifdef ENABLE_MYST
-class MohawkEngine_Myst;
-
-class MystOptionsDialog : public MohawkOptionsDialog {
+class MystOptionsWidget : public GUI::OptionsContainerWidget {
public:
- explicit MystOptionsDialog(MohawkEngine_Myst *vm);
- ~MystOptionsDialog() override;
-
- enum ResultAction {
- kActionSaveSettings = 1,
- kActionDropPage,
- kActionShowMap,
- kActionGoToMenu,
- kActionShowCredits
- };
-
- void setCanDropPage(bool canDropPage);
- void setCanShowMap(bool canShowMap);
- void setCanReturnToMenu(bool canReturnToMenu);
+ MystOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
+ ~MystOptionsWidget() override;
- bool getZipMode() const;
- void setZipMode(bool enabled);
- bool getTransitions() const;
- void setTransitions(bool enabled);
-
- void open() override;
+ // Widget API
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
- int getLoadSlot() const { return _loadSlot; }
- int getSaveSlot() const { return _saveSlot; }
- Common::String getSaveDescription() const { return _saveDescription; }
+ // OptionsContainerWidget API
+ void load() override;
+ bool save() override;
private:
- void save();
- void load();
-
- MohawkEngine_Myst *_vm;
+ // OptionsContainerWidget API
+ void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
- GUI::ButtonWidget *_loadButton;
- GUI::ButtonWidget *_saveButton;
- GUI::ButtonWidget *_quitButton;
-
- GUI::SaveLoadChooser *_loadDialog;
- GUI::SaveLoadChooser *_saveDialog;
-
- int _loadSlot;
- int _saveSlot;
- Common::String _saveDescription;
-
- bool _canDropPage;
- bool _canShowMap;
- bool _canReturnToMenu;
+ bool isInGame() const;
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_transitionsCheckbox;
+ GUI::CheckboxWidget *_mystFlyByCheckbox;
GUI::ButtonWidget *_dropPageButton;
GUI::ButtonWidget *_showMapButton;
GUI::ButtonWidget *_returnToMenuButton;
};
+class MystMenuDialog : public MainMenuDialog {
+public:
+ MystMenuDialog(Engine *engine);
+ ~MystMenuDialog() override;
+
+ // MainMenuDialog API
+ void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
+};
+
#endif
#ifdef ENABLE_RIVEN
diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h
index 1fd2b7db5f..2195cb4065 100644
--- a/engines/mohawk/mohawk.h
+++ b/engines/mohawk/mohawk.h
@@ -57,9 +57,9 @@ enum MohawkGameType {
GType_LIVINGBOOKSV5
};
-#define GAMEOPTION_PLAY_MYST_FLYBY GUIO_GAMEOPTIONS1
-#define GAMEOPTION_25TH GUIO_GAMEOPTIONS2
-#define GAMEOPTION_DEMO GUIO_GAMEOPTIONS3
+#define GAMEOPTION_ME GUIO_GAMEOPTIONS1
+#define GAMEOPTION_25TH GUIO_GAMEOPTIONS2
+#define GAMEOPTION_DEMO GUIO_GAMEOPTIONS3
enum MohawkGameFeatures {
GF_ME = (1 << 0), // Myst Masterpiece Edition
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 9432972556..d1f398aec6 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -31,9 +31,11 @@
#include "common/translation.h"
#include "common/textconsole.h"
+#include "engines/dialogs.h"
#include "gui/saveload.h"
#include "mohawk/cursors.h"
+#include "mohawk/dialogs.h"
#include "mohawk/myst.h"
#include "mohawk/myst_areas.h"
#include "mohawk/myst_card.h"
@@ -41,7 +43,6 @@
#include "mohawk/myst_scripts.h"
#include "mohawk/myst_sound.h"
#include "mohawk/myst_state.h"
-#include "mohawk/dialogs.h"
#include "mohawk/resource.h"
#include "mohawk/resource_cache.h"
#include "mohawk/video.h"
@@ -63,16 +64,6 @@
namespace Mohawk {
-enum MystEventAction {
- kMystActionOpenMainMenu,
- kMystActionSkip,
- kMystActionInteract,
- kMystActionLoadGameState,
- kMystActionSaveGameState,
- kMystActionOpenOptionsDialog,
- kMystActionPause
-};
-
MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription *gamedesc) :
MohawkEngine(syst, gamedesc) {
DebugMan.addDebugChannel(kDebugVariable, "Variable", "Track Variable Accesses");
@@ -89,18 +80,23 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_currentCursor = 0;
_mainCursor = kDefaultMystCursor;
_showResourceRects = false;
+ _scheduledAction = kMystActionNone;
_sound = nullptr;
_video = nullptr;
_gfx = nullptr;
_gameState = nullptr;
- _optionsDialog = nullptr;
_rnd = nullptr;
_mouseClicked = false;
_mouseMoved = false;
_escapePressed = false;
_waitingOnBlockingOperation = false;
+
+ // We have a custom GMM subclass to show the credits when quitting
+ // and to support the drop page and other actions in the options dialog.
+ assert(!_mainMenuDialog);
+ _mainMenuDialog = new MystMenuDialog(this);
}
MohawkEngine_Myst::~MohawkEngine_Myst() {
@@ -110,7 +106,6 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
delete _video;
delete _sound;
delete _gameState;
- delete _optionsDialog;
delete _rnd;
}
@@ -410,15 +405,11 @@ Common::Error MohawkEngine_Myst::run() {
return Common::kAudioDeviceInitFailed;
}
- ConfMan.registerDefault("zip_mode", false);
- ConfMan.registerDefault("transition_mode", false);
-
_gfx = new MystGraphics(this);
_video = new VideoManager(this);
_sound = new MystSound(this);
setDebugger(new MystConsole(this));
_gameState = new MystGameState(this, _saveFileMan);
- _optionsDialog = new MystOptionsDialog(this);
_cursor = new MystCursorManager(this);
_rnd = new Common::RandomSource("myst");
@@ -500,20 +491,35 @@ void MohawkEngine_Myst::loadArchive(const char *archiveName, const char *languag
_mhk.push_back(archive);
}
+void MohawkEngine_Myst::registerDefaultSettings() {
+ ConfMan.registerDefault("playmystflyby", false);
+ ConfMan.registerDefault("zip_mode", false);
+ ConfMan.registerDefault("transition_mode", false);
+}
+
Common::KeymapArray MohawkEngine_Myst::initKeymaps(const char *target) {
using namespace Common;
+ String guiOptions = ConfMan.get("guioptions", target);
+ bool isME = checkGameGUIOption(GAMEOPTION_ME, guiOptions);
+ bool is25th = checkGameGUIOption(GAMEOPTION_25TH, guiOptions);
+ bool isDemo = checkGameGUIOption(GAMEOPTION_DEMO, guiOptions);
+
Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "myst", "Myst");
Action *act;
- if (checkGameGUIOption(GAMEOPTION_25TH, ConfMan.get("guioptions", target))) {
- act = new Action(kStandardActionOpenMainMenu, _("Open main menu"));
- act->setCustomEngineActionEvent(kMystActionOpenMainMenu);
+ act = new Action(kStandardActionOpenMainMenu, _("Open main menu"));
+ act->setCustomEngineActionEvent(kMystActionOpenMainMenu);
+ act->addDefaultInputMapping("JOY_X");
+ if (is25th) {
act->addDefaultInputMapping("ESCAPE");
- act->addDefaultInputMapping("JOY_X");
- engineKeyMap->addAction(act);
+ } else if (isDemo) {
+ // TODO: Check the original keybinding for the demo version menu
+ } else {
+ act->addDefaultInputMapping("F5");
}
+ engineKeyMap->addAction(act);
act = new Action(kStandardActionSkip, _("Skip"));
act->setCustomEngineActionEvent(kMystActionSkip);
@@ -539,7 +545,9 @@ Common::KeymapArray MohawkEngine_Myst::initKeymaps(const char *target) {
act = new Action(kStandardActionOpenSettings, _("Show options menu"));
act->setCustomEngineActionEvent(kMystActionOpenOptionsDialog);
- act->addDefaultInputMapping("F5");
+ if (is25th || isDemo) {
+ act->addDefaultInputMapping("F5");
+ }
engineKeyMap->addAction(act);
act = new Action(kStandardActionPause, _("Pause"));
@@ -547,6 +555,18 @@ Common::KeymapArray MohawkEngine_Myst::initKeymaps(const char *target) {
act->addDefaultInputMapping("SPACE");
engineKeyMap->addAction(act);
+ act = new Action("DRPP", _("Drop page"));
+ act->setCustomEngineActionEvent(kMystActionDropPage);
+ act->addDefaultInputMapping("A+d");
+ engineKeyMap->addAction(act);
+
+ if (isME) {
+ act = new Action("SMAP", _("Show map"));
+ act->setCustomEngineActionEvent(kMystActionShowMap);
+ act->addDefaultInputMapping("A+F8");
+ engineKeyMap->addAction(act);
+ }
+
return Keymap::arrayOf(engineKeyMap);
}
@@ -566,53 +586,7 @@ void MohawkEngine_Myst::doFrame() {
_mouseMoved = true;
break;
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
- switch ((MystEventAction)event.customType) {
- case kMystActionInteract:
- _mouseClicked = true;
- break;
- case kMystActionPause:
- pauseGame();
- break;
- case kMystActionOpenOptionsDialog:
- runOptionsDialog();
- break;
- case kMystActionOpenMainMenu:
- if (_stack->getStackId() == kCreditsStack) {
- // Don't allow going to the menu while the credits play
- break;
- }
-
- if (getFeatures() & GF_25TH && isInteractive()) {
- if (_stack->getStackId() == kMenuStack) {
- // If the menu is active and a game is loaded, go back to the game
- if (_prevStack) {
- resumeFromMainMenu();
- }
- } else {
- // If the game is interactive, open the main menu
- goToMainMenu();
- }
- }
- break;
- case kMystActionSkip:
- if (!isInteractive()) {
- // Try to skip the currently playing video
- _escapePressed = true;
- }
- break;
- case kMystActionLoadGameState:
- if (canLoadGameStateCurrently()) {
- runLoadDialog();
- }
- break;
- case kMystActionSaveGameState:
- if (canSaveGameStateCurrently()) {
- runSaveDialog();
- }
- break;
- default:
- break;
- }
+ doAction((MystEventAction)event.customType);
break;
case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
switch ((MystEventAction)event.customType) {
@@ -655,78 +629,128 @@ void MohawkEngine_Myst::doFrame() {
_system->delayMillis(10);
}
-void MohawkEngine_Myst::runOptionsDialog() {
+bool MohawkEngine_Myst::canDoAction(MystEventAction action) {
bool inMenu = (_stack->getStackId() == kMenuStack) && _prevStack;
bool actionsAllowed = inMenu || isInteractive();
- MystScriptParserPtr stack;
- if (inMenu) {
- stack = _prevStack;
- } else {
- stack = _stack;
- }
+ const MystScriptParserPtr &stack = inMenu ? _prevStack : _stack;
- if (isGameStarted()) {
- _optionsDialog->setZipMode(_gameState->_globals.zipMode);
- _optionsDialog->setTransitions(_gameState->_globals.transitions);
- } else {
- _optionsDialog->setZipMode(ConfMan.getBool("zip_mode"));
- _optionsDialog->setTransitions(ConfMan.getBool("transition_mode"));
+ switch (action) {
+ case kMystActionDropPage:
+ return actionsAllowed && _gameState->_globals.heldPage != kNoPage;
+ case kMystActionShowMap:
+ return actionsAllowed && stack->getMap();
+ case kMystActionOpenMainMenu:
+ assert(getFeatures() & GF_DEMO);
+ return actionsAllowed && stack->getStackId() != kDemoStack;
+ default:
+ // Not implemented yet
+ assert(false);
}
+}
- _optionsDialog->setCanDropPage(actionsAllowed && _gameState->_globals.heldPage != kNoPage);
- _optionsDialog->setCanShowMap(actionsAllowed && stack->getMap());
- _optionsDialog->setCanReturnToMenu(actionsAllowed && stack->getStackId() != kDemoStack);
+void MohawkEngine_Myst::doAction(MystEventAction action) {
+ switch (action) {
+ case kMystActionInteract:
+ _mouseClicked = true;
+ break;
+ case kMystActionPause:
+ pauseGame();
+ break;
+ case kMystActionOpenOptionsDialog:
+ runOptionsDialog();
+ break;
+ case kMystActionOpenMainMenu:
+ if (_stack->getStackId() == kCreditsStack) {
+ // Don't allow going to the menu while the credits play
+ break;
+ }
- switch (runDialog(*_optionsDialog)) {
- case MystOptionsDialog::kActionDropPage:
- if (inMenu) {
- resumeFromMainMenu();
+ if (getFeatures() & GF_DEMO) {
+ if (_stack->getStackId() != kDemoStack && isInteractive()) {
+ changeToStack(kDemoStack, 2002, 0, 0);
+ }
+ break;
}
- dropPage();
- break;
- case MystOptionsDialog::kActionShowMap:
- if (inMenu) {
- resumeFromMainMenu();
+ if (getFeatures() & GF_25TH && isInteractive()) {
+ if (_stack->getStackId() == kMenuStack) {
+ // If the menu is active and a game is loaded, go back to the game
+ if (_prevStack) {
+ resumeFromMainMenu();
+ }
+ } else {
+ // If the game is interactive, open the main menu
+ goToMainMenu();
+ }
+ break;
}
- stack->showMap();
- break;
- case MystOptionsDialog::kActionGoToMenu:
- if (inMenu) {
- resumeFromMainMenu();
+ if (isInteractive()) {
+ openMainMenuDialog();
}
- changeToStack(kDemoStack, 2002, 0, 0);
break;
- case MystOptionsDialog::kActionShowCredits:
- if (isInteractive() && getGameType() != GType_MAKINGOF) {
- _cursor->hideCursor();
- changeToStack(kCreditsStack, 10000, 0, 0);
- } else {
- // Showing the credits in the middle of a script is not possible
- // because it unloads the previous age, removing data needed by the
- // rest of the script. Instead we just quit without showing the credits.
- quitGame();
+ case kMystActionSkip:
+ if (!isInteractive()) {
+ // Try to skip the currently playing video
+ _escapePressed = true;
}
break;
- case MystOptionsDialog::kActionSaveSettings:
- if (isGameStarted()) {
- _gameState->_globals.zipMode = _optionsDialog->getZipMode();
- _gameState->_globals.transitions = _optionsDialog->getTransitions();
- } else {
- ConfMan.setBool("zip_mode", _optionsDialog->getZipMode());
- ConfMan.setBool("transition_mode", _optionsDialog->getTransitions());
- ConfMan.flushToDisk();
+ case kMystActionLoadGameState:
+ if (canLoadGameStateCurrently()) {
+ runLoadDialog();
}
break;
- default:
- if (_optionsDialog->getLoadSlot() >= 0)
- loadGameState(_optionsDialog->getLoadSlot());
- if (_optionsDialog->getSaveSlot() >= 0)
- saveGameState(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription());
+ case kMystActionSaveGameState:
+ if (canSaveGameStateCurrently()) {
+ runSaveDialog();
+ }
+ break;
+ case kMystActionDropPage:
+ if (_gameState->_globals.heldPage != kNoPage && isInteractive()) {
+ dropPage();
+ }
break;
+ case kMystActionShowMap:
+ if (_stack->getMap() && isInteractive()) {
+ _stack->showMap();
+ }
+ break;
+ case kMystActionNone:
+ break;
+ }
+}
+
+void MohawkEngine_Myst::scheduleAction(MystEventAction action) {
+ _scheduledAction = action;
+}
+
+void MohawkEngine_Myst::runOptionsDialog() {
+ GUI::ConfigDialog dlg;
+ int result = runDialog(dlg);
+ if (result > 0) {
+ syncSoundSettings();
+ }
+
+ if (result > kMystActionNone && result <= kMystActionLast) {
+ if (_prevStack) {
+ resumeFromMainMenu();
+ }
+
+ doAction(static_cast<MystEventAction>(result));
+ }
+}
+
+void MohawkEngine_Myst::runCredits() {
+ if (isInteractive() && getGameType() != GType_MAKINGOF) {
+ _cursor->hideCursor();
+ changeToStack(kCreditsStack, 10000, 0, 0);
+ } else {
+ // Showing the credits in the middle of a script is not possible
+ // because it unloads the previous age, removing data needed by the
+ // rest of the script. Instead we just quit without showing the credits.
+ quitGame();
}
}
@@ -757,7 +781,13 @@ void MohawkEngine_Myst::pauseEngineIntern(bool pause) {
// We may have missed events while paused
_mouseClicked = (_eventMan->getButtonState() & 1) != 0;
+
+ if (_scheduledAction != kMystActionNone) {
+ doAction(_scheduledAction);
+ }
}
+
+ _scheduledAction = kMystActionNone;
}
void MohawkEngine_Myst::changeToStack(MystStack stackId, uint16 card, uint16 linkSrcSound, uint16 linkDstSound) {
@@ -883,7 +913,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
// Make sure the screen is updated
if (transition != kNoTransition) {
- if (_gameState->_globals.transitions) {
+ if (ConfMan.getBool("transition_mode")) {
_gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
} else {
_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
@@ -1197,6 +1227,8 @@ bool MohawkEngine_Myst::isGameStarted() const {
}
void MohawkEngine_Myst::resumeFromMainMenu() {
+ assert(_prevStack);
+
_card->leave();
_card.reset();
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 2785740a53..6f444a25c2 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -25,6 +25,7 @@
#include "mohawk/console.h"
#include "mohawk/mohawk.h"
+#include "mohawk/myst_actions.h"
#include "mohawk/resource_cache.h"
#include "mohawk/video.h"
@@ -41,7 +42,7 @@ class MystGraphics;
class MystScriptParser;
class MystConsole;
class MystGameState;
-class MystOptionsDialog;
+class MystOptionsWidget;
class MystSound;
class MystArea;
class MystAreaImageSwitch;
@@ -194,6 +195,7 @@ public:
}
bool hasFeature(EngineFeature f) const override;
+ static void registerDefaultSettings();
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
void resumeFromMainMenu();
@@ -201,9 +203,13 @@ public:
void runLoadDialog();
void runSaveDialog();
void runOptionsDialog();
+ void runCredits();
+
+ bool canDoAction(MystEventAction action);
+ void doAction(MystEventAction action);
+ void scheduleAction(MystEventAction action);
private:
- MystOptionsDialog *_optionsDialog;
ResourceCache _cache;
MystScriptParserPtr _prevStack;
@@ -232,6 +238,8 @@ private:
uint16 _currentCursor;
uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none)
+
+ MystEventAction _scheduledAction;
};
} // End of namespace Mohawk
diff --git a/engines/mohawk/myst_actions.h b/engines/mohawk/myst_actions.h
new file mode 100644
index 0000000000..a7d4c86606
--- /dev/null
+++ b/engines/mohawk/myst_actions.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MOHAWK_MYST_ACTIONS_H
+#define MOHAWK_MYST_ACTIONS_H
+
+namespace Mohawk {
+
+enum MystEventAction {
+ kMystActionNone = 100,
+ kMystActionOpenMainMenu,
+ kMystActionSkip,
+ kMystActionInteract,
+ kMystActionLoadGameState,
+ kMystActionSaveGameState,
+ kMystActionOpenOptionsDialog,
+ kMystActionPause,
+ kMystActionDropPage,
+ kMystActionShowMap,
+
+ kMystActionLast = kMystActionShowMap
+};
+
+} // End of namespace Mohawk
+
+#endif
diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp
index c23d01c6b6..6dd424ee3b 100644
--- a/engines/mohawk/myst_state.cpp
+++ b/engines/mohawk/myst_state.cpp
@@ -95,9 +95,6 @@ void MystGameState::reset() {
_globals.u1 = 1;
_globals.ending = kDniNotVisited;
- _globals.zipMode = ConfMan.getBool("zip_mode");
- _globals.transitions = ConfMan.getBool("transition_mode");
-
// Library Bookcase Door - Default to Up
_myst.libraryBookcaseDoor = 1;
// Dock Imager Numeric Selection - Default to 67
@@ -577,7 +574,7 @@ void MystGameState::addZipDest(MystStack stack, uint16 view) {
bool MystGameState::isReachableZipDest(MystStack stack, uint16 view) {
// Zip mode enabled
- if (!_globals.zipMode)
+ if (!ConfMan.getBool("zip_mode"))
return false;
// The demo has no zip dest storage
diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h
index e9f1860815..533d5eba8c 100644
--- a/engines/mohawk/myst_state.h
+++ b/engines/mohawk/myst_state.h
@@ -131,8 +131,8 @@ public:
ActiveAge currentAge;
HeldPage heldPage;
uint16 u1;
- uint16 transitions;
- uint16 zipMode;
+ uint16 transitions; // Unused in ScummVM
+ uint16 zipMode; // Unused in ScummVM
uint16 redPagesInBook;
uint16 bluePagesInBook;
DniEnding ending;
Commit: 1f5d4d1fdd31e72f7d3981a10b86e4d62253320b
https://github.com/scummvm/scummvm/commit/1f5d4d1fdd31e72f7d3981a10b86e4d62253320b
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
MOHAWK: RIVEN: Configuration dialog changes
* Unify the custom options dialog (previously accessed through F5), and
the in-game options dialog accessed through the Global Main Menu.
* Change the default keybinding for F5 to show the GMM for the non-25th
anniversary editions of the game. This allows easy access to
the load and save functionality. With the 25th anniversary edition,
the main menu accessed through ESC should be used instead.
Changed paths:
engines/mohawk/detection.cpp
engines/mohawk/dialogs.cpp
engines/mohawk/dialogs.h
engines/mohawk/riven.cpp
engines/mohawk/riven.h
engines/mohawk/riven_graphics.cpp
engines/mohawk/riven_graphics.h
engines/mohawk/riven_saveload.cpp
engines/mohawk/riven_vars.cpp
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index f974f96d3f..fa339988a3 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -133,8 +133,9 @@ bool MohawkEngine_Myst::hasFeature(EngineFeature f) const {
bool MohawkEngine_Riven::hasFeature(EngineFeature f) const {
return
MohawkEngine::hasFeature(f)
- || (f == kSupportsLoadingDuringRuntime)
- || (f == kSupportsSavingDuringRuntime);
+ || (f == kSupportsLoadingDuringRuntime)
+ || (f == kSupportsSavingDuringRuntime)
+ || (f == kSupportsChangingOptionsDuringRuntime);
}
#endif
@@ -346,6 +347,11 @@ void MohawkMetaEngine::registerDefaultSettings(const Common::String &target) con
return Mohawk::MohawkEngine_Myst::registerDefaultSettings();
}
#endif
+#ifdef ENABLE_RIVEN
+ if (gameId == "riven") {
+ return Mohawk::MohawkEngine_Riven::registerDefaultSettings();
+ }
+#endif
return AdvancedMetaEngine::registerDefaultSettings(target);
}
@@ -358,6 +364,11 @@ GUI::OptionsContainerWidget *MohawkMetaEngine::buildEngineOptionsWidget(GUI::Gui
return new Mohawk::MystOptionsWidget(boss, name, target);
}
#endif
+#ifdef ENABLE_RIVEN
+ if (gameId == "riven") {
+ return new Mohawk::RivenOptionsWidget(boss, name, target);
+ }
+#endif
return AdvancedMetaEngine::buildEngineOptionsWidget(boss, name, target);
}
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index 507e81e7e2..62c98299c2 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -84,52 +84,11 @@ void PauseDialog::handleKeyDown(Common::KeyState state) {
}
enum {
- kZipCmd = 'ZIPM',
- kTransCmd = 'TRAN',
- kWaterCmd = 'WATR',
kDropCmd = 'DROP',
- kMapCmd = 'SMAP',
- kMenuCmd = 'MENU',
- kSaveCmd = 'SAVE',
- kLoadCmd = 'LOAD',
- kQuitCmd = 'QUIT'
+ kMapCmd = 'SMAP',
+ kMenuCmd = 'MENU'
};
-#if defined(ENABLE_MYST) || defined(ENABLE_RIVEN)
-
-MohawkOptionsDialog::MohawkOptionsDialog() :
- GUI::Dialog(0, 0, 360, 200) {
- new GUI::ButtonWidget(this, 95, 160, 120, 25, _("~O~K"), nullptr, GUI::kOKCmd);
- new GUI::ButtonWidget(this, 225, 160, 120, 25, _("~C~ancel"), nullptr, GUI::kCloseCmd);
-}
-
-MohawkOptionsDialog::~MohawkOptionsDialog() {
-}
-
-void MohawkOptionsDialog::reflowLayout() {
- const int screenW = g_system->getOverlayWidth();
- const int screenH = g_system->getOverlayHeight();
-
- // Center the dialog
- _x = (screenW - getWidth()) / 2;
- _y = (screenH - getHeight()) / 2;
-
- GUI::Dialog::reflowLayout();
-}
-
-
-void MohawkOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
- switch (cmd) {
- case GUI::kCloseCmd:
- close();
- break;
- default:
- GUI::Dialog::handleCommand(sender, cmd, data);
- }
-}
-
-#endif
-
#ifdef ENABLE_MYST
MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
@@ -296,54 +255,54 @@ void MystMenuDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint3
#ifdef ENABLE_RIVEN
-RivenOptionsDialog::RivenOptionsDialog() : MohawkOptionsDialog() {
- _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 220, 15, _("~Z~ip Mode Activated"), nullptr, kZipCmd);
- _waterEffectCheckbox = new GUI::CheckboxWidget(this, 15, 35, 220, 15, _("~W~ater Effect Enabled"), nullptr, kWaterCmd);
+RivenOptionsWidget::RivenOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
+ OptionsContainerWidget(boss, name, "RivenOptionsDialog", false, domain) {
+
+ _zipModeCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "RivenOptionsDialog.ZipMode", _("~Z~ip Mode Activated"));
+ _waterEffectCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "RivenOptionsDialog.WaterEffect", _("~W~ater Effect Enabled"));
+
+ GUI::StaticTextWidget *transitionModeCaption = new GUI::StaticTextWidget(widgetsBoss(), "RivenOptionsDialog.TransistionsDesc", _("Transitions:"));
+ transitionModeCaption->setAlign(Graphics::kTextAlignRight);
- _transitionModeCaption = new GUI::StaticTextWidget(this, 15, 60, 90, 20, _("Transitions:"), Graphics::kTextAlignRight);
- _transitionModePopUp = new GUI::PopUpWidget(this, 115, 60, 120, 20);
+ _transitionModePopUp = new GUI::PopUpWidget(widgetsBoss(), "RivenOptionsDialog.Transistions");
_transitionModePopUp->appendEntry(_("Disabled"), kRivenTransitionModeDisabled);
_transitionModePopUp->appendEntry(_("Fastest"), kRivenTransitionModeFastest);
_transitionModePopUp->appendEntry(_("Normal"), kRivenTransitionModeNormal);
_transitionModePopUp->appendEntry(_("Best"), kRivenTransitionModeBest);
}
-RivenOptionsDialog::~RivenOptionsDialog() {
-}
-
-bool RivenOptionsDialog::getZipMode() const {
- return _zipModeCheckbox->getState();
+RivenOptionsWidget::~RivenOptionsWidget() {
}
-void RivenOptionsDialog::setZipMode(bool enabled) {
- _zipModeCheckbox->setState(enabled);
+void RivenOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
+ layouts.addDialog(layoutName, overlayedLayout)
+ .addLayout(GUI::ThemeLayout::kLayoutVertical)
+ .addPadding(16, 16, 16, 16)
+ .addWidget("ZipMode", "Checkbox")
+ .addWidget("WaterEffect", "Checkbox")
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("TransistionsDesc", "OptionsLabel")
+ .addWidget("Transistions", "PopUp")
+ .closeLayout()
+ .closeLayout()
+ .closeDialog();
}
-bool RivenOptionsDialog::getWaterEffect() const {
- return _waterEffectCheckbox->getState();
-}
+void RivenOptionsWidget::load() {
+ _zipModeCheckbox->setState(ConfMan.getBool("zip_mode", _domain));
+ _waterEffectCheckbox->setState(ConfMan.getBool("water_effects", _domain));
-void RivenOptionsDialog::setWaterEffect(bool enabled) {
- _waterEffectCheckbox->setState(enabled);
+ uint32 transitions = ConfMan.getInt("transition_mode", _domain);
+ _transitionModePopUp->setSelectedTag(RivenGraphics::sanitizeTransitionMode(transitions));
}
-uint32 RivenOptionsDialog::getTransitions() const {
- return _transitionModePopUp->getSelectedTag();
-}
+bool RivenOptionsWidget::save() {
+ ConfMan.setBool("zip_mode", _zipModeCheckbox->getState(), _domain);
+ ConfMan.setBool("water_effects", _waterEffectCheckbox->getState(), _domain);
+ ConfMan.setInt("transition_mode", _transitionModePopUp->getSelectedTag(), _domain);
-void RivenOptionsDialog::setTransitions(uint32 mode) {
- _transitionModePopUp->setSelectedTag(mode);
-}
-
-void RivenOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
- switch (cmd) {
- case GUI::kOKCmd:
- setResult(1);
- close();
- break;
- default:
- MohawkOptionsDialog::handleCommand(sender, cmd, data);
- }
+ return true;
}
#endif
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index e67da6c331..0ad6fd33c7 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -76,19 +76,6 @@ public:
void handleKeyDown(Common::KeyState state) override;
};
-#if defined(ENABLE_MYST) || defined(ENABLE_RIVEN)
-
-class MohawkOptionsDialog : public GUI::Dialog {
-public:
- explicit MohawkOptionsDialog();
- ~MohawkOptionsDialog() override;
-
- void reflowLayout() override;
- void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
-};
-
-#endif
-
#ifdef ENABLE_MYST
class MystOptionsWidget : public GUI::OptionsContainerWidget {
@@ -131,23 +118,21 @@ public:
#ifdef ENABLE_RIVEN
-class RivenOptionsDialog : public MohawkOptionsDialog {
+class RivenOptionsWidget : public GUI::OptionsContainerWidget {
public:
- explicit RivenOptionsDialog();
- ~RivenOptionsDialog() override;
+ explicit RivenOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
+ ~RivenOptionsWidget() override;
- void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
+ // OptionsContainerWidget API
+ void load() override;
+ bool save() override;
- bool getZipMode() const;
- void setZipMode(bool enabled);
- bool getWaterEffect() const;
- void setWaterEffect(bool enabled);
- uint32 getTransitions() const;
- void setTransitions(uint32 mode);
private:
+ // OptionsContainerWidget API
+ void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
+
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_waterEffectCheckbox;
- GUI::StaticTextWidget *_transitionModeCaption;
GUI::PopUpWidget *_transitionModePopUp;
};
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index d4a89c5819..4e9185d842 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -30,6 +30,7 @@
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymapper.h"
#include "backends/keymapper/standard-actions.h"
+#include "engines/dialogs.h"
#include "graphics/scaler.h"
#include "gui/saveload.h"
#include "gui/message.h"
@@ -72,7 +73,6 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
_rnd = nullptr;
_scriptMan = nullptr;
_saveLoad = nullptr;
- _optionsDialog = nullptr;
_card = nullptr;
_inventory = nullptr;
_lastSaveTime = 0;
@@ -106,7 +106,6 @@ MohawkEngine_Riven::~MohawkEngine_Riven() {
delete _extrasFile;
delete _saveLoad;
delete _scriptMan;
- delete _optionsDialog;
delete _inventory;
delete _rnd;
@@ -120,10 +119,6 @@ Common::Error MohawkEngine_Riven::run() {
return Common::kAudioDeviceInitFailed;
}
- ConfMan.registerDefault("zip_mode", false);
- ConfMan.registerDefault("water_effects", true);
- ConfMan.registerDefault("transition_mode", kRivenTransitionModeFastest);
-
// Let's try to open the installer file (it holds extras.mhk)
// Though, we set a low priority to prefer the extracted version
if (_installerArchive.open("arcriven.z"))
@@ -134,7 +129,6 @@ Common::Error MohawkEngine_Riven::run() {
_sound = new RivenSoundManager(this);
setDebugger(new RivenConsole(this));
_saveLoad = new RivenSaveLoad(this, _saveFileMan);
- _optionsDialog = new RivenOptionsDialog();
_scriptMan = new RivenScriptManager(this);
_inventory = new RivenInventory(this);
@@ -149,6 +143,7 @@ Common::Error MohawkEngine_Riven::run() {
_cursor = new MacCursorManager("Riven");
initVars();
+ applyGameSettings();
// Check the user has copied all the required datafiles
if (!checkDatafiles()) {
@@ -175,9 +170,6 @@ Common::Error MohawkEngine_Riven::run() {
return Common::kNoGameDataFoundError;
}
- // Set the transition speed
- _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
-
// Start at main cursor
_cursor->setCursor(kRivenMainCursor);
_cursor->showCursor();
@@ -282,6 +274,8 @@ void MohawkEngine_Riven::processInput() {
} else {
resumeFromMainMenu();
}
+ } else if (!_scriptMan->hasQueuedScripts()) {
+ openMainMenuDialog();
}
break;
case kRivenActionPlayIntroVideos:
@@ -371,17 +365,6 @@ void MohawkEngine_Riven::pauseEngineIntern(bool pause) {
}
}
-uint32 MohawkEngine_Riven::sanitizeTransitionMode(uint32 mode) {
- if (mode != kRivenTransitionModeDisabled
- && mode != kRivenTransitionModeFastest
- && mode != kRivenTransitionModeNormal
- && mode != kRivenTransitionModeBest) {
- return kRivenTransitionModeFastest;
- }
-
- return mode;
-}
-
// Stack/Card-Related Functions
void MohawkEngine_Riven::changeToStack(uint16 stackId) {
@@ -658,11 +641,10 @@ void MohawkEngine_Riven::startNewGame() {
_vars.clear();
initVars();
+ applyGameSettings();
_zipModeData.clear();
- _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
-
setTotalPlayTime(0);
}
@@ -800,54 +782,56 @@ void MohawkEngine_Riven::setGameEnded() {
}
void MohawkEngine_Riven::runOptionsDialog() {
- if (isGameStarted()) {
- _optionsDialog->setZipMode(_vars["azip"] != 0);
- _optionsDialog->setWaterEffect(_vars["waterenabled"] != 0);
- _optionsDialog->setTransitions(_vars["transitionmode"]);
- } else {
- _optionsDialog->setZipMode(ConfMan.getBool("zip_mode"));
- _optionsDialog->setWaterEffect(ConfMan.getBool("water_effects"));
-
- uint32 transitions = ConfMan.getInt("transition_mode");
- _optionsDialog->setTransitions(sanitizeTransitionMode(transitions));
- }
-
- if (runDialog(*_optionsDialog) > 0) {
- if (isGameStarted()) {
- _vars["azip"] = _optionsDialog->getZipMode() ? 1 : 0;
- _vars["waterenabled"] = _optionsDialog->getWaterEffect() ? 1 : 0;
- _vars["transitionmode"] = _optionsDialog->getTransitions();
- } else {
- ConfMan.setBool("zip_mode", _optionsDialog->getZipMode());
- ConfMan.setBool("water_effects", _optionsDialog->getWaterEffect());
- ConfMan.setInt("transition_mode", _optionsDialog->getTransitions());
- ConfMan.flushToDisk();
- }
+ GUI::ConfigDialog dlg;
+ if (runDialog(dlg)) {
+ syncSoundSettings();
+ applyGameSettings();
}
+}
+
+void MohawkEngine_Riven::applyGameSettings() {
+ int transitions = ConfMan.getInt("transition_mode");
+ RivenTransitionMode transitionsMode = RivenGraphics::sanitizeTransitionMode(transitions);
+
+ _vars["transitionmode"] = transitionsMode;
+ _vars["azip"] = ConfMan.getBool("zip_mode");
+ _vars["waterenabled"] = ConfMan.getBool("water_effects");
- if (hasGameEnded()) {
- // Attempt to autosave before exiting
- saveAutosaveIfEnabled();
+ _gfx->setTransitionMode(transitionsMode);
+
+ if (_card) {
+ _card->initializeZipMode();
}
+}
- _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
- _card->initializeZipMode();
+void MohawkEngine_Riven::registerDefaultSettings() {
+ ConfMan.registerDefault("zip_mode", false);
+ ConfMan.registerDefault("water_effects", true);
+ ConfMan.registerDefault("transition_mode", kRivenTransitionModeFastest);
}
Common::KeymapArray MohawkEngine_Riven::initKeymaps(const char *target) {
using namespace Common;
+ String guiOptions = ConfMan.get("guioptions", target);
+ bool is25th = checkGameGUIOption(GAMEOPTION_25TH, guiOptions);
+ bool isDemo = checkGameGUIOption(GAMEOPTION_DEMO, guiOptions);
+
Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "riven", "Riven");
Action *act;
- if (checkGameGUIOption(GAMEOPTION_25TH, ConfMan.get("guioptions", target))) {
- act = new Action(kStandardActionOpenMainMenu, _("Open main menu"));
- act->setCustomEngineActionEvent(kRivenActionOpenMainMenu);
+ act = new Action(kStandardActionOpenMainMenu, _("Open main menu"));
+ act->setCustomEngineActionEvent(kRivenActionOpenMainMenu);
+ act->addDefaultInputMapping("JOY_X");
+ if (is25th) {
act->addDefaultInputMapping("ESCAPE");
- act->addDefaultInputMapping("JOY_X");
- engineKeyMap->addAction(act);
+ } else if (isDemo) {
+ act->addDefaultInputMapping("C+r");
+ } else {
+ act->addDefaultInputMapping("F5");
}
+ engineKeyMap->addAction(act);
act = new Action(kStandardActionSkip, _("Skip"));
act->setCustomEngineActionEvent(kRivenActionSkip);
@@ -873,7 +857,9 @@ Common::KeymapArray MohawkEngine_Riven::initKeymaps(const char *target) {
act = new Action(kStandardActionOpenSettings, _("Show options menu"));
act->setCustomEngineActionEvent(kRivenActionOpenOptionsDialog);
- act->addDefaultInputMapping("F5");
+ if (is25th) {
+ act->addDefaultInputMapping("F5");
+ }
engineKeyMap->addAction(act);
act = new Action(kStandardActionPause, _("Pause"));
@@ -923,12 +909,7 @@ Common::KeymapArray MohawkEngine_Riven::initKeymaps(const char *target) {
act->addDefaultInputMapping("PAGEDOWN");
engineKeyMap->addAction(act);
- if (checkGameGUIOption(GAMEOPTION_DEMO, ConfMan.get("guioptions", target))) {
- act = new Action(kStandardActionOpenMainMenu, _("Return to main menu"));
- act->setCustomEngineActionEvent(kRivenActionOpenMainMenu);
- act->addDefaultInputMapping("C+r");
- engineKeyMap->addAction(act);
-
+ if (isDemo) {
act = new Action("INTV", _("Play intro videos"));
act->setCustomEngineActionEvent(kRivenActionPlayIntroVideos);
act->addDefaultInputMapping("C+p");
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index b1bd4c9bcd..4923f0e5ad 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -37,6 +37,11 @@ namespace Common {
class Keymap;
}
+namespace GUI {
+class GuiObject;
+class OptionsContainerWidget;
+}
+
namespace Mohawk {
struct MohawkGameDescription;
@@ -44,7 +49,7 @@ class MohawkArchive;
class RivenGraphics;
class RivenConsole;
class RivenSaveLoad;
-class RivenOptionsDialog;
+class RivenOptionsWidget;
class RivenStack;
class RivenCard;
class RivenHotspot;
@@ -109,6 +114,8 @@ public:
return Common::String::format("riven-%03d.rvn", slot);
}
bool hasFeature(EngineFeature f) const override;
+ static void registerDefaultSettings();
+ void applyGameSettings() override;
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
void doFrame();
@@ -122,7 +129,6 @@ private:
bool checkDatafiles();
RivenSaveLoad *_saveLoad;
- RivenOptionsDialog *_optionsDialog;
InstallerArchive _installerArchive;
// Stack/Card-related functions and variables
@@ -140,7 +146,7 @@ private:
void initVars();
void pauseEngineIntern(bool) override;
- uint32 sanitizeTransitionMode(uint32 mode);
+
public:
// Stack/card/script funtions
RivenStack *constructStackById(uint16 id);
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index eb72d3a9c3..0a07d8dd5b 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -523,6 +523,17 @@ void RivenGraphics::setTransitionMode(RivenTransitionMode mode) {
}
}
+RivenTransitionMode RivenGraphics::sanitizeTransitionMode(int mode) {
+ if (mode != kRivenTransitionModeDisabled
+ && mode != kRivenTransitionModeFastest
+ && mode != kRivenTransitionModeNormal
+ && mode != kRivenTransitionModeBest) {
+ return kRivenTransitionModeFastest;
+ }
+
+ return static_cast<RivenTransitionMode>(mode);
+}
+
void RivenGraphics::scheduleTransition(RivenTransition id, const Common::Rect &rect) {
_scheduledTransition = id;
_transitionRect = rect;
diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h
index 845fbf25a1..d48d16121b 100644
--- a/engines/mohawk/riven_graphics.h
+++ b/engines/mohawk/riven_graphics.h
@@ -103,6 +103,7 @@ public:
void runScheduledTransition();
void fadeToBlack();
void setTransitionMode(RivenTransitionMode mode);
+ static RivenTransitionMode sanitizeTransitionMode(int mode);
// Main menu
void drawText(const Common::U32String &text, const Common::Rect &dest, uint8 greyLevel);
diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp
index 593745895e..da8463e367 100644
--- a/engines/mohawk/riven_saveload.cpp
+++ b/engines/mohawk/riven_saveload.cpp
@@ -252,7 +252,7 @@ Common::Error RivenSaveLoad::loadGame(const int slot) {
var = rawVariables[i];
}
- _vm->_gfx->setTransitionMode((RivenTransitionMode) _vm->_vars["transitionmode"]);
+ _vm->applyGameSettings();
_vm->changeToStack(_vm->_vars["CurrentStackID"]);
_vm->changeToCard(_vm->_vars["CurrentCardID"]);
diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp
index e79d418b97..33de9b2196 100644
--- a/engines/mohawk/riven_vars.cpp
+++ b/engines/mohawk/riven_vars.cpp
@@ -21,7 +21,6 @@
*/
#include "common/str.h"
-#include "common/config-manager.h"
#include "mohawk/riven.h"
#include "mohawk/riven_stack.h"
@@ -303,8 +302,7 @@ void MohawkEngine_Riven::initVars() {
_vars["blabpage"] = 1;
_vars["bidvlv"] = 1;
_vars["bvise"] = 1;
- _vars["azip"] = ConfMan.getBool("zip_mode");
- _vars["waterenabled"] = ConfMan.getBool("water_effects");
+ _vars["waterenabled"] = 1;
_vars["ogehnpage"] = 1;
_vars["bblrsw"] = 1;
_vars["ocage"] = 1;
@@ -322,9 +320,7 @@ void MohawkEngine_Riven::initVars() {
_vars["grviewmpos"] = 1617;
_vars["omusicplayer"] = 1;
_vars["tdomeelev"] = 1;
-
- uint32 transitions = ConfMan.getInt("transition_mode");
- _vars["transitionmode"] = sanitizeTransitionMode(transitions);
+ _vars["transitionmode"] = kRivenTransitionModeFastest;
// Randomize the telescope combination
uint32 &teleCombo = _vars["tcorrectorder"];
Commit: 195d593405d06fb3b78f57458e87c10f94cf970d
https://github.com/scummvm/scummvm/commit/195d593405d06fb3b78f57458e87c10f94cf970d
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
MOHAWK: RIVEN: Allow changing the game language at run-time
Changed paths:
engines/mohawk/detection.cpp
engines/mohawk/detection_tables.h
engines/mohawk/dialogs.cpp
engines/mohawk/dialogs.h
engines/mohawk/mohawk.cpp
engines/mohawk/mohawk.h
engines/mohawk/riven.cpp
engines/mohawk/riven.h
engines/mohawk/riven_graphics.cpp
engines/mohawk/riven_graphics.h
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index fa339988a3..dde15df350 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -208,6 +208,8 @@ public:
return "Myst and Riven (C) Cyan Worlds\nMohawk OS (C) Ubisoft";
}
+ DetectedGames detectGames(const Common::FSList &fslist) const override;
+
bool hasFeature(MetaEngineFeature f) const override;
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
SaveStateList listSaves(const char *target) const override;
@@ -220,6 +222,29 @@ public:
GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
};
+DetectedGames MohawkMetaEngine::detectGames(const Common::FSList &fslist) const {
+ DetectedGames detectedGames = AdvancedMetaEngine::detectGames(fslist);
+
+ // The AdvancedDetector model only allows specifying a single supported
+ // game language. The 25th anniversary edition Myst games are multilanguage.
+ // Here we amend the detected games to set the list of supported languages.
+ for (uint i = 0; i < detectedGames.size(); i++) {
+ DetectedGame &game = detectedGames[i];
+#ifdef ENABLE_RIVEN
+ if (game.gameId == "riven"
+ && Common::checkGameGUIOption(GAMEOPTION_25TH, game.getGUIOptions())) {
+ const Mohawk::RivenLanguage *languages = Mohawk::MohawkEngine_Riven::listLanguages();
+ while (languages->language != Common::UNK_LANG) {
+ game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(languages->language));
+ languages++;
+ }
+ }
+#endif
+ }
+
+ return detectedGames;
+}
+
bool MohawkMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves)
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h
index f09376b2fd..a73c823f8e 100644
--- a/engines/mohawk/detection_tables.h
+++ b/engines/mohawk/detection_tables.h
@@ -676,174 +676,29 @@ static const MohawkGameDescription gameDescriptions[] = {
},
// Riven: The Sequel to Myst - 25th anniversary
- // English - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- // The french datafile is included in the list because
- // in the 25th anniversary edition, all the files sit in the same
- // package. All the detection entries need to have the same amount
- // of files to show in the detection results.
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_french.mhk", 0, "ad7547ed7159a97be98a005f62862f85", 7088579 },
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // French - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_french.mhk", 0, "ad7547ed7159a97be98a005f62862f85", 7088579 },
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // German - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_german.mhk", 0, "5ebd301bd4bf6fd7667c4a46eebf6532", 7098655 },
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // Italian - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_italian.mhk", 0, "9d53b178510ce90f10b32ad3ca967d38", 6677740 },
- AD_LISTEND
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // Japanese - Created by the ScummVM team
+ // Created by the ScummVM team
{
{
"riven",
"25th Anniversary",
{
{ "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_japanese.mhk", 0, "bf43cf8af21fefc5a02881f7cfb68f52", 7237370 },
+ { "a_data_french.mhk", 0, "ad7547ed7159a97be98a005f62862f85", 7088579 },
+ { "a_data_german.mhk", 0, "5ebd301bd4bf6fd7667c4a46eebf6532", 7098655 },
+ { "a_data_italian.mhk", 0, "9d53b178510ce90f10b32ad3ca967d38", 6677740 },
+ { "a_data_japanese.mhk", 0, "bf43cf8af21fefc5a02881f7cfb68f52", 7237370 },
+ { "a_data_polish.mhk", 0, "5c7cd4b1a1a4c63cc670485816b0b5ec", 14588293 },
+ { "a_data_russian.mhk", 0, "76e12906637f5274bb6af8ab42871c25", 14349136 },
+ { "a_data_spanish.mhk", 0, "6226a3e1748e64962971b2f6536ef283", 8133297 },
AD_LISTEND
},
- Common::JA_JPN,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // Polish - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_polish.mhk", 0, "5c7cd4b1a1a4c63cc670485816b0b5ec", 14588293 },
- AD_LISTEND
- },
- Common::PL_POL,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // Russian - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_russian.mhk", 0, "76e12906637f5274bb6af8ab42871c25", 14349136 },
- AD_LISTEND
- },
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_DROPPLATFORM,
- GUI_OPTIONS_RIVEN_25TH
- },
- GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Riven: The Sequel to Myst - 25th anniversary
- // Spanish - Created by the ScummVM team
- {
- {
- "riven",
- "25th Anniversary",
- {
- { "a_data.mhk", 0, "08fcaa5d5a2a01d7a5a6960f497212fe", 10218888 },
- { "a_data_spanish.mhk", 0, "6226a3e1748e64962971b2f6536ef283", 8133297 },
- AD_LISTEND
- },
- Common::ES_ESP,
+ Common::UNK_LANG,
Common::kPlatformWindows,
ADGF_DROPPLATFORM,
GUI_OPTIONS_RIVEN_25TH
},
GType_RIVEN,
- GF_DVD | GF_25TH | GF_LANGUAGE_FILES,
+ GF_DVD | GF_25TH,
0,
},
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index 62c98299c2..f563a210fb 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -256,7 +256,10 @@ void MystMenuDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint3
#ifdef ENABLE_RIVEN
RivenOptionsWidget::RivenOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
- OptionsContainerWidget(boss, name, "RivenOptionsDialog", false, domain) {
+ OptionsContainerWidget(boss, name, "RivenOptionsDialog", false, domain),
+ _languagePopUp(nullptr) {
+ Common::String guiOptions = ConfMan.get("guioptions", domain);
+ bool is25th = checkGameGUIOption(GAMEOPTION_25TH, guiOptions);
_zipModeCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "RivenOptionsDialog.ZipMode", _("~Z~ip Mode Activated"));
_waterEffectCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "RivenOptionsDialog.WaterEffect", _("~W~ater Effect Enabled"));
@@ -269,6 +272,27 @@ RivenOptionsWidget::RivenOptionsWidget(GuiObject *boss, const Common::String &na
_transitionModePopUp->appendEntry(_("Fastest"), kRivenTransitionModeFastest);
_transitionModePopUp->appendEntry(_("Normal"), kRivenTransitionModeNormal);
_transitionModePopUp->appendEntry(_("Best"), kRivenTransitionModeBest);
+
+ // Only the 25th anniversary edition is multi-language
+ // Only allow changing the language at run-time, so that there is only one
+ // language selection drop down in the edit game dialog.
+ if (is25th && g_engine) {
+ bool canChangeLanguage = true;
+ MohawkEngine_Riven *vm = static_cast<MohawkEngine_Riven *>(g_engine);
+ canChangeLanguage = vm->isInteractive();
+
+ GUI::StaticTextWidget *languageCaption = new GUI::StaticTextWidget(widgetsBoss(), "RivenOptionsDialog.LanguageDesc", _("Language:"));
+ languageCaption->setAlign(Graphics::kTextAlignRight);
+
+ _languagePopUp = new GUI::PopUpWidget(widgetsBoss(), "RivenOptionsDialog.Language");
+ _languagePopUp->setEnabled(canChangeLanguage);
+
+ const RivenLanguage *languages = MohawkEngine_Riven::listLanguages();
+ while (languages->language != Common::UNK_LANG) {
+ _languagePopUp->appendEntry(Common::getLanguageDescription(languages->language), languages->language);
+ languages++;
+ }
+ }
}
RivenOptionsWidget::~RivenOptionsWidget() {
@@ -285,6 +309,11 @@ void RivenOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Str
.addWidget("TransistionsDesc", "OptionsLabel")
.addWidget("Transistions", "PopUp")
.closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("LanguageDesc", "OptionsLabel")
+ .addWidget("Language", "PopUp")
+ .closeLayout()
.closeLayout()
.closeDialog();
}
@@ -295,6 +324,14 @@ void RivenOptionsWidget::load() {
uint32 transitions = ConfMan.getInt("transition_mode", _domain);
_transitionModePopUp->setSelectedTag(RivenGraphics::sanitizeTransitionMode(transitions));
+
+ if (_languagePopUp) {
+ Common::Language language = Common::parseLanguage(ConfMan.get("language", _domain));
+ const RivenLanguage *languageDesc = MohawkEngine_Riven::getLanguageDesc(language);
+ if (languageDesc) {
+ _languagePopUp->setSelectedTag(languageDesc->language);
+ }
+ }
}
bool RivenOptionsWidget::save() {
@@ -302,6 +339,18 @@ bool RivenOptionsWidget::save() {
ConfMan.setBool("water_effects", _waterEffectCheckbox->getState(), _domain);
ConfMan.setInt("transition_mode", _transitionModePopUp->getSelectedTag(), _domain);
+ if (_languagePopUp) {
+ int32 selectedLanguage = _languagePopUp->getSelectedTag();
+ const RivenLanguage *languageDesc = nullptr;
+ if (selectedLanguage >= 0) {
+ languageDesc = MohawkEngine_Riven::getLanguageDesc(static_cast<Common::Language>(selectedLanguage));
+ }
+
+ if (languageDesc != nullptr) {
+ ConfMan.set("language", Common::getLanguageCode(languageDesc->language));
+ }
+ }
+
return true;
}
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index 0ad6fd33c7..abebfcc3af 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -134,6 +134,7 @@ private:
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_waterEffectCheckbox;
GUI::PopUpWidget *_transitionModePopUp;
+ GUI::PopUpWidget *_languagePopUp;
};
#endif
diff --git a/engines/mohawk/mohawk.cpp b/engines/mohawk/mohawk.cpp
index 2b7e90e0c8..c49aea8326 100644
--- a/engines/mohawk/mohawk.cpp
+++ b/engines/mohawk/mohawk.cpp
@@ -45,10 +45,7 @@ MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc)
MohawkEngine::~MohawkEngine() {
delete _pauseDialog;
delete _cursor;
-
- for (uint32 i = 0; i < _mhk.size(); i++)
- delete _mhk[i];
- _mhk.clear();
+ closeAllArchives();
}
Common::Error MohawkEngine::run() {
@@ -110,4 +107,11 @@ Common::String MohawkEngine::getResourceName(uint32 tag, uint16 id) {
error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
}
+void MohawkEngine::closeAllArchives() {
+ for (uint32 i = 0; i < _mhk.size(); i++)
+ delete _mhk[i];
+
+ _mhk.clear();
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h
index 2195cb4065..f36dd5eb56 100644
--- a/engines/mohawk/mohawk.h
+++ b/engines/mohawk/mohawk.h
@@ -91,7 +91,7 @@ public:
const char *getAppName() const;
Common::Platform getPlatform() const;
uint8 getGameType() const;
- Common::Language getLanguage() const;
+ virtual Common::Language getLanguage() const;
Common::String getDatafileLanguageName(const char *prefix) const;
bool hasFeature(EngineFeature f) const override;
@@ -104,6 +104,7 @@ public:
uint32 getResourceOffset(uint32 tag, uint16 id);
uint16 findResourceID(uint32 type, const Common::String &resName);
Common::String getResourceName(uint32 tag, uint16 id);
+ void closeAllArchives();
void pauseGame();
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 4e9185d842..a594bdb97b 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -76,6 +76,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
_card = nullptr;
_inventory = nullptr;
_lastSaveTime = 0;
+ _currentLanguage = getLanguage();
_menuSavedCard = -1;
_menuSavedStack = -1;
@@ -385,15 +386,13 @@ void MohawkEngine_Riven::changeToStack(uint16 stackId) {
_gfx->clearCache();
// Clear the old stack files out
- for (uint32 i = 0; i < _mhk.size(); i++)
- delete _mhk[i];
- _mhk.clear();
+ closeAllArchives();
// Get the prefix character for the destination stack
char prefix = RivenStacks::getName(stackId)[0];
// Load the localization override file if any
- if (getFeatures() & GF_LANGUAGE_FILES) {
+ if (getFeatures() & GF_25TH) {
loadLanguageDatafile(prefix, stackId);
}
@@ -421,6 +420,17 @@ void MohawkEngine_Riven::changeToStack(uint16 stackId) {
_stack->onMouseMove(getEventManager()->getMousePos());
}
+void MohawkEngine_Riven::reloadCurrentCard() {
+ assert(_stack && _card);
+
+ uint16 cardId = _card->getId();
+
+ closeAllArchives();
+
+ changeToStack(_stack->getId());
+ changeToCard(cardId);
+}
+
const char **MohawkEngine_Riven::listExpectedDatafiles() const {
// The files are in reverse order because of the way the 1.02 patch works.
// The only "Data3" file is j_Data3.mhk from that patch. Patch files have higher
@@ -497,13 +507,43 @@ bool MohawkEngine_Riven::checkDatafiles() {
return false;
}
+const RivenLanguage *MohawkEngine_Riven::listLanguages() {
+ static const RivenLanguage languages[] = {
+ { Common::EN_ANY, "english" },
+ { Common::FR_FRA, "french" },
+ { Common::DE_DEU, "german" },
+ { Common::IT_ITA, "italian" },
+ { Common::JA_JPN, "japanese" },
+ { Common::PL_POL, "polish" },
+ { Common::RU_RUS, "russian" },
+ { Common::ES_ESP, "spanish" },
+ { Common::UNK_LANG, nullptr }
+ };
+ return languages;
+}
+
+const RivenLanguage *MohawkEngine_Riven::getLanguageDesc(Common::Language language) {
+ const RivenLanguage *languages = listLanguages();
+
+ while (languages->language != Common::UNK_LANG) {
+ if (languages->language == language) {
+ return languages;
+ }
+
+ languages++;
+ }
+
+ return nullptr;
+}
+
void MohawkEngine_Riven::loadLanguageDatafile(char prefix, uint16 stackId) {
- Common::String language = getDatafileLanguageName("a_data_");
- if (language.empty()) {
+ Common::Language language = getLanguage();
+ const RivenLanguage *languageDesc = getLanguageDesc(language);
+ if (!languageDesc) {
return;
}
- Common::String languageDatafile = Common::String::format("%c_data_%s.mhk", prefix, language.c_str());
+ Common::String languageDatafile = Common::String::format("%c_data_%s.mhk", prefix, languageDesc->archiveSuffix);
MohawkArchive *mhk = new MohawkArchive();
if (mhk->openFile(languageDatafile)) {
@@ -718,6 +758,21 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &
return error;
}
+Common::Language MohawkEngine_Riven::getLanguage() const {
+ Common::Language language = MohawkEngine::getLanguage();
+
+ // The language can be changed at run time in the 25th anniversary edition
+ if (language == Common::UNK_LANG) {
+ language = Common::parseLanguage(ConfMan.get("language"));
+ }
+
+ if (language == Common::UNK_LANG) {
+ language = Common::EN_ANY;
+ }
+
+ return language;
+}
+
void MohawkEngine_Riven::saveGameStateAndDisplayError(int slot, const Common::String &desc) {
assert(slot >= 0 && !desc.empty());
@@ -799,11 +854,22 @@ void MohawkEngine_Riven::applyGameSettings() {
_gfx->setTransitionMode(transitionsMode);
+ Common::Language newLanguage = getLanguage();
+ if (_stack && newLanguage != _currentLanguage) {
+ _gfx->loadMenuFont();
+ reloadCurrentCard();
+ }
+ _currentLanguage = newLanguage;
+
if (_card) {
_card->initializeZipMode();
}
}
+bool MohawkEngine_Riven::isInteractive() const {
+ return !_scriptMan->hasQueuedScripts() && !hasGameEnded();
+}
+
void MohawkEngine_Riven::registerDefaultSettings() {
ConfMan.registerDefault("zip_mode", false);
ConfMan.registerDefault("water_effects", true);
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 4923f0e5ad..f7ebba1f7f 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -48,6 +48,7 @@ struct MohawkGameDescription;
class MohawkArchive;
class RivenGraphics;
class RivenConsole;
+struct RivenLanguage;
class RivenSaveLoad;
class RivenOptionsWidget;
class RivenStack;
@@ -113,11 +114,17 @@ public:
Common::String getSaveStateName(int slot) const override {
return Common::String::format("riven-%03d.rvn", slot);
}
+
+ static const RivenLanguage *listLanguages();
+ static const RivenLanguage *getLanguageDesc(Common::Language language);
+ Common::Language getLanguage() const override;
+
bool hasFeature(EngineFeature f) const override;
static void registerDefaultSettings();
void applyGameSettings() override;
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
+ bool isInteractive() const;
void doFrame();
void processInput();
@@ -141,6 +148,7 @@ private:
bool _gameEnded;
uint32 _lastSaveTime;
+ Common::Language _currentLanguage;
// Variables
void initVars();
@@ -152,6 +160,7 @@ public:
RivenStack *constructStackById(uint16 id);
void changeToCard(uint16 dest);
void changeToStack(uint16 stackId);
+ void reloadCurrentCard();
RivenCard *getCard() const { return _card; }
RivenStack *getStack() const { return _stack; }
@@ -197,6 +206,11 @@ public:
void startNewGame();
};
+struct RivenLanguage {
+ Common::Language language;
+ const char *archiveSuffix;
+};
+
} // End of namespace Mohawk
#endif
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index 0a07d8dd5b..72f020c50f 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -802,6 +802,9 @@ void RivenGraphics::drawText(const Common::U32String &text, const Common::Rect &
}
void RivenGraphics::loadMenuFont() {
+ delete _menuFont;
+ _menuFont = nullptr;
+
const char *fontName;
if (_vm->getLanguage() != Common::JA_JPN) {
diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h
index d48d16121b..2da51da79d 100644
--- a/engines/mohawk/riven_graphics.h
+++ b/engines/mohawk/riven_graphics.h
@@ -106,6 +106,7 @@ public:
static RivenTransitionMode sanitizeTransitionMode(int mode);
// Main menu
+ void loadMenuFont();
void drawText(const Common::U32String &text, const Common::Rect &dest, uint8 greyLevel);
// Credits
@@ -147,7 +148,6 @@ private:
// Main menu
Graphics::Font *_menuFont;
- void loadMenuFont();
const Graphics::Font *getMenuFont() const;
// Credits
Commit: bfe7aad96aac6680cc6d7daa82b95df613c9cacd
https://github.com/scummvm/scummvm/commit/bfe7aad96aac6680cc6d7daa82b95df613c9cacd
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
ENGINES: Return a const reference for DetectedGame::getGUIOptions
Changed paths:
engines/game.h
diff --git a/engines/game.h b/engines/game.h
index 8316857e24..57c5e88237 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -121,7 +121,7 @@ struct DetectedGame {
void setGUIOptions(const Common::String &options);
void appendGUIOptions(const Common::String &str);
- Common::String getGUIOptions() const { return _guiOptions; }
+ const Common::String &getGUIOptions() const { return _guiOptions; }
Common::String engineId;
Commit: c9476543e0d8d1cbb31e125fa238235c4737e349
https://github.com/scummvm/scummvm/commit/c9476543e0d8d1cbb31e125fa238235c4737e349
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
MOHAWK: MYST: Allow changing the game language while on the main menu
Changed paths:
engines/mohawk/detection.cpp
engines/mohawk/detection_tables.h
engines/mohawk/dialogs.cpp
engines/mohawk/dialogs.h
engines/mohawk/mohawk.h
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_graphics.cpp
engines/mohawk/myst_graphics.h
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index dde15df350..e6e9c8d20a 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -98,24 +98,6 @@ bool MohawkEngine::hasFeature(EngineFeature f) const {
(f == kSupportsRTL);
}
-Common::String MohawkEngine::getDatafileLanguageName(const char *prefix) const {
- const ADGameFileDescription *fileDesc;
- for (fileDesc = _gameDescription->desc.filesDescriptions; fileDesc->fileName; fileDesc++) {
- if (Common::String(fileDesc->fileName).hasPrefix(prefix)) {
- break;
- }
- }
-
- if (!fileDesc->fileName) {
- warning("Malformed detection entry");
-
- return "";
- }
-
- size_t prefixLength = strlen(prefix);
- return Common::String(&fileDesc->fileName[prefixLength], strlen(fileDesc->fileName) - prefixLength - 4);
-}
-
#ifdef ENABLE_MYST
bool MohawkEngine_Myst::hasFeature(EngineFeature f) const {
@@ -230,6 +212,19 @@ DetectedGames MohawkMetaEngine::detectGames(const Common::FSList &fslist) const
// Here we amend the detected games to set the list of supported languages.
for (uint i = 0; i < detectedGames.size(); i++) {
DetectedGame &game = detectedGames[i];
+
+#ifdef ENABLE_MYST
+ if (game.gameId == "myst"
+ && Common::checkGameGUIOption(GAMEOPTION_25TH, game.getGUIOptions())
+ && Common::checkGameGUIOption(GAMEOPTION_ME, game.getGUIOptions())) {
+ const Mohawk::MystLanguage *languages = Mohawk::MohawkEngine_Myst::listLanguages();
+ while (languages->language != Common::UNK_LANG) {
+ game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(languages->language));
+ languages++;
+ }
+ }
+#endif
+
#ifdef ENABLE_RIVEN
if (game.gameId == "riven"
&& Common::checkGameGUIOption(GAMEOPTION_25TH, game.getGUIOptions())) {
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h
index a73c823f8e..2823852ba7 100644
--- a/engines/mohawk/detection_tables.h
+++ b/engines/mohawk/detection_tables.h
@@ -339,107 +339,27 @@ static const MohawkGameDescription gameDescriptions[] = {
},
// Myst Masterpiece Edition - 25th Anniversary
- // English Windows - Created by the ScummVM team
+ // Repacked by the ScummVM team
{
{
"myst",
"Masterpiece Edition - 25th Anniversary",
{
{"myst.dat", 0, "c4cae9f143b5947262e6cb2397e1617e", -1},
- {"menu.dat", 0, "7dc23051084f79b1c2bccc84cdec0503", -1},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUI_OPTIONS_MYST_ME_25TH
- },
- GType_MYST,
- GF_ME | GF_25TH,
- 0,
- },
-
- // Myst Masterpiece Edition - 25th Anniversary
- // French Windows - Repacked by the ScummVM team
- {
- {
- "myst",
- "Masterpiece Edition - 25th Anniversary",
- {
{"myst_french.dat", 0, "7c8230be50ffcac588e7db8788ad7614", -1},
- {"menu.dat", 0, "7dc23051084f79b1c2bccc84cdec0503", -1},
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUI_OPTIONS_MYST_ME_25TH
- },
- GType_MYST,
- GF_ME | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Myst Masterpiece Edition - 25th Anniversary
- // German Windows - Repacked by the ScummVM team
- {
- {
- "myst",
- "Masterpiece Edition - 25th Anniversary",
- {
{"myst_german.dat", 0, "3952554439960b22a360e8e006dfed58", -1},
- {"menu.dat", 0, "7dc23051084f79b1c2bccc84cdec0503", -1},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUI_OPTIONS_MYST_ME_25TH
- },
- GType_MYST,
- GF_ME | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Myst Masterpiece Edition - 25th Anniversary
- // Polish Windows - Repacked by the ScummVM team
- {
- {
- "myst",
- "Masterpiece Edition - 25th Anniversary",
- {
{"myst_polish.dat", 0, "9ca82ff26fcbfacf40e4164523a50854", -1},
- {"menu.dat", 0, "7dc23051084f79b1c2bccc84cdec0503", -1},
- AD_LISTEND
- },
- Common::PL_POL,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUI_OPTIONS_MYST_ME_25TH
- },
- GType_MYST,
- GF_ME | GF_25TH | GF_LANGUAGE_FILES,
- 0,
- },
-
- // Myst Masterpiece Edition - 25th Anniversary
- // Spanish Windows - Repacked by the ScummVM team
- {
- {
- "myst",
- "Masterpiece Edition - 25th Anniversary",
- {
{"myst_spanish.dat", 0, "822ed3c0de912c10b877dcd2cc078493", -1},
{"menu.dat", 0, "7dc23051084f79b1c2bccc84cdec0503", -1},
AD_LISTEND
},
- Common::ES_ESP,
+ Common::UNK_LANG,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUI_OPTIONS_MYST_ME_25TH
},
GType_MYST,
- GF_ME | GF_25TH | GF_LANGUAGE_FILES,
+ GF_ME | GF_25TH,
0,
},
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index f563a210fb..cec2b38e29 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -24,6 +24,7 @@
#include "mohawk/dialogs.h"
#include "gui/gui-manager.h"
+#include "gui/message.h"
#include "gui/saveload.h"
#include "gui/ThemeEval.h"
#include "gui/widget.h"
@@ -96,18 +97,22 @@ MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name
_zipModeCheckbox(nullptr),
_transitionsCheckbox(nullptr),
_mystFlyByCheckbox(nullptr),
+ _languagePopUp(nullptr),
_dropPageButton(nullptr),
_showMapButton(nullptr),
_returnToMenuButton(nullptr) {
+ Common::String guiOptions = ConfMan.get("guioptions", _domain);
+ bool isDemo = checkGameGUIOption(GAMEOPTION_DEMO, guiOptions);
+ bool isME = checkGameGUIOption(GAMEOPTION_ME, guiOptions);
- if (!checkGameGUIOption(GAMEOPTION_DEMO, ConfMan.get("guioptions", _domain))) {
+ if (!isDemo) {
// I18N: Option for fast scene switching
_zipModeCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.ZipMode", _("~Z~ip Mode Activated"));
}
_transitionsCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.Transistions", _("~T~ransitions Enabled"));
- if (checkGameGUIOption(GAMEOPTION_ME, ConfMan.get("guioptions", _domain))) {
+ if (isME) {
_mystFlyByCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "MystOptionsDialog.PlayMystFlyBy", _("Play the Myst fly by movie"),
_("The Myst fly by movie was not played by the original engine."));
}
@@ -128,6 +133,19 @@ MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name
if (vm->getFeatures() & GF_DEMO) {
_returnToMenuButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.MainMenu", _("Main Men~u~"), nullptr, kMenuCmd);
}
+
+ if (vm->getFeatures() & GF_25TH) {
+ GUI::StaticTextWidget *languageCaption = new GUI::StaticTextWidget(widgetsBoss(), "MystOptionsDialog.LanguageDesc", _("Language:"));
+ languageCaption->setAlign(Graphics::kTextAlignRight);
+
+ _languagePopUp = new GUI::PopUpWidget(widgetsBoss(), "MystOptionsDialog.Language");
+
+ const MystLanguage *languages = MohawkEngine_Myst::listLanguages();
+ while (languages->language != Common::UNK_LANG) {
+ _languagePopUp->appendEntry(Common::getLanguageDescription(languages->language), languages->language);
+ languages++;
+ }
+ }
}
}
@@ -141,6 +159,11 @@ void MystOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Stri
.addWidget("ZipMode", "Checkbox")
.addWidget("Transistions", "Checkbox")
.addWidget("PlayMystFlyBy", "Checkbox")
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("LanguageDesc", "OptionsLabel")
+ .addWidget("Language", "PopUp")
+ .closeLayout()
.addLayout(GUI::ThemeLayout::kLayoutHorizontal)
.addPadding(0, 0, 16, 0)
.addSpace()
@@ -168,6 +191,14 @@ void MystOptionsWidget::load() {
_mystFlyByCheckbox->setState(ConfMan.getBool("playmystflyby", _domain));
}
+ if (_languagePopUp) {
+ Common::Language language = Common::parseLanguage(ConfMan.get("language", _domain));
+ const MystLanguage *languageDesc = MohawkEngine_Myst::getLanguageDesc(language);
+ if (languageDesc) {
+ _languagePopUp->setSelectedTag(languageDesc->language);
+ }
+ }
+
if (isInGame()) {
MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
assert(vm);
@@ -196,6 +227,29 @@ bool MystOptionsWidget::save() {
ConfMan.setBool("playmystflyby", _mystFlyByCheckbox->getState(), _domain);
}
+ if (_languagePopUp) {
+ MohawkEngine_Myst *vm = static_cast<MohawkEngine_Myst *>(g_engine);
+ assert(vm);
+
+ int32 selectedLanguage = _languagePopUp->getSelectedTag();
+ const MystLanguage *languageDesc = nullptr;
+ if (selectedLanguage >= 0) {
+ languageDesc = MohawkEngine_Myst::getLanguageDesc(static_cast<Common::Language>(selectedLanguage));
+ }
+
+ Common::Language newLanguage = Common::UNK_LANG;
+ if (languageDesc != nullptr) {
+ newLanguage = languageDesc->language;
+ ConfMan.set("language", Common::getLanguageCode(languageDesc->language));
+ }
+
+ Common::Language currentLanguage = vm->getLanguage();
+ if (newLanguage != currentLanguage && vm->isGameStarted()) {
+ GUI::MessageDialog dialog(_("The new language will be applied after restarting the game."));
+ dialog.runModal();
+ }
+ }
+
return true;
}
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index abebfcc3af..47ae65e185 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -99,6 +99,7 @@ private:
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_transitionsCheckbox;
GUI::CheckboxWidget *_mystFlyByCheckbox;
+ GUI::PopUpWidget *_languagePopUp;
GUI::ButtonWidget *_dropPageButton;
GUI::ButtonWidget *_showMapButton;
diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h
index f36dd5eb56..0230e6a900 100644
--- a/engines/mohawk/mohawk.h
+++ b/engines/mohawk/mohawk.h
@@ -66,8 +66,7 @@ enum MohawkGameFeatures {
GF_25TH = (1 << 1), // Myst and Riven 25th Anniversary
GF_DVD = (1 << 2),
GF_DEMO = (1 << 3),
- GF_LB_10 = (1 << 4), // very early Living Books 1.0 games
- GF_LANGUAGE_FILES = (1 << 5) // Myst and Riven versions using language override files
+ GF_LB_10 = (1 << 4) // very early Living Books 1.0 games
};
struct MohawkGameDescription;
@@ -92,7 +91,6 @@ public:
Common::Platform getPlatform() const;
uint8 getGameType() const;
virtual Common::Language getLanguage() const;
- Common::String getDatafileLanguageName(const char *prefix) const;
bool hasFeature(EngineFeature f) const override;
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index d1f398aec6..21ab9fcfe2 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -81,6 +81,8 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_mainCursor = kDefaultMystCursor;
_showResourceRects = false;
_scheduledAction = kMystActionNone;
+ _currentLanguage = Common::UNK_LANG;
+ _currentLanguage = getLanguage();
_sound = nullptr;
_video = nullptr;
@@ -233,17 +235,19 @@ Common::String MohawkEngine_Myst::wrapMovieFilename(const Common::String &movieN
}
Common::String MohawkEngine_Myst::selectLocalizedMovieFilename(const Common::String &movieName) {
- Common::String language;
- if (getFeatures() & GF_LANGUAGE_FILES) {
- language = getDatafileLanguageName("myst_");
+ Common::Language language = getLanguage();
+ const MystLanguage *languageDesc = getLanguageDesc(language);
+
+ if (!languageDesc) {
+ return movieName;
}
- Common::String localizedMovieName = Common::String::format("%s/%s", language.c_str(), movieName.c_str());
- if (!language.empty() && SearchMan.hasFile(localizedMovieName)) {
- return localizedMovieName;
- } else {
+ Common::String localizedMovieName = Common::String::format("%s/%s", languageDesc->archiveSuffix, movieName.c_str());
+ if (!SearchMan.hasFile(localizedMovieName)) {
return movieName;
}
+
+ return localizedMovieName;
}
VideoEntryPtr MohawkEngine_Myst::playMovie(const Common::String &name, MystStack stack) {
@@ -440,26 +444,66 @@ Common::Error MohawkEngine_Myst::run() {
return Common::kNoError;
}
-void MohawkEngine_Myst::loadStackArchives(MystStack stackId) {
- for (uint i = 0; i < _mhk.size(); i++) {
- delete _mhk[i];
+const MystLanguage *MohawkEngine_Myst::listLanguages() {
+ static const MystLanguage languages[] = {
+ { Common::EN_ANY, "english" },
+ { Common::FR_FRA, "french" },
+ { Common::DE_DEU, "german" },
+ { Common::PL_POL, "polish" },
+ { Common::ES_ESP, "spanish" },
+ { Common::UNK_LANG, nullptr }
+ };
+ return languages;
+}
+
+const MystLanguage *MohawkEngine_Myst::getLanguageDesc(Common::Language language) {
+ const MystLanguage *languages = listLanguages();
+
+ while (languages->language != Common::UNK_LANG) {
+ if (languages->language == language) {
+ return languages;
+ }
+
+ languages++;
+ }
+
+ return nullptr;
+}
+
+Common::Language MohawkEngine_Myst::getLanguage() const {
+ Common::Language language = MohawkEngine::getLanguage();
+
+ if (language == Common::UNK_LANG) {
+ language = _currentLanguage;
}
- _mhk.clear();
- Common::String language;
- if (getFeatures() & GF_LANGUAGE_FILES) {
- language = getDatafileLanguageName("myst_");
+ // The language can be changed at run time in the 25th anniversary edition
+ if (language == Common::UNK_LANG) {
+ language = Common::parseLanguage(ConfMan.get("language"));
}
- if (!language.empty()) {
- loadArchive(mystFiles[stackId], language.c_str(), false);
+ if (language == Common::UNK_LANG) {
+ language = Common::EN_ANY;
+ }
+
+ return language;
+}
+
+void MohawkEngine_Myst::loadStackArchives(MystStack stackId) {
+ closeAllArchives();
+
+ Common::Language language = getLanguage();
+ const MystLanguage *languageDesc = getLanguageDesc(language);
+
+ if (languageDesc) {
+ loadArchive(mystFiles[stackId], languageDesc->archiveSuffix, false);
}
loadArchive(mystFiles[stackId], nullptr, true);
if (getFeatures() & GF_ME) {
- if (!language.empty()) {
- loadArchive("help", language.c_str(), false);
+ if (languageDesc) {
+ loadArchive("help", languageDesc->archiveSuffix, false);
}
loadArchive("help", nullptr, true);
@@ -497,6 +541,17 @@ void MohawkEngine_Myst::registerDefaultSettings() {
ConfMan.registerDefault("transition_mode", false);
}
+void MohawkEngine_Myst::applyGameSettings() {
+ // Allow changing the language when in the main menu when the game has not yet been started.
+ // It's not possible to reliably change the language one the game is started as the current
+ // view cannot be reconstructed using the save / stack state.
+ if ((getFeatures() & GF_25TH) && !isGameStarted()) {
+ _currentLanguage = Common::parseLanguage(ConfMan.get("language"));
+ _gfx->loadMenuFont();
+ changeToStack(_stack->getStackId(), _card->getId(), 0, 0);
+ }
+}
+
Common::KeymapArray MohawkEngine_Myst::initKeymaps(const char *target) {
using namespace Common;
@@ -731,6 +786,7 @@ void MohawkEngine_Myst::runOptionsDialog() {
int result = runDialog(dlg);
if (result > 0) {
syncSoundSettings();
+ applyGameSettings();
}
if (result > kMystActionNone && result <= kMystActionLast) {
@@ -1006,7 +1062,7 @@ bool MohawkEngine_Myst::hasGameSaveSupport() const {
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
}
-bool MohawkEngine_Myst::isInteractive() {
+bool MohawkEngine_Myst::isInteractive() const {
return !_stack->isScriptRunning() && !_waitingOnBlockingOperation;
}
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 6f444a25c2..eb19587d9d 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -42,6 +42,7 @@ class MystGraphics;
class MystScriptParser;
class MystConsole;
class MystGameState;
+struct MystLanguage;
class MystOptionsWidget;
class MystSound;
class MystArea;
@@ -185,7 +186,8 @@ public:
* When the game is interactive, the user can interact with the game world
* and perform other operations such as loading saved games, ...
*/
- bool isInteractive();
+ bool isInteractive() const;
+ bool isGameStarted() const;
bool canLoadGameStateCurrently() override;
bool canSaveGameStateCurrently() override;
Common::Error loadGameState(int slot) override;
@@ -196,6 +198,7 @@ public:
bool hasFeature(EngineFeature f) const override;
static void registerDefaultSettings();
+ void applyGameSettings() override;
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
void resumeFromMainMenu();
@@ -209,6 +212,10 @@ public:
void doAction(MystEventAction action);
void scheduleAction(MystEventAction action);
+ static const MystLanguage *listLanguages();
+ static const MystLanguage *getLanguageDesc(Common::Language language);
+ Common::Language getLanguage() const override;
+
private:
ResourceCache _cache;
@@ -221,7 +228,6 @@ private:
void pauseEngineIntern(bool pause) override;
void goToMainMenu();
- bool isGameStarted() const;
void dropPage();
@@ -239,9 +245,15 @@ private:
uint16 _currentCursor;
uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none)
+ Common::Language _currentLanguage;
MystEventAction _scheduledAction;
};
+struct MystLanguage {
+ Common::Language language;
+ const char *archiveSuffix;
+};
+
} // End of namespace Mohawk
#endif
diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index dc144eb166..4f918e26aa 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -67,24 +67,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) :
_mainMenuBackupBackBuffer.reset(new Graphics::Surface());
if (_vm->getFeatures() & GF_25TH) {
- const char *menuFontName = "NotoSans-ExtraBold.ttf";
-#ifdef USE_FREETYPE2
- int fontSize;
- if (_vm->getLanguage() == Common::PL_POL) {
- fontSize = 11; // The Polish diacritics need significantly more space, so we use a smaller font
- } else {
- fontSize = 16;
- }
-
- Common::SeekableReadStream *fontStream = SearchMan.createReadStreamForMember(menuFontName);
- if (fontStream) {
- _menuFont = Graphics::loadTTFFont(*fontStream, fontSize);
- delete fontStream;
- } else
-#endif
- {
- warning("Unable to open the menu font file '%s'", menuFontName);
- }
+ loadMenuFont();
}
}
@@ -96,6 +79,30 @@ MystGraphics::~MystGraphics() {
delete _menuFont;
}
+void MystGraphics::loadMenuFont() {
+ delete _menuFont;
+ _menuFont = nullptr;
+
+ const char *menuFontName = "NotoSans-ExtraBold.ttf";
+#ifdef USE_FREETYPE2
+ int fontSize;
+ if (_vm->getLanguage() == Common::PL_POL) {
+ fontSize = 11; // The Polish diacritics need significantly more space, so we use a smaller font
+ } else {
+ fontSize = 16;
+ }
+
+ Common::SeekableReadStream *fontStream = SearchMan.createReadStreamForMember(menuFontName);
+ if (fontStream) {
+ _menuFont = Graphics::loadTTFFont(*fontStream, fontSize);
+ delete fontStream;
+ } else
+#endif
+ {
+ warning("Unable to open the menu font file '%s'", menuFontName);
+ }
+}
+
MohawkSurface *MystGraphics::decodeImage(uint16 id) {
// We need to grab the image from the current stack archive, however, we don't know
// if it's a PICT or WDIB resource. If it's Myst ME it's most likely a PICT, and if it's
diff --git a/engines/mohawk/myst_graphics.h b/engines/mohawk/myst_graphics.h
index 63c559f7b3..d12c3a6577 100644
--- a/engines/mohawk/myst_graphics.h
+++ b/engines/mohawk/myst_graphics.h
@@ -64,6 +64,7 @@ public:
void restoreStateForMainMenu();
Graphics::Surface *getThumbnailForMainMenu() const;
+ void loadMenuFont();
Common::Rect getTextBoundingBox(const Common::U32String &text, const Common::Rect &dest, Graphics::TextAlign align);
void drawText(uint16 image, const Common::U32String &text, const Common::Rect &dest, uint8 r, uint8 g, uint8 b, Graphics::TextAlign align, int16 deltaY);
Commit: 1d731aeef9025e3213ad67e60160898fbe3c00cc
https://github.com/scummvm/scummvm/commit/1d731aeef9025e3213ad67e60160898fbe3c00cc
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-03-28T07:38:39+01:00
Commit Message:
MOHAWK: Simplify retrieving game features
Changed paths:
engines/mohawk/cursors.cpp
engines/mohawk/detection.cpp
engines/mohawk/dialogs.cpp
engines/mohawk/mohawk.h
engines/mohawk/myst.cpp
engines/mohawk/myst_card.cpp
engines/mohawk/myst_graphics.cpp
engines/mohawk/myst_scripts.cpp
engines/mohawk/myst_sound.cpp
engines/mohawk/myst_stacks/intro.cpp
engines/mohawk/myst_stacks/myst.cpp
engines/mohawk/myst_state.cpp
engines/mohawk/riven.cpp
engines/mohawk/riven_card.cpp
engines/mohawk/riven_graphics.cpp
engines/mohawk/riven_inventory.cpp
engines/mohawk/riven_saveload.cpp
engines/mohawk/riven_scripts.cpp
engines/mohawk/riven_stacks/aspit.cpp
engines/mohawk/video.cpp
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 152861b806..a4a04210cd 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -127,7 +127,7 @@ void MystCursorManager::setCursor(uint16 id) {
// We're using the screen palette for the original game, but we need
// to use this for any 8bpp cursor in ME.
- if (_vm->getFeatures() & GF_ME)
+ if (_vm->isGameVariant(GF_ME))
CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
} else {
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index e6e9c8d20a..9bacfc9533 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -73,6 +73,10 @@ uint32 MohawkEngine::getFeatures() const {
return _gameDescription->features;
}
+bool MohawkEngine::isGameVariant(MohawkGameFeatures feature) const {
+ return (_gameDescription->features & feature) != 0;
+}
+
Common::Platform MohawkEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index cec2b38e29..9387ad2b8d 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -125,16 +125,16 @@ MystOptionsWidget::MystOptionsWidget(GuiObject *boss, const Common::String &name
_dropPageButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.DropPage", _("~D~rop Page"), nullptr, kDropCmd);
// Myst ME only has maps
- if (vm->getFeatures() & GF_ME) {
+ if (vm->isGameVariant(GF_ME)) {
_showMapButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.ShowMap", _("Show ~M~ap"), nullptr, kMapCmd);
}
// Myst demo only has a menu
- if (vm->getFeatures() & GF_DEMO) {
+ if (vm->isGameVariant(GF_DEMO)) {
_returnToMenuButton = new GUI::ButtonWidget(widgetsBoss(), "MystOptionsDialog.MainMenu", _("Main Men~u~"), nullptr, kMenuCmd);
}
- if (vm->getFeatures() & GF_25TH) {
+ if (vm->isGameVariant(GF_25TH)) {
GUI::StaticTextWidget *languageCaption = new GUI::StaticTextWidget(widgetsBoss(), "MystOptionsDialog.LanguageDesc", _("Language:"));
languageCaption->setAlign(Graphics::kTextAlignRight);
diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h
index 0230e6a900..0f0ecaa7cf 100644
--- a/engines/mohawk/mohawk.h
+++ b/engines/mohawk/mohawk.h
@@ -87,6 +87,7 @@ public:
const MohawkGameDescription *_gameDescription;
const char *getGameId() const;
uint32 getFeatures() const;
+ bool isGameVariant(MohawkGameFeatures feature) const;
const char *getAppName() const;
Common::Platform getPlatform() const;
uint8 getGameType() const;
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 21ab9fcfe2..29a4bb962d 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -144,7 +144,7 @@ void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) {
for (uint32 i = 0; i < _mhk.size(); i++) {
// Check for MJMP in Myst ME
- if ((getFeatures() & GF_ME) && tag == ID_MSND && _mhk[i]->hasResource(ID_MJMP, id)) {
+ if (isGameVariant(GF_ME) && tag == ID_MSND && _mhk[i]->hasResource(ID_MJMP, id)) {
Common::SeekableReadStream *tempData = _mhk[i]->getResource(ID_MJMP, id);
uint16 msndId = tempData->readUint16LE();
delete tempData;
@@ -429,9 +429,9 @@ Common::Error MohawkEngine_Myst::run() {
// Start us on the first stack.
if (getGameType() == GType_MAKINGOF)
changeToStack(kMakingOfStack, 1, 0, 0);
- else if (getFeatures() & GF_DEMO)
+ else if (isGameVariant(GF_DEMO))
changeToStack(kDemoStack, 2000, 0, 0);
- else if (getFeatures() & GF_25TH)
+ else if (isGameVariant(GF_25TH))
changeToStack(kMenuStack, 1, 0, 0);
else
changeToStack(kIntroStack, 1, 0, 0);
@@ -501,7 +501,7 @@ void MohawkEngine_Myst::loadStackArchives(MystStack stackId) {
loadArchive(mystFiles[stackId], nullptr, true);
- if (getFeatures() & GF_ME) {
+ if (isGameVariant(GF_ME)) {
if (languageDesc) {
loadArchive("help", languageDesc->archiveSuffix, false);
}
@@ -509,7 +509,7 @@ void MohawkEngine_Myst::loadStackArchives(MystStack stackId) {
loadArchive("help", nullptr, true);
}
- if (getFeatures() & GF_25TH) {
+ if (isGameVariant(GF_25TH)) {
loadArchive("menu", nullptr, true);
}
}
@@ -543,9 +543,9 @@ void MohawkEngine_Myst::registerDefaultSettings() {
void MohawkEngine_Myst::applyGameSettings() {
// Allow changing the language when in the main menu when the game has not yet been started.
- // It's not possible to reliably change the language one the game is started as the current
+ // It's not possible to reliably change the language once the game is started as the current
// view cannot be reconstructed using the save / stack state.
- if ((getFeatures() & GF_25TH) && !isGameStarted()) {
+ if (isGameVariant(GF_25TH) && !isGameStarted()) {
_currentLanguage = Common::parseLanguage(ConfMan.get("language"));
_gfx->loadMenuFont();
changeToStack(_stack->getStackId(), _card->getId(), 0, 0);
@@ -696,7 +696,7 @@ bool MohawkEngine_Myst::canDoAction(MystEventAction action) {
case kMystActionShowMap:
return actionsAllowed && stack->getMap();
case kMystActionOpenMainMenu:
- assert(getFeatures() & GF_DEMO);
+ assert(isGameVariant(GF_DEMO));
return actionsAllowed && stack->getStackId() != kDemoStack;
default:
// Not implemented yet
@@ -721,14 +721,14 @@ void MohawkEngine_Myst::doAction(MystEventAction action) {
break;
}
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
if (_stack->getStackId() != kDemoStack && isInteractive()) {
changeToStack(kDemoStack, 2002, 0, 0);
}
break;
}
- if (getFeatures() & GF_25TH && isInteractive()) {
+ if (isGameVariant(GF_25TH) && isInteractive()) {
if (_stack->getStackId() == kMenuStack) {
// If the menu is active and a game is loaded, go back to the game
if (_prevStack) {
@@ -858,7 +858,7 @@ void MohawkEngine_Myst::changeToStack(MystStack stackId, uint16 card, uint16 lin
// In Myst ME, play a fullscreen flyby movie, except when loading saves.
// Also play a flyby when first linking to Myst.
- if (getFeatures() & GF_ME
+ if (isGameVariant(GF_ME)
&& ((_stack && _stack->getStackId() == kMystStack) || (stackId == kMystStack && card == 4134))) {
playFlybyMovie(stackId);
}
@@ -962,7 +962,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
_card->enter();
// The demo resets the cursor at each card change except when in the library
- if (getFeatures() & GF_DEMO
+ if (isGameVariant(GF_DEMO)
&& _gameState->_globals.currentAge != kMystLibrary) {
_cursor->setDefaultCursor();
}
@@ -1059,7 +1059,7 @@ Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &d
}
bool MohawkEngine_Myst::hasGameSaveSupport() const {
- return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
+ return !isGameVariant(GF_DEMO) && getGameType() != GType_MAKINGOF;
}
bool MohawkEngine_Myst::isInteractive() const {
diff --git a/engines/mohawk/myst_card.cpp b/engines/mohawk/myst_card.cpp
index 691f07d3d1..e57ac1c9a4 100644
--- a/engines/mohawk/myst_card.cpp
+++ b/engines/mohawk/myst_card.cpp
@@ -176,7 +176,7 @@ void MystCard::loadView() {
// Precache Card Resources
uint32 cacheImageType;
- if (_vm->getFeatures() & GF_ME)
+ if (_vm->isGameVariant(GF_ME))
cacheImageType = ID_PICT;
else
cacheImageType = ID_WDIB;
diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index 4f918e26aa..1cb4d2651f 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -44,7 +44,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) :
_viewport = Common::Rect(544, 332);
- if (_vm->getFeatures() & GF_ME) {
+ if (_vm->isGameVariant(GF_ME)) {
// High color
initGraphics(_viewport.width(), _viewport.height(), nullptr);
@@ -66,7 +66,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) :
_mainMenuBackupScreenThumbnail.reset(new Graphics::Surface());
_mainMenuBackupBackBuffer.reset(new Graphics::Surface());
- if (_vm->getFeatures() & GF_25TH) {
+ if (_vm->isGameVariant(GF_ME) && _vm->isGameVariant(GF_25TH)) {
loadMenuFont();
}
}
@@ -110,7 +110,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
// that PICT resources can contain WDIB's instead of PICT's.
Common::SeekableReadStream *dataStream = nullptr;
- if (_vm->getFeatures() & GF_ME && _vm->hasResource(ID_PICT, id)) {
+ if (_vm->isGameVariant(GF_ME) && _vm->hasResource(ID_PICT, id)) {
// The PICT resource exists. However, it could still contain a MystBitmap
// instead of a PICT image...
dataStream = _vm->getResource(ID_PICT, id);
@@ -121,7 +121,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
bool isPict = false;
- if ((_vm->getFeatures() & GF_ME) && dataStream->size() > 512 + 10 + 4) {
+ if (_vm->isGameVariant(GF_ME) && dataStream->size() > 512 + 10 + 4) {
// Here we detect whether it's really a PICT or a WDIB. Since a MystBitmap
// would be compressed, there's no way to detect for the BM without a hack.
// So, we search for the PICT version opcode for detection.
@@ -144,7 +144,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
} else {
mhkSurface = _bmpDecoder->decodeImage(dataStream);
- if (_vm->getFeatures() & GF_ME) {
+ if (_vm->isGameVariant(GF_ME)) {
mhkSurface->convertToTrueColor();
} else {
remapSurfaceToSystemPalette(mhkSurface);
@@ -166,7 +166,7 @@ void MystGraphics::applyImagePatches(uint16 id, const MohawkSurface *mhkSurface)
//
// Here we stomp over the "off" with an "on".
// The fixed image was provided by dafioram in bug Trac#10115.
- if (id == 2019 && _vm->getFeatures() & GF_ME && _vm->getLanguage() == Common::EN_ANY) {
+ if (id == 2019 && _vm->isGameVariant(GF_ME) && _vm->getLanguage() == Common::EN_ANY) {
static const byte markerSwitchInstructionsFixPic[] = {
0x1d, 0x1c, 0x19, 0x19, 0x19, 0x19, 0x1c, 0x19, 0x19, 0x17, 0x19, 0x19, 0x19, 0x19, 0x19,
0x1e, 0x1e, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19,
@@ -270,7 +270,7 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src,
MohawkSurface *mhkSurface = findImage(image);
Graphics::Surface *surface = mhkSurface->getSurface();
- if (image == 2258 && _vm->getFeatures() & GF_ME) {
+ if (image == 2258 && _vm->isGameVariant(GF_ME)) {
// In Myst ME, the image for the open red page brother door
// when the special lights are on does not have the correct width.
// We work around this issue by tweaking the destination rectangle
@@ -317,7 +317,7 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src,
for (uint16 i = 0; i < height; i++)
memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->format.bytesPerPixel);
- if (!(_vm->getFeatures() & GF_ME)) {
+ if (!_vm->isGameVariant(GF_ME)) {
// Make sure the palette is set
assert(mhkSurface->getPalette());
memcpy(_palette, mhkSurface->getPalette(), 256 * 3);
@@ -685,11 +685,11 @@ void MystGraphics::drawRect(Common::Rect rect, RectState state) {
Graphics::Surface *screen = _vm->_system->lockScreen();
if (state == kRectEnabled)
- screen->frameRect(rect, (_vm->getFeatures() & GF_ME) ? _pixelFormat.RGBToColor(0, 255, 0) : 250);
+ screen->frameRect(rect, _vm->isGameVariant(GF_ME) ? _pixelFormat.RGBToColor(0, 255, 0) : 250);
else if (state == kRectUnreachable)
- screen->frameRect(rect, (_vm->getFeatures() & GF_ME) ? _pixelFormat.RGBToColor(0, 0, 255) : 252);
+ screen->frameRect(rect, _vm->isGameVariant(GF_ME) ? _pixelFormat.RGBToColor(0, 0, 255) : 252);
else
- screen->frameRect(rect, (_vm->getFeatures() & GF_ME) ? _pixelFormat.RGBToColor(255, 0, 0) : 249);
+ screen->frameRect(rect, _vm->isGameVariant(GF_ME) ? _pixelFormat.RGBToColor(255, 0, 0) : 249);
_vm->_system->unlockScreen();
}
@@ -700,7 +700,7 @@ void MystGraphics::drawLine(const Common::Point &p1, const Common::Point &p2, ui
void MystGraphics::fadeToBlack() {
// This is only for the demo
- assert(!(_vm->getFeatures() & GF_ME));
+ assert(!_vm->isGameVariant(GF_ME));
// Linear fade in 64 steps
for (int i = 63; i >= 0; i--) {
@@ -718,7 +718,7 @@ void MystGraphics::fadeToBlack() {
void MystGraphics::fadeFromBlack() {
// This is only for the demo
- assert(!(_vm->getFeatures() & GF_ME));
+ assert(!_vm->isGameVariant(GF_ME));
copyBackBufferToScreen(_viewport);
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 5cd4e817da..a6ee4e8632 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -764,7 +764,7 @@ void MystScriptParser::o_changeStack(uint16 var, const ArgumentsArray &args) {
_vm->_sound->stopEffect();
- if (_vm->getFeatures() & GF_DEMO) {
+ if (_vm->isGameVariant(GF_DEMO)) {
// No need to have a table for just this data...
if (targetStack == 1)
_vm->changeToStack(kDemoSlidesStack, 1000, soundIdLinkSrc, soundIdLinkDst);
diff --git a/engines/mohawk/myst_sound.cpp b/engines/mohawk/myst_sound.cpp
index a0a167d3af..fc5d1b3489 100644
--- a/engines/mohawk/myst_sound.cpp
+++ b/engines/mohawk/myst_sound.cpp
@@ -46,7 +46,7 @@ MystSound::~MystSound() {
}
Audio::RewindableAudioStream *MystSound::makeAudioStream(uint16 id, CueList *cueList) {
- if (_vm->getFeatures() & GF_ME)
+ if (_vm->isGameVariant(GF_ME))
return Audio::makeWAVStream(_vm->getResource(ID_MSND, convertMystID(id)), DisposeAfterUse::YES);
else
return makeMohawkWaveStream(_vm->getResource(ID_MSND, id), cueList);
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index 15c7195fe1..1f3912c792 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -116,7 +116,7 @@ void Intro::introMovies_run() {
case 4:
_introStep = 5;
- if (!(_vm->getFeatures() & GF_DEMO)) { // The demo doesn't have the intro video
+ if (!_vm->isGameVariant(GF_DEMO)) { // The demo doesn't have the intro video
video = _vm->playMovieFullscreen("intro", kIntroStack);
}
break;
@@ -125,7 +125,7 @@ void Intro::introMovies_run() {
_introStep = 6;
break;
default:
- if (_vm->getFeatures() & GF_DEMO)
+ if (_vm->isGameVariant(GF_DEMO))
_vm->changeToCard(2001, kTransitionRightToLeft);
else
_vm->changeToCard(2, kTransitionRightToLeft);
@@ -135,7 +135,7 @@ void Intro::introMovies_run() {
void Intro::o_playIntroMovies(uint16 var, const ArgumentsArray &args) {
_introMoviesRunning = true;
- if (_vm->getFeatures() & GF_25TH) {
+ if (_vm->isGameVariant(GF_25TH)) {
// In the 25th anniversary version, the Broderbund / Cyan Logo were already shown
// before the main menu. No need to play them again here.
_introStep = 4;
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 820fd714a5..15eab936b3 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -2975,7 +2975,7 @@ void Myst::clockGearForwardOneStep(uint16 gear) {
void Myst::clockWeightDownOneStep() {
// The Myst ME version of this video is encoded faster than the original
// The weight goes on the floor one step too early. Original ME engine also has this behavior.
- bool updateVideo = !(_vm->getFeatures() & GF_ME) || _clockWeightPosition < (2214 - 246);
+ bool updateVideo = !_vm->isGameVariant(GF_ME) || _clockWeightPosition < (2214 - 246);
// Set video bounds
if (updateVideo) {
@@ -3278,7 +3278,7 @@ Common::Point Myst::towerRotationMapComputeCoords(uint16 angle) {
void Myst::towerRotationMapDrawLine(const Common::Point &end, bool rotationLabelVisible) {
uint32 color;
- if (_vm->getFeatures() & GF_ME) {
+ if (_vm->isGameVariant(GF_ME)) {
Graphics::PixelFormat pf = _vm->_system->getScreenFormat();
if (!_towerRotationOverSpot)
@@ -3505,7 +3505,7 @@ void Myst::o_observatory_init(uint16 var, const ArgumentsArray &args) {
bool Myst::observatoryIsDDMMYYYY2400() {
// TODO: Auto-detect based on the month rect position
- return !(_vm->getFeatures() & GF_ME) && (_vm->getLanguage() == Common::FR_FRA
+ return !_vm->isGameVariant(GF_ME) && (_vm->getLanguage() == Common::FR_FRA
|| _vm->getLanguage() == Common::DE_DEU);
}
diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp
index 6dd424ee3b..574f6c32a8 100644
--- a/engines/mohawk/myst_state.cpp
+++ b/engines/mohawk/myst_state.cpp
@@ -213,7 +213,7 @@ bool MystGameState::saveState(int slot) {
debugC(kDebugSaveLoad, "Saving game to '%s'", filename.c_str());
Common::Serializer s(nullptr, saveFile);
- syncGameState(s, _vm->getFeatures() & GF_ME);
+ syncGameState(s, _vm->isGameVariant(GF_ME));
saveFile->finalize();
delete saveFile;
@@ -532,7 +532,7 @@ void MystGameState::addZipDest(MystStack stack, uint16 view) {
ZipDests *zipDests = nullptr;
// The demo has no zip dest storage
- if (_vm->getFeatures() & GF_DEMO)
+ if (_vm->isGameVariant(GF_DEMO))
return;
// Select stack
@@ -578,7 +578,7 @@ bool MystGameState::isReachableZipDest(MystStack stack, uint16 view) {
return false;
// The demo has no zip dest storage
- if (_vm->getFeatures() & GF_DEMO)
+ if (_vm->isGameVariant(GF_DEMO))
return false;
// Select stack
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index a594bdb97b..f799b698fe 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -176,7 +176,7 @@ Common::Error MohawkEngine_Riven::run() {
_cursor->showCursor();
// Let's begin, shall we?
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
// Start the demo off with the videos
changeToStack(kStackAspit);
changeToCard(6);
@@ -263,12 +263,12 @@ void MohawkEngine_Riven::processInput() {
runOptionsDialog();
break;
case kRivenActionOpenMainMenu:
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
// Return to the main menu in the demo
if (_stack->getId() != kStackAspit)
changeToStack(kStackAspit);
changeToCard(1);
- } else if (!_scriptMan->hasQueuedScripts() && getFeatures() & GF_25TH) {
+ } else if (!_scriptMan->hasQueuedScripts() && isGameVariant(GF_25TH)) {
// Check if we haven't jumped to menu
if (_menuSavedStack == -1) {
goToMainMenu();
@@ -281,7 +281,7 @@ void MohawkEngine_Riven::processInput() {
break;
case kRivenActionPlayIntroVideos:
// Play the intro videos in the demo
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
if (_stack->getId() != kStackAspit)
changeToStack(kStackAspit);
changeToCard(6);
@@ -392,7 +392,7 @@ void MohawkEngine_Riven::changeToStack(uint16 stackId) {
char prefix = RivenStacks::getName(stackId)[0];
// Load the localization override file if any
- if (getFeatures() & GF_25TH) {
+ if (isGameVariant(GF_25TH)) {
loadLanguageDatafile(prefix, stackId);
}
@@ -467,9 +467,9 @@ const char **MohawkEngine_Riven::listExpectedDatafiles() const {
};
const char **datafiles;
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
datafiles = datafilesDemo;
- } else if (getFeatures() & GF_DVD) {
+ } else if (isGameVariant(GF_DVD)) {
datafiles = datafilesDVD;
} else {
datafiles = datafilesCD;
@@ -624,7 +624,7 @@ void MohawkEngine_Riven::changeToCard(uint16 dest) {
// on different cards).
_gfx->clearCache();
- if (!(getFeatures() & GF_DEMO)) {
+ if (!isGameVariant(GF_DEMO)) {
for (byte i = 0; i < ARRAYSIZE(rivenSpecialChange); i++)
if (_stack->getId() == rivenSpecialChange[i].startStack && dest == _stack->getCardStackId(
rivenSpecialChange[i].startCardRMAP)) {
@@ -813,7 +813,7 @@ bool MohawkEngine_Riven::isZipVisitedCard(const Common::String &hotspotName) con
}
bool MohawkEngine_Riven::canLoadGameStateCurrently() {
- if (getFeatures() & GF_DEMO) {
+ if (isGameVariant(GF_DEMO)) {
return false;
}
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 1a8438af5a..bb5b139c93 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -219,7 +219,7 @@ void RivenCard::applyPropertiesPatch2E76(uint32 globalId) {
// }
// break;
// }
- if (globalId == 0x2E76 && !(_vm->getFeatures() & GF_DVD)) {
+ if (globalId == 0x2E76 && !_vm->isGameVariant(GF_DVD)) {
uint16 aGehnVariable = _vm->getStack()->getIdFromName(kVariableNames, "agehn");
uint16 aTrapBookVariable = _vm->getStack()->getIdFromName(kVariableNames, "atrapbook");
uint16 patchData[] = {
@@ -398,7 +398,7 @@ void RivenCard::applyPropertiesPatch22118(uint32 globalId) {
}
void RivenCard::applyPropertiesPatchE2E(uint32 globalId) {
- if (!(_vm->getFeatures() & GF_25TH))
+ if (!_vm->isGameVariant(GF_25TH))
return;
// The main menu in the Myst 25th anniversary version is patched to include new items:
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index 72f020c50f..f6ec2c09f0 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -340,7 +340,9 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) :
_effectScreen = new Graphics::Surface();
_effectScreen->create(608, 392, _pixelFormat);
- loadMenuFont();
+ if (_vm->isGameVariant(GF_25TH)) {
+ loadMenuFont();
+ }
}
RivenGraphics::~RivenGraphics() {
diff --git a/engines/mohawk/riven_inventory.cpp b/engines/mohawk/riven_inventory.cpp
index 7479080685..6918a88b0f 100644
--- a/engines/mohawk/riven_inventory.cpp
+++ b/engines/mohawk/riven_inventory.cpp
@@ -54,7 +54,7 @@ void RivenInventory::draw() {
clearArea();
// Draw the demo's exit button
- if (_vm->getFeatures() & GF_DEMO) {
+ if (_vm->isGameVariant(GF_DEMO)) {
// extras.mhk tBMP 101 contains "EXIT" instead of Atrus' journal in the demo!
// The demo's extras.mhk contains all the other inventory/marble/credits image
// but has hacked tBMP 101 with "EXIT". *sigh*
@@ -100,7 +100,7 @@ void RivenInventory::checkClick(const Common::Point &mousePos) {
}
// In the demo, check if we've clicked the exit button
- if (_vm->getFeatures() & GF_DEMO) {
+ if (_vm->isGameVariant(GF_DEMO)) {
if (_demoExitRect.contains(mousePos)) {
if (_vm->getStack()->getId() == kStackAspit && _vm->getCard()->getId() == 1) {
// From the main menu, go to the "quit" screen
@@ -181,7 +181,7 @@ bool RivenInventory::isVisible() const {
return false;
}
- if (_vm->getFeatures() & GF_DEMO) {
+ if (_vm->isGameVariant(GF_DEMO)) {
// The inventory is always visible in the demo
return true;
}
diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp
index da8463e367..0aeef7dbbe 100644
--- a/engines/mohawk/riven_saveload.cpp
+++ b/engines/mohawk/riven_saveload.cpp
@@ -165,7 +165,7 @@ SaveStateDescriptor RivenSaveLoad::querySaveMetaInfos(const int slot) {
}
Common::Error RivenSaveLoad::loadGame(const int slot) {
- if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo
+ if (_vm->isGameVariant(GF_DEMO)) // Don't load games in the demo
return Common::kNoError;
Common::String filename = buildSaveFilename(slot);
@@ -187,8 +187,8 @@ Common::Error RivenSaveLoad::loadGame(const int slot) {
Common::SeekableReadStream *vers = mhk->getResource(ID_VERS, 1);
uint32 saveGameVersion = vers->readUint32BE();
delete vers;
- if ((saveGameVersion == kCDSaveGameVersion && (_vm->getFeatures() & GF_DVD))
- || (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) {
+ if ((saveGameVersion == kCDSaveGameVersion && _vm->isGameVariant(GF_DVD))
+ || (saveGameVersion == kDVDSaveGameVersion && !_vm->isGameVariant(GF_DVD))) {
warning("Unable to load: Saved game created using an incompatible game version - CD vs DVD");
delete mhk;
return Common::Error(Common::kUnknownError, "Saved game created using an incompatible game version - CD vs DVD");
@@ -297,7 +297,7 @@ Common::Error RivenSaveLoad::loadGame(const int slot) {
Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVERSSection() {
Common::MemoryWriteStreamDynamic *stream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
- if (_vm->getFeatures() & GF_DVD)
+ if (_vm->isGameVariant(GF_DVD))
stream->writeUint32BE(kDVDSaveGameVersion);
else
stream->writeUint32BE(kCDSaveGameVersion);
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index a59850f1ee..65e339d93f 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -313,7 +313,7 @@ void RivenScript::applyCardPatches(MohawkEngine_Riven *vm, uint32 cardGlobalId,
// switchCard(534);
// playSound(112, 256, 0);
if (cardGlobalId == 0x2E900 && scriptType == kMouseDownScript && hotspotId == 3
- && !(vm->getFeatures() & GF_DVD)) {
+ && !vm->isGameVariant(GF_DVD)) {
shouldApplyPatches = true;
RivenSimpleCommand::ArgumentArray arguments;
arguments.push_back(112);
@@ -325,7 +325,7 @@ void RivenScript::applyCardPatches(MohawkEngine_Riven *vm, uint32 cardGlobalId,
// Second part of the patch to fix the invalid card change when entering Gehn's office
// The first part is in the card patches.
- if (cardGlobalId == 0x2E76 && scriptType == kCardUpdateScript && !(vm->getFeatures() & GF_DVD)) {
+ if (cardGlobalId == 0x2E76 && scriptType == kCardUpdateScript && !vm->isGameVariant(GF_DVD)) {
shouldApplyPatches = true;
for (uint i = 0; i < _commands.size(); i++) {
@@ -367,7 +367,7 @@ void RivenScript::applyCardPatches(MohawkEngine_Riven *vm, uint32 cardGlobalId,
// Override the main menu new game script to call an external command.
// This way we can reset all the state when starting a new game while a game is already started.
if (cardGlobalId == 0xE2E && scriptType == kMouseDownScript && hotspotId == 16
- && (vm->getFeatures() & GF_25TH)) {
+ && vm->isGameVariant(GF_25TH)) {
shouldApplyPatches = true;
_commands.clear();
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index ba36dccdd7..922bbd9345 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -90,7 +90,7 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
// The original game hides the start/setup buttons depending on an ini entry.
// It's safe to ignore this command.
- if (!(_vm->getFeatures() & GF_25TH))
+ if (!_vm->isGameVariant(GF_25TH))
return;
int lang = -1;
@@ -202,7 +202,7 @@ void ASpit::xaatrusbooknextpage(const ArgumentArray &args) {
// Keep turning pages while the mouse is pressed
while (keepTurningPages()) {
// Check for the last page
- if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10)
+ if ((_vm->isGameVariant(GF_DEMO) && page == 6) || page == 10)
return;
// Update the page number
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index ae20a59370..5f2cf01728 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -140,7 +140,7 @@ void VideoEntry::setVolume(int volume) {
VideoManager::VideoManager(MohawkEngine *vm) : _vm(vm) {
// Set dithering enabled, if required
- _enableDither = (_vm->getGameType() == GType_MYST || _vm->getGameType() == GType_MAKINGOF) && !(_vm->getFeatures() & GF_ME);
+ _enableDither = (_vm->getGameType() == GType_MYST || _vm->getGameType() == GType_MAKINGOF) && !_vm->isGameVariant(GF_ME);
}
VideoManager::~VideoManager() {
More information about the Scummvm-git-logs
mailing list