[Scummvm-git-logs] scummvm master -> c5cfe75f22ee3f1a8f10fc2385b2765cf764e5cc
dreammaster
paulfgilbert at gmail.com
Fri Mar 6 05:15:42 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c5cfe75f22 ULTIMA8: Beginning of transition to ScummVM keymapper
Commit: c5cfe75f22ee3f1a8f10fc2385b2765cf764e5cc
https://github.com/scummvm/scummvm/commit/c5cfe75f22ee3f1a8f10fc2385b2765cf764e5cc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-03-05T21:11:03-08:00
Commit Message:
ULTIMA8: Beginning of transition to ScummVM keymapper
Changed paths:
A engines/ultima/ultima8/meta_engine.cpp
A engines/ultima/ultima8/meta_engine.h
engines/ultima/detection.cpp
engines/ultima/detection.h
engines/ultima/module.mk
engines/ultima/ultima8/ultima8.cpp
diff --git a/engines/ultima/detection.cpp b/engines/ultima/detection.cpp
index cd3149190f..89adf34ef1 100644
--- a/engines/ultima/detection.cpp
+++ b/engines/ultima/detection.cpp
@@ -32,6 +32,7 @@
#include "ultima/nuvie/meta_engine.h"
#include "ultima/nuvie/nuvie.h"
#include "ultima/ultima8/ultima8.h"
+#include "ultima/ultima8/meta_engine.h"
namespace Ultima {
@@ -102,6 +103,7 @@ const char *UltimaMetaEngine::getSavegameFile(int saveGameIdx, const char *targe
SaveStateList UltimaMetaEngine::listSaves(const char *target) const {
SaveStateList saveList = AdvancedMetaEngine::listSaves(target);
+ ConfMan.setActiveDomain(target);
Common::String gameId = ConfMan.get("gameid");
if (gameId == "ultima6" || gameId == "ultima6_enh")
Ultima::Nuvie::MetaEngine::listSaves(saveList);
@@ -109,6 +111,15 @@ SaveStateList UltimaMetaEngine::listSaves(const char *target) const {
return saveList;
}
+Common::KeymapArray UltimaMetaEngine::initKeymaps(const char *target) const {
+ ConfMan.setActiveDomain(target);
+ Common::String gameId = ConfMan.get("gameid");
+ if (gameId == "ultima8")
+ return Ultima::Ultima8::MetaEngine::initKeymaps();
+
+ return Common::KeymapArray();
+}
+
#if PLUGIN_ENABLED_DYNAMIC(ULTIMA)
REGISTER_PLUGIN_DYNAMIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
#else
diff --git a/engines/ultima/detection.h b/engines/ultima/detection.h
index 03515b7ddf..889ca1dc70 100644
--- a/engines/ultima/detection.h
+++ b/engines/ultima/detection.h
@@ -24,6 +24,7 @@
#define ULTIMA_DETECTION
#include "engines/advancedDetector.h"
+#include "backends/keymapper/keymapper.h"
#define MAX_SAVES 99
@@ -56,7 +57,7 @@ struct UltimaGameDescription {
uint32 features;
};
-} // End of namespace Ultima8
+} // End of namespace Ultima
class UltimaMetaEngine : public AdvancedMetaEngine {
public:
@@ -85,6 +86,11 @@ public:
* Return a list of all save states associated with the given target.
*/
SaveStateList listSaves(const char *target) const override;
+
+ /**
+ * Initialize keymaps
+ */
+ Common::KeymapArray initKeymaps(const char *target) const override;
};
#endif
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 9c38076102..7ab047c575 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -324,6 +324,7 @@ MODULE_OBJS := \
nuvie/lua/lvm.o \
nuvie/lua/lzio.o \
nuvie/lua/scummvm_file.o \
+ ultima8/meta_engine.o \
ultima8/ultima8.o \
ultima8/audio/audio_channel.o \
ultima8/audio/audio_mixer.o \
diff --git a/engines/ultima/ultima8/meta_engine.cpp b/engines/ultima/ultima8/meta_engine.cpp
new file mode 100644
index 0000000000..352c9ac58f
--- /dev/null
+++ b/engines/ultima/ultima8/meta_engine.cpp
@@ -0,0 +1,67 @@
+/* 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.
+ *
+ */
+
+#include "ultima/ultima8/meta_engine.h"
+#include "ultima/ultima8/misc/debugger.h"
+#include "common/translation.h"
+#include "backends/keymapper/action.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+struct KeybindingRecord {
+ KeybindingAction _action;
+ const char *_id;
+ const char *_desc;
+ const char *_method;
+ const char *_key;
+};
+
+static const KeybindingRecord KEYS[] = {
+ { ACTION_COMBAT, "COMBAT", "Combat", "MainActor::toggleCombat", "c" },
+ { ACTION_NONE, nullptr, nullptr, nullptr, nullptr }
+};
+
+Common::KeymapArray MetaEngine::initKeymaps() {
+ Common::Keymap *keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame, "ultima8", _("Ultima VIII"));
+
+ for (const KeybindingRecord *r = KEYS; r->_id; ++r) {
+ Common::Action *act = new Common::Action(r->_id, _(r->_desc));
+ act->setCustomEngineActionEvent(r->_action);
+ act->addDefaultInputMapping(r->_key);
+ keyMap->addAction(act);
+ }
+
+ return Common::Keymap::arrayOf(keyMap);
+}
+
+void MetaEngine::executeAction(KeybindingAction keyAction) {
+ for (const KeybindingRecord *r = KEYS; r->_id; ++r) {
+ if (r->_action == keyAction) {
+ g_debugger->executeCommand(r->_method);
+ break;
+ }
+ }
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/meta_engine.h b/engines/ultima/ultima8/meta_engine.h
new file mode 100644
index 0000000000..3fc4d4fef4
--- /dev/null
+++ b/engines/ultima/ultima8/meta_engine.h
@@ -0,0 +1,51 @@
+/* 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 ULTIMA_ULTIMA8_META_ENGINE
+#define ULTIMA_ULTIMA8_META_ENGINE
+
+#include "backends/keymapper/keymapper.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+enum KeybindingAction {
+ ACTION_NONE, ACTION_COMBAT
+};
+
+class MetaEngine {
+public:
+ /**
+ * Initialize keymaps
+ */
+ static Common::KeymapArray initKeymaps();
+
+ /**
+ * Execute an engine keymap action
+ */
+ static void executeAction(KeybindingAction keyAction);
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 33fbe736ce..4915521b3b 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -110,6 +110,7 @@
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/misc/util.h"
#include "ultima/ultima8/audio/midi_player.h"
+#include "ultima/ultima8/meta_engine.h"
namespace Ultima {
namespace Ultima8 {
@@ -807,6 +808,10 @@ void Ultima8Engine::handleEvent(const Common::Event &event) {
_mouse->setMouseCoords(event.mouse.x, event.mouse.y);
break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ MetaEngine::executeAction((KeybindingAction)event.customType);
+ break;
+
case Common::EVENT_QUIT:
_isRunning = false;
break;
More information about the Scummvm-git-logs
mailing list