Changeset 80


Ignore:
Timestamp:
06/02/09 03:05:02 (10 years ago)
Author:
bretzel_parpg
Message:

Added lots of stuff:

-> Changed some code in the HUD so it will be easier to skin
-> Added options to change the resolution and render backend in the options menu
-> Removed the reset images button in the inventory
-> Made the close button in the inventory toggle the inventory button on the HUD

Location:
trunk/PARPG
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/gui/hud.xml

    r74 r80  
    1 <HBox position_technique="center:bottom" min_size="640,0"> 
    2   <VBox> 
    3   <Button name="menuButton" text="Menu"  max_size="200,15"/> 
    4   <Button name="saveButton" text="Save" max_size="200,15"/> 
    5   <Button name="loadButton" text="Load" max_size="200,15"/> 
    6   </VBox> 
     1<Container name="mainHudWindow" position_technique="center:bottom"> 
    72 
    8   <VBox max_size="50,50"> 
    9     <Spacer /> 
    10     <HBox><Label text="  HP:" /><Label name="HealthPoints" text="100" /></HBox> 
    11     <HBox><Label text="  AP:" /><Label name="ActionPoints" text="100" /></HBox> 
    12   </VBox> 
     3  <Button name="menuButton" text="Menu"  max_size="200,15" position="5,5"/> 
     4  <Button name="saveButton" text="Save" max_size="200,15" position="6,25"/> 
     5  <Button name="loadButton" text="Load" max_size="200,15" position="6,45"/> 
    136 
    14   <HBox min_size="395,50"> 
    15     <Spacer /> 
    16     <ScrollArea size="300,55" vertical_scrollbar="1" horizontal_scrollbar="0"> 
    17       <ListBox name="ActionsBox" min_size="300,50"/> 
    18     </ScrollArea> 
    19   </HBox> 
     7  <Label name="healthPoints" text="HP: 100" position="56,14"/> 
     8  <Label name="actionPoints" text="AP: 100" position="56,34" /> 
    209 
    21   <Spacer /> 
     10  <ScrollArea name="actionsScrollArea" vertical_scrollbar="1" horizontal_scrollbar="0" 
     11              position="105,5"> 
     12    <ListBox name="actionsBox" min_size="300,48"/> 
     13  </ScrollArea> 
    2214 
    2315  <ToggleButton name="inventoryButton" up_image="gui/inv_images/inv_backpack.png"  
    2416                down_image="gui/inv_images/inv_backpack_open.png"  
    2517                hover_image="gui/inv_images/inv_backpack.png" /> 
    26 </HBox> 
     18</Container> 
    2719 
  • trunk/PARPG/gui/hud_options.xml

    r76 r80  
    44  <CheckBox name="FullscreenBox" text="Full Screen" /> 
    55  <CheckBox name="SoundsBox" text="Play Sounds" /> 
     6  <HBox min_size="120,90"> 
     7    <Label text="Resolution: " /> 
     8    <ListBox name="ResolutionBox" min_size="120,0" /> 
     9  </HBox> 
     10  <HBox min_size="120,47"> 
     11    <Label text="Render Backend: " /> 
     12    <ListBox name="RenderBox" min_size="120,0" /> 
     13  </HBox> 
    614 
    715  <Spacer /> 
  • trunk/PARPG/gui/inventory.xml

    r63 r80  
    9999        <Spacer /> 
    100100        <Button name="close_button" text="Close" /> 
    101         <Button name="reset_button" text="Reset Images" /> 
    102101        </HBox> 
    103102         
  • trunk/PARPG/scripts/hud.py

    r76 r80  
    11#!/usr/bin/python 
    2  
    3 # Make the actions append at the top instead of the bottom 
    42 
    53"""Import all necessary modules""" 
     
    2119 
    2220        self.settings = settings 
    23         self.hp = self.hud.findChild(name="HealthPoints") 
    24         self.ap = self.hud.findChild(name="ActionPoints") 
    25         self.actionsBox = self.hud.findChild(name="ActionsBox") 
     21        self.hp = self.hud.findChild(name="healthPoints") 
     22        self.ap = self.hud.findChild(name="actionPoints") 
     23        self.actionsBox = self.hud.findChild(name="actionsBox") 
    2624        self.actionsText = [] 
    2725        self.menu_displayed = False 
    28  
     26         
     27        self.initializeHud() 
     28        self.initializeMainMenu() 
     29        self.initializeOptionsMenu() 
     30 
     31    def initializeHud(self): 
    2932        """Initialize and show the main HUD""" 
    3033        self.events_to_map = {"menuButton":self.displayMenu, "saveButton":self.saveGame, 
    3134                              "loadButton":self.loadGame} 
    3235        self.hud.mapEvents(self.events_to_map)  
     36 
     37        screen_width = int(self.settings.readSetting('ScreenWidth')) 
     38        self.hud.findChild(name="mainHudWindow").size = (screen_width, 65) 
     39 
     40        self.hud.findChild(name="inventoryButton").position = (screen_width-59, 7) 
     41         
     42        actions_width = screen_width - 175  
     43        self.hud.findChild(name="actionsBox").min_size = (actions_width, 0) 
     44        self.hud.findChild(name="actionsScrollArea").size = (actions_width, 55) 
     45 
    3346        self.hud.show() 
    3447         
     48    def initializeMainMenu(self): 
    3549        """Initalize the main menu""" 
    3650        self.main_menu = pychan.loadXML("gui/hud_main_menu.xml") 
     
    4054        self.main_menu.mapEvents(self.menu_events) 
    4155 
     56 
     57    def initializeOptionsMenu(self): 
    4258        """Initalize the options menu""" 
    4359        self.options_menu = pychan.loadXML("gui/hud_options.xml") 
    44         self.options_events = {"applyButton":self.applyOptions, "closeButton":self.options_menu.hide} 
    45  
    46         self.options_menu.distributeData({'FullscreenBox':int(self.settings.readSetting(name="FullScreen")), 
    47                                           'SoundsBox':int(self.settings.readSetting(name="PlaySounds"))}) 
     60        self.options_events = {"applyButton":self.applyOptions, 
     61                               "closeButton":self.options_menu.hide} 
     62 
     63        self.Resolutions = ['640x480', '800x600', '1024x768', '1280x1024', '1440x900'] 
     64        self.RenderBackends = ['OpenGL', 'SDL'] 
     65        self.renderNumber = 0 
     66        if (str(self.settings.readSetting('RenderBackend')) == "SDL"): 
     67            self.renderNumber = 1 
     68        self.options_menu.distributeInitialData({ 
     69                'ResolutionBox': self.Resolutions, 
     70                'RenderBox': self.RenderBackends 
     71                }) 
     72        self.options_menu.distributeData({ 
     73                'FullscreenBox':int(self.settings.readSetting(name="FullScreen")),  
     74                'SoundsBox':int(self.settings.readSetting(name="PlaySounds")), 
     75                'ResolutionBox':self.Resolutions.index(str(self.settings.readSetting("ScreenWidth")) + 'x' + str(self.settings.readSetting("ScreenHeight"))), 
     76                'RenderBox': self.renderNumber 
     77                }) 
    4878         
    4979        self.options_menu.mapEvents(self.options_events) 
     
    79109        """ 
    80110        self.requireRestart = False 
    81         enable_fullscreen, enable_sound = self.options_menu.collectData('FullscreenBox', 'SoundsBox') 
     111        enable_fullscreen, enable_sound, screen_resolution, render_backend = self.options_menu.collectData('FullscreenBox', 'SoundsBox', 'ResolutionBox', 'RenderBox') 
    82112 
    83113        if (int(enable_fullscreen) != int(self.settings.readSetting('FullScreen'))): 
     
    87117        if (int(enable_sound) != int(self.settings.readSetting('PlaySounds'))): 
    88118            self.setOption('PlaySounds', int(enable_sound)) 
     119            self.requireRestart = True 
     120 
     121        if (screen_resolution != self.Resolutions.index(str(self.settings.readSetting("ScreenWidth")) + 'x' + str(self.settings.readSetting("ScreenHeight")))): 
     122            self.setOption('ScreenWidth', int(self.Resolutions[screen_resolution].partition('x')[0])) 
     123            self.setOption('ScreenHeight', int(self.Resolutions[screen_resolution].partition('x')[2])) 
     124            self.requireRestart = True 
     125         
     126        if (render_backend == 0): 
     127            render_backend = 'OpenGL' 
     128        else: 
     129            render_backend = 'SDL' 
     130 
     131        if (render_backend != str(self.settings.readSetting("RenderBackend"))): 
     132            self.setOption('RenderBackend', render_backend) 
    89133            self.requireRestart = True 
    90134 
  • trunk/PARPG/scripts/inventory.py

    r74 r80  
    2121 
    2222        self.inventory = pychan.loadXML("gui/inventory.xml") 
    23         events_to_map = {'close_button':self.inventory.hide, 
    24                          'reset_button':self.resetImages} 
     23        self.events_to_map = {} 
    2524 
    2625        # the images that should be used for the buttons when they are "empty" 
     
    7877        for button in self.buttons: 
    7978            # make every button's callback be self.dragDrop 
    80             events_to_map[button] = cbwa(self.dragDrop, button) 
     79            self.events_to_map[button] = cbwa(self.dragDrop, button) 
    8180            ch = self.inventory.findChild(name = button) 
    8281            # make every slot's item be empty 
    8382            ch.item = "" 
    8483 
    85         self.inventory.mapEvents(events_to_map)    
     84        self.inventory.mapEvents(self.events_to_map)    
    8685        self.resetMouseCursor() 
    8786        self.inventory.show() 
     
    9493        """Show the inventory""" 
    9594        self.inventory.show() 
    96  
    97     def resetImages(self): 
    98         """Reset all images in the program to the way they were when the  
    99            program was first launched 
    100            TODO: should be taken out on release (WHY?)""" 
    101         for image in self.empty_images: 
    102             child = self.inventory.findChild(name = image) 
    103             original_image = self.empty_images[image] 
    104             child._setUpImage(original_image) 
    105             child._setDownImage(original_image) 
    106             child._setHoverImage(original_image) 
    10795 
    10896    def setMouseCursor(self, image, dummy_image, type = "native"):  
  • trunk/PARPG/scripts/world.py

    r79 r80  
    149149            self.obj_hash[obj].say(str(text), 3500) 
    150150 
     151    def closeInventoryAndToggle(self): 
     152        self.inventory.closeInventory() 
     153        self.hud.toggleInventory() 
     154        self.inventoryShown = False 
     155 
    151156    def displayInventory(self, callFromHud): 
    152157        """Pause the game and enter the inventory screen 
     
    157162        if(self.firstInventory == True): 
    158163            self.inventory = inventory.Inventory(self.engine) 
     164            self.inventory.events_to_map['close_button'] = self.closeInventoryAndToggle 
     165            self.inventory.inventory.mapEvents(self.inventory.events_to_map) 
    159166            self.firstInventory = False 
    160167            self.inventoryShown = True 
Note: See TracChangeset for help on using the changeset viewer.