Beispiel #1
0
    ////////////////////////////////////////////////////////////////////////////                     
    ////////////////////////////////////////////////////////////////////////////

    #endregion

    #region //// Properties ////////

    ////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////

    #endregion

    #region //// Construstors //////

    ////////////////////////////////////////////////////////////////////////////       
    ////////////////////////////////////////////////////////////////////////////

    #endregion
    
    #region //// Methods ///////////    
    
    ////////////////////////////////////////////////////////////////////////////    
    public static Container Load(Manager manager, string asset)
    {
      Container win = null;
      LayoutXmlDocument doc = new LayoutXmlDocument();
      ArchiveManager content = new ArchiveManager(manager.Game.Services);            
      
      try
      {      
        content.RootDirectory = manager.LayoutDirectory;
        
        #if (!XBOX && !XBOX_FAKE)
        
        string file = content.RootDirectory + asset;
        
        if (File.Exists(file))
        {
          doc.Load(file);
        }
        else
        
        #endif
        {
          doc = content.Load<LayoutXmlDocument>(asset);
        }  
          
        
        if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes)
        {       
          XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);         
          string cls = node.Attributes["Class"].Value;
          Type type = Type.GetType(cls);
          
          if (type == null)
          {
            cls = "TomShane.Neoforce.Controls." + cls;
            type = Type.GetType(cls);
          }
                    
          win = (Container)LoadControl(manager, node, type, null);                    
        }  
        
      }
      finally
      {
        content.Dispose();
      }                  
      
      return win;
    }
Beispiel #2
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Properties ////////

        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Construstors //////

        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Methods ///////////

        ////////////////////////////////////////////////////////////////////////////
        public static Container Load(Manager manager, string asset)
        {
            Container         win     = null;
            LayoutXmlDocument doc     = new LayoutXmlDocument();
            ArchiveManager    content = new ArchiveManager(manager.Services);

            try
            {
                content.RootDirectory = manager.LayoutDirectory;

        #if (!XBOX && !XBOX_FAKE)
                string file = content.RootDirectory + asset;

                if (File.Exists(file))
                {
                    doc.Load(file);
                }
                else
        #endif
                {
                    doc = content.Load <LayoutXmlDocument>(asset);
                }


                if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes)
                {
                    XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);
                    string  cls  = node.Attributes["Class"].Value;
                    Type    type = Type.GetType(cls);

                    if (type == null)
                    {
                        cls  = "TomShane.Neoforce.Controls." + cls;
                        type = Type.GetType(cls);
                    }

                    win = (Container)LoadControl(manager, node, type, null);
                }
            }
            finally
            {
                content.Dispose();
            }

            return(win);
        }
Beispiel #3
0
        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes a new instance of the Manager class.
        /// </summary>
        /// <param name="game">
        /// The Game class.
        /// </param>
        /// <param name="graphics">
        /// The GraphicsDeviceManager class provided by the Game class.
        /// </param>
        /// <param name="skin">
        /// The name of the skin being loaded at the start.
        /// </param>
        public Manager(Game game, GraphicsDeviceManager graphics, string skin)
            : base(game)
        {
            disposing = false;

            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleUnhadledExceptions);

            content = new ArchiveManager(Game.Services);
            input = new InputSystem(this, new InputOffset(0, 0, 1f, 1f));
            components = new List<Component>();
            controls = new ControlsList();
            orderList = new ControlsList();

            this.graphics = graphics;
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(PrepareGraphicsDevice);

            skinName = skin;

            #if (XBOX_FAKE)
            game.Window.Title += " (XBOX_FAKE)";
            #endif

            states.Buttons = new Control[32];
            states.Click = -1;
            states.Over = null;

            input.MouseDown += new MouseEventHandler(MouseDownProcess);
            input.MouseUp += new MouseEventHandler(MouseUpProcess);
            input.MousePress += new MouseEventHandler(MousePressProcess);
            input.MouseMove += new MouseEventHandler(MouseMoveProcess);
            input.MouseScroll += new MouseEventHandler(MouseScrollProcess);

            input.GamePadDown += new GamePadEventHandler(GamePadDownProcess);
            input.GamePadUp += new GamePadEventHandler(GamePadUpProcess);
            input.GamePadPress += new GamePadEventHandler(GamePadPressProcess);

            input.KeyDown += new KeyEventHandler(KeyDownProcess);
            input.KeyUp += new KeyEventHandler(KeyUpProcess);
            input.KeyPress += new KeyEventHandler(KeyPressProcess);

            keyboardLayouts.Add(new KeyboardLayout());
            keyboardLayouts.Add(new CzechKeyboardLayout());
            keyboardLayouts.Add(new GermanKeyboardLayout());
        }
Beispiel #4
0
        ////////////////////////////////////////////////////////////////////////////
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.disposing = true;

                // Recursively disposing all controls added to the manager and its child controls.
                if (controls != null)
                {
                    int c = controls.Count;
                    for (int i = 0; i < c; i++)
                    {
                        if (controls.Count > 0) controls[0].Dispose();
                    }
                }

                // Disposing all components added to manager.
                if (components != null)
                {
                    int c = components.Count;
                    for (int i = 0; i < c; i++)
                    {
                        if (components.Count > 0) components[0].Dispose();
                    }
                }

                if (content != null)
                {
                    content.Unload();
                    content.Dispose();
                    content = null;
                }

                if (renderer != null)
                {
                    renderer.Dispose();
                    renderer = null;
                }
                if (input != null)
                {
                    input.Dispose();
                    input = null;
                }
            }
            if (GraphicsDevice != null)
                GraphicsDevice.DeviceReset -= new System.EventHandler<System.EventArgs>(GraphicsDevice_DeviceReset);
            base.Dispose(disposing);
        }
Beispiel #5
0
        ////////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Destructors ///////

        ////////////////////////////////////////////////////////////////////////////
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.disposing = true;

                // Recursively disposing all controls added to the manager and its child controls.
                if (controls != null)
                {
                    int c = controls.Count;
                    for (int i = 0; i < c; i++)
                    {
                        if (controls.Count > 0) controls[0].Dispose();
                    }
                }

                // Disposing all components added to manager.
                if (components != null)
                {
                    int c = components.Count;
                    for (int i = 0; i < c; i++)
                    {
                        if (components.Count > 0) components[0].Dispose();
                    }
                }

                if (content != null)
                {
                    content.Unload();
                    content.Dispose();
                    content = null;
                }

                if (renderer != null)
                {
                    renderer.Dispose();
                    renderer = null;
                }
                if (input != null)
                {
                    input.Dispose();
                    input = null;
                }
            }
            base.Dispose(disposing);
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the Manager class.
        /// </summary>
        /// <param name="game">
        /// The Game class.
        /// </param>
        /// <param name="graphics">
        /// The GraphicsDeviceManager class provided by the Game class.
        /// </param>
        /// <param name="skin">
        /// The name of the skin being loaded at the start.
        /// </param>
        public Manager(Game game, GraphicsDeviceManager graphics, string skin)
            : base(game)
        {
            disposing = false;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleUnhadledExceptions);

            #if (!XBOX && !XBOX_FAKE)
            menuDelay = SystemInformation.MenuShowDelay;
            doubleClickTime = SystemInformation.DoubleClickTime;
            #endif

            #if (!XBOX && !XBOX_FAKE)
            window = (Form)Form.FromHandle(Game.Window.Handle);
            window.FormClosing += new FormClosingEventHandler(Window_FormClosing);
            #endif
            content = new ArchiveManager(Game.Services);
            input = new InputSystem(this, new InputOffset(0, 0, 1f, 1f));
            components = new List<Component>();
            controls = new ControlsList();
            orderList = new ControlsList();

            this.graphics = graphics;
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(PrepareGraphicsDevice);

            skinName = skin;

            #if (XBOX_FAKE)
            game.Window.Title += " (XBOX_FAKE)";
            #endif
            states.Buttons = new Control[32];
            states.Click = -1;
            states.Over = null;

            // Hook up the input system mouse events.
            input.MouseDown += new MouseEventHandler(MouseDownProcess);
            input.MouseUp += new MouseEventHandler(MouseUpProcess);
            input.MousePress += new MouseEventHandler(MousePressProcess);
            input.MouseMove += new MouseEventHandler(MouseMoveProcess);
            input.MouseScroll += new MouseEventHandler(MouseScrollProcess);
            // Hook up the input system gamepad events.
            input.GamePadDown += new GamePadEventHandler(GamePadDownProcess);
            input.GamePadUp += new GamePadEventHandler(GamePadUpProcess);
            input.GamePadPress += new GamePadEventHandler(GamePadPressProcess);

            // Hook up the input system key events.
            input.KeyDown += new KeyEventHandler(KeyDownProcess);
            input.KeyUp += new KeyEventHandler(KeyUpProcess);
            input.KeyPress += new KeyEventHandler(KeyPressProcess);

            // Create the English (US), Czech, and German keyboard layouts.
            keyboardLayouts.Add(new KeyboardLayout());
            keyboardLayouts.Add(new CzechKeyboardLayout());
            keyboardLayouts.Add(new GermanKeyboardLayout());
        }