Changeset 541


Ignore:
Timestamp:
06/16/10 19:18:01 (9 years ago)
Author:
beliar
Message:
  • Change to make PARPG run with the latest FIFE revision (3373)
    • Removed argument to addCamera that FIFE no longer needs
  • Changed settings code to use the FIFE extension fife_settings
  • Additions to pylintrc
Location:
trunk/game
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/local_loaders/xmlmap.py

    r540 r541  
    437437                                    map.getLayer(str(ref_layer_id)), \ 
    438438                                    fife.Rect(\ 
    439                                     *[int(c) for c in view_port.split(',')]),\ 
    440                                     fife.ExactModelCoordinate(0,0,0)) 
     439                                    *[int(c) for c in view_port.split(',')])) 
    441440                else: 
    442441                    screen = self.engine.getRenderBackend() 
     
    444443                                    map.getLayer(str(ref_layer_id)), \ 
    445444                                    fife.Rect(0, 0, screen.getScreenWidth(), \ 
    446                                               screen.getScreenHeight()), \ 
    447                                               fife.ExactModelCoordinate(0, 0,\ 
    448                                                                         0)) 
     445                                              screen.getScreenHeight()) ) 
    449446 
    450447                cam.setCellImageDimensions(int(ref_cell_width), \ 
  • trunk/game/pylintrc

    r530 r541  
    5454 
    5555# Disable the message(s) with the given id(s). 
    56 disable-msg=W0704,W0105,W0142,R0901,R0913,W0221,W0613,R0903 
     56disable-msg=W0704,W0105,W0142,R0901,R0913,W0221,W0613,R0903,R0902 
    5757 
    5858 
     
    140140 
    141141# Good variable names which should always be accepted, separated by a comma 
    142 good-names=k,ex,Run,_,__init__,__getstate__,__setstate__ 
     142good-names=k,ex,Run,_,__init__,__getstate__,__setstate__,ID,X,Y,__repr__ 
    143143 
    144144# Bad variable names which should always be refused, separated by a comma 
  • trunk/game/run.py

    r537 r541  
    2727from fife.extensions import fife_compat, fifelog, pychan 
    2828from fife.extensions.basicapplication import ApplicationBase 
     29from fife.extensions.fife_settings import Setting 
    2930 
    3031from scripts import world 
     
    3334from scripts.engine import Engine 
    3435from scripts.common import eventlistenerbase 
    35 from settings import Setting 
     36#from settings import Setting 
    3637 
    37 TDS = Setting() 
     38TDS = Setting(app_name="PARPG", 
     39              settings_file="./settings.xml",  
     40              settings_gui_xml="") 
    3841 
    3942"""This folder holds the main meta-data for PARPG. This file should be 
     
    99102        self.world = world.World(self.engine) 
    100103        self.model = engine.Engine(self.world) 
    101         self.model.readObjectDB(str(TDS.readSetting("ObjectDatabaseFile"))) 
     104        self.model.readObjectDB(str(TDS.get("PARPG", "ObjectDatabaseFile"))) 
    102105        self.world.data = self.model 
    103106        self.world.initHud() 
    104107        self.listener = ApplicationListener(self.engine, self.world, self.model) 
    105108        self.world.quitFunction = self.listener.quitGame 
    106         self.model.loadMap("main-map", str(TDS.readSetting("MapFile"))) 
     109        self.model.loadMap("main-map", str(TDS.get("PARPG", "MapFile"))) 
    107110        pychan.init(self.engine, debug = True) 
    108  
    109     def loadSettings(self): 
    110         """Load the settings from a python file and load them into the engine. 
    111            Called in the ApplicationBase constructor. 
    112            @return: None""" 
    113         import settings 
    114         self.settings = settings 
    115         e_set = self.engine.getSettings() 
    116         e_set.setDefaultFontGlyphs(str(TDS.readSetting("FontGlyphs", 
    117                                                       strip=False))) 
    118         e_set.setDefaultFontPath(str(TDS.readSetting("Font"))) 
    119         e_set.setDefaultFontSize(int(TDS.readSetting("FontSize", default=12))) 
    120         e_set.setBitsPerPixel(int(TDS.readSetting("BitsPerPixel"))) 
    121         e_set.setInitialVolume(float(TDS.readSetting("InitialVolume"))) 
    122         e_set.setSDLRemoveFakeAlpha(int(TDS.readSetting("SDLRemoveFakeAlpha"))) 
    123         e_set.setScreenWidth(int(TDS.readSetting("ScreenWidth"))) 
    124         e_set.setScreenHeight(int(TDS.readSetting("ScreenHeight"))) 
    125         e_set.setRenderBackend(str(TDS.readSetting("RenderBackend"))) 
    126         e_set.setFullScreen(int(TDS.readSetting("FullScreen"))) 
    127         try: 
    128             e_set.setWindowTitle(str(TDS.readSetting("WindowTitle"))) 
    129             e_set.setWindowIcon(str(TDS.readSetting("WindowIcon"))) 
    130         except: 
    131             pass             
    132         try: 
    133             e_set.setImageChunkingSize(int(TDS.readSetting("ImageChunkSize"))) 
    134         except: 
    135             pass 
    136  
    137     def initLogging(self): 
    138         """Initialize the LogManager. 
    139            @return: None""" 
    140         LogModules = TDS.readSetting("LogModules",type='list') 
    141         self.log = fifelog.LogManager(self.engine, 
    142                                       int(TDS.readSetting("LogToPrompt")), 
    143                                       int(TDS.readSetting("LogToFile"))) 
    144         if(LogModules): 
    145             self.log.setVisibleModules(*LogModules) 
    146111 
    147112    def createListener(self): 
  • trunk/game/scripts/gui/hud.py

    r487 r541  
    6666        self.initializeMainMenu() 
    6767        self.initializeContextMenu() 
    68         self.initializeOptionsMenu() 
    6968        self.initializeHelpMenu() 
    7069        self.initializeEvents() 
     
    7776        self.hud.mapEvents(self.events_to_map)  
    7877        # set HUD size according to screen size 
    79         screen_width = int(self.settings.readSetting('ScreenWidth')) 
     78        screen_width = self.engine.getSettings().getScreenWidth() 
    8079        self.hud.findChild(name="mainHudWindow").size = (screen_width, 65) 
    8180        self.hud.findChild(name="inventoryButton").position = \ 
     
    167166        self.main_menu = pychan.loadXML("gui/hud_main_menu.xml") 
    168167        self.menu_events = {"resumeButton":self.hideMenu,  
    169                             "optionsButton":self.displayOptions, 
     168                            "optionsButton":self.settings.onOptionsPress, 
    170169                            "helpButton":self.displayHelp} 
    171170        self.main_menu.mapEvents(self.menu_events) 
     
    236235                                                     }) 
    237236         
    238     def initializeOptionsMenu(self): 
    239         """Initialize the options menu, this will generate a list of fullscreen 
    240            resolutions and a list of windowed resolutions. Next to this the  
    241            current active settings are read and also selected in the matching 
    242            widgets. 
    243            @return: None""" 
    244             
    245         self.options_menu = pychan.loadXML("gui/hud_options.xml") 
    246         self.options_events = {"applyButton":self.applyOptions, 
    247                                "closeButton":self.options_menu.hide, 
    248                                "defaultsButton":self.setToDefaults, 
    249                                "FullscreenBox": self.switchResolutions, 
    250                                "InitialVolumeSlider":self.updateVolumeText} 
    251          
    252         settings = self.engine.getSettings() 
    253         # The settings need to be set to fullscreen for the call to  
    254         # getPossibleResolutions() to function. 
    255         current_fullscreen = settings.isFullScreen() 
    256         settings.setFullScreen(True) 
    257          
    258         available_fullscreen_resolutions = settings.getPossibleResolutions() 
    259         available_windowed_resolutions = ((1920, 1200), (1920, 1080), \ 
    260                                           (1856, 1392), (1792, 1344), \ 
    261                                           (1680, 1050), (1600, 1200), \ 
    262                                           (1600, 1024), (1440,  900), \ 
    263                                           (1400, 1050), (1360,  768), \ 
    264                                           (1280, 1024), (1280,  960), \ 
    265                                           (1152,  864), (1024,  768)) 
    266         # Filter too small resolutions from the fullscreen resolutions 
    267         self.resolutions_fullscreen = [] 
    268         for x in available_fullscreen_resolutions: 
    269             if x[0] >= 1024 and x[1] >= 768: 
    270                 self.resolutions_fullscreen.append(str(x[0]) + 'x' + str(x[1])) 
    271  
    272         # Filter too large resolution from the windowed resolutions  
    273         self.resolutions_windowed = [] 
    274         for x in available_windowed_resolutions: 
    275             if x[0] <= available_fullscreen_resolutions[0][0] and \ 
    276             x[1] <= available_fullscreen_resolutions[0][1]: 
    277                 self.resolutions_windowed.append(str(x[0]) + 'x' + str(x[1]))         
    278          
    279         settings.setFullScreen(current_fullscreen) 
    280         self.render_backends = ['OpenGL', 'SDL'] 
    281         self.render_number = 0 
    282         if (str(self.settings.readSetting('RenderBackend')) == "SDL"): 
    283             self.render_number = 1 
    284         initial_volume = float(self.settings.readSetting('InitialVolume')) 
    285         initial_volume_text = str('Initial Volume: %.0f%s' % 
    286                                 (int(initial_volume*10), "%")) 
    287         initial_data_to_distribute = {     
    288                 'RenderBox'          : self.render_backends, 
    289                 'InitialVolumeLabel' : initial_volume_text 
    290                 } 
    291  
    292         s_fullscreen = self.settings.readSetting(name="FullScreen") 
    293         s_sounds = self.settings.readSetting(name="PlaySounds") 
    294         s_render = self.render_number 
    295         s_volume = initial_volume 
    296  
    297         # Find the current active resolution so we can select it  
    298         screen_width = self.settings.readSetting(name="ScreenWidth") 
    299         screen_height = self.settings.readSetting(name="ScreenHeight") 
    300         index_res = str(screen_width + 'x' + screen_height) 
    301         try: 
    302             if int(s_fullscreen) == 0: 
    303                 s_resolution = self.resolutions_windowed.index(index_res) 
    304             else: 
    305                 s_resolution = self.resolutions_fullscreen.index(index_res) 
    306             resolution_in_list = True 
    307         except: 
    308             resolution_in_list = False 
    309              
    310         data_to_distribute = { 
    311                 'FullscreenBox'      : int(s_fullscreen),  
    312                 'SoundsBox'          : int(s_sounds), 
    313                 'RenderBox'          : s_render, 
    314                 'InitialVolumeSlider': s_volume 
    315                 } 
    316  
    317         if int(s_fullscreen) == 0: 
    318             initial_data_to_distribute['ResolutionBox'] = self.resolutions_windowed 
    319         else: 
    320             initial_data_to_distribute['ResolutionBox'] = self.resolutions_fullscreen 
    321              
    322         if (resolution_in_list == True): 
    323             data_to_distribute['ResolutionBox'] = s_resolution 
    324  
    325         self.options_menu.distributeInitialData(initial_data_to_distribute) 
    326         self.options_menu.distributeData(data_to_distribute) 
    327         self.options_menu.mapEvents(self.options_events) 
     237 
    328238 
    329239    def saveGame(self): 
     
    461371                                    (int(volume*10), "%")) 
    462372 
    463     def requireRestartDialog(self): 
    464         """Show a dialog asking the user to restart PARPG in order for their 
    465            changes to take effect. 
    466            @return: None""" 
    467         require_restart_dialog = pychan.loadXML('gui/hud_require_restart.xml') 
    468         require_restart_dialog.mapEvents(\ 
    469                                 {'okButton':require_restart_dialog.hide}) 
    470         require_restart_dialog.show() 
    471  
    472     def applyOptions(self): 
    473         """Apply the current options. 
    474            @return: None""" 
    475         # At first no restart is required 
    476         self.require_restart = False 
    477  
    478         # get the current values of each setting from the options menu 
    479         enable_fullscreen = self.options_menu.collectData('FullscreenBox') 
    480         enable_sound = self.options_menu.collectData('SoundsBox') 
    481         screen_resolution = self.options_menu.collectData('ResolutionBox') 
    482         if enable_fullscreen: 
    483             partition = self.resolutions_fullscreen[screen_resolution].partition('x') 
    484         else: 
    485             partition = self.resolutions_windowed[screen_resolution].partition('x') 
    486         screen_width = partition[0] 
    487         screen_height = partition[2] 
    488         render_backend = self.options_menu.collectData('RenderBox') 
    489         initial_volume = self.options_menu.collectData('InitialVolumeSlider') 
    490         initial_volume = "%.1f" % initial_volume 
    491  
    492         # get the options that are being used right now from settings.xml 
    493         s_fullscreen = self.settings.readSetting('FullScreen') 
    494         s_sounds = self.settings.readSetting('PlaySounds') 
    495         s_render = self.settings.readSetting('RenderBackend') 
    496         s_volume = self.settings.readSetting('InitialVolume') 
    497  
    498         s_screen_height = self.settings.readSetting('ScreenHeight') 
    499         s_screen_width = self.settings.readSetting('ScreenWidth') 
    500         s_resolution = s_screen_width + 'x' + s_screen_height 
    501  
    502         # On each: 
    503         # - Check to see whether the option within the xml matches the 
    504         #   option within the options menu 
    505         # - If they do not match, set the option within the xml to 
    506         #   to be what is within the options menu 
    507         # - Require a restart 
    508  
    509         if (int(enable_fullscreen) != int(s_fullscreen)): 
    510             self.setOption('FullScreen', int(enable_fullscreen)) 
    511             self.require_restart = True 
    512              
    513         if (int(enable_sound) != int(s_sounds)): 
    514             self.setOption('PlaySounds', int(enable_sound)) 
    515             self.require_restart = True 
    516  
    517         if (screen_resolution != s_resolution): 
    518             self.setOption('ScreenWidth', int(screen_width)) 
    519             self.setOption('ScreenHeight', int(screen_height)) 
    520             self.require_restart = True 
    521  
    522         # Convert the number from the list of render backends to 
    523         # the string that FIFE wants for its settings.xml 
    524         if (render_backend == 0): 
    525             render_backend = 'OpenGL' 
    526         else: 
    527             render_backend = 'SDL' 
    528  
    529         if (render_backend != str(s_render)): 
    530             self.setOption('RenderBackend', render_backend) 
    531             self.require_restart = True 
    532  
    533         if (initial_volume != float(s_volume)): 
    534             self.setOption('InitialVolume', initial_volume) 
    535             self.require_restart = True 
    536          
    537         # Write all the settings to settings.xml 
    538         self.settings.saveSettings(); 
    539          
    540         # If the changes require a restart, popup the dialog telling 
    541         # the user to do so 
    542         if (self.require_restart): 
    543             self.requireRestartDialog() 
    544         # Once we are done, we close the options menu 
    545         self.options_menu.hide() 
    546  
    547373    def setOption(self, name, value): 
    548374        """Set an option within the xml. 
     
    565391        self.requireRestartDialog() 
    566392        self.options_menu.hide() 
    567  
    568     def displayOptions(self): 
    569         """Display the options menu. 
    570            @return: None""" 
    571         self.options_menu.show() 
    572393     
    573394    def readyAction(self, ready_button): 
  • trunk/game/scripts/map.py

    r501 r541  
    2020from local_loaders.loaders import loadMapFile 
    2121from scripts.common.eventlistenerbase import EventListenerBase 
    22 from settings import Setting 
     22from fife.extensions.fife_settings import Setting 
    2323 
    24 TDS = Setting() 
     24TDS = Setting(app_name="PARPG", 
     25              settings_file="./settings.xml",  
     26              settings_gui_xml="") 
    2527 
    2628class Map(fife.MapChangeListener): 
     
    124126        At this point we also set the viewport to the current resolution.""" 
    125127        for cam in self.map.getCameras(): 
    126             width = int(TDS.readSetting(name="ScreenWidth")) 
    127             height = int(TDS.readSetting(name="ScreenHeight")) 
     128            width = self.engine.getSettings().getScreenWidth() 
     129            height = self.engine.getSettings().getScreenHeight()  
    128130            viewport = fife.Rect(0,0,width,height) 
    129131            cam.setViewPort(viewport) 
     
    141143        text = self.engine.getGuiManager().\ 
    142144                        createFont('fonts/rpgfont.png', 0, \ 
    143                                    str(TDS.readSetting("FontGlyphs", \ 
    144                                                        strip=False))) 
     145                                   TDS.get("FIFE", "FontGlyphs")) 
    145146        rend.changeDefaultFont(text) 
    146147        rend.activateAllLayers(self.map) 
  • trunk/game/scripts/objects/actors.py

    r533 r541  
    2626__all__ = ["PlayerCharacter", "NonPlayerCharacter",] 
    2727 
    28 TDS = Setting() 
     28TDS = Setting(app_name="PARPG", 
     29              settings_file="./settings.xml",  
     30              settings_gui_xml="") 
    2931_AGENT_STATE_NONE, _AGENT_STATE_IDLE, _AGENT_STATE_APPROACH, _AGENT_STATE_RUN, _AGENT_STATE_WANDER, _AGENT_STATE_TALK = xrange(6) 
    3032 
     
    4446        self.state = _AGENT_STATE_NONE 
    4547        # TODO: rework/improve 
    46         self.speed = float(TDS.readSetting("PCSpeed"))-1 
     48        self.speed = TDS.get("PARPG", "PCSpeed")-1 
    4749         
    4850    def getX(self): 
     
    6769        self.idle_counter = 1 
    6870        # TODO: rework/improve 
    69         self.speed = float(TDS.readSetting("PCSpeed")) 
     71        self.speed = TDS.get("PARPG", "PCSpeed") 
    7072        self.nextAction = None 
    7173        self.agent = None 
  • trunk/game/scripts/objects/base.py

    r530 r541  
    5353            
    5454from fife import fife 
    55 from settings import Setting 
     55from fife.extensions.fife_settings import Setting 
    5656from random import randrange 
    5757from scripts.gui.popups import ExaminePopup, ContainerGUI 
  • trunk/game/scripts/world.py

    r527 r541  
    2727from local_loaders.loaders import loadMapFile 
    2828from sounds import SoundEngine 
    29 from settings import Setting 
     29from fife.extensions.fife_settings import Setting 
    3030from scripts.gui import hud 
    3131from scripts.gui.popups import * 
     
    3333from map import Map 
    3434 
    35 TDS = Setting() 
     35TDS = Setting(app_name="PARPG", 
     36              settings_file="./settings.xml",  
     37              settings_gui_xml="") 
    3638 
    3739# this file should be the meta-file for all FIFE-related code 
     
    7173 
    7274        # don't force restart if skipping to new section 
    73         if TDS.readSetting("PlaySounds") == "1": 
     75        if TDS.get("FIFE",  "PlaySounds"): 
    7476            if not self.sounds.music_init: 
    7577                self.sounds.playMusic(random.choice(glob.glob(os.path.join("music", "*.ogg"))))  
  • trunk/game/settings-dist.xml

    r537 r541  
     1<?xml version='1.0' encoding='UTF-8'?> 
    12<Settings> 
    2      
    3         <FullScreen>1</FullScreen> 
    4         <PlaySounds>1</PlaySounds> 
    5         <RenderBackend> OpenGL </RenderBackend> 
    6         <ScreenWidth>1024</ScreenWidth> 
    7         <ScreenHeight>768</ScreenHeight> 
    8         <BitsPerPixel> 0 </BitsPerPixel> 
    9         <InitialVolume> 5.0 </InitialVolume> 
    10         <SDLRemoveFakeAlpha> 1 </SDLRemoveFakeAlpha> 
    11         <WindowTitle> PARPG Techdemo 1 </WindowTitle> 
    12         <WindowIcon>gui/icons/window_icon.png</WindowIcon> 
    13         <MapFile> maps/map.xml </MapFile> 
    14         <ObjectDatabaseFile>objects/ObjectDatabase.yaml</ObjectDatabaseFile> 
    15         <Font> fonts/samanata.ttf </Font> 
    16         <FontGlyphs> abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&amp;`'*#=[]\"</FontGlyphs> 
    17         <FontSize>12</FontSize> 
    18         <LogModules> controller </LogModules> 
    19         <LogToPrompt> 0 </LogToPrompt> 
    20         <LogToFile> 0 </LogToFile> 
    21         <ImageChunkSize> 256 </ImageChunkSize> 
    22         <PCSpeed> 3 </PCSpeed> 
     3        <Module name="FIFE">     
     4        <Setting name="FullScreen" type="bool"> False </Setting> 
     5        <Setting name="PlaySounds" type="bool"> True </Setting> 
     6        <Setting name="RenderBackend" type="str"> OpenGL </Setting> 
     7                <Setting name="ScreenResolution" type="str">1024x768</Setting> 
     8        <Setting name="BitsPerPixel" type="int"> 0 </Setting> 
     9        <Setting name="InitialVolume" type="float"> 5.0 </Setting> 
     10        <Setting name="SDLRemoveFakeAlpha" type="int"> 1 </Setting> 
     11        <Setting name="WindowTitle" type="str"> PARPG Demo </Setting> 
     12        <Setting name="WindowIcon" type="str"> gui/icons/window_icon.png </Setting> 
     13        <Setting name="Font" type="str"> fonts/samanata.ttf </Setting> 
     14        <Setting name="FontGlyphs" strip="0" type="str">  abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&amp;`'*#=[]\"</Setting> 
     15        <Setting name="DefaultFontSize" type="int"> 12 </Setting> 
     16        <Setting name="LogModules" type="list"> controller </Setting> 
     17                <Setting name="PychanDebug" type="bool"> False </Setting> 
     18        <Setting name="LogToPrompt" type="int"> 0 </Setting> 
     19        <Setting name="LogToFile" type="int"> 0 </Setting> 
     20                <Setting name="UsePsyco" type="bool"> False </Setting> 
     21                <Setting name="ProfilingOn" type="bool"> False </Setting> 
     22        <Setting name="ImageChunkSize" type="int"> 256 </Setting> 
     23    </Module> 
     24    <Module name="PARPG"> 
     25        <Setting name="MapFile" type="str"> maps/map.xml </Setting> 
     26        <Setting name="ObjectDatabaseFile" type="str"> objects/ObjectDatabase.yaml</Setting> 
     27        <Setting name="PCSpeed" type="int"> 3 </Setting> 
     28    </Module> 
    2329</Settings> 
Note: See TracChangeset for help on using the changeset viewer.