mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
Changed Action constructor to take a pointer to the Keymap it belongs too, meaning Keymap::addAction is automatically called
svn-id: r33885
This commit is contained in:
parent
6d0ed23b44
commit
c61294e70f
@ -28,29 +28,18 @@
|
||||
|
||||
namespace Common {
|
||||
|
||||
Action::Action(int32 i, String des,
|
||||
ActionCategory cat, ActionType typ,
|
||||
int pri, int grp, int flg) {
|
||||
id = i;
|
||||
description = des;
|
||||
category = cat;
|
||||
type = typ;
|
||||
priority = pri;
|
||||
group = grp;
|
||||
flags = flg;
|
||||
_hwKey = 0;
|
||||
_parent = 0;
|
||||
}
|
||||
|
||||
void Action::setParent(Keymap *parent) {
|
||||
_parent = parent;
|
||||
Action::Action(Keymap *boss, int32 i, String des, ActionCategory cat,
|
||||
ActionType typ, int pri, int grp, int flg)
|
||||
: _boss(boss), id(i), description(des), category(cat), type(typ),
|
||||
priority(pri), group(grp), flags(flg), _hwKey(0) {
|
||||
assert(_boss);
|
||||
_boss->addAction(this);
|
||||
}
|
||||
|
||||
void Action::mapKey(const HardwareKey *key) {
|
||||
assert(_parent);
|
||||
if (_hwKey) _parent->unregisterMapping(this);
|
||||
if (_hwKey) _boss->unregisterMapping(this);
|
||||
_hwKey = key;
|
||||
if (_hwKey) _parent->registerMapping(this, _hwKey);
|
||||
if (_hwKey) _boss->registerMapping(this, _hwKey);
|
||||
}
|
||||
|
||||
const HardwareKey *Action::getMappedKey() const {
|
||||
|
@ -85,18 +85,16 @@ struct Action {
|
||||
private:
|
||||
/** Hardware key that is mapped to this Action */
|
||||
const HardwareKey *_hwKey;
|
||||
Keymap *_parent;
|
||||
Keymap *_boss;
|
||||
|
||||
public:
|
||||
Action( int32 id,
|
||||
String des = "",
|
||||
ActionCategory cat = kGenericActionCategory,
|
||||
ActionType typ = kGenericActionType,
|
||||
int pri = 0, int grp = 0, int flg = 0 );
|
||||
Action(Keymap *boss, int32 id, String des = "",
|
||||
ActionCategory cat = kGenericActionCategory,
|
||||
ActionType typ = kGenericActionType,
|
||||
int pri = 0, int grp = 0, int flg = 0 );
|
||||
|
||||
void addEvent(const Event &evt) { events.push_back(evt); }
|
||||
void setParent(Keymap *parent);
|
||||
Keymap *getParent() { return _parent; }
|
||||
Keymap *getBoss() { return _boss; }
|
||||
void mapKey(const HardwareKey *key);
|
||||
const HardwareKey *getMappedKey() const;
|
||||
|
||||
|
@ -47,7 +47,6 @@ Keymap::~Keymap() {
|
||||
void Keymap::addAction(Action *action) {
|
||||
if (findAction(action->id))
|
||||
error("Action with id %d already in KeyMap!", action->id);
|
||||
action->setParent(this);
|
||||
_actions.push_back(action);
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,6 @@ public:
|
||||
~Keymap();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Adds a new Action to this Map,
|
||||
* adding it at the back of the internal array
|
||||
* @param action the Action to add
|
||||
*/
|
||||
void addAction(Action *action);
|
||||
|
||||
/**
|
||||
* Retrieves the Action with the given id
|
||||
* @param id id of Action to retrieve
|
||||
@ -108,6 +101,14 @@ public:
|
||||
|
||||
private:
|
||||
friend struct Action;
|
||||
|
||||
/**
|
||||
* Adds a new Action to this Map,
|
||||
* adding it at the back of the internal array
|
||||
* @param action the Action to add
|
||||
*/
|
||||
void addAction(Action *action);
|
||||
|
||||
/**
|
||||
* Registers a HardwareKey to the given Action
|
||||
* @param action Action in this Keymap
|
||||
|
@ -542,33 +542,26 @@ void OSystem_SDL::setupKeymapper() {
|
||||
evt.kbd = KeyState(kc, asc, flags); \
|
||||
act->events.push_back(evt);
|
||||
|
||||
act = new Action('MENU', "Menu", kGenericActionCategory, kMenuAction);
|
||||
act = new Action(global, 'MENU', "Menu", kGenericActionCategory, kMenuAction);
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_F5, ASCII_F5, 0)
|
||||
global->addAction(act);
|
||||
|
||||
act = new Action('SKCT', "Skip");
|
||||
act = new Action(global, 'SKCT', "Skip");
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0);
|
||||
global->addAction(act);
|
||||
|
||||
act = new Action('PAUS', "Pause");
|
||||
act = new Action(global, 'PAUS', "Pause");
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_SPACE, ' ', 0)
|
||||
global->addAction(act);
|
||||
|
||||
act = new Action('SKLI', "Skip line");
|
||||
act = new Action(global, 'SKLI', "Skip line");
|
||||
ADD_KEYDOWN_EVENT(Common::KEYCODE_PERIOD, '.', 0);
|
||||
global->addAction(act);
|
||||
|
||||
act = new Action('JUMP', "Jump");
|
||||
act = new Action(specific, 'JUMP', "Jump");
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_j, 'j', 0);
|
||||
specific->addAction(act);
|
||||
|
||||
act = new Action('DUCK', "Duck");
|
||||
act = new Action(specific, 'DUCK', "Duck");
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_d, 'd', 0);
|
||||
specific->addAction(act);
|
||||
|
||||
act = new Action('RUN_', "Run");
|
||||
act = new Action(specific, 'RUN_', "Run");
|
||||
ADD_KEYDOWN_EVENT(KEYCODE_r, 'r', 0);
|
||||
specific->addAction(act);
|
||||
|
||||
#undef ADD_KEYDOWN_EVENT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user