Skip to content

Commit

Permalink
Showing 5 changed files with 47 additions and 73 deletions.
4 changes: 0 additions & 4 deletions Models/ToNIndex.cs
Original file line number Diff line number Diff line change
@@ -103,9 +103,6 @@ public string GetNames(string separator = ", ")

// Events
"Cold Night" , "冷たい夜", // Winterfest

// Beyond's favorite
"Custom" , "カスタム", // IGNORE SAVES FOR THIS ONE
};

static string GetEngRoundType(string roundType)
@@ -149,7 +146,6 @@ static ToNRoundType GetRoundType(string raw)

{ ToNRoundType.RUN, 0xC15E3D },
{ ToNRoundType.Eight_Pages, 0xFFFFFF },
{ ToNRoundType.Custom, 0x000000 }, // Ignored

{ ToNRoundType.Cold_Night, 0xA37BE4 },
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
- Right Click to reset audio file back to 'default.wav'
- `Colorful Objectives` Items in the 'Objectives' window will show colors that correspond to those of the items in the game.
- `Auto Discord Backup` Uses a [discord webhook](#how-to-properly-configure-automatic-discord-backup-using-webhooks) to automatically upload a backup of your new codes to a discord channel as you play.
- `Send OSC Parameters` Sends avatar parameters to VRChat using OSC.
- `Send OSC Parameters` Sends avatar parameters to VRChat using OSC. Check the [documentation](#osc-documentation) below for more info.
<details><summary>Preview Image</summary><p> <img src="Resources/settings.png" > </p></details>

## Right Click Menus
2 changes: 1 addition & 1 deletion Utils/LilOSC.cs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ internal static class LilOSC {
static bool LastOptedIn = false;

static bool IsOptedIn = false;
public static TerrorMatrix TMatrix;
public static TerrorMatrix TMatrix = TerrorMatrix.Empty;

internal static void SetTerrorMatrix(TerrorMatrix terrorMatrix) {
TMatrix = terrorMatrix;
2 changes: 2 additions & 0 deletions Windows/SettingsWindow.Designer.cs

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

110 changes: 43 additions & 67 deletions Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
using System.Diagnostics;
using ToNSaveManager.Extensions;
using ToNSaveManager.Models;
using ToNSaveManager.Utils;
using ToNSaveManager.Utils.Discord;
using Timer = System.Windows.Forms.Timer;

namespace ToNSaveManager.Windows
{
public partial class SettingsWindow : Form
{
public partial class SettingsWindow : Form {
#region Initialization
static SettingsWindow? Instance;

readonly Timer ClickTimer = new Timer() { Interval = 200 };
readonly Stopwatch Stopwatch = new Stopwatch();

public SettingsWindow()
{
public SettingsWindow() {
InitializeComponent();
ClickTimer.Tick += ClickTimer_Tick;
}

public static void Open(Form parent)
{
public static void Open(Form parent) {
if (Instance == null || Instance.IsDisposed) Instance = new();

if (Instance.Visible)
{
if (Instance.Visible) {
Instance.BringToFront();
return;
}
@@ -41,8 +38,7 @@ public static void Open(Form parent)

#region Form Events
// Subscribe to events on load
private void SettingsWindow_Load(object sender, EventArgs e)
{
private void SettingsWindow_Load(object sender, EventArgs e) {
BindControlsRecursive(Controls);
// Custom audio handling
PostAudioLocationSet();
@@ -68,8 +64,7 @@ private void SettingsWindow_Load(object sender, EventArgs e)
checkDiscordBackup.CheckedChanged += CheckDiscordBackup_CheckedChanged;
}

private void SettingsWindow_FormClosed(object sender, FormClosedEventArgs e)
{
private void SettingsWindow_FormClosed(object sender, FormClosedEventArgs e) {
ClickTimer.Dispose();

MainWindow.RefreshLists();
@@ -78,27 +73,22 @@ private void SettingsWindow_FormClosed(object sender, FormClosedEventArgs e)

private void TimeFormat_CheckedChanged(object? sender, EventArgs e) => MainWindow.RefreshLists();
private void CheckXSOverlay_CheckedChanged(object? sender, EventArgs e) => MainWindow.SendXSNotification(true);
private void CheckPlayAudio_CheckedChanged(object? sender, EventArgs e)
{
private void CheckPlayAudio_CheckedChanged(object? sender, EventArgs e) {
MainWindow.PlayNotification();
if (!checkPlayAudio.Checked) MainWindow.ResetNotification();
}

private void checkSaveTerrors_CheckedChanged(object? sender, EventArgs e)
{
private void checkSaveTerrors_CheckedChanged(object? sender, EventArgs e) {
checkSaveTerrorsNote.ForeColor = checkSaveTerrors.Checked ? Color.White : Color.Gray;
checkShowWinLose.ForeColor = checkSaveTerrorsNote.ForeColor;
TimeFormat_CheckedChanged(sender, e);
}

private void CheckDiscordBackup_CheckedChanged(object? sender, EventArgs e)
{
if (checkDiscordBackup.Checked)
{
private void CheckDiscordBackup_CheckedChanged(object? sender, EventArgs e) {
if (checkDiscordBackup.Checked) {
string url = Settings.Get.DiscordWebhookURL ?? string.Empty;
EditResult edit = EditWindow.Show(Settings.Get.DiscordWebhookURL ?? string.Empty, "Discord Webhook URL", this);
if (edit.Accept && !edit.Text.Equals(url, StringComparison.Ordinal))
{
if (edit.Accept && !edit.Text.Equals(url, StringComparison.Ordinal)) {
url = edit.Text.Trim();

if (!string.IsNullOrWhiteSpace(url)) {
@@ -121,27 +111,22 @@ private void CheckDiscordBackup_CheckedChanged(object? sender, EventArgs e)
MainWindow.Instance?.SetBackupButton(checkDiscordBackup.Checked);
}

private void btnCheckForUpdates_Click(object sender, EventArgs e)
{
private void btnCheckForUpdates_Click(object sender, EventArgs e) {
if (Program.StartCheckForUpdate(true)) this.Close();
}

private void btnOpenData_Click(object sender, EventArgs e)
{
private void btnOpenData_Click(object sender, EventArgs e) {
SaveData.OpenDataLocation();
}

private void checkPlayAudio_MouseDown(object sender, MouseEventArgs e)
{
private void checkPlayAudio_MouseDown(object sender, MouseEventArgs e) {
if (e.Button != MouseButtons.Left) return;
Stopwatch.Start();
CancelNext = false;
}

private void checkPlayAudio_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && !string.IsNullOrEmpty(Settings.Get.AudioLocation))
{
private void checkPlayAudio_MouseUp(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right && !string.IsNullOrEmpty(Settings.Get.AudioLocation)) {
Settings.Get.AudioLocation = null;
Settings.Export();
PostAudioLocationSet();
@@ -154,20 +139,17 @@ private void checkPlayAudio_MouseUp(object sender, MouseEventArgs e)
long elapsed = Stopwatch.ElapsedMilliseconds;
Stopwatch.Reset();

if (CancelNext)
{
if (CancelNext) {
CancelNext = false;
return;
}

if (elapsed > 210)
{
if (elapsed > 210) {
TogglePlayAudio();
return;
}

if (!DoubleClickCheck)
{
if (!DoubleClickCheck) {
DoubleClickCheck = true;
ClickTimer.Stop();
ClickTimer.Start();
@@ -177,44 +159,46 @@ private void checkPlayAudio_MouseUp(object sender, MouseEventArgs e)
DoubleClickCheck = false;
ClickTimer.Stop();

using (OpenFileDialog fileDialog = new OpenFileDialog())
{
using (OpenFileDialog fileDialog = new OpenFileDialog()) {
fileDialog.InitialDirectory = "./";
fileDialog.Title = "Select Custom Sound";
fileDialog.Filter = "Waveform Audio (*.wav)|*.wav";

if (fileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(fileDialog.FileName))
{
if (fileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(fileDialog.FileName)) {
Settings.Get.AudioLocation = fileDialog.FileName;
Settings.Export();
PostAudioLocationSet();
}
}
}

private void ctxItemPickFolder_Click(object sender, EventArgs e)
{
private void checkOSCEnabled_CheckedChanged(object? sender, EventArgs e) {
if (checkOSCEnabled.Checked) LilOSC.SendData(true);
}

private void checkOSCEnabled_MouseUp(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right)
MainWindow.OpenExternalLink("https://github.com/ChrisFeline/ToNSaveManager/?tab=readme-ov-file#osc-documentation");
}

private void ctxItemPickFolder_Click(object sender, EventArgs e) {
SaveData.SetDataLocation(false);
}

private void ctxItemResetToDefault_Click(object sender, EventArgs e)
{
private void ctxItemResetToDefault_Click(object sender, EventArgs e) {
SaveData.SetDataLocation(true);
}

private void CheckColorObjectives_CheckedChanged(object? sender, EventArgs e)
{
private void CheckColorObjectives_CheckedChanged(object? sender, EventArgs e) {
ObjectivesWindow.RefreshLists();
}

// Double click
private bool DoubleClickCheck = false;
private bool CancelNext = false;
private void ClickTimer_Tick(object? sender, EventArgs e)
{
private void ClickTimer_Tick(object? sender, EventArgs e) {
ClickTimer.Stop();
if (DoubleClickCheck)
{
if (DoubleClickCheck) {
DoubleClickCheck = false;
CancelNext = true;
TogglePlayAudio();
@@ -223,29 +207,23 @@ private void ClickTimer_Tick(object? sender, EventArgs e)
#endregion

#region Utils
private void TogglePlayAudio()
{
private void TogglePlayAudio() {
checkPlayAudio.Checked = !checkPlayAudio.Checked;
}

private void BindControlsRecursive(Control.ControlCollection controls)
{
foreach (Control c in controls)
{
private void BindControlsRecursive(Control.ControlCollection controls) {
foreach (Control c in controls) {
string? tag = c.Tag?.ToString();
if (!string.IsNullOrEmpty(tag))
{
if (!string.IsNullOrEmpty(tag)) {
int index = tag.IndexOf('|', StringComparison.InvariantCulture);
if (index > -1)
{
if (index > -1) {
string tooltip = tag.Substring(index + 1).Replace("\\n", Environment.NewLine, StringComparison.Ordinal);
tag = tag.Substring(0, index);
toolTip.SetToolTip(c, tooltip);
}
}

switch (c)
{
switch (c) {
case GroupBox g:
BindControlsRecursive(g.Controls);
break;
@@ -258,8 +236,7 @@ private void BindControlsRecursive(Control.ControlCollection controls)
}
}

private void PostAudioLocationSet()
{
private void PostAudioLocationSet() {
bool hasLocation = string.IsNullOrEmpty(Settings.Get.AudioLocation);
checkPlayAudio.Text = "Play Audio (" + (hasLocation ? "default.wav" : Path.GetFileName(Settings.Get.AudioLocation)) + ")";
}
@@ -292,6 +269,5 @@ private void WriteInstanceLogs()
}
*/
#endregion

}
}

0 comments on commit e6c46d4

Please sign in to comment.