mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Asset renaming + AssetHierarchy: major refactoring for file tree construction
+ AssetFile: Added "AssetConfigPath" Property + Less crashy, more cleaner
This commit is contained in:
@@ -6,6 +6,7 @@ using GlitchyEngine.Collections;
|
||||
using System.Collections;
|
||||
using GlitchyEngine.Renderer;
|
||||
using GlitchyEngine.Math;
|
||||
using GlitchyEngine.Content;
|
||||
using GlitchyEngine;
|
||||
using GlitchyEditor.Assets;
|
||||
|
||||
@@ -48,6 +49,9 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
private append String _selectedFile = .();
|
||||
|
||||
private append String _assetToRename = .();
|
||||
private char8[128] _renameFileNameBuffer;
|
||||
|
||||
public static SubTexture2D s_FolderTexture;
|
||||
public static SubTexture2D s_FileTexture;
|
||||
|
||||
@@ -467,7 +471,44 @@ namespace GlitchyEditor.EditWindows
|
||||
EntryDoubleClicked(entry);
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(entry->Name);
|
||||
if (_assetToRename == entry->Path)
|
||||
{
|
||||
ImGui.PushItemWidth((.)IconSize.X);
|
||||
|
||||
if (ImGui.InputText("##renameBox", &_renameFileNameBuffer, _renameFileNameBuffer.Count - 1, .AutoSelectAll | .EnterReturnsTrue))
|
||||
{
|
||||
}
|
||||
|
||||
ImGui.PopItemWidth();
|
||||
|
||||
if (ImGui.IsKeyDown(.Escape))
|
||||
{
|
||||
_assetToRename.Clear();
|
||||
}
|
||||
else if (ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
StringView newName = StringView(&_renameFileNameBuffer);
|
||||
|
||||
if (!newName.IsWhiteSpace)
|
||||
_manager.AssetHierarchy.RenameFile(entry.Value, newName);
|
||||
|
||||
_assetToRename.Clear();
|
||||
}
|
||||
else if (ImGui.IsItemDeactivated())
|
||||
{
|
||||
_assetToRename.Clear();
|
||||
}
|
||||
|
||||
// TODO: Textbox
|
||||
// TODO: Save when focus lost
|
||||
// TODO: Abort on escape
|
||||
|
||||
//ImGui.TextUnformatted(entry->Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(entry->Name);
|
||||
}
|
||||
|
||||
bool wantsDelete = false;
|
||||
|
||||
@@ -575,6 +616,16 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.MenuItem("Rename"))
|
||||
{
|
||||
// Copy the path, just for the rare case that fileOrFolder gets deleted
|
||||
_assetToRename.Set(fileOrFolder->Path);
|
||||
|
||||
fileOrFolder->Name.CopyTo(_renameFileNameBuffer);
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Delete"))
|
||||
{
|
||||
wantsDelete = true;
|
||||
|
||||
Reference in New Issue
Block a user