Mercurial > fife-parpg
changeset 546:8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 03 Jun 2010 21:35:06 +0000 |
parents | bc7e3c3122d7 |
children | e59ece21ab3e |
files | demos/rpg/maps/allobjects.xml demos/rpg/maps/level1_objects.xml demos/rpg/maps/quests.xml demos/rpg/maps/town_objects.xml demos/rpg/scripts/actors/baseactor.py demos/rpg/scripts/actors/player.py demos/rpg/scripts/actors/questgiver.py demos/rpg/scripts/gamecontroller.py demos/rpg/scripts/objects/baseobject.py demos/rpg/scripts/objects/items.py demos/rpg/scripts/scene.py demos/rpg/settings-dist.xml |
diffstat | 12 files changed, 169 insertions(+), 190 deletions(-) [+] |
line wrap: on
line diff
--- a/demos/rpg/maps/allobjects.xml Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/maps/allobjects.xml Thu Jun 03 21:35:06 2010 +0000 @@ -1,15 +1,15 @@ <?xml version='1.0' encoding='UTF-8'?> <Settings> <Module name="models"> - <Setting name="Player" type="dict"> type : ITEM ; file : objects/actors/player/warrior/object.xml ; model : goldstack </Setting> - <Setting name="GoldStack" type="dict"> type : GOLD ; file : objects/items/goldstack/object.xml ; model : goldstack </Setting> - <Setting name="Quiller" type="dict"> type : QUESTGIVER ; file : objects/actors/player/warrior/object.xml ; model : warrior </Setting> - <Setting name="TempleEntrance" type="dict"> type : PORTAL ; file : objects/ground/temple_entrance/object.xml ; model : temple_entrance </Setting> + <Setting name="Player" type="dict"> file : objects/actors/player/warrior/object.xml ; model : goldstack </Setting> + <Setting name="GoldStack" type="dict"> file : objects/items/goldstack/object.xml ; model : goldstack </Setting> + <Setting name="Quiller" type="dict"> file : objects/actors/player/warrior/object.xml ; model : warrior </Setting> + <Setting name="TempleEntrance" type="dict"> file : objects/ground/temple_entrance/object.xml ; model : temple_entrance </Setting> </Module> - <Module name="Quiller"> - <Setting name="questcount" type="int"> 2 </Setting> - <Setting name="quest1" type="dict"> type : RETURN_ITEM ; name : Test quest ; desc : This is the first quest you will get ; items : GoldStack ; value : 5000 </Setting> - <Setting name="quest2" type="dict"> type : RETURN_ITEM ; name : Second quest ; desc : This is the second quest you will get ; items : GoldStack ; value : 5000 </Setting> + <Module name="objects"> + <Setting name="goldstack" type="dict"> type : GOLD ; modelname : GoldStack ; value : 5000 </Setting> + <Setting name="templeportal" type="dict"> type : PORTAL ; modelname : TempleEntrance ; dest : town </Setting> + <Setting name="quiller" type="dict"> type : QUESTGIVER ; modelname : Quiller ; stat1 : 20 ; stat2 : 343 </Setting> </Module> </Settings>
--- a/demos/rpg/maps/level1_objects.xml Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/maps/level1_objects.xml Thu Jun 03 21:35:06 2010 +0000 @@ -1,11 +1,8 @@ <?xml version='1.0' encoding='UTF-8'?> <Settings> - <Module name="items"> - <Setting name="itemlist" type="list"> gstack1 ; temple </Setting> - <Setting name="gstack1" type="dict"> typename : GoldStack ; value : 5000 ; posx : -3.0 ; posy : -3.0 </Setting> - <Setting name="temple" type="dict"> typename : TempleEntrance ; dest : town ; posx : 3.0 ; posy : 2.0 </Setting> - </Module> - <Module name="npcs"> - + <Module name="objects"> + <Setting name="objectlist" type="list"> gstack2 ; townportal </Setting> + <Setting name="gstack2" type="dict"> objectname : goldstack ; value : 5000 ; posx : -3.0 ; posy : -3.0 </Setting> + <Setting name="townportal" type="dict"> objectname : templeportal ; dest : town ; posx : 3.0 ; posy : 2.0 </Setting> </Module> </Settings>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/rpg/maps/quests.xml Thu Jun 03 21:35:06 2010 +0000 @@ -0,0 +1,16 @@ +<?xml version='1.0' encoding='UTF-8'?> +<Settings> + <Module name="Quiller"> + <Setting name="questlist" type="list"> test_quest1 ; test_quest2 </Setting> + <Setting name="test_quest1" type="dict"> type : RETURN_ITEM ; name : Test quest ; desc : This is the first quest you will get </Setting> + <Setting name="test_quest2" type="dict"> type : RETURN_ITEM ; name : Second quest ; desc : This is the second quest you will get ; items : GoldStack ; value : 5000 </Setting> + </Module> + <Module name="test_quest1_items"> + <Setting name="itemlist" type="list"> gold1 </Setting> + <Setting name="gold1" type="dict"> name : GOLD_COINS ; value : 5000 </Setting> + </Module> + <Module name="test_quest2_items"> + <Setting name="itemlist" type="list"> gold1 </Setting> + <Setting name="gold1" type="dict"> name : GOLD_COINS ; value : 5000 </Setting> + </Module> +</Settings>
--- a/demos/rpg/maps/town_objects.xml Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/maps/town_objects.xml Thu Jun 03 21:35:06 2010 +0000 @@ -1,12 +1,9 @@ <?xml version='1.0' encoding='UTF-8'?> <Settings> - <Module name="items"> - <Setting name="itemlist" type="list"> gstack1 ; temple </Setting> - <Setting name="gstack1" type="dict"> typename : GoldStack ; value : 5000 ; posx : 3.0 ; posy : 3.0 </Setting> - <Setting name="temple" type="dict"> typename : TempleEntrance ; dest : level1 ; posx : 3.0 ; posy : -2.0 </Setting> - </Module> - <Module name="npcs"> - <Setting name="npclist" type="list"> Quiller </Setting> - <Setting name="Quiller" type="dict"> typename : Quiller ; stat1 : 20 ; stat2 : 343 ; posx : 1.0 ; posy : 1.0 </Setting> + <Module name="objects"> + <Setting name="objectlist" type="list"> gstack1 ; temple ; Quiller </Setting> + <Setting name="gstack1" type="dict"> objectname : goldstack ; value : 5000 ; posx : 3.0 ; posy : 3.0 </Setting> + <Setting name="temple" type="dict"> objectname : templeportal ; dest : level1 ; posx : 3.0 ; posy : -2.0 </Setting> + <Setting name="Quiller" type="dict"> objectname : quiller ; posx : 1.0 ; posy : 1.0 </Setting> </Module> </Settings>
--- a/demos/rpg/scripts/actors/baseactor.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/actors/baseactor.py Thu Jun 03 21:35:06 2010 +0000 @@ -96,8 +96,8 @@ self._object.performNextAction() class Actor(BaseGameObject): - def __init__(self, gamecontroller, layer, typename, instancename, instanceid=None, createInstance=False): - super(Actor, self).__init__(gamecontroller, layer, typename, instancename, instanceid, createInstance) + def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): + super(Actor, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance) self._type = GameObjectTypes["DEFAULT"]
--- a/demos/rpg/scripts/actors/player.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/actors/player.py Thu Jun 03 21:35:06 2010 +0000 @@ -41,7 +41,7 @@ class Player(Actor): def __init__(self, gamecontroller, layer, playermodelname): - super(Player, self).__init__(gamecontroller, layer, "Player", playermodelname, "player", True) + super(Player, self).__init__(gamecontroller, layer, "Player", "player", playermodelname, "player", True) self._type = GameObjectTypes["PLAYER"] self._playermodelname = playermodelname
--- a/demos/rpg/scripts/actors/questgiver.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/actors/questgiver.py Thu Jun 03 21:35:06 2010 +0000 @@ -32,8 +32,8 @@ from scripts.actors.baseactor import Actor class QuestGiver(Actor): - def __init__(self, gamecontroller, layer, typename, instancename, instanceid=None, createInstance=False): - super(QuestGiver, self).__init__(gamecontroller, layer, typename, instancename, instanceid, createInstance) + def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): + super(QuestGiver, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance) self._type = GameObjectTypes["QUESTGIVER"] self._quests = []
--- a/demos/rpg/scripts/gamecontroller.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/gamecontroller.py Thu Jun 03 21:35:06 2010 +0000 @@ -218,28 +218,23 @@ cmd.append(arg) if cmd[0] == "spawn": - result = "Usage: spawn [item|actor] [object id] [posx] [posy]" - if len(cmd) != 5: + result = "Usage: spawn [object template] [posx] [posy]" + if len(cmd) != 4: return result else: try: - if cmd[1] == "item": - obj = self._scene.loadItem(cmd[2]) - elif cmd[1] == "actor": - obj = self._scene.loadActor(cmd[2]) - else: - return result + obj = self._scene.loadObject(cmd[1]) except ObjectNotFoundError, e: - result = "Error: Cannot load [" + cmd[2] + "]. It could not be found!" + result = "Error: Cannot load [" + cmd[1] + "]. It could not be found!" obj = None if obj: try: self._scene.addObjectToScene(obj) - obj.position = (float(cmd[3]), float(cmd[4])) + obj.position = (float(cmd[2]), float(cmd[3])) result = "--OK--" except ObjectAlreadyInSceneError, e: - result = "Error: [" + cmd[2] + "] is already on the scene." + result = "Error: [" + cmd[1] + "] is already on the scene." elif cmd[0] == "move": result = "Usage: move [object id] [posx] [posy]" @@ -252,6 +247,10 @@ result = "--OK--" else: result = "Error: [" + cmd[1] + "] does not exist on the scene." + + elif cmd[0] == "loadmap": + result = "Usage: loadmap [map name]" + return result @@ -290,6 +289,7 @@ self._switchmaprequested = True self._newmap = newmapname + #save before switching scenes self._scene.serialize() def endGame(self):
--- a/demos/rpg/scripts/objects/baseobject.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/objects/baseobject.py Thu Jun 03 21:35:06 2010 +0000 @@ -67,7 +67,7 @@ class BaseGameObject(object): - def __init__(self, gamecontroller, layer, typename, instancename, instanceid=None, createInstance=False): + def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): """ @param gamecontroller: A reference to the master game controller @param instancename: The name of the object to load. The object's XML file must @@ -81,7 +81,9 @@ self._gamecontroller = gamecontroller self._fifeobject = None - self._typename = typename + self._typename = typename + self._baseobjectname = baseobjectname + self._name = instancename if instanceid: self._id = instanceid @@ -128,23 +130,19 @@ curloc.setExactLayerCoordinates(self._position) self.location = curloc - def serialize(self, settings): + def serialize(self): lvars = {} - lvars['posx'] = self._position.x - lvars['posy'] = self._position.y - lvars['typename'] = self._typename - - module = getModuleByType(self._type) + (x,y) = self.position + lvars['posx'] = x + lvars['posy'] = y + lvars['type'] = self._typename + lvars['objectname'] = self._baseobjectname - settings.set(module, self._id, lvars) - - def deserialize(self, settings): - module = getModuleByType(self._type) + return lvars - lvars = settings.get(module, self._id, {}) - - x = float(lvars['posx']) - y = float(lvars['posy']) + def deserialize(self, valuedict): + x = float(valuedict['posx']) + y = float(valuedict['posy']) self.setMapPosition(x,y)
--- a/demos/rpg/scripts/objects/items.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/objects/items.py Thu Jun 03 21:35:06 2010 +0000 @@ -32,8 +32,8 @@ class BaseItem(BaseGameObject): - def __init__(self, gamecontroller, layer, typename, itemtype, itemname): - super(BaseItem, self).__init__(gamecontroller, layer, typename, itemtype, itemname, True) + def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): + super(BaseItem, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname, True) def _getItemType(self): return self._name @@ -45,8 +45,8 @@ itemname = property(_getItemName) class PickableItem(BaseItem): - def __init__(self, gamecontroller, layer, typename, itemtype, itemname): - super(PickableItem, self).__init__(gamecontroller, layer, typename, itemtype, itemname) + def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): + super(PickableItem, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) self._type = GameObjectTypes["ITEM"] def onPickUp(self): @@ -61,29 +61,21 @@ self._gamecontroller.scene.addObjectToScene(self) class GoldStack(PickableItem): - def __init__(self, gamecontroller, layer, typename, itemtype, itemname): - super(GoldStack, self).__init__(gamecontroller, layer, typename, itemtype, itemname) + def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): + super(GoldStack, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) self._value = 0 - def serialize(self, settings): - super(GoldStack, self).serialize(settings) - - module = getModuleByType(self._type) - - lvars = settings.get(module, self._id, {}) + def serialize(self): + lvars = super(GoldStack, self).serialize() lvars['value'] = self._value + + return lvars + + def deserialize(self, valuedict): + super(GoldStack, self).deserialize(valuedict) - settings.set(module, self._id, lvars) - - def deserialize(self, settings): - super(GoldStack, self).deserialize(settings) - - module = getModuleByType(self._type) - - lvars = settings.get(module, self._id, {}) - - self._value = int(lvars['value']) + self._value = int(valuedict['value']) def _getValue(self): return self._value @@ -94,30 +86,22 @@ value = property(_getValue, _setValue) class Portal(BaseItem): - def __init__(self, gamecontroller, layer, typename, itemtype, itemname): - super(Portal, self).__init__(gamecontroller, layer, typename, itemtype, itemname) + def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): + super(Portal, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) self._type = GameObjectTypes["PORTAL"] self._dest = None - def serialize(self, settings): - super(Portal, self).serialize(settings) - - module = getModuleByType(self._type) - - lvars = settings.get(module, self._id, {}) + def serialize(self): + lvars = super(Portal, self).serialize() lvars['dest'] = self._dest - settings.set(module, self._id, lvars) - - def deserialize(self, settings): - super(Portal, self).deserialize(settings) + return lvars - module = getModuleByType(self._type) + def deserialize(self, valuedict): + super(Portal, self).deserialize(valuedict) - lvars = settings.get(module, self._id, {}) - - self._dest = lvars['dest'] + self._dest = valuedict['dest'] def _getDest(self): return self._dest
--- a/demos/rpg/scripts/scene.py Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/scripts/scene.py Thu Jun 03 21:35:06 2010 +0000 @@ -24,7 +24,7 @@ # #################################################################### # This is the rio de hola client for FIFE. -import sys, os, re, math, random, shutil +import sys, os, re, math, random, shutil, uuid from fife import fife from fife.extensions.loaders import loadMapFile @@ -55,97 +55,79 @@ self._objectsettings = None self._modelsettings = None + self._questsettings = None - def loadItem(self, itemid): + def loadObject(self, objectname, objectid=None, valuedict=None): + if objectid: + identifier = objectid + else: + #identifier = uuid.uuid1() + identifier = "blkdjfkdj" + try: - itemdict = self._objectsettings.get("items", itemid, {}) - modeldict = self._modelsettings.get("models", itemdict["typename"], {}) - print itemdict + objdict = self._modelsettings.get("objects", objectname, {}) + modeldict = self._modelsettings.get("models", objdict["modelname"], {}) + + print objdict print modeldict + loadImportFile(modeldict["file"], self._gamecontroller.engine) + + if objdict["type"] == "GOLD": + newobject = GoldStack(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) + elif objdict["type"] == "PORTAL": + newobject = Portal(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) + elif objdict["type"] == "QUESTGIVER": + newobject = QuestGiver(self._gamecontroller, self.actorlayer, objdict["type"], objectname, modeldict["model"], identifier, True) + + for quest in self._questsettings.get(identifier, "questlist", []): + questdict = self._questsettings.get(identifier, quest, {}) + + if questdict['type'] == "RETURN_ITEM": + questobj = ReturnItemQuest(newobject, questdict['name'], questdict['desc']) + for ritem in self._questsettings.get(quest+"_items", "itemlist", []): + itemdict = self._questsettings.get(quest+"_items", ritem, {}) + if itemdict["name"] == "GOLD_COINS": + questobj.addRequiredGold(int(itemdict['value'])) + else: + questobj.addRequiredItem(ritem) + else: + questobj = Quest(actor, questdict['name'], questdict['desc']) + + newobject.addQuest(questobj) + + elif objdict["type"] == "NPC": + newobject = Actor(self._gamecontroller, self.actorlayer, objdict["type"], objectname, modeldict["model"], identifier, True) + else: + return None + + if valuedict: + newobject.deserialize(valuedict) + else: + newobject.deserialize(objdict) - if modeldict["type"] == "GOLD": - newitem = GoldStack(self._gamecontroller, self.itemlayer, itemdict["typename"], modeldict["model"], itemid) - newitem.value = itemdict["value"] - elif modeldict["type"] == "PORTAL": - newitem = Portal(self._gamecontroller, self.itemlayer, itemdict["typename"], modeldict["model"], itemid) - newitem.dest = itemdict["dest"] - else: - newitem = BaseItem(self._gamecontroller, self.itemlayer, itemdict["typename"], modeldict["model"], itemid) - - newitem.deserialize(self._objectsettings) - except KeyError, e: raise ObjectNotFoundError - return newitem - - def loadActor(self, actorid): - try: - objdict = self._objectsettings.get("npcs", actorid, {}) - modeldict = self._modelsettings.get("models", objdict["typename"], {}) - - loadImportFile(modeldict["file"], self._gamecontroller.engine) - - if modeldict["type"] == "QUESTGIVER": - actor = QuestGiver(self._gamecontroller, self.actorlayer, objdict["typename"], modeldict["model"], actorid, True) - questcount = self._modelsettings.get(actorid, "questcount", 0) - for x in range(1,questcount+1): - quest = "quest" + str(x) - questdict = self._modelsettings.get(actorid, quest, {}) - - if questdict['type'] == "RETURN_ITEM": - quest = ReturnItemQuest(actor, questdict['name'], questdict['desc']) - for ritem in questdict['items'].split(" , "): - if ritem == "GoldStack": - quest.addRequiredGold(int(questdict['value'])) - else: - quest.addRequiredItem(ritem) - else: - quest = Quest(actor, questdict['name'], questdict['desc']) - - actor.addQuest(quest) - - elif modeldict["type"] == "NPC": - actor = Actor(self._gamecontroller, self.actorlayer, objdict["typename"], modeldict["model"], npc, True) + return newobject - actor.setMapPosition(float(objdict["posx"]), float(objdict["posy"])) - - except KeyError, e: - raise ObjectNotFoundError - - return actor - - def loadItems(self, mapfilename): - for item in self._objectsettings.get("items", "itemlist", []): + def loadObjects(self, mapfilename): + for obj in self._objectsettings.get("objects", "objectlist", []): try: - newitem = self.loadItem(item) - self._gamecontroller.logger.log_debug("Loaded item: " + item) + objdict = self._objectsettings.get("objects", obj, {}) + newobj = self.loadObject(objdict["objectname"], obj, objdict) + self._gamecontroller.logger.log_debug("Loaded object: " + obj) except ObjectNotFoundError, e: - self._gamecontroller.logger.log_error("Error while loading item: " + item) + self._gamecontroller.logger.log_error("Error while loading object: " + obj) continue - + try: - self.addObjectToScene(newitem) + if newobj: + self.addObjectToScene(newobj) except ObjectAlreadyInSceneError, e: - self._gamecontroller.logger.log_error("Item already part of scene: " + newitem) + self._gamecontroller.logger.log_error("Object already part of scene:" + obj) continue - - def loadActors(self, mapfilename): - for npc in self._objectsettings.get("npcs", "npclist", []): - try: - actor = self.loadActor(npc) - self._gamecontroller.logger.log_debug("Loaded actor: " + npc) - except ObjectNotFoundError, e: - self._gamecontroller.logger.log_error("Error while loading actor:" + npc) - continue - - try: - self.addObjectToScene(actor) - except ObjectAlreadyInSceneError, e: - self._gamecontroller.logger.log_error("Actor already part of scene:" + actor) - continue - + def createPlayerObject(self): """ @todo: once we have all art assets this should be able to load one of 3 player models @@ -159,7 +141,8 @@ if os.path.isfile(playerfilename): player_settings = Setting(settings_file=playerfilename, copy_dist=False) - self._player.deserialize(player_settings) + pvals = player_settings.get("player", "player", {}) + self._player.deserialize(pvals) def createScene(self, mapname): mapfilename = os.path.join("maps", mapname + ".xml") @@ -177,10 +160,11 @@ objectfile = os.path.join("maps", mapname + "_objects.xml") modelfile = self._gamecontroller.settings.get("RPG", "AllObjectFile", "maps/allobjects.xml") + questfile = self._gamecontroller.settings.get("RPG", "QuestFile", "maps/quests.xml") - print objectfile - self._objectsettings = Setting(app_name="",settings_file=objectfile) - self._modelsettings = Setting(app_name="", settings_file=modelfile) + self._objectsettings = Setting(settings_file=objectfile) + self._modelsettings = Setting(settings_file=modelfile) + self._questsettings = Setting(settings_file=questfile) for cam in self._map.getCameras(): self._cameras[cam.getId()] = cam @@ -190,8 +174,9 @@ self._actorlayer = self._map.getLayer(self._gamecontroller.settings.get("RPG", "ActorLayer", "actor_layer")) self._itemlayer = self._map.getLayer(self._gamecontroller.settings.get("RPG", "ItemLayer", "item_layer")) - self.loadItems(mapfilename) - self.loadActors(mapfilename) + #self.loadItems(mapfilename) + #self.loadActors(mapfilename) + self.loadObjects(mapfilename) #finally load the player self.createPlayerObject() @@ -224,6 +209,7 @@ self._objectsettings = None self._modelsettings = None + self._questsettings = None def getInstancesAt(self, clickpoint, layer): """ @@ -250,6 +236,9 @@ raise ObjectAlreadyInSceneError def getObject(self, objid): + """ + @todo: throw ObjectNowFoundError + """ if self._objectlist.has_key(objid): return self._objectlist[objid] else: @@ -262,30 +251,27 @@ def serialize(self): filename = os.path.join("saves", self._mapname + "_save.xml") playerfilename = os.path.join("saves", "player_save.xml") - settings = Setting(settings_file=filename, copy_dist=False) + map_settings = Setting(settings_file=filename, copy_dist=False) player_settings = Setting(settings_file=playerfilename, copy_dist=False) - itemlist = [] - npclist = [] + objectlist = [] for obj in self._objectlist.values(): - obj.serialize(settings) - module = getModuleByType(obj.type) - if module == "items": - itemlist.append(obj.id) - elif module == "npcs": - npclist.append(obj.id) + ovals = obj.serialize() + map_settings.set("objects", obj.id, ovals) + objectlist.append(obj.id) - settings.set("items", "itemlist", itemlist) - settings.set("npcs", "npclist", npclist) + map_settings.set("objects", "objectlist", objectlist) - self._player.serialize(player_settings) + pvals = self._player.serialize() + player_settings.set("player", "player", pvals) - settings.saveSettings() + map_settings.saveSettings() player_settings.saveSettings() def deserialize(self): - pass + if self._mapname: + createScene(self._mapname) def updateScene(self): pass
--- a/demos/rpg/settings-dist.xml Thu Jun 03 02:40:05 2010 +0000 +++ b/demos/rpg/settings-dist.xml Thu Jun 03 21:35:06 2010 +0000 @@ -24,6 +24,7 @@ <Module name="RPG"> <Setting name="TownMapFile" type="str"> town </Setting> <Setting name="AllObjectFile" type="str"> maps/allobjects.xml </Setting> + <Setting name="QuestFile" type="str"> maps/quests.xml </Setting> <Setting name="DefaultCameraName" type="str"> camera1 </Setting> <Setting name="DefaultZoom" type="float"> 1.0 </Setting> <Setting name="ObjectNamespace" type="str"> http://www.fifengine.de/xml/rpg </Setting>