Skip to content

Commit

Permalink
Implement Master Change to Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisFeline committed Oct 18, 2024
1 parent c474b27 commit 5e13abf
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 17 deletions.
5 changes: 5 additions & 0 deletions Localization/Language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@
"SETTINGS.OSCDEATHEVENT_COOLDOWN": "(Cooldown)",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TT": "Set the time (in milliseconds) to wait before setting the ID value for this parameter after multiple players die in quick succession.",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TITLE": "Set Cooldown Time",
"SETTINGS.OSCMASTERCHANGE": "Send Master Change",
"SETTINGS.OSCMASTERCHANGE.TT": "Sends 'TRUE' to the parameter 'ToN_MasterChange' when the instance master has changed.",
"SETTINGS.OSCMASTERCHANGE_EDIT": "(Set Interval)",
"SETTINGS.OSCMASTERCHANGE_EDIT.TT": "Sets the interval (in milliseconds) to wait before setting this parameter value back to 'FALSE'",
"SETTINGS.OSCMASTERCHANGE.TITLE": "Set Master Interval",

"SETTINGS.GROUP.NOTIFICATIONS": "Notifications",

Expand Down
4 changes: 2 additions & 2 deletions Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ public int GetDeathID (string id) {
/// <summary>
/// OSC Master Changed event for OSC.
/// </summary>
public bool OSCMasterChange { get; set; } = true;
public bool OSCMasterChange { get; set; } = false;
/// <summary>
/// OSC Master Change event interval.
/// </summary>
public int OSCMasterChangeInterval { get; set; } = 200;
public int OSCMasterChangeInterval { get; set; } = 500;

/// <summary>
/// Enables OSC chatbox messages.
Expand Down
76 changes: 65 additions & 11 deletions Windows/SettingsWindow.Designer.cs

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

17 changes: 14 additions & 3 deletions Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void Open(Form parent) {

#region Form Events
private Dictionary<string, Control> LocalizedControlCache = new Dictionary<string, Control>();
private readonly string[] ColorFormatLabels = [ "HSV", "RGB", "HSL", "RGB32" ];
private readonly string[] ColorFormatLabels = ["HSV", "RGB", "HSL", "RGB32"];
private static string ColorFormatTooltip = "Sends the current Terror color represented as {3}.\nColor will be sent as 3 FLOAT parameters:\n- {0}\n- {1}\n- {2}";

internal void LocalizeContent() {
Expand All @@ -92,6 +92,7 @@ internal void LocalizeContent() {
// OSC LINKS
LANG.C(linkEditChatbox, "SETTINGS.OSCSENDCHATBOX_EDIT", toolTip);
LANG.C(linkSetDamageInterval, "SETTINGS.OSCDAMAGEDEVENT_EDIT", toolTip);
LANG.C(linkSetMasterInterval, "SETTINGS.OSCMASTERCHANGE_EDIT", toolTip);
LANG.C(linkEditDeathID, "SETTINGS.OSCDEATHEVENT_EDIT", toolTip);
LANG.C(linkSetDeathDecay, "SETTINGS.OSCDEATHEVENT_DECAY", toolTip);
LANG.C(linkSetDeathCooldown, "SETTINGS.OSCDEATHEVENT_COOLDOWN", toolTip);
Expand Down Expand Up @@ -636,6 +637,17 @@ private void linkAutoNoteEdit_LinkClicked(object sender, LinkLabelLinkClickedEve
}
}

private void linkSetMasterInterval_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
int original = Settings.Get.OSCMasterChangeInterval;
string value = original.ToString();
EditResult show = EditWindow.Show(value, LANG.S("SETTINGS.OSCMASTERCHANGE.TITLE") ?? "Set Interval", this);

if (show.Accept && !string.IsNullOrEmpty(show.Text) && int.TryParse(show.Text.Trim(), out int result) && result != original) {
Settings.Get.OSCMasterChangeInterval = result;
Settings.Export();
}
}

private void linkSetDamageInterval_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
int original = Settings.Get.OSCDamagedInterval;
string value = original.ToString();
Expand Down Expand Up @@ -686,7 +698,7 @@ private void checkAutoCopy_CheckedChanged(object? sender, EventArgs e) {

private void checkOSCEnabled_CheckedChanged(object? sender, EventArgs e) {
if (checkOSCEnabled.Checked && sender != null) LilOSC.SendData(true);
checkOSCDeathEvent.ForeColor = checkOSCSendDamage.ForeColor = checkOSCSendColor.ForeColor =
checkOSCMasterChange.ForeColor = checkOSCDeathEvent.ForeColor = checkOSCSendDamage.ForeColor = checkOSCSendColor.ForeColor =
checkOSCEnabled.Checked ? Color.White : Color.Gray;
}

Expand Down Expand Up @@ -778,6 +790,5 @@ private void BindControlsRecursive(Control.ControlCollection controls) {
}
}
#endregion

}
}
2 changes: 1 addition & 1 deletion Windows/SettingsWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<value>RoundInfoToFile|Write round information to a file. (Such as terror name, map name, round type, etc.)\nThese files can be used in streaming tools like OBS to give your viewers more information about your current pain and suffering.</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>33</value>
<value>25</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down

0 comments on commit 5e13abf

Please sign in to comment.