Changeset 556


Ignore:
Timestamp:
06/20/10 20:05:58 (9 years ago)
Author:
beliar
Message:
  • Added maps/maps.yaml. This contains the map name and the belonging file. The GameModel? will load this file and store the values. The file can be set in the settings file.
  • loadMap and changeMap now only take the map name as an argument. The actual file is then read from the stored content of maps.yaml.
  • The Map setting now has the name of the map instead of the file
  • main-map has been renamed to Mall and map2 to Farm
  • Deleted maps/shanty_objects.xml. This seemes to be meant for something similiar to what we are currently doing
Location:
branches/map_loading_change/game
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • branches/map_loading_change/game/maps/map.xml

    r540 r556  
    11<?xml version="1.0" encoding="ascii"?> 
    2 <map format="1.0" id="main-map"> 
     2<map format="1.0" id="Mall"> 
    33        <import file="../objects/ground/snow/snow0/snow02.xml" /> 
    44        <import file="../objects/ground/gravel/gravel.xml" /> 
     
    53625362                                </inventory> 
    53635363                        </i> 
    5364                         <i id="shanty-door01" is_open="False" locked="None" o="shanty-door" object_type="ShantyDoor" r="0" target_map="maps/map2.xml" target_map_name="map2" target_x="10.0" target_y="10.0" x="-6.0" y="-13.0" z="0.0" /> 
     5364                        <i id="shanty-door01" is_open="False" locked="None" o="shanty-door" object_type="ShantyDoor" r="0" target_map_name="Farm" target_x="10.0" target_y="10.0" x="-6.0" y="-13.0" z="0.0" /> 
    53655365                        <i o="container_house01" r="0" x="-1.0" y="2.0" z="0.0" /> 
    53665366                        <i o="container_house02" r="0" x="14.0" y="4.0" z="0.0" /> 
  • branches/map_loading_change/game/maps/map2.xml

    r539 r556  
    11<?xml version="1.0" encoding="ascii"?> 
    2 <map format="1.0" id="map2"> 
     2<map format="1.0" id="Farm"> 
    33        <import file="../objects/ground/grass/grass-a.xml" /> 
    44        <import file="../objects/buildings/shanty/shanty-door.xml" /> 
     
    10131013                        <i dialogue="dialogue/farm_boy1.yaml" id="farm_boy0" is_open="None" locked="None" name="Sami"    o="long_coat_male" object_type="NonPlayerCharacter" r="0" target_map="None" target_map_name="None" target_x="None" target_y="None" text="An earstwhile boy, working hard" x="3.0" y="4.0" z="0.0" /> 
    10141014                        <i dialogue="dialogue/farm_boy2.yaml" id="farm_boy1" is_open="None" locked="None" name="Rasmus"  o="long_coat_male" object_type="NonPlayerCharacter" r="0" target_map="None" target_map_name="None" target_x="None" target_y="None" text="A grimy looking farmer" x="4.0" y="3.0" z="0.0" /> 
    1015                         <i id="shanty-door01" is_open="False" locked="None" o="shanty-door" object_type="ShantyDoor" r="0" target_map="maps/map.xml" target_map_name="main-map" target_x="5.0" target_y="5.0" text="Looks like the exit of the building." x="-2.0" y="6.0" z="0.0" /> 
     1015                        <i id="shanty-door01" is_open="False" locked="None" o="shanty-door" object_type="ShantyDoor" r="0" target_map_name="Mall" target_x="5.0" target_y="5.0" text="Looks like the exit of the building." x="-2.0" y="6.0" z="0.0" /> 
    10161016                </instances> 
    10171017        </layer> 
  • branches/map_loading_change/game/scripts/gamemodel.py

    r553 r556  
    2323from map import Map 
    2424from fife import fife 
    25  
    2625import yaml 
    2726 
     
    4544        self.target_position = None 
    4645        self.target_map_name = None 
    47         self.target_map_file = None 
    4846        self.object_db = {} 
    4947        # self.map is a Map object, set to none here 
    5048        self.active_map = None 
    5149        self.maps = {} 
    52         self.engine = engine         
     50        self.map_files = {} 
     51        self.engine = engine       
    5352 
    5453    def checkAttributes(self, attributes): 
     
    215214        self.active_map.togglePause() 
    216215     
    217     def loadMap(self, map_name, map_file): 
     216    def getMapFiles(self, maps_file): 
     217        """Get all a available map-files and store them""" 
     218        maps = file(maps_file) 
     219        self.map_files = yaml.load(maps)["Maps"] 
     220     
     221    def loadMap(self, map_name): 
    218222        """Load a new map. 
    219223           @type map_name: string 
     
    222226           @param map_file: Filename of map file to load 
    223227           @return: None""" 
    224         self.game_state.current_map_file = map_file 
    225228        self.game_state.current_map_name = map_name 
     229        self.game_state.current_map_file = self.map_files[map_name] 
    226230 
    227231        if not map_name in self.maps:            
    228232            new_map = Map(self.engine, self) 
    229233            self.maps[map_name] = new_map 
    230             new_map.load(map_file) 
     234            new_map.load(self.map_files[map_name]) 
    231235        else: 
    232236            self.setActiveMap(map_name) 
     
    236240        self.game_state.PlayerCharacter.start() 
    237241 
    238     def changeMap(self, map_name, map_file, target_position): 
     242    def changeMap(self, map_name, target_position): 
    239243        """Registers for a map change on the next pump(). 
    240244           @type map_name: String 
     
    248252        if map_name != self.game_state.current_map_name: 
    249253            self.target_map_name = map_name 
    250             self.target_map_file = map_file 
    251254            self.target_position = target_position 
    252255            # issue the map change 
  • branches/map_loading_change/game/scripts/gamescenecontroller.py

    r553 r556  
    173173    def handleCommands(self): 
    174174        if self.model.map_change: 
    175             self.model.loadMap(self.model.target_map_name,  
    176                                self.model.target_map_file) 
     175            self.model.loadMap(self.model.target_map_name) 
    177176            self.model.teleport(self.model.target_position) 
    178177            self.model.map_change = False 
  • branches/map_loading_change/game/scripts/objects/action.py

    r553 r556  
    4747    def execute(self): 
    4848        """Executes the map change.""" 
    49         self.model.changeMap(self.target_map_name, self.target_map_file,\ 
     49        self.model.changeMap(self.target_map_name, 
    5050                              self.target_pos) 
    5151        
     
    148148        # If we are too far away, we approach the NPC again 
    149149        if distance_squared > 2: 
    150             pc.approach([self.npc.getLocation().\ 
    151                          getLayerCoordinates().x, \ 
    152                          self.npc.getLocation().\ 
    153                          getLayerCoordinates().y], \ 
    154                         TalkAction(self.model,\ 
     150            pc.approach([self.npc.getLocation(). 
     151                         getLayerCoordinates().x, 
     152                         self.npc.getLocation(). 
     153                         getLayerCoordinates().y],  
     154                        TalkAction(self.model, 
     155                                   self.view, 
    155156                                   self.npc))         
    156157        else: 
  • branches/map_loading_change/game/scripts/parpg.py

    r553 r556  
    9797        #self.engine.getModel(self) 
    9898        self.model = gamemodel.GameModel(self.engine) 
     99        self.model.getMapFiles(self._setting.get("PARPG",  
     100                                                  "MapsFile")) 
    99101        self.view = gamesceneview.GameSceneView(self.engine, self.model) 
    100102        self.controller = gamescenecontroller.GameSceneController(self.engine,  
     
    109111                                            self.view,  
    110112                                            self.model) 
    111         self.model.loadMap("main-map", str(self._setting.get("PARPG",  
    112                                                              "MapFile"))) 
     113        self.model.loadMap(str(self._setting.get("PARPG", "Map"))) 
    113114        pychan.init(self.engine, debug = True) 
    114115 
  • branches/map_loading_change/game/settings-dist.xml

    r543 r556  
    11<?xml version='1.0' encoding='UTF-8'?> 
    22<Settings> 
    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> 
     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> 
    77                <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> 
     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> 
    2424    <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> 
     25        <Setting name="Map" type="str">Mall</Setting> 
     26        <Setting name="ObjectDatabaseFile" type="str">objects/ObjectDatabase.yaml</Setting> 
     27        <Setting name="MapsFile" type = "str">maps/maps.yaml</Setting> 
     28        <Setting name="PCSpeed" type="int">3</Setting> 
     29   </Module> 
    2930</Settings> 
Note: See TracChangeset for help on using the changeset viewer.