ZVISION: Disable the keymap when InputControl is focused
This commit is contained in:
parent
db87cb0c63
commit
6ed8dea829
6 changed files with 52 additions and 30 deletions
|
@ -145,90 +145,92 @@ Common::KeymapArray ZVisionMetaEngine::initKeymaps(const char *target) const {
|
|||
act->addDefaultInputMapping("JOY_B");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
Keymap *gameKeymap = new Keymap(Keymap::kKeymapTypeGame, gameKeymapId, "Z-Vision - Game");
|
||||
|
||||
act = new Action(kStandardActionMoveUp, _("Look Up"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionUp);
|
||||
act->addDefaultInputMapping("UP");
|
||||
act->addDefaultInputMapping("JOY_UP");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveDown, _("Look Down"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionDown);
|
||||
act->addDefaultInputMapping("DOWN");
|
||||
act->addDefaultInputMapping("JOY_DOWN");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveLeft, _("Turn Left"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionLeft);
|
||||
act->addDefaultInputMapping("LEFT");
|
||||
act->addDefaultInputMapping("JOY_LEFT");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveRight, _("Turn Right"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionRight);
|
||||
act->addDefaultInputMapping("RIGHT");
|
||||
act->addDefaultInputMapping("JOY_RIGHT");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("FPS", _("Show FPS"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionShowFPS);
|
||||
act->addDefaultInputMapping("F10");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("HELP", _("Help"));
|
||||
act->setKeyEvent(KEYCODE_F1);
|
||||
act->addDefaultInputMapping("F1");
|
||||
act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("INV", _("Inventory"));
|
||||
act->setKeyEvent(KEYCODE_F5);
|
||||
act->addDefaultInputMapping("F5");
|
||||
act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("SPELL", _("Spellbook"));
|
||||
act->setKeyEvent(KEYCODE_F6);
|
||||
act->addDefaultInputMapping("F6");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("SCORE", _("Score"));
|
||||
act->setKeyEvent(KEYCODE_F7);
|
||||
act->addDefaultInputMapping("F7");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("AWAY", _("Put away object"));
|
||||
act->setKeyEvent(KEYCODE_F8);
|
||||
act->addDefaultInputMapping("F8");
|
||||
act->addDefaultInputMapping("JOY_X");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("COIN", _("Extract coin"));
|
||||
act->setKeyEvent(KEYCODE_F9);
|
||||
act->addDefaultInputMapping("F9");
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionSave, _("Save"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionSave);
|
||||
act->addDefaultInputMapping("C+s");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionLoad, _("Restore"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionRestore);
|
||||
act->addDefaultInputMapping("C+r");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action("QUIT", _("Quit"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionQuit);
|
||||
act->addDefaultInputMapping("C+q");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionOpenSettings, _("Preferences"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionPreferences);
|
||||
act->addDefaultInputMapping("C+p");
|
||||
mainKeymap->addAction(act);
|
||||
gameKeymap->addAction(act);
|
||||
|
||||
Keymap *cutscenesKeymap = new Keymap(Keymap::kKeymapTypeGame, cutscenesKeymapId, "Z-Vision - Cutscenes");
|
||||
|
||||
|
@ -243,9 +245,10 @@ Common::KeymapArray ZVisionMetaEngine::initKeymaps(const char *target) const {
|
|||
act->addDefaultInputMapping("C+q");
|
||||
cutscenesKeymap->addAction(act);
|
||||
|
||||
KeymapArray keymaps(2);
|
||||
KeymapArray keymaps(3);
|
||||
keymaps[0] = mainKeymap;
|
||||
keymaps[1] = cutscenesKeymap;
|
||||
keymaps[1] = gameKeymap;
|
||||
keymaps[2] = cutscenesKeymap;
|
||||
|
||||
return keymaps;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
#include "zvision/text/string_manager.h"
|
||||
#include "zvision/graphics/render_manager.h"
|
||||
|
||||
#include "backends/keymapper/keymap.h"
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/system.h"
|
||||
#include "common/rect.h"
|
||||
#include "video/video_decoder.h"
|
||||
|
||||
|
@ -118,6 +121,23 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
|
|||
InputControl::~InputControl() {
|
||||
_background->free();
|
||||
delete _background;
|
||||
unfocus();
|
||||
}
|
||||
|
||||
void InputControl::focus() {
|
||||
if (!_readOnly) {
|
||||
_engine->getGameKeymap()->setEnabled(false);
|
||||
}
|
||||
_focused = true;
|
||||
_textChanged = true;
|
||||
}
|
||||
|
||||
void InputControl::unfocus() {
|
||||
if (!_readOnly) {
|
||||
_engine->getGameKeymap()->setEnabled(true);
|
||||
}
|
||||
_focused = false;
|
||||
_textChanged = true;
|
||||
}
|
||||
|
||||
bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
|
||||
|
|
|
@ -59,14 +59,8 @@ private:
|
|||
Video::VideoDecoder *_animation;
|
||||
|
||||
public:
|
||||
void focus() override {
|
||||
_focused = true;
|
||||
_textChanged = true;
|
||||
}
|
||||
void unfocus() override {
|
||||
_focused = false;
|
||||
_textChanged = true;
|
||||
}
|
||||
void focus() override;
|
||||
void unfocus() override;
|
||||
bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) override;
|
||||
bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) override;
|
||||
bool onKeyDown(Common::KeyState keyState) override;
|
||||
|
|
|
@ -94,7 +94,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
|
|||
_videoIsPlaying = true;
|
||||
|
||||
_cutscenesKeymap->setEnabled(true);
|
||||
_mainKeymap->setEnabled(false);
|
||||
_gameKeymap->setEnabled(false);
|
||||
|
||||
// Only continue while the video is still playing
|
||||
while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
|
||||
|
@ -142,7 +142,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
|
|||
}
|
||||
|
||||
_cutscenesKeymap->setEnabled(false);
|
||||
_mainKeymap->setEnabled(true);
|
||||
_gameKeymap->setEnabled(true);
|
||||
|
||||
_videoIsPlaying = false;
|
||||
_clock.start();
|
||||
|
|
|
@ -80,6 +80,7 @@ struct zvisionIniSettings {
|
|||
};
|
||||
|
||||
const char *mainKeymapId = "zvision";
|
||||
const char *gameKeymapId = "zvision-game";
|
||||
const char *cutscenesKeymapId = "zvision-cutscenes";
|
||||
|
||||
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
|
||||
|
@ -207,8 +208,8 @@ void ZVision::initialize() {
|
|||
initScreen();
|
||||
|
||||
Common::Keymapper *keymapper = _system->getEventManager()->getKeymapper();
|
||||
_mainKeymap = keymapper->getKeymap(mainKeymapId);
|
||||
_mainKeymap->setEnabled(true);
|
||||
_gameKeymap = keymapper->getKeymap(gameKeymapId);
|
||||
_gameKeymap->setEnabled(true);
|
||||
_cutscenesKeymap = keymapper->getKeymap(cutscenesKeymapId);
|
||||
_cutscenesKeymap->setEnabled(false);
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ enum ZVisionAction {
|
|||
};
|
||||
|
||||
extern const char *mainKeymapId;
|
||||
extern const char *gameKeymapId;
|
||||
extern const char *cutscenesKeymapId;
|
||||
|
||||
class ZVision : public Engine {
|
||||
|
@ -162,7 +163,7 @@ private:
|
|||
// To prevent allocation every time we process events
|
||||
Common::Event _event;
|
||||
|
||||
Common::Keymap *_mainKeymap, *_cutscenesKeymap;
|
||||
Common::Keymap *_gameKeymap, *_cutscenesKeymap;
|
||||
|
||||
int _frameRenderDelay;
|
||||
int _renderedFrameCount;
|
||||
|
@ -210,6 +211,9 @@ public:
|
|||
return _menu;
|
||||
}
|
||||
|
||||
Common::Keymap *getGameKeymap() const {
|
||||
return _gameKeymap;
|
||||
}
|
||||
Common::RandomSource *getRandomSource() const {
|
||||
return _rnd;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue