Ignore:
Timestamp:
05/26/09 16:09:26 (11 years ago)
Author:
bretzel_parpg
Message:

Added the first version of the HUD. Also updated the inventory so that when there is a different image then the normal one is dragged around, the imagebutton it was dragged from is restored to it's original "empty" image

File:
1 edited

Legend:

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

    r73 r74  
    2525from settings import Setting 
    2626from scripts import inventory 
     27from scripts import hud 
     28from pychan.tools import callbackWithArguments as cbwa 
    2729 
    2830TDS = Setting() 
     
    7173        self.mouseCallback = None 
    7274 
     75        self.hud = hud.Hud(self.engine) 
     76        self.hud.events_to_map["inventoryButton"] = cbwa(self.displayInventory, True) 
     77        self.hud.hud.mapEvents(self.hud.events_to_map) 
     78 
     79        self.hud.menu_events["quitButton"] = self.quitGame 
     80        self.hud.main_menu.mapEvents(self.hud.menu_events) 
     81 
     82        self.action_number = 1 
     83 
    7384    def reset(self): 
    7485        """Rest the map to default settings""" 
     
    123134        fife.InstanceVisual.create(obj) 
    124135 
    125     def displayInventory(self): 
     136    def displayInventory(self, callFromHud): 
    126137        """Pause the game and enter the inventory screen 
    127            or close the inventory screen and resume the game""" 
     138           or close the inventory screen and resume the game 
     139           callFromHud should be set to true if you call this 
     140           function from the hud script""" 
    128141        # show the inventory 
    129142        if(self.firstInventory == True): 
     
    131144            self.firstInventory = False 
    132145            self.inventoryShown = True 
     146            if (callFromHud == False): 
     147                self.hud.toggleInventory() 
    133148        # logically firstInventory is false here 
    134149        elif(self.inventoryShown == True): 
    135150            self.inventory.closeInventory() 
    136151            self.inventoryShown = False 
     152            if (callFromHud == False): 
     153                self.hud.toggleInventory() 
    137154        # and here inventoryShown must be false 
    138155        else: 
    139156            self.inventory.showInventory() 
    140157            self.inventoryShown = True 
     158            if (callFromHud == False): 
     159                self.hud.toggleInventory() 
    141160 
    142161    # all key / mouse event handling routines go here 
     
    165184        if(keyval == key.I): 
    166185            # I opens and closes the inventory 
    167             self.displayInventory() 
     186            self.displayInventory(callFromHud=False) 
     187        if(keyval == key.A): 
     188            # A adds a test action to the action box 
     189            # The test actions will follow this format: Action 1, Action 2, etc. 
     190            self.hud.addAction("Action " + str(self.action_number)) 
     191            self.action_number += 1 
     192        if(keyval == key.ESCAPE): 
     193            # Escape brings up the main menu 
     194            self.hud.displayMenu() 
    168195 
    169196    def getCoords(self, click): 
Note: See TracChangeset for help on using the changeset viewer.