Skip to content

Commit

Permalink
Sort global labels to end
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Aug 17, 2021
1 parent 726bb54 commit 3e8420a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion GUI/Dialogs/EditLabelsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ private void LoadTree()
LabelSelectionTree.Nodes.Clear();
var groups = this.labels.Labels
.GroupBy(l => l.InstanceName)
.OrderBy(g => g.Key);
.OrderBy(g => g.Key == null)
.ThenBy(g => g.Key);
foreach (var group in groups)
{
string groupName = string.IsNullOrEmpty(group.Key)
Expand Down Expand Up @@ -275,6 +276,8 @@ private bool TrySave(out string errMsg)
{
labels.Labels = labels.Labels
.Concat(new ModuleLabel[] { currentlyEditing })
.OrderBy(l => l.InstanceName == null)
.ThenBy(l => l.InstanceName)
.ToArray();
}
currentlyEditing.Name = NameTextBox.Text;
Expand Down
10 changes: 10 additions & 0 deletions GUI/Labels/ModuleLabelList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace CKAN
Expand Down Expand Up @@ -63,6 +64,15 @@ public static ModuleLabelList Load(string path)
}
}

[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
// false < true
Labels = Labels.OrderBy(l => l.InstanceName == null)
.ThenBy(l => l.InstanceName)
.ToArray();
}

public bool Save(string path)
{
try
Expand Down

0 comments on commit 3e8420a

Please sign in to comment.