diff --git a/GlitchyEditor/SandboxProject/Assets/Scripts/Properties/AssemblyInfo.cs b/GlitchyEditor/SandboxProject/Assets/Scripts/Properties/AssemblyInfo.cs
index 1e0009f..c4acc55 100644
--- a/GlitchyEditor/SandboxProject/Assets/Scripts/Properties/AssemblyInfo.cs
+++ b/GlitchyEditor/SandboxProject/Assets/Scripts/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
-[assembly: AssemblyTitle("Sanbox")]
+[assembly: AssemblyTitle("SandboxProject")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Sanbox")]
+[assembly: AssemblyProduct("SandboxProject")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.csproj b/GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.csproj
similarity index 96%
rename from GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.csproj
rename to GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.csproj
index eed696f..8d5b2bc 100644
--- a/GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.csproj
+++ b/GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.csproj
@@ -7,8 +7,8 @@
{7A70819C-5317-402A-8553-95C5A001E370}
Library
Properties
- Sandbox
- Sandbox
+ SandboxProject
+ SandboxProject
v4.7.2
512
true
diff --git a/GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.sln b/GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.sln
similarity index 93%
rename from GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.sln
rename to GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.sln
index dcc6eec..e334177 100644
--- a/GlitchyEditor/SandboxProject/Assets/Scripts/Sandbox.sln
+++ b/GlitchyEditor/SandboxProject/Assets/Scripts/SandboxProject.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox.csproj", "{7A70819C-5317-402A-8553-95C5A001E370}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandboxProject", "SandboxProject.csproj", "{7A70819C-5317-402A-8553-95C5A001E370}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCore", "..\..\..\..\ScriptCore\ScriptCore.csproj", "{6222C226-FC78-498C-80BA-5CF10AC9123C}"
EndProject
diff --git a/GlitchyEditor/SandboxProject/project.gep b/GlitchyEditor/SandboxProject/project.gep
new file mode 100644
index 0000000..d6924ee
--- /dev/null
+++ b/GlitchyEditor/SandboxProject/project.gep
@@ -0,0 +1 @@
+{_projectName="SandboxProject"}
\ No newline at end of file
diff --git a/GlitchyEditor/resources/ProjectTemplate/.gitignore b/GlitchyEditor/resources/ProjectTemplate/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/.gitignore b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/.gitignore
new file mode 100644
index 0000000..8a30d25
--- /dev/null
+++ b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/.gitignore
@@ -0,0 +1,398 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
diff --git a/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/Properties/AssemblyInfo.cs b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f73cedc
--- /dev/null
+++ b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("[ProjectName]")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("[ProjectName]")]
+[assembly: AssemblyCopyright("Copyright © 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("7a70819c-5317-402a-8553-95c5a001e370")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// indem Sie "*" wie unten gezeigt eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.csproj b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.csproj
new file mode 100644
index 0000000..700eefa
--- /dev/null
+++ b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.csproj
@@ -0,0 +1,53 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7A70819C-5317-402A-8553-95C5A001E370}
+ Library
+ Properties
+ [ProjectName]
+ [ProjectName]
+ v4.7.2
+ 512
+ true
+
+
+ true
+ portable
+ false
+ bin\
+ DEBUG;TRACE
+ prompt
+ 4
+ default
+
+
+ pdbonly
+ true
+ bin\
+ TRACE
+ prompt
+ 4
+ default
+
+
+
+ False
+ [CoreLibPath]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.sln b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.sln
new file mode 100644
index 0000000..a2054d7
--- /dev/null
+++ b/GlitchyEditor/resources/ProjectTemplate/Assets/Scripts/TemplateProject.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.4.33205.214
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "[ProjectName]", "[ProjectName].csproj", "{7A70819C-5317-402A-8553-95C5A001E370}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7A70819C-5317-402A-8553-95C5A001E370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A70819C-5317-402A-8553-95C5A001E370}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A70819C-5317-402A-8553-95C5A001E370}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A70819C-5317-402A-8553-95C5A001E370}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {B5D43D8D-D80B-41AA-BE40-1DC507D87148}
+ EndGlobalSection
+EndGlobal
diff --git a/GlitchyEditor/src/Assets/AssetHierarchy.bf b/GlitchyEditor/src/Assets/AssetHierarchy.bf
index a2020f9..94884eb 100644
--- a/GlitchyEditor/src/Assets/AssetHierarchy.bf
+++ b/GlitchyEditor/src/Assets/AssetHierarchy.bf
@@ -145,7 +145,9 @@ class AssetHierarchy
_pathToAssetNode.Remove(node->Path);
_identifierToAssetNode.Remove(node->Identifier);
});
+ _assetRootNode.RemoveChild(_resourcesDirectoryNode);
DeleteTreeAndChildren!(_resourcesDirectoryNode);
+ _resourcesDirectoryNode = null;
if (!Directory.Exists(ResourcesDirectory))
{
@@ -182,7 +184,9 @@ class AssetHierarchy
_pathToAssetNode.Remove(node->Path);
_identifierToAssetNode.Remove(node->Identifier);
});
+ _assetRootNode.RemoveChild(_assetsDirectoryNode);
DeleteTreeAndChildren!(_assetsDirectoryNode);
+ _assetsDirectoryNode = null;
if (!Directory.Exists(AssetsDirectory))
{
@@ -190,6 +194,7 @@ class AssetHierarchy
Log.EngineLogger.Warning($"Assets directory \"{AssetsDirectory}\" doesn't exist.");
return;
}
+
AssetNode assetNode = new AssetNode();
assetNode.Path = new String(AssetsDirectory);
@@ -297,6 +302,27 @@ class AssetHierarchy
}
}
+ /// Determines and set the Identfier for the given asset node.
+ private void DetermineIdentifier(TreeNode assetNode)
+ {
+ if (assetNode->Identifier == null)
+ assetNode->Identifier = new String();
+
+ assetNode->Identifier.Clear();
+
+ // Get the Identifier which is simply the path relative to the asste root (either Resources- or Assets-Folder)
+ if (assetNode.IsInSubtree(_resourcesDirectoryNode))
+ {
+ Path.GetRelativePath(assetNode->Path, _resourcesDirectoryNode->Path, assetNode->Identifier);
+ assetNode->Identifier.Insert(0, "Resources/");
+ }
+ else if (assetNode.IsInSubtree(_assetsDirectoryNode))
+ {
+ Path.GetRelativePath(assetNode->Path, _assetsDirectoryNode->Path, assetNode->Identifier);
+ assetNode->Identifier.Insert(0, "Assets/");
+ }
+ AssetIdentifier.Fixup(assetNode->Identifier);
+ }
/// Rebuilds the asset file hierarchy.
private void UpdateFiles()
@@ -324,6 +350,7 @@ class AssetHierarchy
entry.GetFilePath(filepathBuffer..Clear());
Path.GetExtension(filepathBuffer, .. extensionBuffer..Clear());
+ filepathBuffer.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
// Ignore meta files.
if (extensionBuffer.Equals(AssetFile.ConfigFileExtension, .OrdinalIgnoreCase))
@@ -337,14 +364,13 @@ class AssetHierarchy
assetNode.Name = new String();
Path.GetFileName(filepathBuffer, assetNode.Name);
- filepathBuffer.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
-
assetNode.Path = new String(filepathBuffer);
assetNode.IsDirectory = false;
- DetermineIdentifier(assetNode, directory);
-
treeNode = directory.AddChild(assetNode);
+
+ DetermineIdentifier(treeNode);
+
_pathToAssetNode.Add(assetNode.Path, treeNode);
_identifierToAssetNode.Add(assetNode.Identifier, treeNode);
@@ -376,27 +402,6 @@ class AssetHierarchy
}
}
- void DetermineIdentifier(AssetNode assetNode, TreeNode parentNode)
- {
- if (assetNode.Identifier == null)
- assetNode.Identifier = new String();
-
- assetNode.Identifier.Clear();
-
- // Get the Identifier which is simply the path relative to the asste root (either Resources- or Assets-Folder)
- if (parentNode.IsInSubtree(_resourcesDirectoryNode))
- {
- Path.GetRelativePath(assetNode.Path, _resourcesDirectoryNode->Path, assetNode.Identifier);
- assetNode.Identifier.Insert(0, "Resources/");
- }
- else if (parentNode.IsInSubtree(_assetsDirectoryNode))
- {
- Path.GetRelativePath(assetNode.Path, _assetsDirectoryNode->Path, assetNode.Identifier);
- assetNode.Identifier.Insert(0, "Assets/");
- }
- AssetIdentifier.Fixup(assetNode.Identifier);
- }
-
/// Adds the given directory to the specified tree.
/// Recursively adds all Files and Subdirectories.
void AddDirectoryToTree(String path, TreeNode parentNode)
@@ -416,8 +421,6 @@ class AssetHierarchy
assetNode.IsDirectory = true;
Path.GetFileName(assetNode.Path, assetNode.Name);
- DetermineIdentifier(assetNode, parentNode);
-
/*// Get the Identifier which is simply the path relative to the asste root (either Resources- or Assets-Folder)
if (parentNode == _resourcesDirectoryNode || parentNode.IsChildOf(_resourcesDirectoryNode))
{
@@ -432,6 +435,9 @@ class AssetHierarchy
AssetIdentifier.Fixup(assetNode.Identifier);*/
treeNode = parentNode.AddChild(assetNode);
+
+ DetermineIdentifier(treeNode);
+
_pathToAssetNode.Add(assetNode.Path, treeNode);
// No Identifiers for Directories, because we can't use directories as Assets anyways...
//_identifierToAssetNode.Add(assetNode.Identifier, treeNode);
@@ -450,10 +456,9 @@ class AssetHierarchy
AddDirectoryToTree(directoryNameBuffer, treeNode);
}
-
- AddFilesOfDirectory(treeNode);
-
+
RemoveOrphanedEntries(treeNode);
+ AddFilesOfDirectory(treeNode);
}
if (!AssetsDirectory.IsWhiteSpace)
@@ -573,9 +578,13 @@ class AssetHierarchy
}
_pathToAssetNode.Remove(oldFileNameWithContentRoot);
+ _identifierToAssetNode.Remove(node->Identifier);
node->Path.Set(newFileNameWithContentRoot);
_pathToAssetNode.Add(node->Path, node);
+
+ DetermineIdentifier(node);
+ _identifierToAssetNode.Add(node->Identifier, node);
node->Name.Clear();
Path.GetFileName(newFileNameWithContentRoot, node->Name);
diff --git a/GlitchyEditor/src/EditorLayer.bf b/GlitchyEditor/src/EditorLayer.bf
index aed2d2e..1e941b8 100644
--- a/GlitchyEditor/src/EditorLayer.bf
+++ b/GlitchyEditor/src/EditorLayer.bf
@@ -663,8 +663,18 @@ namespace GlitchyEditor
}
Project newProject = Project.CreateNew(directory, projectName);
+
+ defer
+ {
+ // If we return an error, we need to cleanup the directory.
+ if (@return == .Err)
+ {
+ Directory.DelTree(directory);
+ delete newProject;
+ }
+ }
- var createAssetDirResult = Directory.CreateDirectory(newProject.AssetsFolder);
+ /*var createAssetDirResult = Directory.CreateDirectory(newProject.AssetsFolder);
if (createAssetDirResult case .Err(let error))
{
@@ -681,12 +691,145 @@ namespace GlitchyEditor
{
Log.ClientLogger.Error($"Failed to copy .gitignore (\"{error}\").");
}
+
+ CreateScriptsProject(newProject);*/
- // TODO: VS Project
+ Try!(InitProject(newProject));
+
+ Try!(OpenProject(newProject));
return .Ok;
}
+ private static Result CopyTemplate(Project project)
+ {
+ String templatePath = scope .();
+ Directory.GetCurrentDirectory(templatePath);
+ Path.Combine(templatePath, "Resources/ProjectTemplate");
+
+ if (Directory.Copy(templatePath, project.WorkspacePath) case .Err)
+ {
+ Log.EngineLogger.Error($"CopyTemplate: Failed to copy template {templatePath} to {project.WorkspacePath}.");
+ return .Err;
+ }
+
+ return .Ok;
+ }
+
+ private static Result InitProject(Project project)
+ {
+ Try!(CopyTemplate(project));
+
+ Try!(MoveFile(project, "Assets/Scripts/TemplateProject.sln", scope $"Assets/Scripts/{project.Name}.sln"));
+ Try!(MoveFile(project, "Assets/Scripts/TemplateProject.csproj", scope $"Assets/Scripts/{project.Name}.csproj"));
+
+ Try!(FixupFile(project, scope $"Assets/Scripts/{project.Name}.sln"));
+ Try!(FixupFile(project, scope $"Assets/Scripts/{project.Name}.csproj"));
+ Try!(FixupFile(project, scope $"Assets/Scripts/Properties/AssemblyInfo.cs"));
+
+ return .Ok;
+ }
+
+ private static Result MoveFile(Project project, StringView fromName, StringView toName)
+ {
+ String fromPath = scope String();
+ project.PathInProject(fromPath, fromName);
+
+ String toPath = scope String();
+ project.PathInProject(toPath, toName);
+
+ if (File.Move(fromPath, toPath) case .Err(let error))
+ {
+ Log.EngineLogger.Error($"Failed to move file from {fromPath} to {toPath}. ({error})");
+ return .Err;
+ }
+
+ return .Ok;
+ }
+
+ private static Result FixupFile(Project project, StringView fileName)
+ {
+ String fileTargetPath = scope String();
+ project.PathInProject(fileTargetPath, fileName);
+
+ String fileContent = new:ScopedAlloc! String();
+ if (File.ReadAllText(fileTargetPath, fileContent, true) case .Err)
+ {
+ Log.EngineLogger.Error($"FixupFile: Failed to read file {fileTargetPath}.");
+ return .Err;
+ }
+
+ fileContent.Replace("[ProjectName]", project.Name);
+
+ String scriptCorePath = scope .();
+ Directory.GetCurrentDirectory(scriptCorePath);
+ scriptCorePath.Append("/Resources/Scripts/ScriptCore.dll");
+ fileContent.Replace("[CoreLibPath]", scriptCorePath);
+
+ if (File.WriteAllText(fileTargetPath, fileContent, false) case .Err)
+ {
+ Log.EngineLogger.Error($"FixupFile: Failed to write file {fileTargetPath}.");
+ return .Err;
+ }
+
+ return .Ok;
+ }
+
+ /*private static Result CreateFolderInProject(Project project, StringView directoryName)
+ {
+ String directoryPath = scope String();
+ project.PathInProject(directoryPath, directoryName);
+
+ if (Directory.CreateDirectory(directoryPath) case .Err(let error))
+ {
+ Log.ClientLogger.Error($"Failed to create directory \"{project.AssetsFolder}\".");
+ return .Err;
+ }
+
+ return .Ok;
+ }*/
+
+ /*private static Result CopyAndFixupFile(Project project, StringView sourcePath, StringView targetName)
+ {
+ String fileTargetPath = scope String();
+ project.PathInProject(fileTargetPath, targetName);
+
+ if (File.Copy(sourcePath, fileTargetPath) case .Err(let error))
+ {
+ Log.ClientLogger.Error($"Failed to copy file (\"{error}\").");
+ return .Err;
+ }
+
+ String fileContent = new:ScopedAlloc! String();
+
+ Try!(File.ReadAllText(fileTargetPath, fileContent, true));
+
+ fileContent.Replace("[ProjectName]", project.Name);
+
+ String scriptCorePath = scope .();
+ Directory.GetCurrentDirectory(scriptCorePath);
+ scriptCorePath.Append("/Resources/Scripts/ScriptCore.dll");
+ fileContent.Replace("[CoreLibPath]", scriptCorePath);
+
+ Try!(File.WriteAllText(fileTargetPath, fileContent, false));
+
+ return .Ok;
+ }*/
+
+ /*private Result CreateScriptsProject(Project project)
+ {
+ Try!(CreateFolderInProject(project, "Assets/Scripts"));
+ Try!(CreateFolderInProject(project, "Assets/Scripts/Properties"));
+
+ Try!(CopyAndFixupFile(project, "Resources/Scripts/EmptyProject/EmptyProject.sln", scope $"Assets/Scripts/{project.Name}.sln"));
+ Try!(CopyAndFixupFile(project, "Resources/Scripts/EmptyProject/EmptyProject.csproj", scope $"Assets/Scripts/{project.Name}.csproj"));
+ Try!(CopyAndFixupFile(project, "Resources/Scripts/EmptyProject/Properties/AssemblyInfo.cs", scope $"Assets/Scripts/Properties/AssemblyInfo.cs"));
+
+ Try!(CopyAndFixupFile(project, "Resources/Scripts/EmptyProject/.gitignore", scope $"Assets/Scripts/.gitignore"));
+
+ return .Ok;
+ }*/
+
private bool _openCreateProjectModal;
private void ShowCreateNewProjectModal()
@@ -763,6 +906,17 @@ namespace GlitchyEditor
}
}
+ private void ShowOpenProjectDialog()
+ {
+ FolderBrowserDialog folderDialog = scope FolderBrowserDialog();
+ Result result = folderDialog.ShowDialog();
+
+ if (result case .Ok(let dialogResult) && dialogResult case .OK)
+ {
+ OpenProject(folderDialog.SelectedPath);
+ }
+ }
+
private void CloseCurrentProject()
{
OnSceneStop();
@@ -778,15 +932,27 @@ namespace GlitchyEditor
private Result OpenProject(StringView workspacePath)
{
+ Project openedProject = Project.Load(workspacePath);
+
+ Try!(OpenProject(openedProject));
+
+ return .Ok;
+ }
+
+ private Result OpenProject(Project project)
+ {
+ if (project == null)
+ return .Err;
+
CloseCurrentProject();
- _currentProject = Project.Load(workspacePath);
+ _currentProject = project;
String appAssemblyPath = scope String();
_contentManager.SetAssetDirectory(_currentProject.AssetsFolder);
-
+
// TODO: obviously change dll name, configurable?
- Path.Combine(appAssemblyPath, _currentProject.AssetsFolder, "Scripts/bin/Sandbox.dll");
+ Path.Combine(appAssemblyPath, _currentProject.AssetsFolder, scope $"Scripts/bin/{_currentProject.Name}.dll");
ScriptEngine.SetAppAssemblyPath(appAssemblyPath);
@@ -933,6 +1099,9 @@ namespace GlitchyEditor
if (ImGui.MenuItem("Create new Project...", "Ctrl+N"))
_openCreateProjectModal = true;
+ if (ImGui.MenuItem("Open Project...", "Ctrl+O"))
+ ShowOpenProjectDialog();
+
if (ImGui.MenuItem("New", "Ctrl+N"))
NewScene();
diff --git a/GlitchyEditor/src/Project.bf b/GlitchyEditor/src/Project.bf
index fe9e67c..f2e9c35 100644
--- a/GlitchyEditor/src/Project.bf
+++ b/GlitchyEditor/src/Project.bf
@@ -20,7 +20,7 @@ class Project
[BonIgnore]
private String _scriptFolder ~ delete _;
- public StringView ProjectName => _projectName;
+ public StringView Name => _projectName;
public StringView WorkspacePath => _workspacePath;
public StringView AssetsFolder => _assetsFolder;
@@ -77,8 +77,22 @@ class Project
else
{
Log.EngineLogger.Warning($"Project file \"{settingsFile}\" doesn't exist.");
+
+ if (project.Name.IsWhiteSpace)
+ {
+ if (project._projectName == null)
+ project._projectName = new String();
+
+ Path.GetFileName(project.WorkspacePath, project._projectName);
+
+ Result result = Bon.SerializeIntoFile(project, settingsFile);
+
+ if (result case .Err)
+ Log.EngineLogger.Warning($"Failed to save project file \"{settingsFile}\".");
+ }
}
+
return project;
}
}
\ No newline at end of file
diff --git a/GlitchyEngine/src/Collections/TreeNode.bf b/GlitchyEngine/src/Collections/TreeNode.bf
index a9a30ad..c764ce2 100644
--- a/GlitchyEngine/src/Collections/TreeNode.bf
+++ b/GlitchyEngine/src/Collections/TreeNode.bf
@@ -1,4 +1,5 @@
using System.Collections;
+using System;
namespace GlitchyEngine.Collections
{
@@ -37,6 +38,11 @@ namespace GlitchyEngine.Collections
return newChild;
}
+ public bool RemoveChild(TreeNode value)
+ {
+ return Children.Remove(value);
+ }
+
public Self FindNode(T value)
{
if (Value == value)
diff --git a/GlitchyEngine/src/Extension/System/IO/Directory.bf b/GlitchyEngine/src/Extension/System/IO/Directory.bf
index 2f712ca..4fbf2ff 100644
--- a/GlitchyEngine/src/Extension/System/IO/Directory.bf
+++ b/GlitchyEngine/src/Extension/System/IO/Directory.bf
@@ -10,4 +10,53 @@ extension Directory
// TODO: This is obviously windows only
return PathIsDirectoryEmptyW(fileName.ToScopedNativeWChar!());
}
+
+ public static Result Copy(StringView fromPath, StringView toPath)
+ {
+ if (fromPath.Length <= 2)
+ return .Err(.InvalidParameter);
+ if ((fromPath[0] != '/') && (fromPath[0] != '\\'))
+ {
+ if (fromPath[1] == ':')
+ {
+ if (fromPath.Length < 3)
+ return .Err(.InvalidParameter);
+ }
+ }
+
+ if (!Directory.Exists(fromPath))
+ return .Err(.NotFound);
+
+ Try!(Directory.CreateDirectory(toPath));
+
+ for (var directoryEntry in Directory.EnumerateDirectories(fromPath))
+ {
+ let dirFromPath = scope String();
+ directoryEntry.GetFilePath(dirFromPath);
+
+ let dirName = scope String();
+ directoryEntry.GetFileName(dirName);
+
+ let dirToPath = scope String();
+ Path.Combine(dirToPath, toPath, dirName);
+
+ Try!(Copy(dirFromPath, dirToPath));
+ }
+
+ for (var fileEntry in Directory.EnumerateFiles(fromPath))
+ {
+ let fileFromPath = scope String();
+ fileEntry.GetFilePath(fileFromPath);
+
+ let fileName = scope String();
+ fileEntry.GetFileName(fileName);
+
+ let fileToPath = scope String();
+ Path.Combine(fileToPath, toPath, fileName);
+
+ Try!(File.Copy(fileFromPath, fileToPath));
+ }
+
+ return .Ok;
+ }
}
\ No newline at end of file
diff --git a/GlitchyEngine/src/Extension/System/IO/Path.bf b/GlitchyEngine/src/Extension/System/IO/Path.bf
index 58f6cf8..966130b 100644
--- a/GlitchyEngine/src/Extension/System/IO/Path.bf
+++ b/GlitchyEngine/src/Extension/System/IO/Path.bf
@@ -43,5 +43,7 @@ extension Path
target.Append(Path.DirectorySeparatorChar);
target.Append(component);
}
+
+ target.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
}
\ No newline at end of file