mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
Merge branch 'master' of https://github.com/goatcorp/Dalamud
This commit is contained in:
commit
4c9f6e0d6f
2 changed files with 36 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using CheapLoc;
|
using CheapLoc;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
|
|
@ -114,7 +115,8 @@ namespace Dalamud.Interface.Internal
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether category content needs to be rebuild with BuildCategoryContent() function.
|
/// Gets a value indicating whether current group + category selection changed recently.
|
||||||
|
/// Changes in Available group should be followed with <see cref="GetCurrentCategoryContent"/>, everythine else can use <see cref="ResetContentDirty"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContentDirty => this.isContentDirty;
|
public bool IsContentDirty => this.isContentDirty;
|
||||||
|
|
||||||
|
|
@ -136,6 +138,10 @@ namespace Dalamud.Interface.Internal
|
||||||
// rebuild map plugin name -> categoryIds
|
// rebuild map plugin name -> categoryIds
|
||||||
this.mapPluginCategories.Clear();
|
this.mapPluginCategories.Clear();
|
||||||
|
|
||||||
|
var groupAvail = Array.Find(this.groupList, x => x.GroupKind == GroupKind.Available);
|
||||||
|
var prevCategoryIds = new List<int>();
|
||||||
|
prevCategoryIds.AddRange(groupAvail.Categories);
|
||||||
|
|
||||||
var categoryList = new List<int>();
|
var categoryList = new List<int>();
|
||||||
var allCategoryIndices = new List<int>();
|
var allCategoryIndices = new List<int>();
|
||||||
|
|
||||||
|
|
@ -174,7 +180,6 @@ namespace Dalamud.Interface.Internal
|
||||||
allCategoryIndices.Sort((idxX, idxY) => this.CategoryList[idxX].Name.CompareTo(this.CategoryList[idxY].Name));
|
allCategoryIndices.Sort((idxX, idxY) => this.CategoryList[idxX].Name.CompareTo(this.CategoryList[idxY].Name));
|
||||||
|
|
||||||
// rebuild all categories in group, leaving first entry = All intact and always on top
|
// rebuild all categories in group, leaving first entry = All intact and always on top
|
||||||
var groupAvail = Array.Find(this.groupList, x => x.GroupKind == GroupKind.Available);
|
|
||||||
if (groupAvail.Categories.Count > 1)
|
if (groupAvail.Categories.Count > 1)
|
||||||
{
|
{
|
||||||
groupAvail.Categories.RemoveRange(1, groupAvail.Categories.Count - 1);
|
groupAvail.Categories.RemoveRange(1, groupAvail.Categories.Count - 1);
|
||||||
|
|
@ -185,12 +190,17 @@ namespace Dalamud.Interface.Internal
|
||||||
groupAvail.Categories.Add(this.CategoryList[categoryIdx].CategoryId);
|
groupAvail.Categories.Add(this.CategoryList[categoryIdx].CategoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isContentDirty = true;
|
// compare with prev state and mark as dirty if needed
|
||||||
|
var noCategoryChanges = Enumerable.SequenceEqual(prevCategoryIds, groupAvail.Categories);
|
||||||
|
if (!noCategoryChanges)
|
||||||
|
{
|
||||||
|
this.isContentDirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filters list of available plugins based on currently selected category.
|
/// Filters list of available plugins based on currently selected category.
|
||||||
/// Resets <see cref="isContentDirty"/>.
|
/// Resets <see cref="IsContentDirty"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="plugins">List of available plugins to install.</param>
|
/// <param name="plugins">List of available plugins to install.</param>
|
||||||
/// <returns>Filtered list of plugins.</returns>
|
/// <returns>Filtered list of plugins.</returns>
|
||||||
|
|
@ -225,10 +235,18 @@ namespace Dalamud.Interface.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isContentDirty = false;
|
this.ResetContentDirty();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears <see cref="IsContentDirty"/> flag, indicating that all cached values about currently selected group + category have been updated.
|
||||||
|
/// </summary>
|
||||||
|
public void ResetContentDirty()
|
||||||
|
{
|
||||||
|
this.isContentDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets category highlight based on list of plugins. Used for searching.
|
/// Sets category highlight based on list of plugins. Used for searching.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -535,12 +535,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset opened list of collapsibles when switching between categories
|
// get list to show and reset category dirty flag
|
||||||
if (this.categoryManager.IsContentDirty)
|
|
||||||
{
|
|
||||||
this.openPluginCollapsibles.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
var categoryManifestsList = this.categoryManager.GetCurrentCategoryContent(filteredManifests);
|
var categoryManifestsList = this.categoryManager.GetCurrentCategoryContent(filteredManifests);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
@ -726,6 +721,18 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ImGuiHelpers.ScaledVector2(1, 3));
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ImGuiHelpers.ScaledVector2(1, 3));
|
||||||
|
|
||||||
var groupInfo = this.categoryManager.GroupList[this.categoryManager.CurrentGroupIdx];
|
var groupInfo = this.categoryManager.GroupList[this.categoryManager.CurrentGroupIdx];
|
||||||
|
if (this.categoryManager.IsContentDirty)
|
||||||
|
{
|
||||||
|
// reset opened list of collapsibles when switching between categories
|
||||||
|
this.openPluginCollapsibles.Clear();
|
||||||
|
|
||||||
|
// do NOT reset dirty flag when Available group is selected, it will be handled by DrawAvailablePluginList()
|
||||||
|
if (groupInfo.GroupKind != PluginCategoryManager.GroupKind.Available)
|
||||||
|
{
|
||||||
|
this.categoryManager.ResetContentDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.DevTools)
|
if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.DevTools)
|
||||||
{
|
{
|
||||||
// this one is never sorted and remains in hardcoded order from group ctor
|
// this one is never sorted and remains in hardcoded order from group ctor
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue