Changeset 603


Ignore:
Timestamp:
07/28/10 19:22:42 (9 years ago)
Author:
beliar
Message:

Ticket #243: Patch by Domtron_Vox.

  • When examining an object the text is now displayed over the object as well as in the message window.

fixes[s:trac, t:243]

Location:
trunk/game/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gamescenecontroller.py

    r601 r603  
    284284                                self.model.game_state.player_character.approach,  
    285285                                [obj.X, obj.Y], 
    286                                 ExamineAction(self, obj.name, obj.text)]) 
     286                                ExamineAction(self, obj_id, obj.name, obj.text)]) 
    287287                # is it a Door? 
    288288                if obj.trueAttr("door"): 
  • trunk/game/scripts/gamesceneview.py

    r600 r603  
    4141        self.faded_objects = set() 
    4242 
    43     def displayObjectText(self, obj_id, text): 
     43    def displayObjectText(self, obj_id, text, time=1000): 
    4444        """Display on screen the text of the object over the object. 
    4545           @type obj_id: id of fife.instance 
     
    5959                raise 
    6060        if obj: 
    61             obj.say(str(text), 1000) 
     61            obj.say(str(text), time) 
    6262 
    6363    def onWalk(self, click): 
  • trunk/game/scripts/objects/action.py

    r602 r603  
    153153class ExamineAction(Action): 
    154154    """Examine an object.""" 
    155     def __init__(self, controller, examine_name, examine_desc, commands = None): 
    156         """ 
    157         @param controller: A reference to the GameSceneController. 
    158         @type controller: scripts.GameSceneController 
    159         @param commands: Special commands that are executed 
    160         @type commands: Dictionary  
    161         @type view: class derived from scripts.ViewBase 
    162         @param view: The view 
    163         @type examine_name: String 
    164         @param examine_name: Name of the object to be examined. 
    165         @type examine_name: String 
    166         @param examine_name: Description of the object to be examined. 
     155    def __init__(self, controller, examine_id, examine_name, examine_desc, commands = None): 
     156        """ 
     157        @param controller: A reference to the GameSceneController. 
     158        @type controller: scripts.GameSceneController 
     159        @param examine_id: An object id 
     160        @type examine_id: integer 
     161        @param examine_name: An object name 
     162        @type examine_name: string 
     163        @param examine_desc: A description of the object that will be displayed. 
     164        @type examine_desc: string 
     165        @param commands: Special commands that are executed 
     166        @type commands: Dictionary  
     167        @type view: class derived from scripts.ViewBase 
     168        @param view: The view 
     169         
    167170        """ 
    168171        super(ExamineAction, self).__init__(controller, commands) 
    169172        self.view = controller.view 
     173        self.examine_id = examine_id 
    170174        self.examine_name = examine_name 
    171175        self.examine_desc = examine_desc 
    172176         
    173177    def execute(self): 
    174         """Examine the box.""" 
    175         action_text = unicode(self.examine_desc) 
    176         self.view.hud.addAction(action_text) 
     178        """Display the text.""" 
     179        action_text = self.examine_desc 
     180        self.view.hud.addAction(unicode(action_text)) 
    177181        print action_text 
     182        #this code will cut the line up into smaller lines that will be displayed 
     183        place = 25 
     184        while place <= len(action_text): 
     185            if action_text[place] == ' ': 
     186                action_text = action_text[:place] +'\n'+action_text[place:] 
     187                place += 26 #plus 1 character to offset the new line 
     188            else: place += 1 
     189        self.view.displayObjectText(self.examine_id, unicode(action_text), time=3000) 
    178190 
    179191class ExamineItemAction(Action): 
Note: See TracChangeset for help on using the changeset viewer.