public void Draw(GameTime time, GraphicsContext gfx) { gfx.BeginDraw(); var bg = _theme.Theme.GetAccentColor().Darken(0.5F); gfx.DrawRectangle(0, 0, gfx.Width, (int)MathHelper.Lerp(1, gfx.Height, _bgWipeAnim), bg); if (_isTextShowing) { gfx.DrawString(_peacegateError, 0, 0, Color.White, _theme.Theme.GetFont(TextFontStyle.Mono), TextAlignment.Left, gfx.Width, Plex.Engine.TextRenderers.WrapMode.Words); } gfx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { if (_finished) { return; } while (_frames > 0) { _updateShader(); _i++; _frames--; } gfx.BeginDraw(_shader); gfx.DrawRectangle(0, 0, gfx.Width, gfx.Height, Color.Black); gfx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { var headerFont = _theme.Theme.GetFont(TextFontStyle.Header1); var highlightFont = _theme.Theme.GetFont(TextFontStyle.Highlight); string header = "Government Alert"; string highlight = "Your system has alerted the Government due to frequent notorious actions."; var headerMeasure = TextRenderer.MeasureText(header, headerFont, gfx.Width / 2, Plex.Engine.TextRenderers.WrapMode.Words); var highlightMeasure = TextRenderer.MeasureText(highlight, highlightFont, gfx.Width / 2, Plex.Engine.TextRenderers.WrapMode.Words); float y = (gfx.Height - (headerMeasure.Y + highlightMeasure.Y + 5)) / 2; gfx.BeginDraw(); gfx.DrawString(header, (gfx.Width - (gfx.Width / 2)) / 2, (int)y, _theme.Theme.GetFontColor(TextFontStyle.Header1) * _screenShroudOpacity, headerFont, TextAlignment.Center, gfx.Width / 2, Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(highlight, (gfx.Width - (gfx.Width / 2)) / 2, (int)(y + headerMeasure.Y + 5), _theme.Theme.GetFontColor(TextFontStyle.Highlight) * _screenShroudOpacity, highlightFont, TextAlignment.Center, gfx.Width / 2, Plex.Engine.TextRenderers.WrapMode.Words); gfx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { string header = "Hurry up!"; string countdown = _timeout.ToString("#.##"); var headFont = _theme.Theme.GetFont(TextFontStyle.System); var countdownFont = _theme.Theme.GetFont(TextFontStyle.Header1); var headColor = _theme.Theme.GetFontColor(TextFontStyle.System); var countdownColor = _theme.Theme.GetFontColor(TextFontStyle.Header1); var headMeasure = headFont.MeasureString(header); var countdownMeasure = countdownFont.MeasureString(countdown); gfx.BeginDraw(); gfx.DrawString(countdown, (gfx.Width - (int)countdownMeasure.X) - 45, (gfx.Height - (int)countdownMeasure.Y) - 45, countdownColor, countdownFont, TextAlignment.Left); gfx.DrawString(header, (gfx.Width - (int)headMeasure.X) - 45, (((gfx.Height - (int)countdownMeasure.Y) - 45) - (int)headMeasure.Y) - 5, headColor, headFont, TextAlignment.Left); gfx.EndDraw(); }
/// <inheritdoc/> public void Draw(GameTime time, GraphicsContext ctx) { int peacegateX = (_ui.ScreenWidth - _peacegate.Width) / 2; int peacegateYMax = (_ui.ScreenHeight - _peacegate.Height) / 2; int peacegateYMin = peacegateYMax + (int)(_ui.ScreenHeight * 0.15); int peacegateY = (int)MathHelper.Lerp(peacegateYMin, peacegateYMax, _peacegateIconOpacity); ctx.BeginDraw(); ctx.DrawRectangle(peacegateX, peacegateY, _peacegate.Width, _peacegate.Height, _peacegate, Color.White * _peacegateIconOpacity); int _textY = peacegateY + _peacegate.Height + 25; string text = "Welcome to Peacegate."; var measure = TextRenderer.MeasureText(text, _bootFont, int.MaxValue, Plex.Engine.TextRenderers.WrapMode.None); int _textX = ((_ui.ScreenWidth - (int)measure.X) / 2); ctx.DrawString(text, _textX, _textY, Color.White * _peacegateIconOpacity, _bootFont, TextAlignment.Left, int.MaxValue, Plex.Engine.TextRenderers.WrapMode.None); ctx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { gfx.BeginDraw(); gfx.Clear(Color.Black * MathHelper.Lerp(0, 0.75F, _textHeadAnim)); int _half = (gfx.Width - (gfx.Width / 2)) / 2; int headYBase = (!_animReversed) ? _textStartY : _textStartY - (gfx.Height / 10); int headYUnder = (_animReversed) ? _textStartY : _textStartY + (gfx.Height / 10); int headYAnim = (int)MathHelper.Lerp(headYUnder, headYBase, _textHeadAnim); gfx.DrawString(_head, new Vector2(_half, headYAnim), _theme.Theme.GetFontColor(TextFontStyle.Header1) * _textHeadAnim, _theme.Theme.GetFont(TextFontStyle.Header1), TextAlignment.Center, gfx.Width / 2, WrapMode.Words); int descYBase = _textStartY + _headHeight + _headDescPadV; int descYUpper = (!_animReversed) ? descYBase : descYBase - (gfx.Height / 10); int descYLower = (_animReversed) ? descYBase + (gfx.Height / 10) : descYBase; int descYAnim = (int)MathHelper.Lerp(descYLower, descYUpper, _textDescAnim); gfx.DrawString(_desc, new Vector2(_half, descYAnim), _theme.Theme.GetFontColor(TextFontStyle.System) * _textDescAnim, _theme.Theme.GetFont(TextFontStyle.System), TextAlignment.Center, gfx.Width / 2, WrapMode.Words); int mutedY = descYAnim + _descMutePadV + _descHeight; gfx.DrawString(_paused, new Vector2(_half, mutedY), _theme.Theme.GetFontColor(TextFontStyle.Muted) * _textDescAnim, _theme.Theme.GetFont(TextFontStyle.Muted), TextAlignment.Center, gfx.Width / 2, WrapMode.Words); int x = gfx.X; int y = gfx.Y; int w = gfx.Width; int h = gfx.Height; gfx.X = _button.X; gfx.Y = _button.Y; gfx.Width = _button.Width; gfx.Height = _button.Height; _theme.Theme.DrawButton(gfx, _buttonText, null, GetButtonState(), false, Rectangle.Empty, new Rectangle(_buttonMarginH, _buttonMarginV, _button.Width - (_buttonMarginH * 2), _button.Height - (_buttonMarginV * 2))); gfx.X = x; gfx.Y = y; gfx.Width = w; gfx.Height = h; gfx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { gfx.BeginDraw(); gfx.Clear((Color.Black * 0.75F) * _shroudOpacity); gfx.Clear((Color.Red * 0.25F) * _shroudOpacity); int warnHeight = _warning.Height * 2; var textFont = _theme.Theme.GetFont(TextFontStyle.Header1); var descFont = _theme.Theme.GetFont(TextFontStyle.Header3); var textColor = Color.Red.Lighten(0.25F); var descColor = Color.White; int screenRealEstate = (gfx.Width / 2); var textMeasure = TextRenderer.MeasureText(_text, textFont, screenRealEstate, Plex.Engine.TextRenderers.WrapMode.Words); var descMeasure = TextRenderer.MeasureText(_desc, descFont, screenRealEstate, Plex.Engine.TextRenderers.WrapMode.Words); int totalHeight = warnHeight + 30 + (int)textMeasure.Y + 10 + (int)descMeasure.Y; gfx.DrawRectangle((gfx.Width - (_warning.Width * 2)) / 2, (gfx.Height - totalHeight) / 2, _warning.Width * 2, warnHeight, _warning, Color.Red * _warningOpacity); int initialY = (gfx.Height - totalHeight) / 2; gfx.DrawString(_text, (gfx.Width - screenRealEstate) / 2, initialY + warnHeight + 30, textColor * _textOpacity, textFont, TextAlignment.Center, screenRealEstate, Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(_desc, (gfx.Width - screenRealEstate) / 2, initialY + warnHeight + 30 + (int)textMeasure.Y + 10, descColor * _descOpacity, descFont, TextAlignment.Center, screenRealEstate, Plex.Engine.TextRenderers.WrapMode.Words); gfx.Clear((Color.Black * 0.95F) * _tutorialShroudOpacity); var tutTextMeasure = TextRenderer.MeasureText(_tutorialHead, textFont, (gfx.Width - 30), Plex.Engine.TextRenderers.WrapMode.Words); var tutBodyMeasure = TextRenderer.MeasureText(_tutorialBody, descFont, (gfx.Width - 30), Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(_tutorialHead, 15, 15, textColor * _tutorialTextOpacity, textFont, TextAlignment.Left, (gfx.Width - 30), Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(_tutorialBody, 15, 15 + (int)tutTextMeasure.Y + 10, descColor * _tutorialTextOpacity, descFont, TextAlignment.Left, (gfx.Width - 30), Plex.Engine.TextRenderers.WrapMode.Words); gfx.EndDraw(); }
/// <inheritdoc/> public override void Draw(GameTime time, GraphicsContext gfx) { gfx.BeginDraw(); var head1 = _theme.Theme.GetFont(TextFontStyle.Header1); var head2 = _theme.Theme.GetFont(TextFontStyle.Header3); var sys = _theme.Theme.GetFont(TextFontStyle.System); float h = MathHelper.Lerp(_ui.ScreenHeight, (_ui.ScreenHeight / 2) - _totalHeight, _grassPercentage); foreach (var cat in _creditsFile) { var cmeasure = TextRenderer.MeasureText(cat.Text, head1, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(cat.Text, (_ui.ScreenWidth - (int)_maxWidth) / 2, (int)h, _theme.Theme.GetFontColor(TextFontStyle.Header1) * _creditOpacity, head1, TextAlignment.Center, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); h += cmeasure.Y + _catHeadSpacingY; foreach (var entry in cat.Entries) { float opacity = (entry == cat.Entries.Last() && cat == _creditsFile.Last()) ? _youOpacity : _creditOpacity; var hmeasure = TextRenderer.MeasureText(entry.Header, head2, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); var tmeasure = TextRenderer.MeasureText(entry.Text, sys, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); gfx.DrawString(entry.Header, (_ui.ScreenWidth - (int)_maxWidth) / 2, (int)h, _theme.Theme.GetFontColor(TextFontStyle.Header2) * opacity, head2, TextAlignment.Center, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); h += hmeasure.Y + _entryHeadSpacingY; gfx.DrawString(entry.Text, (_ui.ScreenWidth - (int)_maxWidth) / 2, (int)h, _theme.Theme.GetFontColor(TextFontStyle.System) * opacity, sys, TextAlignment.Center, (int)_maxWidth, Plex.Engine.TextRenderers.WrapMode.Words); h += tmeasure.Y + _entryTextSpacingY; } } gfx.DrawRectangle((_ui.ScreenWidth - _peacenet.Width) / 2, (_ui.ScreenHeight - _peacenet.Height) / 2, _peacenet.Width, _peacenet.Height, _peacenet, Color.White * _peacenetOpacity); string thanksText = "Thanks for playing."; var thanksMeasure = head1.MeasureString(thanksText); gfx.Batch.DrawString(head1, thanksText, new Vector2((_ui.ScreenWidth - thanksMeasure.X) / 2, (_ui.ScreenHeight - thanksMeasure.Y) / 2), _theme.Theme.GetFontColor(TextFontStyle.Header1) * _thanksOpacity); gfx.EndDraw(); }
protected override void OnPaint(GameTime time, GraphicsContext gfx) { int x = gfx.X; int y = gfx.Y; int w = gfx.Width; int h = gfx.Height; gfx.EndDraw(); gfx.Device.SetRenderTarget(_scalePreview); gfx.X = 0; gfx.Y = 0; gfx.Width = _scalePreview.Width; gfx.Height = _scalePreview.Height; gfx.BeginDraw(); int rectWidth = 800; int rectHeight = 600; gfx.DrawRectangle(new Vector2((gfx.Width - rectWidth) / 2, (gfx.Height - rectHeight) / 2), new Vector2(rectWidth, rectHeight), Theme.GetAccentColor().Darken(0.5F)); var font = Theme.GetFont(Plex.Engine.Themes.TextFontStyle.System); var fontColor = Theme.GetFontColor(Plex.Engine.Themes.TextFontStyle.System); int fontWidth = rectWidth - 60; string text = "Welcome to Peacegate OS." + "\n" + "\n" + "Peacegate OS is a Unix-based operating system written for use in The Peacenet. Interactive access is given only to administrative users of The Peacenet, such as those working for the Peace Foundation." + "\n" + "\n" + "Peacegate OS's interactive mode features the Peacegate Desktop Environment, a fork of the famous GNOME 2 desktop environment for Linux."; var measure = TextRenderer.MeasureText(text, font, fontWidth, Plex.Engine.TextRenderers.WrapMode.Words); float textY = ((gfx.Height - rectHeight) / 2) + ((rectHeight - measure.Y) / 2); float textX = ((gfx.Width - rectWidth) / 2) + 30; gfx.DrawString(text, new Vector2(textX, textY), fontColor, font, TextAlignment.Center, fontWidth, WrapMode.Words); gfx.EndDraw(); gfx.Device.SetRenderTarget(GetControlBuffer); gfx.X = x; gfx.Y = y; gfx.Width = w; gfx.Height = h; gfx.BeginDraw(); base.OnPaint(time, gfx); Theme.DrawControlDarkBG(gfx, 0, 0, Width, _title.Y + _title.Height + 30); Theme.DrawControlDarkBG(gfx, 0, _description.Y - 30, Width, Height - (_description.Y - 30)); gfx.DrawRectangle(Vector2.Zero, new Vector2(Width, Height), _scalePreview); gfx.EndDraw(); }
public void Draw(GameTime time, GraphicsContext gfx) { if (_current == null) { return; } gfx.BeginDraw(); //Draw the shroud. gfx.Clear(_shroudColor * (_shroudFade / 2)); var headFont = _theme.Theme.GetFont(TextFontStyle.Header1); var nameFont = _theme.Theme.GetFont(TextFontStyle.Header3); var headColor = _theme.Theme.GetFontColor(TextFontStyle.Header1); var nameColor = _theme.Theme.GetFontColor(TextFontStyle.Header3); string headString = "Mission Start"; string nameString = _current.Name; var headMeasure = TextRenderer.MeasureText(headString, headFont, _winsys.Width / 2, Plex.Engine.TextRenderers.WrapMode.Words); var nameMeasure = TextRenderer.MeasureText(nameString, nameFont, (_winsys.Width / 2), Plex.Engine.TextRenderers.WrapMode.Words); float totalHeight = headMeasure.Y + 5 + nameMeasure.Y; float totalCenterY = (_winsys.Height - totalHeight) / 2; float headYMin = (totalCenterY + (_winsys.Height * 0.10f)); gfx.DrawString(headString, (_winsys.Width - (int)headMeasure.X) / 2, (int)MathHelper.Lerp(headYMin, totalCenterY, _missionStartFade), headColor * _missionStartFade, headFont, TextAlignment.Left); float nameYMax = totalCenterY + headMeasure.Y + 5; float nameYMin = nameYMax + (_winsys.Height * 0.10f); gfx.DrawString(nameString, (_winsys.Width - (int)nameMeasure.X) / 2, (int)MathHelper.Lerp(nameYMin, nameYMax, _missionNameFade), nameColor * _missionNameFade, nameFont, TextAlignment.Left); gfx.EndDraw(); if (_objectives == null) { return; } gfx.BeginDraw(); string objectiveName = _objectives[_currentObjective].Name; string objectiveDesc = _objectives[_currentObjective].Description; string pressF6 = "Press [F6] to view objective info"; var objDescFont = _theme.Theme.GetFont(TextFontStyle.System); var objDescColor = _theme.Theme.GetFontColor(TextFontStyle.System); var f6measure = TextRenderer.MeasureText(pressF6, objDescFont, (_winsys.Width / 2), Plex.Engine.TextRenderers.WrapMode.Words); float f6max = (_winsys.Height - f6measure.Y) - 45; float f6min = f6max + (_winsys.Height * 0.1f); gfx.DrawString(pressF6, 45, (int)MathHelper.Lerp(f6min, f6max, _objectiveDescFade), (objDescColor * 0.45F) * _objectiveDescFade, objDescFont, TextAlignment.Left, (_winsys.Width) / 2, Plex.Engine.TextRenderers.WrapMode.Words); var odescmeasure = TextRenderer.MeasureText(objectiveDesc, objDescFont, (_winsys.Width / 2), Plex.Engine.TextRenderers.WrapMode.Words); float odescMax = (f6max - odescmeasure.Y) - 15; float odescMin = odescMax + (_winsys.Height * 0.1f); gfx.DrawString(objectiveDesc, 45, (int)MathHelper.Lerp(odescMin, odescMax, _objectiveDescFade), objDescColor * _objectiveDescFade, objDescFont, TextAlignment.Left, (_winsys.Width) / 2, Plex.Engine.TextRenderers.WrapMode.Words); var onamemeasure = TextRenderer.MeasureText(objectiveName, nameFont, (_winsys.Width / 2), Plex.Engine.TextRenderers.WrapMode.Words); float onameMax = (((((_winsys.Height - 45) - f6measure.Y) - 15) - odescmeasure.Y) - 5) - onamemeasure.Y; float onameMin = onameMax + (_winsys.Height * 0.1f); gfx.DrawString(objectiveName, 45, (int)MathHelper.Lerp(onameMin, onameMax, _objectiveNameFade), nameColor * _objectiveNameFade, nameFont, TextAlignment.Left, (_winsys.Width) / 2, Plex.Engine.TextRenderers.WrapMode.Words); gfx.EndDraw(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { _gfx.Device.Clear(Color.Black); _gfx.BeginDraw(); switch (_gameState) { case 0: string welcome = _activity.ApplicationContext.Resources.GetString(Resource.String.WelcomeToPong); var measure = TextRenderer.MeasureText(welcome, _bodyFont, (int)(_gfx.Width / 1.25), WrapMode.Words); _gfx.DrawString(welcome, (_gfx.Width - (int)(_gfx.Width / 1.25)) / 2, (_gfx.Height - (int)measure.Y) / 2, Color.White, _bodyFont, TextAlignment.Center, (int)(_gfx.Width / 1.25), WrapMode.Words); break; case 1: //Draw the two paddles. _gfx.DrawRectangle(_playerRect.X, _playerRect.Y, _playerRect.Width, _playerRect.Height, Color.White); _gfx.DrawRectangle(_cpuRect.X, _cpuRect.Y, _cpuRect.Width, _cpuRect.Height, Color.White); //Draw the ball. _gfx.DrawCircle(_ballRect.X + (_ballRect.Width / 2), _ballRect.Y + (_ballRect.Width / 2), _ballRect.Width / 2, Color.White); break; case 2: var headMeasure = TextRenderer.MeasureText(_countdownHead, _bodyFont, (int)(_gfx.Width / 1.25), WrapMode.Words); _gfx.DrawString(_countdownHead, (_gfx.Width - (int)(_gfx.Width / 1.25)) / 2, _gfx.Height / 4, Color.White, _bodyFont, TextAlignment.Center, (int)(_gfx.Width / 1.25), WrapMode.Words); _gfx.DrawString(_countdownDesc, (_gfx.Width - (_gfx.Width / 2)) / 2, (_gfx.Height / 4) + (int)headMeasure.Y + 30, Color.White, _scoreFont, TextAlignment.Center, _gfx.Width / 2, WrapMode.Words); string countdownText = Math.Round(_countdown).ToString(); var countdownMeasure = _timeLeftFont.MeasureString(countdownText); _gfx.Batch.DrawString(_timeLeftFont, countdownText, new Vector2((_gfx.Width - countdownMeasure.X) / 2, (_gfx.Height - countdownMeasure.Y) / 2), Color.White); break; } //Measure the "Seconds Left" counter. string secondsleft = $"{Math.Round(_timeLeftSeconds)} Seconds Left"; //Render the seconds left counter _gfx.DrawString(secondsleft, (_gfx.Width - (_gfx.Width / 2)) / 2, 20, Color.White, _timeLeftFont, TextAlignment.Center, _gfx.Width / 2, WrapMode.Words); //Level text string level = $"Level: {_level}"; var lMeasure = TextRenderer.MeasureText(level, _scoreFont, 0, WrapMode.None); //render level text _gfx.DrawString(level, 20, (_gfx.Height - (int)lMeasure.Y) - 20, Color.White, _scoreFont, TextAlignment.Left, 0, WrapMode.None); //Codepoints text string codepoints = $"{_codepoints} Codepoints"; var cMeasure = TextRenderer.MeasureText(codepoints, _scoreFont, 0, WrapMode.None); //render codepoints text _gfx.DrawString(codepoints, (_gfx.Width - (int)cMeasure.X) - 20, (_gfx.Height - (int)lMeasure.Y) - 20, Color.White, _scoreFont, TextAlignment.Left, 0, WrapMode.None); _gfx.EndDraw(); base.Draw(gameTime); }