Example #1
0
        /// <summary>
        /// Dfault Render Event Handler
        /// </summary>
        protected virtual void BaseGameForm_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            ElapsedTime = args.ElapsedTime;
            TotalTime = args.TotalTime;

            //Render all controls at root level
            foreach (IGameControl control in Controls.Values)
                if(control.Visible)
                    control.RaiseEvent(BaseControlEvents.Render, control, args);

            //Render all child forms
            foreach (IGameForm form in ChildForms.Values)
                if(form.Visible)
                    form.RaiseEvent(BaseControlEvents.Render,form,args);
        }
Example #2
0
        /// <summary>
        /// Do this instead of the usual render method
        /// </summary>
        protected override void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;

            //Draw locations for current
            Vector2 roleloc = screenloc + new Vector2((float)CurrentCredit.RoleOffset.X, (float)CurrentCredit.RoleOffset.Y);
            Vector2 nameloc = screenloc + new Vector2((float)CurrentCredit.NamesOffset.X, (float)CurrentCredit.NamesOffset.Y);
            Vector4 cv = CurrentCredit.Colour;
            cv.W = CurrentFadeLevel;
            Color colour = new Color(cv);

            //Draw locations for next
            Vector2 nextroleloc = screenloc + new Vector2((float)CurrentCredit.RoleOffset.X, (float)CurrentCredit.RoleOffset.Y);
            Vector2 nextnameloc = screenloc + new Vector2((float)CurrentCredit.NamesOffset.X, (float)CurrentCredit.NamesOffset.Y);
            Vector4 ncv = NextCredit.Colour;
            ncv.W = (1.0f - CurrentFadeLevel);
            Color nextcolour = new Color(ncv);

            //Draw Current
            args.spriteBatch.DrawString(Font, CurrentCredit.Role, roleloc, colour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            //Draw Next
            args.spriteBatch.DrawString(Font, NextCredit.Role, nextroleloc, nextcolour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth+0.1f);

            //Current Names
            if (CurrentCredit.Names.Length > 0)
            {
                string currentnames = CurrentCredit.Names;
                args.spriteBatch.DrawString(Font, currentnames, nameloc, colour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            }
            //Next Names
            if (NextCredit.Names.Length > 0)
            {
                string nextnames = NextCredit.Names;
                args.spriteBatch.DrawString(Font, nextnames, nextnameloc, nextcolour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            }
        }
Example #3
0
        /// <summary>
        /// This control completely overrides the base render functionality (it has two textures to draw)
        /// </summary>
        protected override void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;
            Color c = new Color(RenderColour);

            //Draw Groove
            args.spriteBatch.Draw(CurrentSkin, screenloc, GrooveSource, c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            FocusRectangle = new Rectangle((int)screenloc.X, (int)screenloc.Y, GrooveSource.Width, GrooveSource.Height);

            //Draw Bar
            //express the current value as a fraction
            float fraction = (Value - MinValue) / (MaxValue - MinValue);
            int barOffsetX=0, baroffsetY=0;

            //If the value is the highest it can be without stepping over the max it should be defaulted to 100
            if (Value + Step > MaxValue) fraction = 1.0f;

            if (this.Alignment == SliderAlignment.Horizontal)
            {
                barOffsetX = (int)((float)GrooveSource.Width * fraction) - (int)(BarSource.Width/2);
                baroffsetY = 0;
            }
            else if (this.Alignment == SliderAlignment.Vertical)
            {
                int barOffsetY = (int)((float)GrooveSource.Height * fraction) - (int)(BarSource.Height/2);
                barOffsetX = 0;
            }

            //Draw bar
            args.spriteBatch.Draw(CurrentSkin, new Vector2(screenloc.X+(float)barOffsetX,screenloc.Y + (float)baroffsetY), BarSource, c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth-0.1f);
        }
Example #4
0
        /// <summary>
        /// Do this instead of the usual render method
        /// </summary>
        protected override void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;
            Color c = new Color(RenderColour * 255);

            //Draw Text
            args.spriteBatch.DrawString(Font, Text, screenloc, c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);

            //Draw Cursor]
            if(ParentForm.UI.ControlWithInputFocus != null && ParentForm.UI.ControlWithInputFocus == this)
                if(blink)
                    args.spriteBatch.DrawString(Font, "|",new Vector2(screenloc.X + Font.MeasureString(Text).X,screenloc.Y), c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
        }