# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1276704440 0 # Node ID 718e154a43c84bd840a29ca4f33a8b969755c6ff # Parent 3b933753cba80fa7a1d44d981ea2d6639e83fc0c When you click on an object behind the player the click is no longer ignored. Fixed a bug where the players next action was performed even though the user clicked somewhere else on the map. diff -r 3b933753cba8 -r 718e154a43c8 demos/rpg/scripts/gamecontroller.py --- a/demos/rpg/scripts/gamecontroller.py Tue Jun 15 21:13:01 2010 +0000 +++ b/demos/rpg/scripts/gamecontroller.py Wed Jun 16 16:07:20 2010 +0000 @@ -111,17 +111,29 @@ if (event.getButton() == fife.MouseEvent.LEFT): self._lastmousepos = (clickpoint.x, clickpoint.y) + + #cancel last action + self._gamecontroller.scene.player.nextaction = None + self._gamecontroller.scene.player.walk( self._gamecontroller.scene.getLocationAt(clickpoint) ) + actor_instances = self._gamecontroller.scene.getInstancesAt(clickpoint, self._gamecontroller.scene.actorlayer) item_instances = self._gamecontroller.scene.getInstancesAt(clickpoint, self._gamecontroller.scene.itemlayer) + if actor_instances: - if actor_instances[0].getId() == "player": - return - - obj = self._gamecontroller.scene.objectlist[actor_instances[0].getId()] - if obj.type == GameObjectTypes["QUESTGIVER"]: - action = TalkAction(self._gamecontroller.scene.player, obj) - self._gamecontroller.scene.player.nextaction = action + actor_instance = None + for actor in actor_instances: + if actor.getId() == "player": + continue + else: + actor_instance = actor + break + + if actor_instance: + obj = self._gamecontroller.scene.objectlist[actor_instance.getId()] + if obj.type == GameObjectTypes["QUESTGIVER"]: + action = TalkAction(self._gamecontroller.scene.player, obj) + self._gamecontroller.scene.player.nextaction = action if item_instances: obj = self._gamecontroller.scene.objectlist[item_instances[0].getId()] @@ -344,10 +356,10 @@ if self._scene: self._scene.serialize() - self._questmanager.destroy() - self._listener.detach() self._scene.destroyScene() + self._questmanager.destroy() + self._scene = None self._instancerenderer = None self._floatingtextrenderer = None diff -r 3b933753cba8 -r 718e154a43c8 demos/rpg/scripts/objects/baseobject.py --- a/demos/rpg/scripts/objects/baseobject.py Tue Jun 15 21:13:01 2010 +0000 +++ b/demos/rpg/scripts/objects/baseobject.py Wed Jun 16 16:07:20 2010 +0000 @@ -110,6 +110,11 @@ """ Deletes the FIFE instance from the actor layer on the map. """ + + #This doesnt work + #self._instance.get2dGfxVisual().setVisible(False) + + #remove from the scene instead if self._actionlistener: self._actionlistener.detachActionListener() self._actionlistener = None @@ -119,6 +124,16 @@ self._instance = None self._activated = False + + def spawn(self, x, y): + #This doesnt work + #self._instance.get2dGfxVisual().setVisible(True) + + self._position.x = x + self._position.y = y + self._createFIFEInstance(self, self._layer) + + self._activated = True def setMapPosition(self, x, y): curloc = self.location @@ -160,13 +175,11 @@ mapmodel = self._gamecontroller.engine.getModel() self._fifeobject = mapmodel.getObject(self._name, self._gamecontroller.settings.get("RPG", "ObjectNamespace", "http://www.fifengine.de/xml/rpg")) - self._instance = layer.createInstance(self._fifeobject, fife.ModelCoordinate(0,0), self._id) + self._instance = layer.createInstance(self._fifeobject, fife.ExactModelCoordinate(self._position.x,self._position.y), self._id) fife.InstanceVisual.create(self._instance) self._instance.thisown = 0 - self.setMapPosition(self._position.x,self._position.y) - def _findFIFEInstance(self, layer): """ @todo: throw InstanceNotFoundError