using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using System.Xml; using DW.UI; using Microsoft.Xna.Framework; using System.Diagnostics; using DW.Data; namespace DW.Stream { /// /// Each camera represents the local viewport space inside the game window /// public class Camera { public Viewport viewport; public HUD hud; /// /// Each camera represents the local viewport space inside the window /// /// Location of the HUD associated with this pane /// Local space viewport public Camera(string fileName, Rectangle location) { viewport = new Viewport(); X = location.X; Y = location.Y; Width = location.Width; Height = location.Height; try { XmlDocument reader = new XmlDocument(); reader.Load(fileName); hud = new HUD(viewport); foreach (XmlNode node in reader.ChildNodes) { if (node.Name == "HUDSettings") { hud.LoadScreenObjects(node); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Error reading xml"); throw e; } } /// /// Find the quadrant viewport for the individual HUDS /// /// Local viewport public void Resize(Rectangle rect) { // Set Size X = rect.X; Y = rect.Y; Width = rect.Width; Height = rect.Height; // Pass it along hud.Resize(rect); } /// /// Handles Update for the cameras and into the HUDs - other classes should /// use this for Update calls as well /// /// Passed down from engine, controls the HUD timer /// Provides a snapshot of timing values public void Update(Stopwatch gameTimer, GameTime gametime) { hud.Update(gameTimer, gametime); } /// /// Draws each camera and the args that belong to the camera /// public void Draw(GameTime gameTime, ObjectLibrary objLib) { objLib.Draw(gameTime); hud.Draw(Renderer.spriteBatch); } #region Dimensions /// /// Get/Set the pane's viewport height /// public int Height { get{return this.viewport.Height;} set{this.viewport.Height = value;} } /// /// Get/Set the pane's viewport width /// public int Width { get{return this.viewport.Width;} set{this.viewport.Width = value;} } /// /// Get/Set the pane's viewport x coordinate (top left corner is 0,0) /// public int X { get{return this.viewport.X;} set{this.viewport.X = value;} } /// /// Get/Set the pane's viewport y coordinate (top left corner is 0,0) /// public int Y { get{return this.viewport.Y;} set{this.viewport.Y = value;} } #endregion } }