Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for ending encounters after wipes and out of game combat #134

Merged
merged 2 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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