mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-09-23 09:12:56 +00:00
Folders now sort on top of other files
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
using System.Collections;
|
using OMI.Formats.Pck;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using OMI.Formats.Pck;
|
|
||||||
using PckStudio.Core.Extensions;
|
using PckStudio.Core.Extensions;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace PckStudio.Internal
|
namespace PckStudio.Internal
|
||||||
{
|
{
|
||||||
@@ -37,20 +36,33 @@ namespace PckStudio.Internal
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int InternalCompare(TreeNode first, TreeNode second)
|
private int InternalCompare(TreeNode first, TreeNode second)
|
||||||
{
|
{
|
||||||
if (first.IsTagOfType<PckAsset>() && !second.IsTagOfType<PckAsset>())
|
bool firstIsFile = first.IsTagOfType<PckAsset>();
|
||||||
return -1;
|
bool secondIsFile = second.IsTagOfType<PckAsset>();
|
||||||
if (!first.IsTagOfType<PckAsset>() && second.IsTagOfType<PckAsset>())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (CheckForSkinAndCapeFiles(first))
|
// Put folders first
|
||||||
return 1;
|
if (!firstIsFile && secondIsFile)
|
||||||
if (CheckForSkinAndCapeFiles(second))
|
return -1;
|
||||||
return 1;
|
if (firstIsFile && !secondIsFile)
|
||||||
|
return 1;
|
||||||
|
|
||||||
return first.Text.CompareTo(second.Text);
|
bool firstIsSkinOrCape = CheckForSkinAndCapeFiles(first);
|
||||||
}
|
bool secondIsSkinOrCape = CheckForSkinAndCapeFiles(second);
|
||||||
}
|
|
||||||
|
// Skins and capes after the rest for simplicity
|
||||||
|
if (firstIsSkinOrCape && !secondIsSkinOrCape)
|
||||||
|
return 1;
|
||||||
|
if (!firstIsSkinOrCape && secondIsSkinOrCape)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// Don't change order if both are skin related files
|
||||||
|
if (firstIsSkinOrCape && secondIsSkinOrCape)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Sort the rest alpha-numerically
|
||||||
|
return string.Compare(first.Text, second.Text, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user