[Scummvm-cvs-logs] SF.net SVN: scummvm:[33885] scummvm/branches/gsoc2008-vkeybd/backends

kenny-d at users.sourceforge.net kenny-d at users.sourceforge.net
Fri Aug 15 01:45:03 CEST 2008


Revision: 33885
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33885&view=rev
Author:   kenny-d
Date:     2008-08-14 23:45:02 +0000 (Thu, 14 Aug 2008)

Log Message:
-----------
Changed Action constructor to take a pointer to the Keymap it belongs too, meaning Keymap::addAction is automatically called

Modified Paths:
--------------
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h
    scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp	2008-08-14 23:38:13 UTC (rev 33884)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp	2008-08-14 23:45:02 UTC (rev 33885)
@@ -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;
+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::setParent(Keymap *parent) {
-	_parent = parent;
-}
-
 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 {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h	2008-08-14 23:38:13 UTC (rev 33884)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h	2008-08-14 23:45:02 UTC (rev 33885)
@@ -85,18 +85,16 @@
 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;
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp	2008-08-14 23:38:13 UTC (rev 33884)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp	2008-08-14 23:45:02 UTC (rev 33885)
@@ -47,7 +47,6 @@
 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);
 }
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h	2008-08-14 23:38:13 UTC (rev 33884)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h	2008-08-14 23:45:02 UTC (rev 33885)
@@ -57,13 +57,6 @@
 
 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
 	 * @return Pointer to the Action or 0 if not found
@@ -108,7 +101,15 @@
 
 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
 	* @param key pointer to HardwareKey to map

Modified: scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp	2008-08-14 23:38:13 UTC (rev 33884)
+++ scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp	2008-08-14 23:45:02 UTC (rev 33885)
@@ -542,33 +542,26 @@
 		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
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list