diff options
Diffstat (limited to 'Penguloon/Controls/MessageBox.cs')
| -rw-r--r-- | Penguloon/Controls/MessageBox.cs | 31 |
1 files changed, 30 insertions, 1 deletions
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) |
