From 3281eed3ffca3b4488335846430b231001aea753 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Sat, 23 Dec 2017 21:33:50 +0100 Subject: dabbing makes me want to kms --- Penguloon/Controls/ControlBase.cs | 3 +++ Penguloon/Controls/IngameOptions.cs | 6 +++++- Penguloon/Controls/MessageBox.cs | 31 ++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'Penguloon/Controls') diff --git a/Penguloon/Controls/ControlBase.cs b/Penguloon/Controls/ControlBase.cs index 42c729e..b6b7a57 100644 --- a/Penguloon/Controls/ControlBase.cs +++ b/Penguloon/Controls/ControlBase.cs @@ -30,6 +30,7 @@ namespace Penguloon.Controls public TextAllignment TextAllignment { get; set; } = TextAllignment.CenterMiddle; public int PaddingTop { get; set; } = 0; + public bool DrawText { get; set; } = true; /// /// Base constructor. @@ -66,6 +67,8 @@ namespace Penguloon.Controls destinationRectangle: new Rectangle(Position.ToPoint(), Size.ToPoint())); break; } + if (!DrawText) return; + if (Font == null) return; if (string.IsNullOrWhiteSpace(Text)) return; diff --git a/Penguloon/Controls/IngameOptions.cs b/Penguloon/Controls/IngameOptions.cs index a7f1f00..d6eda02 100644 --- a/Penguloon/Controls/IngameOptions.cs +++ b/Penguloon/Controls/IngameOptions.cs @@ -25,12 +25,13 @@ namespace Penguloon.Controls public IngameOptions(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) { + this.DrawText = false; this.BackgroundIdle = ContentManager.GetTexture("UI/optionsMenuBackground"); this.BackgroundPressed = ContentManager.GetTexture("UI/optionsMenuBackground"); this.BackgroundDisabled = ContentManager.GetTexture("UI/optionsMenuBackground"); Vector2 BtnSize = new Vector2(Size.X - 90, StaticUIValues.IngameUIPlayButtonHeight); - Vector2 MsgBoxSize = new Vector2(900, 300); + Vector2 MsgBoxSize = new Vector2(900, 450); BtnContinue = new Button(parentScene, new Vector2(position.X + (Size.X / 2) - (BtnSize.X / 2), Position.Y + 50), @@ -54,6 +55,9 @@ namespace Penguloon.Controls private void QuitConfirmationBox_OnYes(object sender, EventArgs e) { + GameScene gameScene = (GameScene)ParentScene; + gameScene.Level.FinishGame(); + SceneManager.SelectedScene = SelectedScene.Menu; } diff --git a/Penguloon/Controls/MessageBox.cs b/Penguloon/Controls/MessageBox.cs index 48ba992..6736132 100644 --- a/Penguloon/Controls/MessageBox.cs +++ b/Penguloon/Controls/MessageBox.cs @@ -17,14 +17,17 @@ namespace Penguloon.Controls public event EventHandler OnYes; public event EventHandler OnNo; + public string[] Lines { get; set; } + public MessageBox(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) { + this.DrawText = false; this.BackgroundIdle = ContentManager.GetTexture("UI/msgBoxBackground"); this.BackgroundPressed = ContentManager.GetTexture("UI/msgBoxBackground"); this.BackgroundDisabled = ContentManager.GetTexture("UI/msgBoxBackground"); this.Text = text; - this.Font = ContentManager.GetFont("Fonts/GWENT/36"); + this.Font = ContentManager.GetFont("Fonts/GWENT/48"); this.ForeColor = Color.White; this.BorderColor = Color.Black; this.BorderWidth = 2; @@ -45,6 +48,23 @@ namespace Penguloon.Controls BtnYes.OnClick += delegate { OnYes?.Invoke(this, EventArgs.Empty); this.State = IngameOptionsState.Hide; }; BtnNo.OnClick += delegate { OnNo?.Invoke(this, EventArgs.Empty); this.State = IngameOptionsState.Hide; }; + + int charsPerLine = 25; + + int lines = (int)Math.Ceiling((double)text.Length / charsPerLine); + Lines = new string[lines]; + + for (int i = 0; i < lines; i++) + { + if (i == lines - 1) + { + Lines[i] = Text.Substring(i * charsPerLine); + } + else + { + Lines[i] = Text.Substring(i * charsPerLine, charsPerLine); + } + } } private void IngameOptions_OnMissClick(object sender, System.EventArgs e) @@ -63,6 +83,15 @@ namespace Penguloon.Controls BtnYes.Draw(deltaTime); BtnNo.Draw(deltaTime); + + if (Font == null) return; + if (string.IsNullOrWhiteSpace(Text)) return; + + for (int i = 0; i < Lines.Length; i++) + { + ParentScene.DrawText(Font, Lines[i], new Vector2(Position.X + PaddingTop, Position.Y + PaddingTop + ((Font.MeasureString(Lines[i]).Y + 5) * i)), + new Vector2(), TextAllignment.LeftTop, ForeColor, BorderColor, BorderWidth); + } } public override void Update(float deltaTime, TouchLocation[] touchLocations) -- cgit v1.2.3-70-g09d2