/// <summary> /// This function renders the contents of the console /// </summary> /// <param name="CurrTime">Current time information</param> protected override void DrawContents(GameTime CurrTime) { Rectangle LetterPos = new Rectangle(0, 0, cFont.CharacterHeight, cFont.CharacterWidth); //Draw the current command LetterPos.Y = ClientRegion.Height - cFont.CharacterHeight; cFont.WriteText(cDrawBatch, cCommand, LetterPos.Y, LetterPos.X, cFontColor); if (cCursorOn == true) { cFont.WriteAsciiCharacter(cDrawBatch, new byte[] { 220 }, cFont.CharacterHeight, LetterPos.Y, cFont.DetermineRenderWidth(cCommand), cFontColor); } //Draw all text lines in reverse order (bottom to top) if (cLines.Count > 0) { LetterPos.Y -= cFont.CharacterHeight; for (int Ctr = cLines.Count - 1; Ctr >= 0; Ctr--) { cFont.WriteText(cDrawBatch, cLines[Ctr], LetterPos.Y, LetterPos.X, cFontColor); LetterPos.Y -= cFont.CharacterHeight; } } }
/// <summary> /// Function to render the contents of hte control to the screen or rendering targetsd /// </summary> /// <param name="CurrTime">Current time information</param> protected override void DrawContents(GameTime CurrTime) { string[] Lines; int Ctr, LineWidth, LinesHeight, TextTop, TextLeft; if (cCaption.Length != 0) { Lines = cCaption.Split('\n'); LinesHeight = Lines.Length * FontSize; for (Ctr = 0; Ctr < Lines.Length; Ctr++) { LineWidth = cFont.DetermineRenderWidth(Lines[Ctr], FontSize); switch (Alignment) { case Justify.TopLeft: TextTop = 0 + (Ctr * FontSize); TextLeft = 0; break; case Justify.TopCenter: TextTop = 0 + (Ctr * FontSize); TextLeft = (Width - LineWidth) / 2; break; case Justify.TopRight: TextTop = 0 + (Ctr * FontSize); TextLeft = Width - LineWidth; break; case Justify.MiddleLeft: TextTop = ((Height - LinesHeight) / 2) + (Ctr * FontSize); TextLeft = 0; break; case Justify.MiddleRight: TextTop = ((Height - LinesHeight) / 2) + (Ctr * FontSize); TextLeft = Width - LineWidth; break; case Justify.BottomLeft: TextTop = (Height - LinesHeight) + (Ctr * FontSize); TextLeft = 0; break; case Justify.BottomCenter: TextTop = (Height - LinesHeight) + (Ctr * FontSize); TextLeft = (Width - LineWidth) / 2; break; case Justify.BottomRight: TextTop = (Height - LinesHeight) + (Ctr * FontSize); TextLeft = Width - LineWidth; break; default: //Middle Center TextTop = ((Height - LinesHeight) / 2) + (Ctr * FontSize); TextLeft = (Width - LineWidth) / 2; break; } cFont.WriteText(cDrawBatch, Lines[Ctr], FontSize, TextTop, TextLeft, FontColor); } } }
public void RenderFullCard(Rectangle DrawRegion, Color ImageTint, Color FontColor, SpriteBatch Draw, TextureFont Font) { Vector2 TitleOrigin, DescOrigin, ComStatOrigin; int TitleHeight, DescHeight, ComStatHeight; Rectangle ImageRegion, IconRegion; //Calculate dimensions of the parts of the card TitleOrigin.X = (DrawRegion.Width * FULLMARGINLEFTRIGHTPERCENT) + DrawRegion.X; TitleOrigin.Y = (DrawRegion.Height * FULLTITLETOPPERCENT) + DrawRegion.Y; TitleHeight = (int)(DrawRegion.Height * FULLTITLEHEIGHTPERCENT); DescOrigin.X = TitleOrigin.X; DescOrigin.Y = (DrawRegion.Height * FULLDESCTOPPERCENT) + DrawRegion.Y; DescHeight = (int)(DrawRegion.Height * FULLDESCTEXTHEIGHTPERCENT); ComStatOrigin.X = (DrawRegion.Width * FULLCOMBATSTATSLEFTPERCENT) + DrawRegion.X; ComStatOrigin.Y = DrawRegion.Height - (DrawRegion.Height * FULLCOMBATSTATSHEIGHT) - (DrawRegion.Height * FULLMARGINTOPBOTTOMPERCENT) + DrawRegion.Y; ComStatHeight = (int)(DrawRegion.Height * FULLCOMBATSTATSHEIGHT); ImageRegion.X = (int)TitleOrigin.X; ImageRegion.Y = (int)(DrawRegion.Height * FULLMARGINTOPBOTTOMPERCENT) + DrawRegion.Y; ImageRegion.Width = DrawRegion.Width - (int)(DrawRegion.Width * FULLMARGINLEFTRIGHTPERCENT * 2); ImageRegion.Height = (int)(DrawRegion.Height * FULLIMAGEHEIGHTPERCENT); IconRegion.X = (int)ComStatOrigin.X; IconRegion.Y = (int)ComStatOrigin.Y; IconRegion.Width = ComStatHeight; IconRegion.Height = ComStatHeight; //Draw the card Draw.Draw(cBackground, DrawRegion, cBackground.Bounds, ImageTint); Draw.Draw(cImage, ImageRegion, cImage.Bounds, ImageTint); Draw.Draw(cHeartIcon, IconRegion, cHeartIcon.Bounds, ImageTint); IconRegion.X += ComStatHeight * 5; Draw.Draw(cSwordIcon, IconRegion, cSwordIcon.Bounds, ImageTint); Font.WriteText(Draw, cTitle, TitleHeight, (int)TitleOrigin.Y, (int)TitleOrigin.X, FontColor); Font.WriteText(Draw, cDesc, DescHeight, (int)DescOrigin.Y, (int)DescOrigin.X, FontColor); Font.WriteText(Draw, " " + cCurrHealth + "/" + cMaxHealth + " " + cAttack, ComStatHeight, (int)ComStatOrigin.Y, (int)ComStatOrigin.X, FontColor); }