changeset 122:21dd4da40eab

Added Graphics component.
author KarstenBock@gmx.net
date Tue, 27 Sep 2011 15:50:28 +0200
parents 24edf5d53083
children d1364aeb61c6
files src/parpg/components/__init__.py src/parpg/components/graphics.py src/parpg/gamemodel.py
diffstat 3 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/components/__init__.py	Tue Sep 27 15:38:24 2011 +0200
+++ b/src/parpg/components/__init__.py	Tue Sep 27 15:50:28 2011 +0200
@@ -11,6 +11,7 @@
 from equip import Equip
 from general import General
 from behaviour import Behaviour
+from graphics import Graphics
 
 components = {
         "general": General(),
@@ -26,4 +27,5 @@
         "equipable": Equipable(),
         "equip": Equip(),
         "behaviour": Behaviour(),
+        "graphics": Graphics(),
     }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parpg/components/graphics.py	Tue Sep 27 15:50:28 2011 +0200
@@ -0,0 +1,22 @@
+#   This program is free software: you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#   
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#   
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from base import Base
+
+
+class Graphics(Base):
+    """Component that stores the values for the graphical representation"""
+    
+    def __init__(self):
+        """Constructor"""
+        Base.__init__(self, gfx=str)
\ No newline at end of file
--- a/src/parpg/gamemodel.py	Tue Sep 27 15:38:24 2011 +0200
+++ b/src/parpg/gamemodel.py	Tue Sep 27 15:50:28 2011 +0200
@@ -334,11 +334,11 @@
         agent[unique_agent_id] = agent_values
         self.agents[namespace].update(agent)
         object_model = ""
-        if agent_values["Entity"].has_key("fifeagent") \
-           and agent_values["Entity"]["fifeagent"].has_key("gfx"): 
-            object_model = agent_values["Entity"]["fifeagent"]["gfx"]
+        if agent_values["Entity"].has_key("graphics") \
+           and agent_values["Entity"]["graphics"].has_key("gfx"): 
+            object_model = agent_values["Entity"]["graphics"]["gfx"]
         else:
-            object_model = self.object_db[agent_values["Template"]]["fifeagent"]["gfx"]
+            object_model = self.object_db[agent_values["Template"]]["graphics"]["gfx"]
         import_file = self.agent_import_files[object_model]
         loadImportFile(self.obj_loader, import_file, self.engine)
         
@@ -400,10 +400,11 @@
 
     def createAgent(self, agent, inst_id, world):
         entity_data = deepcopy(agent["Entity"])
+        entity_data["fifeagent"] = {}
         if agent.has_key("Template"):
             entity_data = self.checkAttributes(entity_data, agent["Template"])
-        object_id = entity_data["fifeagent"]["gfx"] \
-                                if entity_data["fifeagent"].has_key("gfx") \
+        object_id = entity_data["graphics"]["gfx"] \
+                                if entity_data["graphics"].has_key("gfx") \
                                 else "generic_item"
         map_obj = self.fife_model.getObject(str(object_id), "PARPG")
         if not map_obj: