Skip to content

Commit

Permalink
Add options for ending encounters
Browse files Browse the repository at this point in the history
This adds two opt-in event settings for ending encounters, one on wipe
and one five seconds (non-configurable) after game combat ends.

This is already implemented in both cactbot and Triggernometry, and so
it makes some sense to consolidate these options in one place where
they can be useful to everybody.

The "five seconds" combat option is intended for the use cases of
older fights (such as ARR/HW where the Network6D line is not sent)
and dungeons (to split before a boss).
  • Loading branch information
quisquous committed Jun 7, 2020
1 parent ee1f4ba commit dd71ff2
Show file tree
Hide file tree
Showing 6 changed files with 854 additions and 566 deletions.
48 changes: 48 additions & 0 deletions OverlayPlugin.Core/EventSources/BuiltinEventConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class BuiltinEventConfig
public event EventHandler SortKeyChanged;
public event EventHandler SortDescChanged;
public event EventHandler UpdateDpsDuringImportChanged;
public event EventHandler EndEncounterAfterWipeChanged;
public event EventHandler EndEncounterOutOfCombatChanged;

private int updateInterval;
public int UpdateInterval {
Expand Down Expand Up @@ -97,6 +99,40 @@ public bool UpdateDpsDuringImport
}
}

private bool endEncounterAfterWipe;
public bool EndEncounterAfterWipe
{
get
{
return this.endEncounterAfterWipe;
}
set
{
if (this.endEncounterAfterWipe != value)
{
this.endEncounterAfterWipe = value;
EndEncounterAfterWipeChanged?.Invoke(this, new EventArgs());
}
}
}

private bool endEncounterOutOfCombat;
public bool EndEncounterOutOfCombat
{
get
{
return this.endEncounterOutOfCombat;
}
set
{
if (this.endEncounterOutOfCombat != value)
{
this.endEncounterOutOfCombat = value;
EndEncounterOutOfCombatChanged?.Invoke(this, new EventArgs());
}
}
}

// Data that overlays can save/load via event handlers.
public Dictionary<string, JToken> OverlayData = new Dictionary<string, JToken>();

Expand All @@ -107,6 +143,8 @@ public BuiltinEventConfig()
this.sortKey = "encdps";
this.sortDesc = true;
this.updateDpsDuringImport = false;
this.endEncounterAfterWipe = false;
this.endEncounterOutOfCombat = false;
}

public static BuiltinEventConfig LoadConfig(IPluginConfig Config)
Expand Down Expand Up @@ -142,6 +180,16 @@ public static BuiltinEventConfig LoadConfig(IPluginConfig Config)
result.updateDpsDuringImport = value.ToObject<bool>();
}

if (obj.TryGetValue("EndEncounterAfterWipe", out value))
{
result.endEncounterAfterWipe = value.ToObject<bool>();
}

if (obj.TryGetValue("EndEncounterOutOfCombat", out value))
{
result.endEncounterOutOfCombat = value.ToObject<bool>();
}

if (obj.TryGetValue("OverlayData", out value))
{
result.OverlayData = value.ToObject<Dictionary<string, JToken>>();
Expand Down
238 changes: 137 additions & 101 deletions OverlayPlugin.Core/EventSources/BuiltinEventConfigPanel.Designer.cs

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

29 changes: 29 additions & 0 deletions OverlayPlugin.Core/EventSources/BuiltinEventConfigPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ private void SetupControlProperties()

this.checkSortDesc.Checked = config.SortDesc;
this.cbUpdateDuringImport.Checked = config.UpdateDpsDuringImport;

this.cbEndEncounterAfterWipe.Checked = config.EndEncounterAfterWipe;
this.cbEndEncounterOutOfCombat.Checked = config.EndEncounterOutOfCombat;
}

private void SetupConfigEventHandlers()
Expand Down Expand Up @@ -92,6 +95,22 @@ private void SetupConfigEventHandlers()
this.cbUpdateDuringImport.Checked = config.UpdateDpsDuringImport;
});
};

this.config.EndEncounterAfterWipeChanged += (o, e) =>
{
this.InvokeIfRequired(() =>
{
this.cbEndEncounterAfterWipe.Checked = config.EndEncounterAfterWipe;
});
};

this.config.EndEncounterOutOfCombatChanged += (o, e) =>
{
this.InvokeIfRequired(() =>
{
this.cbEndEncounterOutOfCombat.Checked = config.EndEncounterOutOfCombat;
});
};
}

private void InvokeIfRequired(Action action)
Expand Down Expand Up @@ -133,6 +152,16 @@ private void cbUpdateDuringImport_CheckedChanged(object sender, EventArgs e)
this.config.UpdateDpsDuringImport = this.cbUpdateDuringImport.Checked;
}

private void cbEndEncounterAfterWipe_CheckedChanged(object sender, EventArgs e)
{
this.config.EndEncounterAfterWipe = this.cbEndEncounterAfterWipe.Checked;
}

private void cbEndEncounterOutOfCombat_CheckedChanged(object sender, EventArgs e)
{
this.config.EndEncounterOutOfCombat = this.cbEndEncounterOutOfCombat.Checked;
}

private void TextEnmityInterval_Leave(object sender, EventArgs e)
{
if (int.TryParse(this.textEnmityInterval.Text, out int value))
Expand Down
Loading

0 comments on commit dd71ff2

Please sign in to comment.