From 8c4d06c400af3c7406373b5a55919948399f3fb3 Mon Sep 17 00:00:00 2001 From: hunter2actual Date: Sat, 7 Dec 2024 18:08:43 +0000 Subject: [PATCH] 1.2.3.0 Pause timer when game window closed --- DalamudMinesweeper.json | 8 ++++---- DalamudMinesweeper/DalamudMinesweeper.csproj | 2 +- DalamudMinesweeper/DalamudMinesweeper.json | 5 +++-- DalamudMinesweeper/Game/MinesweeperGame.cs | 11 +++++++++++ DalamudMinesweeper/Windows/MainWindow.cs | 12 ++++++++++++ README.md | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/DalamudMinesweeper.json b/DalamudMinesweeper.json index cf1d622..83aed74 100644 --- a/DalamudMinesweeper.json +++ b/DalamudMinesweeper.json @@ -3,7 +3,7 @@ "Author": "hunter2_", "Name": "Minesweeper", "InternalName": "DalamudMinesweeper", - "AssemblyVersion": "1.2.2.0", + "AssemblyVersion": "1.2.3.0", "Description": "Logic puzzle in which you find and flag hidden mines.\n\nLeft click to uncover a square, right click to place a flag.\nThe game ends when all safe squares have been uncovered.\nClick the smiley face to start a new game.", "ApplicableVersion": "any", "Tags": [ @@ -18,9 +18,9 @@ "LoadPriority": 0, "Punchline": "Classic puzzle game.", "AcceptsFeedback": true, - "DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.2.0/latest.zip", - "DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.2.0/latest.zip", + "DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.3.0/latest.zip", + "DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.3.0/latest.zip", "IconUrl": "https://raw.githubusercontent.com/hunter2actual/DalamudMinesweeper/master/images/icon.png", - "Changelog": "Consider game won when all safe cells revealed, even if not all mines are flagged (thanks cheege)" + "Changelog": "Pause timer when game window closed" } ] \ No newline at end of file diff --git a/DalamudMinesweeper/DalamudMinesweeper.csproj b/DalamudMinesweeper/DalamudMinesweeper.csproj index 87f098b..3c9ac7b 100644 --- a/DalamudMinesweeper/DalamudMinesweeper.csproj +++ b/DalamudMinesweeper/DalamudMinesweeper.csproj @@ -3,7 +3,7 @@ - 1.2.2.0 + 1.2.3.0 A logic puzzle featuring hidden mines. https://github.com/hunter2actual/DalamudMinesweeper AGPL-3.0-or-later diff --git a/DalamudMinesweeper/DalamudMinesweeper.json b/DalamudMinesweeper/DalamudMinesweeper.json index f9017cb..b63f7b7 100644 --- a/DalamudMinesweeper/DalamudMinesweeper.json +++ b/DalamudMinesweeper/DalamudMinesweeper.json @@ -2,8 +2,9 @@ "Author": "hunter2_", "Name": "Minesweeper", "Punchline": "Classic puzzle game.", - "Description": "Logic puzzle in which you find and flag hidden mines. \nLeft click to uncover a square, right click to place a flag. \nClick a number that has the right number of flags to reveal adjacent tiles. \nThe game ends when all mines are flagged and all safe squares have been uncovered. \nClick the smiley face to start a new game.", "ApplicableVersion": "any", - "Tags": [ + "Description": "Logic puzzle in which you find and flag hidden mines.\n\nLeft click to uncover a square, right click to place a flag.\nThe game ends when all safe squares have been uncovered.\nClick the smiley face to start a new game.", + "ApplicableVersion": "any", + "Tags": [ "minesweeper", "minigame", "puzzle" diff --git a/DalamudMinesweeper/Game/MinesweeperGame.cs b/DalamudMinesweeper/Game/MinesweeperGame.cs index b33c665..3b37cfe 100644 --- a/DalamudMinesweeper/Game/MinesweeperGame.cs +++ b/DalamudMinesweeper/Game/MinesweeperGame.cs @@ -132,4 +132,15 @@ public int NumUnflaggedMines() public int ElapsedGameTime => (int) _stopwatch.Elapsed.TotalSeconds; public long ElapsedGameTimeMs => _stopwatch.ElapsedMilliseconds; + public void Pause() + { + if (_firstMoveTaken) + _stopwatch.Stop(); + } + + public void Resume() + { + if (_firstMoveTaken) + _stopwatch.Start(); + } } \ No newline at end of file diff --git a/DalamudMinesweeper/Windows/MainWindow.cs b/DalamudMinesweeper/Windows/MainWindow.cs index 7faa147..88b0656 100644 --- a/DalamudMinesweeper/Windows/MainWindow.cs +++ b/DalamudMinesweeper/Windows/MainWindow.cs @@ -96,6 +96,18 @@ public override void Draw() _footer.Draw(bottomLeft - _footerHeightPxVec2); } + public override void OnClose() + { + _game.Pause(); + base.OnClose(); + } + + public override void OnOpen() + { + _game.Resume(); + base.OnOpen(); + } + private MinesweeperGame InitialiseGame() { _game = new MinesweeperGame( diff --git a/README.md b/README.md index b27ac86..f4df867 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Dalamud plugin for FFXIV. How to play: - Left click to uncover a square, right click to place a flag. -- The game ends when all mines are flagged and all safe squares have been uncovered. +- The game ends when all safe squares have been uncovered. - Click the smiley face to start a new game. Features: