mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-09-23 07:22:25 +00:00
Folders now sort on top of other files
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Formats.Pck;
|
||||
using PckStudio.Core.Extensions;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Internal
|
||||
{
|
||||
@@ -39,17 +38,30 @@ namespace PckStudio.Internal
|
||||
|
||||
private int InternalCompare(TreeNode first, TreeNode second)
|
||||
{
|
||||
if (first.IsTagOfType<PckAsset>() && !second.IsTagOfType<PckAsset>())
|
||||
bool firstIsFile = first.IsTagOfType<PckAsset>();
|
||||
bool secondIsFile = second.IsTagOfType<PckAsset>();
|
||||
|
||||
// Put folders first
|
||||
if (!firstIsFile && secondIsFile)
|
||||
return -1;
|
||||
if (!first.IsTagOfType<PckAsset>() && second.IsTagOfType<PckAsset>())
|
||||
if (firstIsFile && !secondIsFile)
|
||||
return 1;
|
||||
|
||||
if (CheckForSkinAndCapeFiles(first))
|
||||
return 1;
|
||||
if (CheckForSkinAndCapeFiles(second))
|
||||
return 1;
|
||||
bool firstIsSkinOrCape = CheckForSkinAndCapeFiles(first);
|
||||
bool secondIsSkinOrCape = CheckForSkinAndCapeFiles(second);
|
||||
|
||||
return first.Text.CompareTo(second.Text);
|
||||
// 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