ULTIMA8: Beginning of transition to ScummVM keymapper

This commit is contained in:
Paul Gilbert 2020-03-05 21:10:04 -08:00
parent 6f70d3530c
commit c5cfe75f22
6 changed files with 142 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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 \

View file

@ -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

View file

@ -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

View file

@ -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;