mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
EditorContentManager Part 2
This commit is contained in:
@@ -61,7 +61,7 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
private void ImGuiPrintEntityTree(TreeNode<EditorContentManager.AssetNode> tree)
|
||||
private void ImGuiPrintEntityTree(TreeNode<AssetNode> tree)
|
||||
{
|
||||
if (!tree->IsDirectory)
|
||||
return;
|
||||
@@ -127,7 +127,7 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDirectoryItem(TreeNode<EditorContentManager.AssetNode> entry)
|
||||
private void DrawDirectoryItem(TreeNode<AssetNode> entry)
|
||||
{
|
||||
ImGui.BeginChild("item", (.)DirectoryItemSize);
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace GlitchyEditor.EditWindows
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
private void EntryDoubleClicked(TreeNode<EditorContentManager.AssetNode> entry)
|
||||
private void EntryDoubleClicked(TreeNode<AssetNode> entry)
|
||||
{
|
||||
if (entry->IsDirectory)
|
||||
{
|
||||
|
||||
@@ -111,7 +111,7 @@ class EditorContentManager : IContentManager
|
||||
|
||||
bool _fileSystemDirty = false;
|
||||
|
||||
internal TreeNode<AssetNode> _assetHierarchy = new TreeNode<AssetNode>() ~ DeleteTreeAndChildren!(_);
|
||||
internal TreeNode<AssetNode> _assetHierarchy = null /*new TreeNode<AssetNode>()*/ ~ DeleteTreeAndChildren!(_);
|
||||
|
||||
private append String _contentDirectory = .();
|
||||
|
||||
@@ -169,14 +169,28 @@ class EditorContentManager : IContentManager
|
||||
}
|
||||
}
|
||||
|
||||
public IAssetLoader GetDefaultAssetLoader(StringView fileExtension)
|
||||
{
|
||||
if (_defaultAssetLoaders.TryGetValue(fileExtension, let value))
|
||||
return value;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Rebuilds the asset file hierarchy.
|
||||
private void UpdateFiles()
|
||||
{
|
||||
// TODO: we don't need to rebuild the entire tree!
|
||||
DeleteTreeAndChildren!(_assetHierarchy);
|
||||
//DeleteTreeAndChildren!(_assetHierarchy);
|
||||
|
||||
if (_assetHierarchy == null)
|
||||
{
|
||||
// TODO: move to init?
|
||||
|
||||
_assetHierarchy = new TreeNode<AssetNode>(new AssetNode());
|
||||
_assetHierarchy->Path = new String(ContentDirectory);
|
||||
_assetHierarchy->Name = new String("Content");
|
||||
}
|
||||
|
||||
String str = scope .(ContentDirectory);
|
||||
|
||||
@@ -250,6 +264,15 @@ class EditorContentManager : IContentManager
|
||||
|
||||
void AddDirectoryToTree(String path, TreeNode<AssetNode> parentNode)
|
||||
{
|
||||
bool b (AssetNode node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//void V() :
|
||||
|
||||
var v = parentNode.Children.First();
|
||||
|
||||
AssetNode node = new AssetNode();
|
||||
node.Path = new String(path);
|
||||
node.Name = new String();
|
||||
@@ -283,14 +306,6 @@ class EditorContentManager : IContentManager
|
||||
_fileSystemDirty = false;
|
||||
}
|
||||
|
||||
public IAssetLoader GetDefaultAssetLoader(StringView fileExtension)
|
||||
{
|
||||
if (_defaultAssetLoaders.TryGetValue(fileExtension, let value))
|
||||
return value;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private append List<String> _supportedExtensions = .() ~ ClearAndDeleteItems!(_);
|
||||
private append List<IAssetLoader> _assetLoaders = .() ~ ClearAndDeleteItems!(_);
|
||||
private append Dictionary<StringView, IAssetLoader> _defaultAssetLoaders = .();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// https://github.com/Moneyl/Beef.Linq/blob/master/src/src/Enumerable.bf
|
||||
|
||||
using System.Collections;
|
||||
using System;
|
||||
using internal System.Linq;
|
||||
@@ -164,7 +162,7 @@ namespace System.Linq
|
||||
}
|
||||
|
||||
public static bool Any<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
|
||||
where TCollection : concrete, IEnumerable<TSource>, class, new
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
for (var it in items)
|
||||
@@ -557,24 +555,6 @@ namespace System.Linq
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool InternalFirst<TEnum, TSource, TPredicate>(TEnum items, out TSource val, TPredicate predicate)
|
||||
where TEnum : concrete, IEnumerator<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
val = default;
|
||||
using (var iterator = Iterator.Wrap(items))
|
||||
{
|
||||
var enumerator = iterator.mEnum;
|
||||
if (enumerator.GetNext() case .Ok(out val))
|
||||
{
|
||||
if (predicate(val))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static TSource First<TCollection, TSource>(this TCollection items)
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
{
|
||||
@@ -583,15 +563,6 @@ namespace System.Linq
|
||||
Runtime.FatalError("Sequence contained no elements.");
|
||||
}
|
||||
|
||||
public static TSource First<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
if (InternalFirst<decltype(default(TCollection).GetEnumerator()), TSource, TPredicate>(items.GetEnumerator(), let val, predicate))
|
||||
return val;
|
||||
Runtime.FatalError("Sequence contained no elements.");
|
||||
}
|
||||
|
||||
public static TSource First<TEnum, TSource>(this TEnum items)
|
||||
where TEnum : concrete, IEnumerator<TSource>
|
||||
{
|
||||
@@ -600,15 +571,6 @@ namespace System.Linq
|
||||
Runtime.FatalError("Sequence contained no elements.");
|
||||
}
|
||||
|
||||
public static TSource First<TEnum, TSource, TPredicate>(this TEnum items, TPredicate predicate)
|
||||
where TEnum : concrete, IEnumerator<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
if (InternalFirst<TEnum, TSource, TPredicate>(items, let val, predicate))
|
||||
return val;
|
||||
Runtime.FatalError("Sequence contained no elements.");
|
||||
}
|
||||
|
||||
public static TSource FirstOrDefault<TCollection, TSource>(this TCollection items)
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
{
|
||||
@@ -618,24 +580,6 @@ namespace System.Linq
|
||||
return default;
|
||||
}
|
||||
|
||||
public static TSource FirstOrDefault<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
if (InternalFirst<decltype(default(TCollection).GetEnumerator()), TSource, TPredicate>(items.GetEnumerator(), let val, predicate))
|
||||
return val;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
/*public static WhereEnumerable<TSource, decltype(default(TCollection).GetEnumerator()), TPredicate>
|
||||
Where<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
|
||||
where TCollection : concrete, IEnumerable<TSource>
|
||||
where TPredicate : delegate bool(TSource)
|
||||
{
|
||||
return .(items.GetEnumerator(), predicate);
|
||||
}*/
|
||||
|
||||
public static TSource FirstOrDefault<TEnum, TSource>(this TEnum items)
|
||||
where TEnum : concrete, IEnumerator<TSource>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user