changeset 106:1fa74d3229d5

Omission of a camera viewport in xml map files now indicates that the camera should use the full window.
author jwt@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 25 Jul 2008 00:59:08 +0000
parents 2241b0d5379e
children 860d81602a2a
files clients/rio_de_hola/maps/shrine.xml engine/extensions/savers.py engine/extensions/serializers/xmlmap.py
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/clients/rio_de_hola/maps/shrine.xml	Thu Jul 24 13:20:39 2008 +0000
+++ b/clients/rio_de_hola/maps/shrine.xml	Fri Jul 25 00:59:08 2008 +0000
@@ -6110,7 +6110,7 @@
 			<i x="-19.0" o="beach_bar" z="0.0" y="2.0" r="180"></i>
 		</instances>
 	</layer>
-	<camera ref_cell_width="64" zoom="1.0" tilt="-42.0" viewport="0,0,1280,800" id="main" ref_layer_id="TechdemoMapGroundObjectLayer" ref_cell_height="48" rotation="45.0">
+	<camera ref_cell_width="64" zoom="1.0" tilt="-42.0" id="main" ref_layer_id="TechdemoMapGroundObjectLayer" ref_cell_height="48" rotation="45.0">
 	</camera>
 	<camera ref_cell_width="128" zoom="1.0" tilt="-42.0" viewport="10,10,400,250" id="small" ref_layer_id="TechdemoMapTileLayer" ref_cell_height="96" rotation="45.0">
 	</camera>
--- a/engine/extensions/savers.py	Thu Jul 24 13:20:39 2008 +0000
+++ b/engine/extensions/savers.py	Fri Jul 25 00:59:08 2008 +0000
@@ -209,7 +209,6 @@
 						(None, 'ref_layer_id'): 'ref_layer_id',
 						(None, 'ref_cell_width'): 'ref_cell_width',
 						(None, 'ref_cell_height'): 'ref_cell_height',
-						(None, 'viewport'): 'viewport',
 				}
 
 				attr_vals = {
@@ -220,9 +219,13 @@
 					(None, 'ref_layer_id'): cam.getLocation().getLayer().getId(),
 					(None, 'ref_cell_width'): str( celldimensions.x ),
 					(None, 'ref_cell_height'): str( celldimensions.y ),
-					(None, 'viewport'): '%d,%d,%d,%d' % (viewport.x, viewport.y, viewport.w, viewport.h),
 				}
 
+				# add a viewport entry if the cam isn't full sized
+				if not (viewport == self.engine.getRenderBackend().getArea()):
+					attr_names[(None,'viewport')] = 'viewport'
+					attr_vals[(None,'viewport')] = '%d,%d,%d,%d' % (viewport.x, viewport.y, viewport.w, viewport.h)
+
 				attrs = AttributesNSImpl( attr_vals, attr_names )
 				self.startElement( 'camera', attrs );
 				self.endElement( 'camera' );
--- a/engine/extensions/serializers/xmlmap.py	Thu Jul 24 13:20:39 2008 +0000
+++ b/engine/extensions/serializers/xmlmap.py	Fri Jul 25 00:59:08 2008 +0000
@@ -229,12 +229,15 @@
 			if not rotation: rotation = 0
 
 			if not id: self._err('Camera declared without an id.')
-			if not viewport: self._err(''.join(['Camera ', str(id), ' declared without a viewport.']))
 			if not ref_layer_id: self._err(''.join(['Camera ', str(id), ' declared with no reference layer.']))
 			if not (ref_cell_width and ref_cell_height): self._err(''.join(['Camera ', str(id), ' declared without reference cell dimensions.']))
 
 			try:
-				cam = self.engine.getView().addCamera(str(id), map.getLayer(str(ref_layer_id)),fife.Rect(*[int(c) for c in viewport.split(',')]),fife.ExactModelCoordinate(0,0,0))
+				if viewport:
+					cam = self.engine.getView().addCamera(str(id), map.getLayer(str(ref_layer_id)),fife.Rect(*[int(c) for c in viewport.split(',')]),fife.ExactModelCoordinate(0,0,0))
+				else:
+					screen = self.engine.getRenderBackend()
+					cam = self.engine.getView().addCamera(str(id), map.getLayer(str(ref_layer_id)),fife.Rect(0,0,screen.getScreenWidth(),screen.getScreenHeight()),fife.ExactModelCoordinate(0,0,0))
 
 				cam.setCellImageDimensions(int(ref_cell_width), int(ref_cell_height))
 				cam.setRotation(float(rotation))