using System; using Microsoft.Xna.Framework.Graphics; using System.Xml; using DW.UserInterface_2D; using Microsoft.Xna.Framework; using System.Diagnostics; using DWGame.Player; namespace DW.Stream { /// /// Each pane represents the local viewport space inside the window /// If in 3D, each 'pane' would be a camera /// public class Pane { public Viewport viewport; public HUD hud; /// /// Each pane represents the local viewport space inside the window /// /// Location of the HUD associated with this pane /// Local space viewport public Pane(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 panes 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) { #region HUD Update // Update the Game Time int seconds = ((int)gameTimer.Elapsed.TotalSeconds) % 60; int minutes = ((int)gameTimer.Elapsed.TotalSeconds) / 60; string formatedSeconds = seconds.ToString(); if (seconds < 10) { formatedSeconds = "0" + seconds.ToString(); } string timing = minutes.ToString() + ":" + formatedSeconds; this.hud.textDisplays[this.hud.getHUDIndex("timerText")].text = timing; string score = Human.human.score.ToString(); this.hud.textDisplays[this.hud.getHUDIndex("scoreText")].text = score; // Call update on HUD if and ONLY if you are using the event system for DIALOGUE // hud.Update(); #endregion } /// /// Draws each pane and the objects that belong to the pane /// public void Draw() { // Not good to pass a global into the HUD but needs redev to fix so !!HACK!! 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 = Renderer.Dimensions.CLIENTBOUNDS.Height;} } /// /// Get/Set the pane's viewport width /// public int Width { get{return this.viewport.Width;} set{this.viewport.Width = Renderer.Dimensions.CLIENTBOUNDS.Width;} } /// /// 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 = Renderer.Dimensions.CLIENTBOUNDS.X;} } /// /// 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 = Renderer.Dimensions.CLIENTBOUNDS.Y;} } #endregion } }