Skip to content

Commit

Permalink
Merge pull request #134 from quisquous/combat
Browse files Browse the repository at this point in the history
Add options for ending encounters after wipes and out of game combat
  • Loading branch information
ngld authored Jul 25, 2020
2 parents e23f887 + dd71ff2 commit c4e90f3
Show file tree
Hide file tree
Showing 9 changed files with 949 additions and 565 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 c4e90f3

Please sign in to comment.