Skip to content

Commit

Permalink
Add some presets
Browse files Browse the repository at this point in the history
Fix some bugs
  • Loading branch information
valarnin committed Jan 8, 2024
1 parent 692eda5 commit 30a3d66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 6 additions & 4 deletions ConfigPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public partial class ConfigPanel : UserControl
{ "FFXIV - ACT Combat Start", @"^(?# FFXIV - ACT Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>1)\|" },
{ "FFXIV - Game Combat Start", @"^(?# FFXIV - Game Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>[^|]*)\|(?<inGameCombat>1)\|" },
{ "FFXIV - Countdown Start", @"(?# FFXIV - Countdown Start)\|Battle commencing in (?<time>[^ ]+) seconds! \((?<player>.*?)\)\|" },
{ "FFXIV - Area Seal", @"(?# FFXIV - Area Seal)(?<area>.*?) will be sealed off in (?<time>[^ ]+) seconds!" },
{ "FFXIV - Engage", @"(?# FFXIV - Countdown Start)\|Engage!\|" },
};

private Dictionary<string, string> stopRecordingRegexes = new Dictionary<string, string>() {
// FFXIV
{ "FFXIV - ACT Combat End", @"^(?# FFXIV - ACT Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>1)\|" },
{ "FFXIV - Game Combat End", @"^(?# FFXIV - Game Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>[^|]*)\|(?<inGameCombat>1)\|" },
{ "FFXIV - Wipe", @"(?# FFXIV - Countdown Start)\|Battle commencing in (?<time>[^ ]+) seconds! \((?<player>.*?)\)\|" },
{ "FFXIV - ACT Combat End", @"^(?# FFXIV - ACT Combat End)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>0)\|" },
{ "FFXIV - Game Combat End", @"^(?# FFXIV - Game Combat End)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>[^|]*)\|(?<inGameCombat>0)\|" },
{ "FFXIV - Wipe", @"^(?# FFXIV - Wipe)(?<type>33)\|(?<timestamp>[^|]*)\|(?<instance>[^|]*)\|(?<command>4000000F)\|" },
{ "FFXIV - Area Unseal", @"(?# FFXIV - Area Unseal)(?<area>.*?) is no longer sealed." },
};

public ConfigPanel(PluginConfig config)
Expand Down Expand Up @@ -94,7 +96,7 @@ private void btnAddStopRecording_Click(object sender, EventArgs e)
{
var key = cmbStopRecording.SelectedItem.ToString();
string value;
if (!startRecordingRegexes.TryGetValue(key, out value))
if (!stopRecordingRegexes.TryGetValue(key, out value))
{
return;
}
Expand Down
10 changes: 9 additions & 1 deletion PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class PluginConfig
private string[] stopRecording = new string[] { };
private string settingsFilePath = Path.Combine(ActGlobals.oFormActMain.AppDataFolder.FullName, "Config\\ACTOBSPlugin.config.json");

private bool loaded = false;

public bool Enabled
{
get => enabled;
Expand Down Expand Up @@ -79,6 +81,7 @@ public string[] StopRecording

public void Load()
{
loaded = true;
try
{
var loadedConfig = JsonConvert.DeserializeObject<PluginConfig>(File.ReadAllText(settingsFilePath));
Expand All @@ -89,7 +92,10 @@ public void Load()
startRecording = loadedConfig.startRecording;
stopRecording = loadedConfig.stopRecording;
}
catch (Exception) { }
catch (Exception ex)
{
ActGlobals.oFormActMain.WriteExceptionLog(ex, "Exception loading ACTOBSPlugin config");
}
}
public void Save()
{
Expand All @@ -99,6 +105,8 @@ public void Save()

private void FireEvent(bool EnabledChanged = false, bool AutoRenameChanged = false, bool HostPortChanged = false, bool PasswordChanged = false, bool StartRecordingChanged = false, bool StopRecordingChanged = false)
{
if (!loaded) return;

if (EnabledChanged || AutoRenameChanged || HostPortChanged || PasswordChanged || StartRecordingChanged || StopRecordingChanged)
{
Save();
Expand Down

0 comments on commit 30a3d66

Please sign in to comment.