feat: add preset copy button

This commit is contained in:
Anna 2021-01-16 20:32:16 -05:00
parent 3b596f289e
commit 3167d286e3
2 changed files with 36 additions and 0 deletions

View File

@ -105,6 +105,28 @@ namespace BetterPartyFinder {
}
}
internal ConfigurationFilter Clone() {
var categories = this.Categories.ToHashSet();
var duties = this.Duties.ToHashSet();
var jobs = this.Jobs.ToList();
return new ConfigurationFilter {
Categories = categories,
Conditions = this.Conditions,
Duties = duties,
Jobs = jobs,
Name = string.Copy(this.Name),
Objectives = this.Objectives,
DutiesMode = this.DutiesMode,
LootRule = this.LootRule,
SearchArea = this.SearchArea,
DutyFinderSettings = this.DutyFinderSettings,
MaxItemLevel = this.MaxItemLevel,
MinItemLevel = this.MinItemLevel,
AllowHugeItemLevel = this.AllowHugeItemLevel,
};
}
internal static ConfigurationFilter Create() {
return new() {
Categories = Enum.GetValues(typeof(UiCategory))

View File

@ -220,6 +220,20 @@ namespace BetterPartyFinder {
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.Copy, "copy") && selected != null) {
if (this.Plugin.Config.Presets.TryGetValue(selected.Value, out var copyFilter)) {
var guid = Guid.NewGuid();
var copied = copyFilter.Clone();
copied.Name += " (copy)";
this.Plugin.Config.Presets.Add(guid, copied);
this.Plugin.Config.SelectedPreset = guid;
this.Plugin.Config.Save();
}
}
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.Cog, "settings")) {
this.SettingsVisible = true;
}