Skip to content

Commit

Permalink
Added ability to sort files
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Jan 16, 2024
1 parent 35f64e8 commit b972762
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
14 changes: 14 additions & 0 deletions FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,12 @@ private static void GetObjectAndListForMoving(out object objectToMove,
.ToList();
}
}
else if(GlueState.Self.CurrentReferencedFileSave != null)
{
objectToMove = GlueState.Self.CurrentReferencedFileSave;
listToRemoveFrom = GlueState.Self.CurrentElement.ReferencedFiles;
listForIndexing = GlueState.Self.CurrentElement.ReferencedFiles;
}
}


Expand All @@ -2464,6 +2470,8 @@ private static void PostMoveActivity(object objectMoved, int oldIndex, int newIn
var variableMoved = objectMoved as CustomVariable;
var namedObjectMoved = objectMoved as NamedObjectSave;
var stateSaveMoved = objectMoved as StateSave;
var fileMoved = objectMoved as ReferencedFileSave;

// Should this be the current? Or the "container" of what was moved...
var element = GlueState.Self.CurrentElement;

Expand All @@ -2487,6 +2495,12 @@ private static void PostMoveActivity(object objectMoved, int oldIndex, int newIn

GlueState.Self.CurrentStateSave = stateSaveMoved;
}
else if(fileMoved != null)
{
GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(element, TreeNodeRefreshType.All); // this could be just files eventually

GlueState.Self.CurrentReferencedFileSave = fileMoved;
}

GlueState.Self.CurrentElement.SortStatesToCustomVariables();
var elementsToRegen = new HashSet<GlueElement>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ public override void RefreshTreeNodes(TreeNodeRefreshType treeNodeRefreshType)
// I don't think we want the files in Glue to identically match the order of the files in the
// Glux - we will want to alphabetize them.
//int index = nodeList.IndexOf(nodeForFile);
// Update January 15, 2024
// they should match because file order matters for things like Spine.
// This sucks but...we need to do it:
int index = nodeList.IndexOf(nodeForFile);

//if (i != index)
//{
// nodeList.RemoveAt(index);
// nodeList.Insert(i, nodeForFile);
//}
if (i != index)
{
nodeList.RemoveAt(index);
nodeList.Insert(i, nodeForFile);
}

string newText = FileManager.RemovePath(file.Name);
if (newText != nodeForFile.Text)
Expand All @@ -108,7 +112,8 @@ public override void RefreshTreeNodes(TreeNodeRefreshType treeNodeRefreshType)

RemoveTreeNodesForRemovedReferenceFileSavesIn(this.Children, glueElement.ReferencedFiles, glueElement);

this.SortByTextConsideringDirectories(Children, true);
// no, don't sort! See above why this is important:
//this.SortByTextConsideringDirectories(Children, true);
}

public NodeViewModel GetTreeNodeFor(ReferencedFileSave referencedFileSave)
Expand Down

0 comments on commit b972762

Please sign in to comment.