Mercurial > parpg-core
comparison 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 |
comparison
equal
deleted
inserted
replaced
136:e1fd4cda237d | 137:140e5e93f026 |
---|---|
197 @type examine_name: string | 197 @type examine_name: string |
198 @param examine_desc: A description of the object that will be displayed. | 198 @param examine_desc: A description of the object that will be displayed. |
199 @type examine_desc: string | 199 @type examine_desc: string |
200 @param commands: Special commands that are executed | 200 @param commands: Special commands that are executed |
201 @type commands: Dictionary | 201 @type commands: Dictionary |
202 @type view: class derived from parpg.ViewBase | |
203 @param view: The view | |
204 | |
205 """ | 202 """ |
206 super(ExamineAction, self).__init__(controller, commands) | 203 super(ExamineAction, self).__init__(controller, commands) |
207 self.view = controller.view | 204 self.view = controller.view |
208 self.examine_id = examine_id | 205 self.examine_id = examine_id |
209 self.examine_name = examine_name | 206 self.examine_name = examine_name |
223 if action_text[place] == ' ': | 220 if action_text[place] == ' ': |
224 action_text = action_text[:place] +'\n'+action_text[place:] | 221 action_text = action_text[:place] +'\n'+action_text[place:] |
225 place += 26 #plus 1 character to offset the new line | 222 place += 26 #plus 1 character to offset the new line |
226 else: place += 1 | 223 else: place += 1 |
227 self.view.displayObjectText(self.examine_id, unicode(action_text), time=3000) | 224 self.view.displayObjectText(self.examine_id, unicode(action_text), time=3000) |
225 Action.execute(self) | |
228 | 226 |
229 class ExamineItemAction(Action): | 227 class ExamineItemAction(Action): |
230 """Examine an item.""" | 228 """Examine an item.""" |
231 def __init__(self, controller, examine_name, examine_desc, commands = None): | 229 def __init__(self, controller, examine_name, examine_desc, commands = None): |
232 """ | 230 """ |
249 def execute(self): | 247 def execute(self): |
250 """Display the text.""" | 248 """Display the text.""" |
251 action_text = unicode(self.examine_desc) | 249 action_text = unicode(self.examine_desc) |
252 self.view.hud.addAction(action_text) | 250 self.view.hud.addAction(action_text) |
253 logger.debug(action_text) | 251 logger.debug(action_text) |
252 Action.execute(self) | |
253 | |
254 class ExamineContentsAction(Action): | |
255 """Examine the contens of an container""" | |
256 def __init__(self, controller, container, commands=None): | |
257 """ | |
258 @param controller: A reference to the GameSceneController. | |
259 @type controller: parpg.GameSceneController | |
260 @param container: The container | |
261 @type container: parpg.entities.General | |
262 @param commands: Special commands that are executed | |
263 @type commands: Dictionary | |
264 """ | |
265 Action.__init__(self, controller, commands) | |
266 self.view = controller.view | |
267 self.container = container | |
268 | |
269 def execute(self): | |
270 """Examine the contents""" | |
271 self.view.hud.createBoxGUI(self.container.description.view_name, | |
272 self.container.container) | |
273 Action.execute(self) | |
254 | 274 |
255 class ReadAction(Action): | 275 class ReadAction(Action): |
256 """Read a text.""" | 276 """Read a text.""" |
257 def __init__(self, controller, text_name, text, commands = None): | 277 def __init__(self, controller, text_name, text, commands = None): |
258 """ | 278 """ |
565 "Read":ReadAction, | 585 "Read":ReadAction, |
566 "Talk":TalkAction, | 586 "Talk":TalkAction, |
567 "Use":UseAction, | 587 "Use":UseAction, |
568 "PickUp":PickUpAction, | 588 "PickUp":PickUpAction, |
569 "DropFromInventory":DropItemFromContainerAction, | 589 "DropFromInventory":DropItemFromContainerAction, |
570 "BrewBeer":BrewBeerAction} | 590 "BrewBeer":BrewBeerAction, |
591 "ExamineContents": ExamineContentsAction, | |
592 } |