Changeset 558


Ignore:
Timestamp:
06/21/10 19:28:59 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Merged changes from trunk
  • Added a methods to read the contents of the file containing all agents, get all agents currently on a map and to reset the agents dictionary
  • Changed loadMap. After loading the map it will now load the contents of the map-specific agent file.
Location:
branches/map_loading_change
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/map_loading_change

    • Property svn:ignore
      •  

        old new  
         1*.pyc 
         2.project 
         3.pydevproject 
        14Thumbs.db 
        2 *.pyc 
    • Property svn:mergeinfo changed
      /trunk (added)merged: 557
  • branches/map_loading_change/game/maps/all_agents.yaml

    r555 r558  
    1919    ObjectType: "PlayerCharacter" 
    2020    ObjectModel: "player" 
    21     Map: "main-map" 
     21    Map: "Mall" 
    2222    Position: [2.0, -8.0, 0.0] 
    2323    Inventory:   
     
    3232    ObjectModel: "long_coat_female" 
    3333    Text: "A woman wearing a large coat, and a big gun." 
    34     Map: "main-map" 
     34    Map: "Mall" 
    3535    Position: [-5.0, -3.0, 0.0] 
    3636--- 
     
    4141    ObjectModel: "long_coat_male" 
    4242    Text: "A very drunk looking man." 
    43     Map: "main-map" 
     43    Map: "Mall" 
    4444    Position: [-5.0, -4.0, 0.0] 
    4545--- 
     
    5050    ObjectModel: "male_traveler_1" 
    5151    Text: "A wild-eyed man with an axe." 
    52     Map: "main-map" 
     52    Map: "Mall" 
    5353    Position: [-5.0, -6.0, 0.0] 
    5454--- 
     
    5959    ObjectModel: "male_traveler_1" 
    6060    Text: "A man shoveling snow into a hole." 
    61     Map: "main-map" 
     61    Map: "Mall" 
    6262    Position: [-8.0, -6.0, 0.0] 
    6363--- 
     
    6868    ObjectModel: "male_traveler_1" 
    6969    Text: "A tough looking dude." 
    70     Map: "main-map" 
     70    Map: "Mall" 
    7171    Position: [2.0, -6.0, 0.0]  
    7272--- 
     
    7777    ObjectModel: "long_coat_male" 
    7878    Text: "A lean man with a sharp face and an appraising gaze." 
    79     Map: "main-map" 
     79    Map: "Mall" 
    8080    Position: [3.0, -6.0, 0.0]  
    8181--- 
     
    8686    ObjectModel: "male_traveler_1" 
    8787    Text: "An older man who exudes confidence and ability." 
    88     Map: "main-map" 
     88    Map: "Mall" 
    8989    Position: [4.0, -6.0, 0.0] 
    9090--- 
     
    9595    ObjectModel: "npc_woman" 
    9696    Text: "A business-like woman, short and stout." 
    97     Map: "main-map" 
     97    Map: "Mall" 
    9898    Position: [5.0, -7.0, 0.0] 
    9999--- 
     
    104104    ObjectModel: "npc_woman" 
    105105    Text: "An ancient crone with a tight lipped smile.  She has an unlit cigarette dangling from her lips." 
    106     Map: "main-map" 
     106    Map: "Mall" 
    107107    Position: [-6.0, -7.0, 0.0] 
    108108--- 
     
    113113    ObjectModel: "npc_woman" 
    114114    Text: "A dark haired, scantily clad woman giving you the once over." 
    115     Map: "main-map" 
     115    Map: "Mall" 
    116116    Position: [-7.0, -7.0, 0.0] 
    117117--- 
     
    122122    ObjectModel: "npc_woman" 
    123123    Text: "A scantily clad blond, checking you out." 
    124     Map: "main-map" 
     124    Map: "Mall" 
    125125    Position: [-8.0, -7.0, 0.0] 
    126126--- 
     
    131131    ObjectModel: "long_coat_female" 
    132132    Text: "A hard-faced pretty young woman. She seems to be scowling." 
    133     Map: "main-map" 
     133    Map: "Mall" 
    134134    Position: [-5.0, -7.0, 0.0] 
    135135--- 
     
    140140    ObjectModel: "long_coat_female" 
    141141    Text: "A plain looking girl with a faraway look in her eye." 
    142     Map: "main-map" 
     142    Map: "Mall" 
    143143    Position: [-5.0, -9.0, 0.0] 
    144144--- 
     
    149149    ObjectModel: "male_farmer_1" 
    150150    Text: "A grimy looking farmer." 
    151     Map: "map2" 
     151    Map: "Farm" 
    152152    Position: [-3.0, -3.0, 0.0] 
    153153--- 
     
    158158    ObjectModel: "long_coat_male" 
    159159    Text: "An earstwhile boy, working hard." 
    160     Map: "map2" 
     160    Map: "Farm" 
    161161    Position: [3.0, 4.0, 0.0] 
    162162--- 
     
    167167    ObjectModel: "long_coat_male" 
    168168    Text: "A grimy looking farmer." 
    169     Map: "map2" 
     169    Map: "Farm" 
    170170    Position: [4.0, 3.0, 0.0] 
    171 --- 
  • branches/map_loading_change/game/scripts/gamemodel.py

    r556 r558  
    4949        self.maps = {} 
    5050        self.map_files = {} 
     51        self.agents = {} 
     52        self.agents["all"] = {} 
    5153        self.engine = engine       
     54        self.maps_file = "maps/maps.yaml" 
     55        self.all_agents_file = "maps/all_agents.yaml" 
    5256 
    5357    def checkAttributes(self, attributes): 
     
    214218        self.active_map.togglePause() 
    215219     
    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    def readMapFiles(self): 
     221        """Read all a available map-files and store them""" 
     222        maps_data = file(self.maps_file) 
     223        self.map_files = yaml.load(maps_data)["Maps"] 
     224     
     225    def readAllAgents(self): 
     226        """Read the agents of the all_agents_file and store them""" 
     227        agents_data = file(self.all_agents_file) 
     228        agents = yaml.load_all(agents_data) 
     229        for agent in agents: 
     230            if not agent == None: 
     231                self.agents["all"].update(agent)   
     232                 
     233    def getAgentsOfMap(self, map_name): 
     234        """Returns the agents that are on the given map 
     235        @param map_name: Name of the map 
     236        @type map_name: str 
     237        @return: A dictionary with the agents of the map 
     238        """ 
     239        if not self.agents.has_key(map_name): 
     240            return {} 
     241        ret_dict = self.agents[map_name] 
     242        for agent_name, agent_value in self.agents["all"].iteritems(): 
     243            if agent_value["Map"] == map_name: 
     244                ret_dict[agent_name] = agent_value 
     245        return ret_dict 
     246                 
     247    def clearAgents(self): 
     248        """Resets the agents dictionary""" 
     249        self.agents = {} 
     250        self.agents["all"] = {} 
    220251     
    221252    def loadMap(self, map_name): 
     
    229260        self.game_state.current_map_file = self.map_files[map_name] 
    230261 
    231         if not map_name in self.maps:            
     262        if not map_name in self.maps:   
     263            map_file = self.map_files[map_name] 
     264            map_agents_file = map_file.replace(".xml", "_agents.yaml")    
    232265            new_map = Map(self.engine, self) 
    233266            self.maps[map_name] = new_map 
    234267            new_map.load(self.map_files[map_name]) 
     268            #Get the agents of the map 
     269            self.agents[map_name] = {} 
     270            agents_data = file(map_agents_file) 
     271            agents = yaml.load_all(agents_data) 
     272            for agent in agents: 
     273                if not agent == None: 
     274                    self.agents[map_name].update(agent)   
    235275        else: 
    236276            self.setActiveMap(map_name) 
  • branches/map_loading_change/game/scripts/gamesceneview.py

    r553 r558  
    5555        """Callback sample for the context menu.""" 
    5656        self.hud.hideContainer() 
    57         self.engine.getModel().game_state.PlayerCharacter.run(click) 
     57        self.model.game_state.PlayerCharacter.run(click) 
    5858 
    5959    def refreshTopLayerTransparencies(self): 
  • branches/map_loading_change/game/scripts/parpg.py

    r556 r558  
    9797        #self.engine.getModel(self) 
    9898        self.model = gamemodel.GameModel(self.engine) 
    99         self.model.getMapFiles(self._setting.get("PARPG",  
    100                                                   "MapsFile")) 
     99        self.model.maps_file = self._setting.get("PARPG", "MapsFile") 
     100        self.model.readMapFiles() 
     101        self.model.all_agents_file = self._setting.get("PARPG", "AllAgentsFile") 
     102        self.model.readAllAgents() 
    101103        self.view = gamesceneview.GameSceneView(self.engine, self.model) 
    102104        self.controller = gamescenecontroller.GameSceneController(self.engine,  
  • branches/map_loading_change/game/settings-dist.xml

    r556 r558  
    2626        <Setting name="ObjectDatabaseFile" type="str">objects/ObjectDatabase.yaml</Setting> 
    2727        <Setting name="MapsFile" type = "str">maps/maps.yaml</Setting> 
     28        <Setting name="AllAgentsFile" type = "str">maps/all_agents.yaml</Setting>         
    2829        <Setting name="PCSpeed" type="int">3</Setting> 
    2930   </Module> 
Note: See TracChangeset for help on using the changeset viewer.