Skip to content

Latest commit

 

History

History
316 lines (245 loc) · 17.4 KB

File metadata and controls

316 lines (245 loc) · 17.4 KB

Panopticon Desktop App

A desktop companion app for your favorite 4x strategy game, Dominion 6 from Illwinter

Timeline feature with git integration.

This feature will give the ability to replay any turns by giving you a timeline of saved “snapshots” (git commit)

This feature will not pollute your on-going game selection window, instead the user can simply revert/advance to any turn via the application then your current game will time travel to the selected turn or if the user wish to branch off and create a new game from a given point in time he will be able to do so and then load it within the Dominion “Continue Old Game” screen.

New Timeline:

  • Select an existing game by browsing the savedgames folder
  • Select timeline mode (Auto, Manual)
  • If Auto mode is selected, user can enable/disable “Auto commit on save and quit”
  • Input default prefix if needed (Timeline, Snapshot, etc.) - default: NONE
  • Input default suffix if needed (TURN, Snapshot, etc.) - default TURN
  • Input current in-game TURN (INT) - default 1
  • Final game name folder name would be something like this: (Timeline_Wailing_Winds_TURN_1)

Mode: Auto - git commit as neded whenever there is a change Manual - git commit manually

Auto: Detect files change and commit automatically.

IF a .trn file is updated auto commit with supplied prefix & suffix (A turn has been made)

IF only the .2h file is updated (no turn has been made) Check Auto commit settings “Auto commit on save and quit” IF the setting is not enabled ask user if a commit is needed (Yes/No)

IF Yes - Simply add suffix to distinguish that we are still on the same turn instead of asking the player for input, example player is on turn 10 then save and quit the game, we would already have a previous commit named Timeline_Wailing_Winds_TURN_10, then it could simply append 0.01 to the new commit like so Timeline_Wailing_Winds_TURN_10.01

IF No - Do not commit.

Manual: User will manually commit a turn whenever is needed.

Time travel Before time traveling the user will be requested to save and exit the game if the game being modified is currently running. I have no way to detect this so user must be extra careful, it would probably corrupt or crash the running game.

In order to time travel the application will do the following by levering git.

When a game is added to the application, it will now be tracked by git.

git add . git commit -m “prefix_gameName_suffix”

Changes will now be committed based on the Timeline mode (Auto, Manual)

The Timeline will be presented to the user via git reflog or git log where the description of the commit is the game name with prefix and suffix which have been configured for this specific game.

Example of git reflog (will need to parse this and present it in a nice UI): e512ed0 (HEAD -> master) HEAD@{0}: commit: Timeline_illWinter_TURN_1 e16b175 HEAD@{1}: commit (initial): Timeline_illWinter_TURN_0

Example of git log (will need to parse this and present it in a nice UI): commit 8b2eed5ecf0e6c094bc991416bf9277fc4a87210 (HEAD -> TL_illWinter_TURN_0) Author: globz <globz@kittybomber.com> Date: Wed Jul 24 15:26:19 2024 -0400

Timeline_illWinter_TURN_1

commit e16b175ba5ac6c2e22c54b1b69cb3565670af58b Author: globz <globz@kittybomber.com> Date: Wed Jul 24 14:10:24 2024 -0400

Timeline_illWinter_TURN_0

User may select a specific commit in the presented Timeline (HEAD@{X}), git will then checkout the commit in a temporary branch which is named after the git commit description of the selected turn. Example, the user is now at turn 11 but made an horrible mistake and decide to go back to turn 10.

git checkout -b Timeline_Wailing_Winds_TURN_10 HEAD@{X}

Then the application will ask the user to select one of the following options:

  1. Time travel to Timeline_Wailing_Winds_TURN_10 within the current game Wailing_Winds
  2. Branch off to a new game based on Timeline_Wailing_Winds_TURN_10

Option 1. The time travel will happen in the current game folder Wailing_Winds, upon reloading the game the user will now be at turn 10.

User may keep progressing through turns as usual while preserving new turn history.

However, the turn 11 is no longer part of this timeline, only turn 0…10 and future turns will populate this timeline.

If the user desire to go back to turn 11 he must go back to the “master” timeline, this will be an option within the application. The application may detect which timeline we are currently using with the following command:

Track which branch is currently in use: git rev-parse --abbrev-ref HEAD **Timeline_illWinter_TURN_0* master

Option 2. User will be prompted to name this new game.

Then the application will create a new game folder inside the savedgames folder with the name provided by the user and then copy the files from commit Timeline_Wailing_Winds_TURN_10 inside this new folder.

cp -R Wailing_Winds/ NAME_OF_MY_NEW_GAME_BASED_ON_TURN_10/

The git repo will be removed (previous timeline is now gone), we are now starting from scratch but at turn 10. A new game folder has now been created, select it from the “Continue Old game” menu within Dominion. User must now add this new game to the application to re-enable tracking in order to create a new timeline.

File change detection When a turn is made the .trn file does update When a game is saved and quit only the .2h file is updated.

Git packaging Use https://github.com/libgit2/libgit2sharp Check out nuget for desktop app https://www.nuget.org/packages/LibGit2Sharp - dotnet add package LibGit2Sharp –version 0.30.0 Documentation - https://github.com/libgit2/libgit2sharp/wiki/LibGit2Sharp-Hitchhiker%27s-Guide-to-Git

Info Game name in Dominion supports up to 23 characters Git commit title 72 characters - Still use it but useless - use Sqlite Git commit description has no limit (we could use this to let the player describe a turn) - Nope use sqlite Git branch are 244 bytes - Panopticon does set this value to 50 characters.

TODO:

  • FileWatcherManager ~ perhaps implement an Adaptive Debounce Delay?
  • Renamed column “sq_turn” to “saved_turn” in table setings (Might not be needed…)
  • Implement TimeTravel.BranchOff (Implemented 2024-10-25)
  • Ability to delete branches from Timeline - (Implemented 2024-11-05)
  • Branch switching menu - (Implemented 2024-10-25)
  • Add Confirmation Dialog when undoing turn(s) (Implemented 2024-10-27)
  • Ability to rename nodes? (Future update, after release?)
  • Implement settings at the branch level, right now settings are global to a specific game. (Implemented 2024-10-15)
  • Remove Save Notes button once inside a TimeTravel option menu - (Implemented 2024-10-18)
  • Call TurnTracker.Update_Turn() on missed turn(s), this is needed for the snapshot implementation. (Implemented 2024-10-24)
  • Save panopticon.db per game file, no need for global DB, this will let users load other player’s game into their own Panopticon. (Implemented 2025-04-06)
  • Check if branch_name is empty before calling BranchOff (Implemented 2025-02-05)
  • Check if .gitignore already exist before creating the file (Implemented 2025-04-06)
  • In the branches overview, set the current active branch to green (Implemented 2025-04-08)
  • Clicking the same node in TreeviewLeft should reset the view (act as a back button) (Implemented 2025-04-08) - Still not sastified with the result, when losing window focus it will reset to selecting the settings node. (Implemented 2025-04-10)
  • Highlight selected node in green in TreeviewLeft (Implemented 2025-04-08)
  • Isolate the @ Hack for force node selection (if we refactor this crap at least it will be all in the same function) - (Implemented 2025-04-12)
  • Polish UI related to new branch name (add groupbox or label so that we can add “branch name:”) - (Implemented 2025-04-13)
  • Rename timelines to timeline since we now have 1 db per game folder. (Implemented 2025-04-14)
  • Fix timeline_root (disable/enable) state while switching between replay_mode state (on/off) (Implemented 2025-04-17)
  • Need to display snapshot nodes differently while in replay mode, no time travel abilities! (Implemented 2025-04-17)
  • Exiting replay mode will now display a MessageBox to exit the current game & ask for user confirmation (Implemented 2025-04-17)
  • Improved branch name validation, you may now focus out of the input field while it is empty. (Implemented 2025-04-18)
  • When persisting Replay, you do not need to exit Dominion (Remove messageBox) - (Implemented 2025-04-18)
  • Revise and remove ALL TODO (Implemented 2025-04-18)
  • Create an app.ico (Implemented 2025-04-18)
  • Implement migration feature to facilitate futures upgrades to the database or local architecture. (Implemented 2025-04-24)
  • Finish implementation details of Replay (Implemented 2025-04-18)
  • Implement (New Game) mode (Implemented 2025-04-25)
  • Delete panopticon.db when deleting timeline. (Implemented 2025-04-25)
  • Fix Tab index on all forms
  • Remove unnecessary Console call
  • Remove all unnecessary Console.WriteLine
  • Delete .gitignore when deleting timeline? improve logic and perhaps read its content if already exist - Not deleting yet
  • Finalize UI and text of New Game (Implemented 2025-04-27)

BUG:

  • Sometimes 2h files writes do not trigger TurnTrackerWorker event, resulting in no new calculated turn. This cause a manual snapshot to fail and Auto_commit won’t trigger at all. (Fixed)
  • Fix TimeTravel.undo - node_seq = 1 condition not return the proper value and UI feedback (Fixed)
  • When undoing turns, rewind the turn(s) value - (Implemented 2024-10-18)
  • Add panopticon.db to .gitignore (Implemented 2025-04-06)
  • Undoing the latest turn will cause a bug related to Git.Commit (‘LibGit2Sharp.EmptyCommitException’ in LibGit2Sharp.dll: ‘No changes; nothing to commit.’)
  • Replay mode - Persist should be disabled if there is no commit to be made or find a way to force it since we wish to persist to a new branch - This will trigger the bug above. This is now “fixed” however the messageBox “There a no pending changes” will be displayed - Snapshot.Create() will now return a boolean, the messageBox logic is now handled outside of this function. (Implemented 2025-04-10)
  • (‘LibGit2Sharp.EmptyCommitException’ in LibGit2Sharp.dll: ‘No changes; nothing to commit.’) - The FileWatcherManager is always active while switching branch, when creation mode is set to “Auto” it will trigger a commit but there is nothing to commit, however the files did change and caused the trigger. (Implemented 2025-04-08)
  • LibGit2Sharp.RepositoryStatus? status = Git.Status(); This will never return null, perhaps use status.modified (Implemented 2025-04-08)
  • Validate all Git.Status() call in Snapshot.cs - (Implemented 2025-04-08)
  • When entering replay mode, the UI will display timeline_root without it being selected (this is caused by our new HACK in TreeViewLeft_AfterSelect (timeline)) - (Implemented 2025-04-11)
  • When exiting replay mode, the UI will display timeline_root without it being selected (this is caused by our new HACK in TreeViewLeft_AfterSelect (timeline)) - (Implemented 2025-04-11)
  • Validate new branch name (Exception thrown: ‘LibGit2Sharp.InvalidSpecificationException’ in LibGit2Sharp.dll: ‘the given reference name ‘refs/heads/Good start’ is not valid’) - (Implemented 2025-04-12)
  • @@@DATALOSS via TimeTravel.Undo() - You are able to undo the same turn UI, the UI does not correctly refresh the node selection so you can still undo the same turn, this causes your whole timeline to be deleted from panopticon.db (Implemented 2025-04-12)
  • Switching game without closing the game seems to not reset the DB.DatabasePath so all the writes and read goes to the wrong database. (Implemented 2025-04-14)
  • Exception thrown: ‘System.InvalidOperationException’ in Microsoft.Data.Sqlite.dll: ‘Invalid attempt to call Read when reader is closed.’ - (Implemented 2025-04-15)
  • Undoing nodes does not remove their associated notes. (Implemented 2025-04-25)
  • Existing notes should carry over when branching off (just like replay mode) (Implemented 2025-04-25)
  • Creating a new Timeline without exiting Panopticon and previously had a loaded game will carry all settings from the previous game. (Implemented 2025-04-27)
  • panopticon.db & .gitignore should be created ONLY if a timeline has been created! (Implemented 2025-04-28)

HEAD - 85b14ecf7cae4b9db7f0cac429654647f82d3cbe

commit e71037c7f72afafc53ac12efe76ed04a8e155d43 Author: Panopticon <panopticon@kittybomber.com> Date: Thu Oct 24 10:44:39 2024 -0400

EA_DebugMissedTurn_TURN_27

git branch my_branch e71037c7f72afafc53ac12efe76ed04a8e155d43

or checkout immediately

git checkout -b my_branch e71037c7f72afafc53ac12efe76ed04a8e155d43

git checkout root git checkout my_branch

commit 9fb36faf0b6af8e9bb0ae039b1048994e2eed444 Author: Panopticon <panopticon@kittybomber.com> Date: Thu Oct 24 09:50:25 2024 -0400

EA_DebugMissedTurn_TURN_9

git checkout -b my_branch2 9fb36faf0b6af8e9bb0ae039b1048994e2eed444

This is exactly what we need for the “Replay” feature - https://www.inmotionhosting.com/support/website/git/git-checkout/

// Start replay mode (detached HEAD) git checkout <commit hash>

// Persist & Exit replay mode // Everything done during Replay mode may be saved to a new branch git switch -c <new-branch-name>

// Discard the latest change made while replay mode is active (no branch) git checkout – * or git reset –hard

// Exit replay mode discarding ALL CHANGES and returning to previous branch git switch - || git checkout <branch> –force

When ReplayMode is Enabled the following should happen:

  • Disable auto-commit (Implemented 2025-02-02)
  • Enable replay mode (Implemented 2025-02-02)
  • Persist replay_mode setting (TRUE) on curren game + (no branch) (Implemented 2025-02-02)
  • Persist turn, sq_turn, compound_turn settings for Game.Name + (no branch) - (Implemented 2025-02-04)
  • Force manual commit mode - User should not be able to enable auto-commit (Implemented 2025-02-04)
  • Remove timeline_root node when using replay node (Implemented 2025-02-03)
  • Fix missing timeline node when Exiting replay mode (Implemented 2025-02-05)
  • Fix “Auto” UI control text in settings when radio button is disabled (Implemented 2025-02-05)
  • Check if branch_name is empty before [Persist] (Implemented 2025-02-06)
  • Fix TimeTravel.ReplayMode.Exit not switching to the previous branch before detaching HEAD to x commit (Implemented 2025-02-06)
  • When enabling replay_mode, example replay turn 4, then save turn 1 to 4 as (no branch) in timelines db (Implemented 2025-02-25)
  • When persisting replay_mode rename all (no branch) timeline history to the new branch name (Implemented 2025-02-25)
  • [BUG] When enabling a replay session, settings.turn will be +1 instead of of what has been selected, example of the problem: (replay turn 4 -> settings.turn = 5) (Implemented 2025-02-17)
  • [BUG] When persisting to a new branch, if there is a pending commit it will not carry over (Implemented 2025-02-25)
  • Maybe Persist Git.previous_branch (new column) unto the game + (no branch) setting - Not need, too much hassle for little gains
  • When branching off or persisting a DETACHED HEAD, it should also carry all the notes associated with existing nodes (previous_nodes) - (Implemented 2025-04-17)
  • When branching off or persisting a DETACHED HEAD, it should also carry all the notes associated with each new nodes - (Implemented 2025-04-17)
  • Snapshot UI & logic must be adapted to work in ReplayMode or dispatch to a new handler via TurnTracker.Refresh_UI:
    • Ask if user wish to [Persist], [Discard], [Continue] or [Exit] (Implemented 2025-02-06)
    • Selecting [Persist] will ask you to name your new branch which will now be based on your replay session. (Implemented 2025-02-25)
    • Selecting [Discard], will discard the outcome of your replay session. (Implemented 2025-02-06)
    • Selecting [Continue], will protect your latest turn from being removed when using [Discard] (Implemented 2025-02-25)
    • Selecting [Exit] will discarding ALL CHANGES made during replay session and return to previous branch (Implemented 2025-02-06)
  • –autosave launch option should be off when using Panopticon (Create player warning).
  • Since all the games are in the same folder (C:\Users\$USER\AppData\Roaming\coe5\saves) - we should isolate panopticon.db into a subfolder (C:\Users\$USER\AppData\Roaming\coe5\saves\my_game)
  • .gitignore should be rewritten each time we switch game file, to ignore all the rest? need to test this out.
  • Save file in the saves folder = Game.Name - (No longer the folder)
  • Rename SUFFIX to SAVE
  • Do not track turn instead we track manual saves from player

Update version(s) in Panopticon.csproj dotnet publish Panopticon.csproj -c Release -r win-x64 –self-contained true -p:PublishSingleFile=true -o ./publish Test release locally Note SHA256 from certutil -hashfile publish/Panopticon.exe SHA256 Update Update release.yml body release description & add updated SHA256 Commit & push latest Panopticon.csprof & release.yml Trigger workflow: git tag -a v1.0.0-xxx -m “Panopticon v1.0.0: XXX Windows x64 release” git push origin v1.0.0-xxx

git tag -a v1.0.0-beta -m “Panopticon v1.0.0: Beta Windows x64 release” git push origin v1.0.0-beta

git push –delete origin tagname git tag –delete tagname

git tag -f v1.0.0-beta git push origin v1.0.0-beta –force

powershell [guid]::NewGuid()

certutil -hashfile publish/Panopticon.exe SHA256