Changeset 143


Ignore:
Timestamp:
06/15/09 14:47:14 (10 years ago)
Author:
maximinus_parpg
Message:

Every game file now epydocc'd.
Man, that was a lot of files to see to.

Location:
trunk/PARPG
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/run.py

    r88 r143  
    2323    shutil.copyfile('settings-dist.xml', 'settings.xml') 
    2424 
    25 import fife_compat 
    26 import fife,fifelog 
     25import fife_compat, fife, fifelog 
    2726from scripts import world 
    2827from scripts import engine 
     
    3332TDS = Setting() 
    3433 
    35 # This folder holds the main meta-data for PARPG. This file should be 
    36 # minimal, since folding code into the controller with MVC is usually bad 
    37 # All game and logic and data is held held and referenced in /scripts/engine.py 
    38 # All fife stuff goes in /scripts/world.py 
     34"""This folder holds the main meta-data for PARPG. This file should be 
     35  minimal, since folding code into the controller with MVC is usually bad 
     36  All game and logic and data is held held and referenced in /scripts/engine.py 
     37   All fife stuff goes in /scripts/world.py""" 
    3938 
    4039class ApplicationListener(eventlistenerbase.EventListenerBase): 
    4140    def __init__(self, engine, world): 
     41        """Initialise the instance. 
     42           @type engine: ??? 
     43           @param engine: ??? 
     44           @type world: ??? 
     45           @param world: ??? 
     46           @return: None""" 
    4247        super(ApplicationListener, self).__init__(engine, 
    4348                                                  regKeys=True,regCmd=True, 
     
    5257 
    5358    def quitGame(self): 
    54         """Forces a quit game on next cycle""" 
     59        """Forces a quit game on next cycle. 
     60           @return: None""" 
    5561        self.quit = True 
    5662 
    5763    def onCommand(self, command): 
    58         """Enables the game to be closed via the 'X' button on the window frame""" 
     64        """Enables the game to be closed via the 'X' button on the window frame 
     65           @type command: fife.Command 
     66           @param command: The command to read. 
     67           @return: None""" 
    5968        if(command.getCommandType() == fife.CMD_QUIT_GAME): 
    6069            self.quit = True 
     
    6776       This file is the minimal controller""" 
    6877    def __init__(self): 
     78        """Initialise the instance. 
     79           @return: None""" 
    6980        super(PARPG,self).__init__() 
    7081        self.world = world.World(self.engine) 
     
    7788    def loadSettings(self): 
    7889        """Load the settings from a python file and load them into the engine. 
    79            Called in the ApplicationBase constructor.""" 
     90           Called in the ApplicationBase constructor. 
     91           @return: None""" 
    8092        import settings 
    8193        self.settings = settings 
     
    102114 
    103115    def initLogging(self): 
    104         """Initialize the LogManager""" 
     116        """Initialize the LogManager. 
     117           @return: None""" 
    105118        LogModules = TDS.readSetting("LogModules",type='list') 
    106119        self.log = fifelog.LogManager(self.engine, 
     
    111124 
    112125    def createListener(self): 
     126        """@return: None""" 
    113127        # already created in constructor 
    114         # but if we don't put here, Fife gets bitchy :-) 
     128        # but if we don't put one here, Fife gets all fussy :-) 
    115129        pass 
    116130 
    117131    def _pump(self): 
    118         """Main game loop 
    119            There are in fact 2 main loops, this one and the one in World""" 
     132        """Main game loop. 
     133           There are in fact 2 main loops, this one and the one in World. 
     134           @return: None""" 
    120135        if self.listener.quit: 
    121136            self.breakRequested = True 
  • trunk/PARPG/scripts/agents/hero.py

    r68 r143  
    2121 
    2222class Hero(fife.InstanceActionListener): 
    23     """This is the class we use for the PC character""" 
    2423    def __init__(self, agentName, layer): 
     24        """This is the class we use for the PC character. 
     25           @type agentName: string 
     26           @param agentName: name of the agent 
     27           @type name: string 
     28           @param name Layer to place agent on 
     29           @return: None""" 
    2530        # add this class for callbacks from fife itself 
    2631        fife.InstanceActionListener.__init__(self) 
     
    3338 
    3439    def onInstanceActionFinished(self, instance, action): 
     40        """@type instance: ??? 
     41           @param instance: ??? 
     42           @type action: ??? 
     43           @param action: ??? 
     44           @return: None""" 
    3545        self.idle() 
    3646        if(action.getId() != 'stand'): 
     
    4050 
    4151    def start(self): 
     52        """@return: None""" 
    4253        self.idle() 
    4354 
    4455    def idle(self): 
     56        """@return: None""" 
    4557        self.state = _STATE_IDLE 
    4658        self.agent.act('stand', self.agent.getFacingLocation()) 
    4759 
    4860    def run(self, location): 
     61        """@type location: ??? 
     62           @param location: ??? 
     63           @return: None""" 
    4964        self.state = _STATE_RUN 
    5065        self.agent.move('run', location, self.speed) 
  • trunk/PARPG/scripts/agents/npc.py

    r128 r143  
    2727    def __init__(self, text, agent_name, layer): 
    2828        """Init function. 
    29            @param text: a string of text that will be output to screen when 
    30                character is right clicked 
    31            @param id: the 'id' of the NPC in the map_object.xml file 
    32            @param layer: a fife.Instance object, (engine.view.agent_layer)""" 
     29           @type text: string 
     30           @param text: The text to draw when character is right clicked. 
     31           @type id: string 
     32           @param id: the ID of the NPC 
     33           @type layer: ??? 
     34           @param layer: ??? 
     35           @return: None""" 
    3336        fife.InstanceActionListener.__init__(self) 
    3437        self.text = text 
     
    4750 
    4851    def getX(self): 
    49         """@return: the x coordinate of the NPC's location as an int""" 
     52        """Get the NPC's x position on the map. 
     53           @rtype: integer" 
     54           @return: the x coordinate of the NPC's location""" 
    5055        return self.agent.getLocation().getLayerCoordinates().x 
    5156 
    5257    def getY(self): 
    53         """@return: the y coordinate of the NPC's location as an int""" 
     58        """Get the NPC's y position on the map. 
     59           @rtype: integer 
     60           @return: the y coordinate of the NPC's location""" 
    5461        return self.agent.getLocation().getLayerCoordinates().y 
    5562 
    5663    def getTargetLocation(self): 
    57         """@return: a fife.Location object based off of the NPC's 
    58            position and current state""" 
     64        """@rtype: fife.Location 
     65           @return: NPC's position""" 
    5966        x = self.getX() 
    6067        y = self.getY() 
     
    7077            x += l[0] 
    7178            y += l[1] 
    72             """ Random Walk """ 
    73             """ 
    74             rl = randint(-1, 1) 
    75             ud = randint(-1, 1) 
    76             x += rl 
    77             y += ud 
    78             """ 
     79            # Random walk is 
     80            # rl = randint(-1, 1);ud = randint(-1, 1);x += rl;y += ud 
    7981        l = fife.Location(self.agent.getLocation()) 
    8082        l.setLayerCoordinates(fife.ModelCoordinate(*tuple([x, y]))) 
     
    8385    def onInstanceActionFinished(self, instance, action): 
    8486        """What the NPC does when it has finished an action. 
    85            Called by the engine and required for InstanceActionListeners""" 
     87           Called by the engine and required for InstanceActionListeners. 
     88           @type instance: ??? 
     89           @param instance: ??? 
     90           @type action: ??? 
     91           @param action: ??? 
     92           @return: None""" 
    8693        if self.state == _STATE_WANDER: 
    8794            self.targetLoc = self.getTargetLocation() 
     
    8996 
    9097    def start(self): 
     98        """@return: None""" 
    9199        self.idle() 
    92100 
    93101    def idle(self): 
    94102        """Controls the NPC when it is idling. Different actions 
    95            based on the NPC's state""" 
     103           based on the NPC's state. 
     104           @return: None""" 
    96105        if self.state == _STATE_NONE: 
    97106            self.state = _STATE_IDLE 
     
    109118    def wander(self, location): 
    110119        """Nice slow movement for random walking. 
    111            @param location: a fife.Location object, where the NPC 
    112            will walk to""" 
     120           @type location: fife.Location 
     121           @param location: Where the NPC will walk to. 
     122           @return: None""" 
    113123        self.agent.move('walk', location, self.speed-1) 
    114124 
    115125    def run(self, location): 
    116126        """Faster movement than walk. 
    117            @param location: a fife.Location object, where the NPC will run to""" 
     127           @type location: fife.Location 
     128           @param location: Where the NPC will run to.""" 
    118129        self.agent.move('run', location, self.speed+1) 
     130 
  • trunk/PARPG/scripts/common/eventlistenerbase.py

    r30 r143  
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
    118import fife 
    219 
    320class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, fife.ConsoleExecuter): 
    421    def __init__(self, engine, regKeys=False, regCmd=False, regMouse=False, regConsole=False, regWidget=False): 
     22        """Initialise the instance""" 
    523        self.eventmanager = engine.getEventManager() 
    624 
     
    2038    def mousePressed(self, evt): 
    2139        pass 
     40 
    2241    def mouseReleased(self, evt): 
    2342        pass     
     43 
    2444    def mouseEntered(self, evt): 
    2545        pass 
     46 
    2647    def mouseExited(self, evt): 
    2748        pass 
     49 
    2850    def mouseClicked(self, evt): 
    2951        pass 
     52 
    3053    def mouseWheelMovedUp(self, evt): 
    3154        pass     
     55 
    3256    def mouseWheelMovedDown(self, evt): 
    3357        pass 
     58 
    3459    def mouseMoved(self, evt): 
    3560        pass 
     61 
    3662    def mouseDragged(self, evt): 
    3763        pass 
     64 
    3865    def keyPressed(self, evt): 
    3966        pass 
     67 
    4068    def keyReleased(self, evt): 
    4169        pass 
     70 
    4271    def onCommand(self, command): 
    4372        pass 
     73 
    4474    def onToolsClick(self): 
    4575        print "No tools set up yet" 
     76 
    4677    def onConsoleCommand(self, command): 
    4778        pass 
     79 
    4880    def onWidgetAction(self, evt): 
    4981        pass 
  • trunk/PARPG/scripts/common/utils.py

    r48 r143  
    1212#   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    1313 
    14 """ 
    15 Miscellaneous game functions. 
    16  
    17 """ 
     14# Miscellaneous game functions 
    1815 
    1916import os, sys 
    2017 
     18# TODO: Having a file like this just looks cheap and 'hackish'. Fix if possible 
     19 
    2120def addPaths (*paths): 
    22     """ 
    23     Adds a list of paths to sys.path. Paths are expected to use forward slashes, 
    24     for example '../../engine/extensions'. Slashes are converted to the  
    25     OS-sepcific equivalent. 
    26     """ 
     21    """Adds a list of paths to sys.path. Paths are expected to use forward 
     22       slashes, for example '../../engine/extensions'. Slashes are converted 
     23       to the OS-specific equivalent. 
     24       @type *paths: ??? 
     25       @param *paths: Paths to files? 
     26       @return: None""" 
    2727    for p in paths: 
    2828        if not p in sys.path: 
    2929            sys.path.append(os.path.sep.join(p.split('/'))) 
     30 
  • trunk/PARPG/scripts/context_menu.py

    r116 r143  
    1919 
    2020class ContextMenu(): 
    21     """Arguments: 
    22        menu_items : A list of items containing the name and  
    23                     text for the menu item and callback 
    24                     i.e. [["menuitem1", "Menu Item 1",  menuCallback1], 
    25                           ["menuitem2", "Menu Item 2", menuCallback2]]""" 
    2621    def __init__(self, engine, menu_items, pos): 
     22        """@type engine: ??? 
     23           @param engine: ???  
     24           @type menu_items: list 
     25           @param menu_items: A list of items containing the name and  
     26                              text for the menu item and callback 
     27                              i.e. [["menu", "Some text",  Callback] 
     28           @type pos: ??? 
     29           @param pos: Screen position to use  
     30           @return: None""" 
    2731        pychan.init(engine, debug = True) 
    2832        self.vbox = pychan.widgets.VBox(position=pos) 
  • trunk/PARPG/scripts/hud.py

    r112 r143  
    11#!/usr/bin/python 
    22 
    3 """Import all necessary modules""" 
    4 import shutil 
    5 import fife 
    6 import pychan 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
     18import shutil, fife, pychan 
    719from pychan.tools import callbackWithArguments as cbwa 
    820 
    9 """Main Hud class""" 
     21 
    1022class Hud(): 
    11     """ 
    12     Arguments: 
    13         engine : an instance of the fife engine 
    14         settings : an instance of the class Setting from settings.py 
    15     """ 
     23    """Main Hud class""" 
    1624    def __init__(self, engine, settings): 
     25        """Initialise the instance. 
     26           @type engine: fife.Engine 
     27           @param engine: An instance of the fife engine 
     28           @type settings: settings.Setting 
     29           @param settings: The settings data 
     30           @return: None""" 
    1731        pychan.init(engine, debug = True) 
    18          
     32        # TODO: perhaps this should not be hard-coded here 
    1933        self.hud = pychan.loadXML("gui/hud.xml") 
    20  
    2134        self.settings = settings 
    2235        self.actionsBox = self.hud.findChild(name="actionsBox") 
    2336        self.actionsText = [] 
    2437        self.menu_displayed = False 
    25          
    2638        self.initializeHud() 
    2739        self.initializeMainMenu() 
     
    3042 
    3143    def initializeHud(self): 
    32         """Initialize and show the main HUD""" 
     44        """Initialize and show the main HUD 
     45           @return: None""" 
    3346        self.events_to_map = {"menuButton":self.displayMenu, "saveButton":self.saveGame, 
    3447                              "loadButton":self.loadGame} 
    3548        self.hud.mapEvents(self.events_to_map)  
    36  
     49        # set HUD size accoriding to screen size 
    3750        screen_width = int(self.settings.readSetting('ScreenWidth')) 
    3851        self.hud.findChild(name="mainHudWindow").size = (screen_width, 65) 
    3952        self.hud.findChild(name="inventoryButton").position = (screen_width-59, 7) 
    40  
     53        # add ready slots 
    4154        ready1 = self.hud.findChild(name='hudReady1') 
    4255        ready2 = self.hud.findChild(name='hudReady2') 
     
    4457        ready4 = self.hud.findChild(name='hudReady4') 
    4558        actions_scroll_area = self.hud.findChild(name='actionsScrollArea') 
    46  
     59        # annoying code that is both essential and boring to enter 
    4760        if (screen_width == 1440): 
    4861            ready1.position = (screen_width-1235, 7) 
     
    5265            actions_scroll_area.position = (325, 5) 
    5366            actions_width = screen_width - 550 
    54  
    5567        elif (screen_width == 1280): 
    5668            ready1.position = (screen_width-1075, 7) 
     
    6072            actions_scroll_area.position = (325, 5) 
    6173            actions_width = screen_width - 550 
    62  
    6374        elif (screen_width == 1024): 
    6475            ready1.position = (screen_width-820, 7) 
     
    6879            actions_scroll_area.position = (325, 5) 
    6980            actions_width = screen_width - 550 
    70  
    7181        elif (screen_width == 800): 
    7282            ready1.position = (screen_width-640, 7) 
     
    7686            actions_scroll_area.position = (280, 5) 
    7787            actions_width = screen_width - 475 
    78  
    7988        else: 
    8089            ready1.position = (screen_width-475, 7) 
     
    8493            actions_scroll_area.position = (280, 5) 
    8594            actions_width = screen_width - 465 
    86  
     95        # and finally add an actions box 
    8796        self.hud.findChild(name="actionsBox").min_size = (actions_width, 0) 
    8897        actions_scroll_area.min_size = (actions_width, 55) 
    8998        actions_scroll_area.max_size = (actions_width, 55) 
    90  
     99        # now it should be OK to display it all 
    91100        self.hud.show() 
    92101 
    93102    def refreshActionsBox(self): 
    94         """  
    95         Refresh the actions box so that it displays the contents of self.actionsText 
    96         """ 
     103        """Refresh the actions box so that it displays the contents of 
     104          self.actionsText 
     105           @return: None""" 
    97106        self.actionsBox.items = self.actionsText 
    98107 
    99108    def addAction(self, action): 
    100         """  
    101         Add an action to the actions box. 
    102         All this function really does is append action to self.actionsText and then 
    103         call refreshActionsBox 
    104         """ 
     109        """Add an action to the actions box. 
     110           @type action: ??? 
     111           @param action: ??? 
     112           @return: None""" 
    105113        self.actionsText.insert(0, action) 
    106114        self.refreshActionsBox() 
    107115 
    108116    def showHUD(self): 
    109         """ 
    110         Show the HUD 
    111         """ 
     117        """Show the HUD. 
     118           @return: None""" 
    112119        self.hud.show() 
    113120 
    114121    def hideHUD(self): 
    115         """ 
    116         Hide the HUD 
    117         """ 
     122        """Hide the HUD. 
     123           @return: None""" 
    118124        self.hud.hide() 
    119125         
    120126    def initializeMainMenu(self): 
    121         """Initalize the main menu""" 
     127        """Initalize the main menu. 
     128           @return: None""" 
    122129        self.main_menu = pychan.loadXML("gui/hud_main_menu.xml") 
    123130        self.menu_events = {"resumeButton":self.hideMenu, "saveButton":self.saveGame, 
     
    128135 
    129136    def displayMenu(self): 
    130         """ 
    131         Displays the main in-game menu 
    132         """ 
     137        """Displays the main in-game menu. 
     138           @return: None""" 
    133139        if (self.menu_displayed == False): 
    134140            self.main_menu.show() 
     
    138144 
    139145    def hideMenu(self): 
    140         """ 
    141         Hides the main in-game menu 
    142         """ 
     146        """Hides the main in-game menu. 
     147           @return: None""" 
    143148        self.main_menu.hide() 
    144149        self.menu_displayed = False 
    145150 
    146151    def initializeHelpMenu(self): 
    147         """Initialize the help menu""" 
    148  
     152        """Initialize the help menu 
     153           @return: None""" 
    149154        self.help_dialog = pychan.loadXML("gui/help.xml") 
    150155        help_events = {"closeButton":self.help_dialog.hide} 
    151156        self.help_dialog.mapEvents(help_events) 
    152  
    153157        main_help_text = "Put help text here" 
    154  
    155         keybindings_text = "A : Add a test action to the actions display[br]I : Toggle the inventory screen[br]F5 : Take a screenshot [br]     (saves to <parpg>/screenshots/)[br]Q : Quit the game" 
    156  
     158        k_text = " A : Add a test action to the actions display" 
     159        k_text+="[br] I : Toggle the inventory screen" 
     160        k_text+="[br]F5 : Take a screenshot" 
     161        k_text+="[br]     (saves to <parpg>/screenshots/)" 
     162        k_text+="[br] M : Toggle music on/off" 
     163        k_text+="[br] Q : Quit the game" 
    157164        self.help_dialog.distributeInitialData({ 
    158165                "MainHelpText":main_help_text, 
    159                 "KeybindText":keybindings_text 
     166                "KeybindText":k_text 
    160167                }) 
    161168 
    162169    def displayHelp(self): 
    163         """ Display the help screen """ 
     170        """Display the help screen. 
     171           @return: None""" 
    164172        self.help_dialog.show() 
    165173 
    166174    def initializeOptionsMenu(self): 
    167         """Initalize the options menu""" 
    168  
     175        """Initalize the options menu. 
     176           @return: None""" 
    169177        self.options_menu = pychan.loadXML("gui/hud_options.xml") 
    170178        self.options_events = {"applyButton":self.applyOptions, 
    171179                               "closeButton":self.options_menu.hide, 
    172180                               "defaultsButton":self.setToDefaults} 
    173  
    174         self.Resolutions = ['640x480', '800x600', '1024x768', '1280x1024', '1440x900'] 
     181        self.Resolutions = ['640x480', '800x600', 
     182                            '1024x768', '1280x1024', '1440x900'] 
    175183        self.RenderBackends = ['OpenGL', 'SDL'] 
    176184        self.renderNumber = 0 
     
    181189                'RenderBox': self.RenderBackends 
    182190                }) 
     191        # TODO: fix bad line length here 
    183192        self.options_menu.distributeData({ 
    184193                'FullscreenBox':int(self.settings.readSetting(name="FullScreen")),  
     
    187196                'RenderBox': self.renderNumber 
    188197                }) 
    189          
    190198        self.options_menu.mapEvents(self.options_events) 
    191199 
    192200    def requireRestartDialog(self): 
    193         """ 
    194         Show a dialog asking the user to restart PARPG for their changes to take effect 
    195         """ 
     201        """Show a dialog asking the user to restart PARPG in order for their 
     202           changes to take effect. 
     203           @return: None""" 
    196204        require_restart_dialog = pychan.loadXML('gui/hud_require_restart.xml') 
    197205        require_restart_dialog.mapEvents({'okButton':require_restart_dialog.hide}) 
     
    199207 
    200208    def applyOptions(self): 
    201         """ 
    202         Apply the current options 
    203         """ 
     209        """Apply the current options. 
     210           @return: None""" 
     211        # TODO: line lengths here are horrible 
     212        # TODO: add comments 
    204213        self.requireRestart = False 
    205214        enable_fullscreen, enable_sound, screen_resolution, render_backend = self.options_menu.collectData('FullscreenBox', 'SoundsBox', 'ResolutionBox', 'RenderBox') 
     
    233242 
    234243    def setOption(self, name, value): 
    235         """ 
    236         Set an option within the xml 
    237         """ 
     244        """Set an option within the xml. 
     245           @type name: ??? 
     246           @param name: The name? 
     247           @type value: ??? 
     248           @param value: The value? 
     249           @return: None""" 
    238250        element = self.settings.root_element.find(name) 
    239         if (element != None): 
    240             if (value != element.text): 
     251        if(element != None): 
     252            if(value != element.text): 
    241253                element.text = str(value) 
    242254        else: 
     
    244256 
    245257    def setToDefaults(self): 
    246         """ Reset all the options to the options in settings-dist.xml """ 
     258        """Reset all the options to the options in settings-dist.xml. 
     259           @return: None""" 
    247260        shutil.copyfile('settings-dist.xml', 'settings.xml') 
    248261        self.requireRestartDialog() 
     
    250263 
    251264    def displayOptions(self): 
    252         """ 
    253         Display the options menu 
    254         """ 
     265        """Display the options menu. 
     266           @return: None""" 
    255267        self.options_menu.show() 
    256268     
    257269    def saveGame(self): 
    258         """ 
    259         Open the save game dialog 
    260         """ 
    261         print "save" 
     270        """Open the save game dialog. 
     271           @return: None""" 
     272        print "Save not yet enabled" 
    262273 
    263274    def loadGame(self): 
    264         """ 
    265         Open the load game dialog 
    266         """ 
    267         print "load" 
     275        """Open the load game dialog. 
     276           @return: None""" 
     277        print "Load not yet enabled" 
    268278         
    269279    def toggleInventory(self): 
    270         """ 
    271         Manually toggles the inventory button 
    272         """ 
     280        """Manually toggles the inventory button. 
     281           @return: None""" 
    273282        button = self.hud.findChild(name="inventoryButton") 
    274         if (button.toggled == 0): 
     283        if(button.toggled == 0): 
    275284            button.toggled = 1 
    276285        else: 
    277286            button.toggled = 0 
     287 
  • trunk/PARPG/scripts/inventory.py

    r103 r143  
    11#!/usr/bin/python 
    22 
    3 import sys,os 
    4  
    5 import fife 
    6 import fifelog 
    7 import pychan 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
     18import sys, os, fife, fifelog, pychan 
    819from pychan.tools import callbackWithArguments as cbwa 
    920 
     
    1122    """Main inventory class""" 
    1223    def __init__(self, engine, readyCallback): 
     24        """Initialise the instance. 
     25           @type engine: fife.Engine 
     26           @param name: An instance of the fife engine 
     27           @type readyCallback: function 
     28           @param readyCallback: ??? 
     29           @return: None""" 
    1330        pychan.init(engine, debug = True) 
    1431        self.engine = engine 
     
    2037        self.dropped_type = None 
    2138        self.original_cursor_id = self.engine.getCursor().getId() 
    22  
     39        # TODO: remove hard-coded string? 
    2340        self.inventory = pychan.loadXML("gui/inventory.xml") 
    2441        self.events_to_map = {} 
    25  
    2642        # the images that should be used for the buttons when they are "empty" 
    2743        self.empty_images = {'A1':'gui/inv_images/inv_backpack.png', 
     
    5874                             'LeftFoot':'gui/inv_images/inv_lfoot.png', 
    5975                             'RightFoot':'gui/inv_images/inv_rfoot.png'} 
    60  
    6176        # every button on the inventory and its category 
    6277        self.buttons = {'A1':'main_inv', 'A2':'main_inv', 'A3':'main_inv', 
     
    8297            # make every slot's item be empty 
    8398            ch.item = "" 
    84  
    8599        self.inventory.mapEvents(self.events_to_map)    
    86100        self.resetMouseCursor() 
    87101 
    88102    def closeInventory(self): 
    89         """Close the inventory""" 
     103        """Close the inventory. 
     104           @return: None""" 
    90105        self.inventory.hide() 
    91106 
    92107    def showInventory(self): 
    93         """Show the inventory""" 
     108        """Show the inventory. 
     109           @return: None""" 
    94110        self.inventory.show() 
    95111 
    96112    def setMouseCursor(self, image, dummy_image, type = "native"):  
    97         """Set the mouse cursor to an image""" 
     113        """Set the mouse cursor to an image. 
     114           @type image: ??? 
     115           @param image: ??? 
     116           @type dummy_image: ??? 
     117           @param dummy_image: ??? 
     118           @type type: string 
     119           @param type: ??? 
     120           @return: None""" 
    98121        cursor = self.engine.getCursor() 
    99122        cursor_type = fife.CURSOR_IMAGE 
     
    111134             
    112135    def resetMouseCursor(self): 
    113         """Reset cursor to default image""" 
     136        """Reset cursor to default image. 
     137           @return: None""" 
    114138        c = self.engine.getCursor() 
    115139        img_pool = self.engine.getImagePool() 
     
    120144        c.set(cursor_type, cursor_id) 
    121145         
    122     # decide whether to drag or drop the image 
    123146    def dragDrop(self, obj): 
     147        """Decide whether to drag or drop the image. 
     148           @type obj: ??? 
     149           @param obj: ??? 
     150           @return: None""" 
    124151        if(self.dragging == True): 
    125152            self.dropObject(obj) 
     
    127154            self.dragObject(obj) 
    128155                 
    129     # drag the selected object 
    130156    def dragObject(self, obj): 
     157        """Drag the selected object. 
     158           @type obj: ??? 
     159           @param obj: ??? 
     160           @return: None""" 
     161        # TODO: add some comments - what's the logic? 
    131162        drag_widget = self.inventory.findChild(name = obj) 
    132163        self.dragged_type = self.buttons[obj] 
     
    137168        self.dragged_image = up_image 
    138169        self.dragging = True 
    139  
    140170        drag_widget._setUpImage(self.empty_images[obj]) 
    141171        drag_widget._setDownImage(self.empty_images[obj]) 
     
    143173         
    144174    def dropObject(self, obj): 
    145         """Drops the object being dropped""" 
     175        """Drops the object being dropped 
     176           @type obj: ??? 
     177           @param obj: ??? 
     178           @return: None""" 
     179        # TODO: add some comments 
    146180        self.dropped_type  =  self.buttons[obj] 
    147181        if((self.dragged_type == 'main_inv') or 
     
    156190            if (self.dropped_type == 'ready'): 
    157191                self.readyCallback() 
    158  
    159192        elif((self.dragged_type == self.dropped_type) and 
    160193             (self.dragged_type in self.locations)): 
     
    166199            self.dragging = False 
    167200            self.resetMouseCursor() 
    168             if (self.dropped_type == 'ready'): 
     201            if(self.dropped_type == 'ready'): 
    169202                self.readyCallback() 
    170203        else: 
    171204            self.resetMouseCursor() 
    172205            self.dragging = False 
     206 
  • trunk/PARPG/scripts/objLoader.py

    r138 r143  
    2424       local objects data""" 
    2525    def __init__(self): 
     26        """Initialise the instance. 
     27           @return: None""" 
    2628        self.search = "objects" 
    2729        self.pc = None 
     
    3133     
    3234    def getParser(self): 
    33         """Simple one liner to remove XML dependencies in engine.py""" 
     35        """Simple one liner to remove XML dependencies in engine.py. 
     36           @rtype: parser 
     37           @return: A parser to work with""" 
    3438        return make_parser() 
    3539     
    3640    def getObject(self, attrs): 
    37         """Grab the object details from the XML""" 
     41        """Grab the object details from the XML data. 
     42           @type attrs: ??? 
     43           @param attrs: XML attributes 
     44           @return: None""" 
    3845        try: 
    3946            display = attrs.getValue("display") 
     
    6067 
    6168    def getDoor(self, attrs): 
    62         """Grab door data""" 
     69        """Grab the door data. 
     70           @type attrs: ??? 
     71           @param attrs: XML attributes 
     72           @return: None""" 
    6373        try: 
    6474            display = attrs.getValue("display") 
     
    8393 
    8494    def startElement(self, name, attrs): 
    85         """Called every time we meet a new element in the XML file""" 
     95        """Called every time we meet a new element in the XML file 
     96           @type name: string 
     97           @param name: XML element? 
     98           @type attrs: ??? 
     99           @param attrs: XML attributes 
     100           @return: None""" 
    86101        # we are only looking for the 'layer' elements, the rest we ignore 
    87102        if(name == "PC"): 
     
    129144            self.doors.append([self.objects[-1][4],new_map, \ 
    130145                    tuple([txpos, typos])]) 
     146 
  • trunk/PARPG/scripts/objects.py

    r121 r143  
    2828           owner -> what it is contained in 
    2929           contain -> True / False is it a container 
    30            carry -> True / False it can be carried""" 
     30           carry -> True / False it can be carried 
     31           @type data: list 
     32           @param data: List of data for the object 
     33           @return: None""" 
    3134        if(data[0] == True): 
    3235            self.display = True 
  • trunk/PARPG/settings.py

    r30 r143  
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
    118import shutil 
    219 
Note: See TracChangeset for help on using the changeset viewer.