Skip to content

Commit

Permalink
Add Settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ItEndsWithTens committed Mar 14, 2024
1 parent 2cf5e68 commit dbb1696
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 30 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

This is currently implemented as a [BizHawk](https://github.com/TASVideos/BizHawk) external tool; also included are the beginnings of a standalone GUI app based on [Eto.Forms](https://github.com/picoe/Eto) and [Eto.Veldrid](https://github.com/picoe/Eto.Veldrid), but that's a long way off, if it ever happens. For now the external tool is a useful, if scatterbrained, testbed for various ideas.

Downloads are available through the badges above, or on the releases page. Just unzip into your BizHawk/ExternalTools directory and enjoy! If instead you'd like to build it yourself, read on.



## Requirements
Expand All @@ -18,6 +16,12 @@



## Installation

Downloads are available through the badges above, or on [the releases page](https://github.com/ItEndsWithTens/SilentHillMapExaminer/releases). Just unzip into your BizHawk/ExternalTools directory and enjoy!



## Usage

TODO: Proper docs for the other tabs.
Expand Down
17 changes: 17 additions & 0 deletions src/SHME.ExternalTool.Extras/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public Settings(string company, string product, string component)
.LoadNow()
.EnableAutosave();

bool save = false;

// Settings that are collections need to be initialized as empty
// first, then populated later. Otherwise JsonSettings creates a
// series of duplicate entries in your settings file on every load.
Expand All @@ -61,6 +63,8 @@ public Settings(string company, string product, string component)
Local.FpsBinds.Add(new InputBind(d));
}
}

save = true;
}

if (Local.FlyBinds?.Count < DefaultLocalSettings.FlyBinds.Count)
Expand All @@ -76,6 +80,19 @@ public Settings(string company, string product, string component)
Local.FlyBinds.Add(new InputBind(d));
}
}

save = true;
}

// JsonSettings can't autosave changes to collections that don't
// implement INotifyCollectionChanged, but even for such collection
// types there are no change events raised when elements of the
// collection have changed, only when the collection itself has
// changed. Developing a custom collection class with that feature
// is much more involved than just calling Save when necessary.
if (save)
{
Local.Save();
}

Roaming = JsonSettings
Expand Down
210 changes: 197 additions & 13 deletions src/SHME.ExternalTool/UI/CustomMainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/SHME.ExternalTool/UI/CustomMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ private void LoadSettings()
Settings = new Settings("com.gyroshot", ToolName, component);

InitializeDataBindings();

TbxSettingsFilesLocal.Text = Settings.Local.FileName;
TbxSettingsFilesRoaming.Text = Settings.Roaming.FileName;
}

private List<((Vertex a, Vertex b), Color color, bool visible)> ScreenSpaceLines { get; } = [];
Expand Down Expand Up @@ -836,7 +839,9 @@ private void InitializeOverlay()

_dummyViewport = new Viewport(0, 0, RenderPort.Width, RenderPort.Height);

CleanUpDisposables();
Pen?.Dispose();
Reticle?.Dispose();
Overlay?.Dispose();

Pen = new Pen(Brushes.White);
Reticle = GenerateReticle(Pen, RenderPort.Width, RenderPort.Height, (float)NudCrosshairLength.Value);
Expand Down
Loading

0 comments on commit dbb1696

Please sign in to comment.