diff src/parpg/objects/action.py @ 137:140e5e93f026

Added ExamineContentsAction. Added "Examine Contents" to the context menu, when the object is a container and does not have a characterstats component.
author KarstenBock@gmx.net
date Fri, 30 Sep 2011 15:31:53 +0200
parents c938a828a38a
children 6e1eb964a6e5
line wrap: on
line diff
--- a/src/parpg/objects/action.py	Fri Sep 30 15:08:53 2011 +0200
+++ b/src/parpg/objects/action.py	Fri Sep 30 15:31:53 2011 +0200
@@ -199,9 +199,6 @@
         @type examine_desc: string
         @param commands: Special commands that are executed
         @type commands: Dictionary 
-        @type view: class derived from parpg.ViewBase
-        @param view: The view
-        
         """
         super(ExamineAction, self).__init__(controller, commands)
         self.view = controller.view
@@ -225,6 +222,7 @@
                 place += 26 #plus 1 character to offset the new line
             else: place += 1
         self.view.displayObjectText(self.examine_id, unicode(action_text), time=3000)
+        Action.execute(self)
 
 class ExamineItemAction(Action):
     """Examine an item."""
@@ -251,6 +249,28 @@
         action_text = unicode(self.examine_desc)
         self.view.hud.addAction(action_text)
         logger.debug(action_text)
+        Action.execute(self)
+
+class ExamineContentsAction(Action):
+    """Examine the contens of an container"""
+    def __init__(self, controller, container, commands=None):
+        """
+        @param controller: A reference to the GameSceneController.
+        @type controller: parpg.GameSceneController
+        @param container: The container
+        @type container: parpg.entities.General
+        @param commands: Special commands that are executed
+        @type commands: Dictionary         
+        """
+        Action.__init__(self, controller, commands)
+        self.view = controller.view
+        self.container = container
+        
+    def execute(self):
+        """Examine the contents"""
+        self.view.hud.createBoxGUI(self.container.description.view_name,
+                                   self.container.container)
+        Action.execute(self)
 
 class ReadAction(Action):
     """Read a text."""
@@ -567,4 +587,6 @@
            "Use":UseAction,
            "PickUp":PickUpAction,
            "DropFromInventory":DropItemFromContainerAction,
-           "BrewBeer":BrewBeerAction}
+           "BrewBeer":BrewBeerAction,
+           "ExamineContents": ExamineContentsAction,
+           }