Changeset 161


Ignore:
Timestamp:
06/23/09 04:07:28 (10 years ago)
Author:
bretzel_parpg
Message:

Added comments and filled in some documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/scripts/inventory.py

    r147 r161  
    1 #!/usr/bin/python 
     1#/usr/bin/python 
    22 
    33#   This file is part of PARPG. 
     
    2626           @param engine: An instance of the fife engine 
    2727           @type readyCallback: function 
    28            @param readyCallback: ??? 
     28           @param readyCallback: The function that will make the 
     29                                 ready slots on the HUD reflect those 
     30                                 within the inventory 
    2931           @return: None""" 
    3032        pychan.init(engine, debug = True) 
     
    112114    def setMouseCursor(self, image, dummy_image, type = "native"):  
    113115        """Set the mouse cursor to an image. 
    114            @type image: ??? 
    115            @param image: ??? 
    116            @type dummy_image: ??? 
     116           @type image: string 
     117           @param image: The image you want to set the cursor to 
     118           @type dummy_image: string 
    117119           @param dummy_image: ??? 
    118120           @type type: string 
     
    146148    def dragDrop(self, obj): 
    147149        """Decide whether to drag or drop the image. 
    148            @type obj: ??? 
    149            @param obj: ??? 
     150           @type obj: string 
     151           @param obj: The name of the object within  
     152                       the dictionary 'self.buttons' 
    150153           @return: None""" 
    151154        if(self.dragging == True): 
     
    156159    def dragObject(self, obj): 
    157160        """Drag the selected object. 
    158            @type obj: ??? 
    159            @param obj: ??? 
    160            @return: None""" 
    161         # TODO: add some comments - what's the logic? 
     161           @type obj: string 
     162           @param obj: The name of the object within 
     163                       the dictionary 'self.buttons' 
     164           @return: None""" 
     165        # get the widget from the inventory with the name obj 
    162166        drag_widget = self.inventory.findChild(name = obj) 
     167        # get it's type (e.g. main_inv) 
    163168        self.dragged_type = self.buttons[obj] 
     169        # get the item that the widget is 'storing' 
    164170        self.dragged_item = drag_widget.item 
     171        # get the up and down images of the widget 
    165172        up_image = drag_widget._getUpImage() 
    166173        down_image = drag_widget._getDownImage() 
     174        # set the mouse cursor to be the widget's image 
    167175        self.setMouseCursor(up_image,down_image) 
    168176        self.dragged_image = up_image 
    169177        self.dragging = True 
     178        # after dragging the 'item', set the widgets' images 
     179        # so that it has it's default 'empty' images 
    170180        drag_widget._setUpImage(self.empty_images[obj]) 
    171181        drag_widget._setDownImage(self.empty_images[obj]) 
     
    174184    def dropObject(self, obj): 
    175185        """Drops the object being dropped 
    176            @type obj: ??? 
    177            @param obj: ??? 
    178            @return: None""" 
    179         # TODO: add some comments 
     186           @type obj: string 
     187           @param obj: The name of the object within 
     188                       the dictionary 'self.buttons'  
     189           @return: None""" 
     190        # find the type of the place that the object 
     191        # is being dropped onto 
    180192        self.dropped_type  =  self.buttons[obj] 
     193        # if the dragged obj or the place it is being dropped is 
     194        # in the main inventory, drop the object 
    181195        if((self.dragged_type == 'main_inv') or 
    182196           (self.dropped_type == 'main_inv')): 
     
    187201            drag_widget.item = self.dragged_item 
    188202            self.dragging = False 
     203            #reset the mouse cursor to the normal cursor 
    189204            self.resetMouseCursor() 
     205            # if the object was dropped onto a ready slot, then 
     206            # update the hud 
    190207            if (self.dropped_type == 'ready'): 
    191208                self.readyCallback() 
     209         
     210        # if the dragged object's type is the same as the location to 
     211        # to drop it at's, and the dragged object's type is in 
     212        # self.locations, then drop the object 
    192213        elif((self.dragged_type == self.dropped_type) and 
    193214             (self.dragged_type in self.locations)): 
     
    198219            drag_widget.item = self.dragged_item 
    199220            self.dragging = False 
     221            # reset the mouse cursor 
    200222            self.resetMouseCursor() 
     223            # if the object was dropped onto a ready slot, then 
     224            # update the hud 
    201225            if(self.dropped_type == 'ready'): 
    202226                self.readyCallback() 
     227        # otherwise, we assume that the player is trying to 
     228        # drop an object onto an incompatible slot 
    203229        else: 
     230            # reset the mouse cursor 
    204231            self.resetMouseCursor() 
    205232            self.dragging = False 
Note: See TracChangeset for help on using the changeset viewer.