示例#1
0
        public void Add(Control control)
        {
            // Prevents infinite looping. If for some reason this does occur, throw exception because itll crash the game anyway
            if (control == this)
            {
                throw new InvalidOperationException();
            }

            // set parent to this.

            // get other loaded stuff from root control
            control.parent = this;

            /*
             * if(control.graphics == null)
             *  control.graphics = RootControl(control).graphics;
             *
             * if(control.contentManager == null)
             *  control.contentManager = RootControl(control).contentManager;
             *
             * // get loaded font from root.
             * if(control.font == null)
             *  control.font = RootControl(this).font;
             */

            // see if controls need to have textures loaded.
            if (RootControl(this).graphics != null && RootControl(this).contentManager != null)
            {
                control.LoadVisuals();
            }

            controls.Add(control);

            if (RootControl(control).gameTime != null)
            {
                control.Update(RootControl(control).gameTime);
            }

            /*
             * if(RootControl(this).graphics != null && RootControl(this).contentManager != null)
             *  control.LoadVisuals();
             *
             * if(RootControl(this).gameTime != null)
             *  control.Update(RootControl(this).gameTime);
             */
            //controls.Add(control.parent = this);
        }
示例#2
0
        public void Add(Control control)
        {
            // Prevents infinite looping. If for some reason this does occur, throw exception because itll crash the game anyway
            if (control == this)
                throw new InvalidOperationException();

            // set parent to this.

            // get other loaded stuff from root control
            control.parent = this;

            /*
            if(control.graphics == null)
                control.graphics = RootControl(control).graphics;

            if(control.contentManager == null)
                control.contentManager = RootControl(control).contentManager;

            // get loaded font from root.
            if(control.font == null)
                control.font = RootControl(this).font;
            */

            // see if controls need to have textures loaded.
            if (RootControl(this).graphics != null && RootControl(this).contentManager != null)
                control.LoadVisuals();

            controls.Add(control);

            if (RootControl(control).gameTime != null)
                control.Update(RootControl(control).gameTime);

            /*
            if(RootControl(this).graphics != null && RootControl(this).contentManager != null)
                control.LoadVisuals();

            if(RootControl(this).gameTime != null)
                control.Update(RootControl(this).gameTime);
             */
            //controls.Add(control.parent = this);
        }