summaryrefslogtreecommitdiff
path: root/Penguloon/Controls/IngameOptions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Controls/IngameOptions.cs')
-rw-r--r--Penguloon/Controls/IngameOptions.cs110
1 files changed, 110 insertions, 0 deletions
diff --git a/Penguloon/Controls/IngameOptions.cs b/Penguloon/Controls/IngameOptions.cs
new file mode 100644
index 0000000..a7f1f00
--- /dev/null
+++ b/Penguloon/Controls/IngameOptions.cs
@@ -0,0 +1,110 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Input.Touch;
+using Penguloon.Scenes;
+using System;
+
+namespace Penguloon.Controls
+{
+ public enum IngameOptionsState
+ {
+ Show,
+ Hide
+ }
+
+ public class IngameOptions : ControlBase
+ {
+ public IngameOptionsState State { get; set; } = IngameOptionsState.Hide;
+
+ public DateTime ShowTime { get; set; }
+
+ public Button BtnContinue { get; set; }
+ public Button BtnQuit { get; set; }
+
+ public MessageBox QuitConfirmationBox { get; set; }
+ public DateTime ShowTimeMsgBox { get; set; }
+
+ public IngameOptions(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size)
+ {
+ 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);
+
+ BtnContinue = new Button(parentScene,
+ new Vector2(position.X + (Size.X / 2) - (BtnSize.X / 2), Position.Y + 50),
+ BtnSize, parentScene.Main.Resources.GetString(Resource.String.IngameOptionsContinue));
+
+ BtnQuit = new Button(parentScene,
+ new Vector2(position.X + (Size.X / 2) - (BtnSize.X / 2), Position.Y + Size.Y - 50 - BtnSize.Y),
+ BtnSize, parentScene.Main.Resources.GetString(Resource.String.IngameOptionsQuit));
+
+ QuitConfirmationBox = new MessageBox(parentScene,
+ new Vector2((StaticUIValues.ScreenViewport.X / 2) - (MsgBoxSize.X / 2), (StaticUIValues.ScreenViewport.Y / 2) - (MsgBoxSize.Y / 2)),
+ MsgBoxSize, parentScene.Main.Resources.GetString(Resource.String.IngameOptionsQuitConfirmation));
+
+ BtnContinue.OnClick += BtnContinue_OnClick;
+ BtnQuit.OnClick += BtnQuit_OnClick;
+
+ OnMissClick += IngameOptions_OnMissClick;
+ QuitConfirmationBox.OnMissClick += QuitConfirmationBox_OnMissClick;
+ QuitConfirmationBox.OnYes += QuitConfirmationBox_OnYes;
+ }
+
+ private void QuitConfirmationBox_OnYes(object sender, EventArgs e)
+ {
+ SceneManager.SelectedScene = SelectedScene.Menu;
+ }
+
+ private void QuitConfirmationBox_OnMissClick(object sender, EventArgs e)
+ {
+ ShowTimeMsgBox = DateTime.Now;
+ }
+
+ private void BtnQuit_OnClick(object sender, ClickArgs e)
+ {
+ QuitConfirmationBox.State = IngameOptionsState.Show;
+ }
+
+ private void BtnContinue_OnClick(object sender, ClickArgs e)
+ {
+ this.State = IngameOptionsState.Hide;
+ }
+
+ private void IngameOptions_OnMissClick(object sender, System.EventArgs e)
+ {
+ if((DateTime.Now - ShowTime).TotalMilliseconds > 200)
+ {
+ State = IngameOptionsState.Hide;
+ }
+ }
+
+ public override void Draw(float deltaTime)
+ {
+ if (State == IngameOptionsState.Hide) return;
+
+ base.Draw(deltaTime);
+
+ BtnContinue.Draw(deltaTime);
+ BtnQuit.Draw(deltaTime);
+ QuitConfirmationBox.Draw(deltaTime);
+ }
+
+ public override void Update(float deltaTime, TouchLocation[] touchLocations)
+ {
+ if (State == IngameOptionsState.Hide) return;
+
+ QuitConfirmationBox.Update(deltaTime, touchLocations);
+
+ if (QuitConfirmationBox.State == IngameOptionsState.Show) return;
+
+ if ((DateTime.Now - ShowTimeMsgBox).TotalMilliseconds <= 200) return;
+
+ base.Update(deltaTime, touchLocations);
+
+ BtnContinue.Update(deltaTime, touchLocations);
+ BtnQuit.Update(deltaTime, touchLocations);
+ }
+ }
+} \ No newline at end of file