diff options
Diffstat (limited to 'Penguloon')
| -rw-r--r-- | Penguloon/Content/Content.mgcb | 24 | ||||
| -rw-r--r-- | Penguloon/Content/UI/BtnResetIdle.png | bin | 0 -> 6734 bytes | |||
| -rw-r--r-- | Penguloon/Content/UI/BtnResetPressed.png | bin | 0 -> 6289 bytes | |||
| -rw-r--r-- | Penguloon/ContentPathManager.cs | 2 | ||||
| -rw-r--r-- | Penguloon/Controls/ButtonReset.cs | 27 | ||||
| -rw-r--r-- | Penguloon/Penguloon.csproj | 1 | ||||
| -rw-r--r-- | Penguloon/Scenes/StatsScene.cs | 34 | ||||
| -rw-r--r-- | Penguloon/UserdataManager.cs | 11 |
8 files changed, 97 insertions, 2 deletions
diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 1bb9d6c..3edc440 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -817,3 +817,27 @@ /processorParam:Quality=Best /build:Sounds/gameover.wav +#begin UI/BtnResetIdle.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:UI/BtnResetIdle.png + +#begin UI/BtnResetPressed.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:UI/BtnResetPressed.png + diff --git a/Penguloon/Content/UI/BtnResetIdle.png b/Penguloon/Content/UI/BtnResetIdle.png Binary files differnew file mode 100644 index 0000000..f5096d5 --- /dev/null +++ b/Penguloon/Content/UI/BtnResetIdle.png diff --git a/Penguloon/Content/UI/BtnResetPressed.png b/Penguloon/Content/UI/BtnResetPressed.png Binary files differnew file mode 100644 index 0000000..b503aa3 --- /dev/null +++ b/Penguloon/Content/UI/BtnResetPressed.png diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index f6dbfa8..afbf735 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -60,6 +60,8 @@ namespace Penguloon "UI/lock", "UI/textPanel", "UI/alertBackground", + "UI/BtnResetPressed", + "UI/BtnResetIdle", "SplashArt/locked", "SplashArt/1", diff --git a/Penguloon/Controls/ButtonReset.cs b/Penguloon/Controls/ButtonReset.cs new file mode 100644 index 0000000..e1e6a12 --- /dev/null +++ b/Penguloon/Controls/ButtonReset.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class ButtonReset : ControlBase + { + public ButtonReset(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/BtnResetIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/BtnResetPressed"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/BtnResetIdle"); + + this.ForeColor = Color.White; + this.BorderColor = Color.Gray; + this.BorderWidth = 0; + this.Font = ContentManager.GetFont(StaticUIValues.MenuFont); + + OnClick += Button_OnClick; + } + + private void Button_OnClick(object sender, ClickArgs e) + { + SoundManager.PlayClickSound(); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 3d1b5b2..71b4060 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -65,6 +65,7 @@ <Compile Include="ContentManager.cs" /> <Compile Include="ContentPathManager.cs" /> <Compile Include="Controls\Alert.cs" /> + <Compile Include="Controls\ButtonReset.cs" /> <Compile Include="Controls\Button.cs" /> <Compile Include="Controls\ButtonIngame.cs" /> <Compile Include="Controls\ControlBase.cs" /> diff --git a/Penguloon/Scenes/StatsScene.cs b/Penguloon/Scenes/StatsScene.cs index f6885d8..b6d4d3e 100644 --- a/Penguloon/Scenes/StatsScene.cs +++ b/Penguloon/Scenes/StatsScene.cs @@ -7,6 +7,8 @@ namespace Penguloon.Scenes { class StatsScene : SceneBase { + MessageBox ResetConfirmationBox; + public StatsScene(Main main) : base(main) { UserdataManager.Level = UserdataManager.GetLevel(); @@ -14,13 +16,36 @@ namespace Penguloon.Scenes public override void CreateControls() { + Vector2 MsgBoxSize = new Vector2(900, 550); + Button btnBack = new Button(this, new Vector2(50, 50), StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); + ButtonReset resetBtn = new ButtonReset(this, new Vector2(50 + StaticUIValues.MenuButtonSize.X + 20, 50), new Vector2(StaticUIValues.MenuButtonSize.Y, StaticUIValues.MenuButtonSize.Y)); + + ResetConfirmationBox = new MessageBox(this, + new Vector2((StaticUIValues.ScreenViewport.X / 2) - (MsgBoxSize.X / 2), (StaticUIValues.ScreenViewport.Y / 2) - (MsgBoxSize.Y / 2)), + MsgBoxSize, Main.Resources.GetString(Resource.String.IngameOptionsQuitConfirmation)); + btnBack.OnClick += BtnStart_OnClick; + resetBtn.OnClick += ResetBtn_OnClick; + + ResetConfirmationBox.OnYes += ResetConfirmationBox_OnYes; Controls.Add(btnBack); + Controls.Add(resetBtn); + } + + private void ResetConfirmationBox_OnYes(object sender, EventArgs e) + { + UserdataManager.ReadData(Main.Context, true); + UserdataManager.Level = UserdataManager.GetLevel(); + } + + private void ResetBtn_OnClick(object sender, ClickArgs e) + { + ResetConfirmationBox.State = IngameOptionsState.Show; } private void BtnStart_OnClick(object sender, ClickArgs e) @@ -28,6 +53,13 @@ namespace Penguloon.Scenes SceneManager.SelectedScene = SelectedScene.Menu; } + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + ResetConfirmationBox.Update(deltaTime, touchLocations); + + base.Update(deltaTime, touchLocations); + } + public override void Draw(float deltaTime) { // background @@ -56,6 +88,8 @@ namespace Penguloon.Scenes DrawStats(borderHorizontalY); base.Draw(deltaTime); + + ResetConfirmationBox.Draw(deltaTime); } private void DrawStats(int borderHorizontalY) diff --git a/Penguloon/UserdataManager.cs b/Penguloon/UserdataManager.cs index f3c5aa5..bdbea57 100644 --- a/Penguloon/UserdataManager.cs +++ b/Penguloon/UserdataManager.cs @@ -30,12 +30,19 @@ namespace Penguloon } } - public static void ReadData(Context context) + public static void ReadData(Context context, bool reset = false) { File file = new File(context.CacheDir, "userdata.txt"); - if (!file.Exists()) + if (!file.Exists() || reset) + { + TotalKills = 0; + TotalMoneySpent = 0; + GamesPlayed = 0; + HighestRound = 0; + HighestKills = 0; WriteData(context); + } using (var streamReader = new System.IO.StreamReader(file.AbsolutePath, true)) { |
