// Copyright (c) Wojciech Figat. All rights reserved.
using System;
using FlaxEngine.GUI;
namespace FlaxEditor.Content
{
///
/// Root tree node for the project workspace.
///
///
public sealed class ProjectFolderTreeNode : ContentFolderTreeNode
{
///
/// The project/
///
public readonly ProjectInfo Project;
///
/// The project content directory.
///
public MainContentFolderTreeNode Content;
///
/// The project source code directory.
///
public MainContentFolderTreeNode Source;
///
/// Initializes a new instance of the class.
///
/// The project.
public ProjectFolderTreeNode(ProjectInfo project)
: base(null, project.ProjectFolderPath)
{
Project = project;
Folder.FileName = Folder.ShortName = Text = project.Name;
}
///
public override string NavButtonLabel => Project.Name;
///
protected override void DoDragDrop()
{
// No drag for root nodes
}
///
public override int Compare(Control other)
{
if (other is ProjectFolderTreeNode otherProject)
{
var gameProject = Editor.Instance.GameProject;
var engineProject = Editor.Instance.EngineProject;
bool isGame = Project == gameProject;
bool isEngine = Project == engineProject;
bool otherIsGame = otherProject.Project == gameProject;
bool otherIsEngine = otherProject.Project == engineProject;
// Main game project at the top
if (isGame && !otherIsGame)
return -1;
if (!isGame && otherIsGame)
return 1;
// Engine project at the bottom (when distinct)
if (isEngine && !otherIsEngine)
return 1;
if (!isEngine && otherIsEngine)
return -1;
return string.CompareOrdinal(Project.Name, otherProject.Project.Name);
}
return base.Compare(other);
}
}
}