From a8f3ed48d9a09a2ef15d1735782eecc5f361e2c6 Mon Sep 17 00:00:00 2001 From: ZeppelinGames <31507417+ZeppelinGames@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:11:45 +1100 Subject: [PATCH 1/5] Fixed BuildWindow crash due to substring name missing char --- Prowl.Editor/Editor/BuildWindow.cs | 4 +++- Prowl.Editor/Project/DotnetCompileOptions.cs | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Prowl.Editor/Editor/BuildWindow.cs b/Prowl.Editor/Editor/BuildWindow.cs index 9384f1994..a85981bb4 100644 --- a/Prowl.Editor/Editor/BuildWindow.cs +++ b/Prowl.Editor/Editor/BuildWindow.cs @@ -77,7 +77,9 @@ private void DrawPlayerList() // Name types are formatted as "Desktop_Player" -> "Desktop" string name = builder.GetType().Name; - name = name.Substring(0, name.IndexOf('_')); + int underscoreIndex = name.IndexOf('_'); + if (underscoreIndex > 0) + name = name.Substring(0, underscoreIndex); gui.Draw2D.DrawText(name, gui.CurrentNode.LayoutData.InnerRect); } } diff --git a/Prowl.Editor/Project/DotnetCompileOptions.cs b/Prowl.Editor/Project/DotnetCompileOptions.cs index 1bbe7f514..2193a981f 100644 --- a/Prowl.Editor/Project/DotnetCompileOptions.cs +++ b/Prowl.Editor/Project/DotnetCompileOptions.cs @@ -19,6 +19,7 @@ public struct DotnetCompileOptions() public DirectoryInfo? outputPath = null; public DirectoryInfo? tempPath = null; + public Dictionary additionalParameters = new Dictionary(); public string ConstructDotnetArgs(FileInfo project) { @@ -86,6 +87,14 @@ public string ConstructDotnetArgs(FileInfo project) }); } + if (additionalParameters.Count > 0) + { + foreach (KeyValuePair kvp in additionalParameters) + { + args.Add($"/p:{kvp.Key}={kvp.Value}"); + } + } + return string.Join(" ", args); } } From a07454e8c558c72dd7987922edefc16986c6af91 Mon Sep 17 00:00:00 2001 From: ZeppelinGames <31507417+ZeppelinGames@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:03:05 +1100 Subject: [PATCH 2/5] Uniformity on opening projects --- Prowl.Editor/Build/DesktopPlayerBuilder.cs | 23 ++++++++- Prowl.Editor/Editor/BuildWindow.cs | 2 + Prowl.Editor/Editor/ProjectsWindow.cs | 57 +++++++++++++++------- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/Prowl.Editor/Build/DesktopPlayerBuilder.cs b/Prowl.Editor/Build/DesktopPlayerBuilder.cs index 8bea2bd4c..18ff3ce7f 100644 --- a/Prowl.Editor/Build/DesktopPlayerBuilder.cs +++ b/Prowl.Editor/Build/DesktopPlayerBuilder.cs @@ -11,6 +11,8 @@ using Prowl.Runtime.Utils; using Prowl.Runtime.Rendering; using Prowl.Echo; +using System.IO; +using Veldrid.MetalBindings; namespace Prowl.Editor.Build; @@ -38,11 +40,18 @@ public enum AssetPacking public AssetPacking assetPacking = AssetPacking.Used; + StreamWriter buildDebugWriter; protected override void Build(AssetRef[] scenes, DirectoryInfo output) { string buildDataPath = Path.Combine(output.FullName, "GameData"); Directory.CreateDirectory(buildDataPath); + // Build logging to file + buildDebugWriter = new StreamWriter(Path.Combine(output.FullName, "build_log.txt"), false); + buildDebugWriter.AutoFlush = true; + + Debug.OnLog += BuildLog; + // Debug.Log($"Compiling project assembly."); CompileProject(out string projectLib); @@ -58,10 +67,20 @@ protected override void Build(AssetRef[] scenes, DirectoryInfo output) // Debug.Log($"Preparing project settings."); PackProjectSettings(buildDataPath); - Debug.Log($"Successfully built project to {output}"); - // Open the Build folder AssetDatabase.OpenPath(output, type: FileOpenType.FileExplorer); + + Debug.OnLog -= BuildLog; + buildDebugWriter.Flush(); + buildDebugWriter.Close(); + Debug.Log($"Successfully built project to {output}"); + } + + void BuildLog(string message, DebugStackTrace? stackTrace, LogSeverity logSeverity) + { + if (buildDebugWriter == null) + return; + buildDebugWriter.WriteLine($"[{logSeverity.ToString()}] {message}"); } diff --git a/Prowl.Editor/Editor/BuildWindow.cs b/Prowl.Editor/Editor/BuildWindow.cs index a85981bb4..cabc95f8c 100644 --- a/Prowl.Editor/Editor/BuildWindow.cs +++ b/Prowl.Editor/Editor/BuildWindow.cs @@ -77,6 +77,8 @@ private void DrawPlayerList() // Name types are formatted as "Desktop_Player" -> "Desktop" string name = builder.GetType().Name; + + // Make sure name does actually include underscore int underscoreIndex = name.IndexOf('_'); if (underscoreIndex > 0) name = name.Substring(0, underscoreIndex); diff --git a/Prowl.Editor/Editor/ProjectsWindow.cs b/Prowl.Editor/Editor/ProjectsWindow.cs index d02465e8d..994c45530 100644 --- a/Prowl.Editor/Editor/ProjectsWindow.cs +++ b/Prowl.Editor/Editor/ProjectsWindow.cs @@ -10,6 +10,8 @@ using Prowl.Runtime.GUI; using Prowl.Runtime.GUI.Layout; +using Vortice.Direct3D11; + namespace Prowl.Editor; public class ProjectsWindow : EditorWindow @@ -81,6 +83,7 @@ protected override void Draw() } } + Rect footer = Rect.Empty; private void DrawProjectsTab() { Rect rect = gui.CurrentNode.LayoutData.Rect; @@ -91,7 +94,7 @@ private void DrawProjectsTab() gui.Draw2D.DrawVerticalBlackGradient(shadowA, shadowB, 30, 0.25f); - Rect footer = new(shadowB.x, shadowB.y, rect.width, 60); + footer = new(shadowB.x, shadowB.y, rect.width, 60); gui.Draw2D.DrawRectFilled(footer, EditorStylePrefs.Instance.WindowBGOne, (float)EditorStylePrefs.Instance.WindowRoundness, 4); shadowA = shadowB; @@ -223,23 +226,9 @@ private void DrawProjectsTab() } else if (SelectedProject != null) { - // Display load info (and possibly load bar). Placed in empty space of footer - - // Opening project info - // Text pos + offset/padding - Vector2 openInfoTextPos = footer.Position + new Vector2(8f, 8f); - gui.Draw2D.DrawText($"Opening '{SelectedProject.Name}'...", openInfoTextPos); - // Add more information about progress here (even console output) - // Change 'open/create' button text text = "Opening..."; - - // Cover controls (fill EditorWindow) - gui.Draw2D.DrawRectFilled(this.Rect, GrayAlpha); - - bool projectOpened = Project.Open(SelectedProject); - if (projectOpened) - isOpened = false; + OpenSelectedProject(); } } } @@ -252,6 +241,39 @@ private void DrawProjectsTab() } } + void OpenSelectedProject() + { + if (SelectedProject == null || footer == Rect.Empty) + return; + + // Display load info (and possibly load bar). Placed in empty space of footer + + // Opening project info + // Text pos + offset/padding + Vector2 openInfoTextPos = footer.Position + new Vector2(8f, 8f); + gui.Draw2D.DrawText($"Opening '{SelectedProject.Name}'...", openInfoTextPos); + + // Add more information about progress here (even console output) + + // Cover controls (fill EditorWindow) + gui.Draw2D.DrawRectFilled(this.Rect, GrayAlpha); + + + // Redirect output of logs to window + Debug.OnLog += OpeningProjectLog; + + // Should probably occur on a new thread to stop blocking UI + bool projectOpened = Project.Open(SelectedProject); + + Debug.OnLog -= OpeningProjectLog; + if (projectOpened) + isOpened = false; + } + + void OpeningProjectLog(string message, DebugStackTrace? trace, LogSeverity severity) + { + gui.Draw2D.DrawText($"{message}", footer.Position + new Vector2(8f, 24f)); + } private void OpenDialog(string title, Action onComplete) { @@ -388,8 +410,7 @@ private void DisplayProject(Project project) { if (gui.IsPointerDoubleClick(MouseButton.Left)) { - Project.Open(project); - isOpened = false; + OpenSelectedProject(); } gui.Draw2D.DrawRectFilled(gui.CurrentNode.LayoutData.Rect, new(0.1f, 0.1f, 0.1f, 0.4f), 2); From 7290146bd20d3dd200e6c2a56d22738d60dede78 Mon Sep 17 00:00:00 2001 From: ZeppelinGames <31507417+ZeppelinGames@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:08:18 +1100 Subject: [PATCH 3/5] Make context menu disappear after mouse leaves rect --- Prowl.Editor/Editor/ProjectsWindow.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Prowl.Editor/Editor/ProjectsWindow.cs b/Prowl.Editor/Editor/ProjectsWindow.cs index 994c45530..62afceea1 100644 --- a/Prowl.Editor/Editor/ProjectsWindow.cs +++ b/Prowl.Editor/Editor/ProjectsWindow.cs @@ -252,7 +252,7 @@ void OpenSelectedProject() // Text pos + offset/padding Vector2 openInfoTextPos = footer.Position + new Vector2(8f, 8f); gui.Draw2D.DrawText($"Opening '{SelectedProject.Name}'...", openInfoTextPos); - + // Add more information about progress here (even console output) // Cover controls (fill EditorWindow) @@ -393,6 +393,7 @@ private void DrawCreateProject() } Project contextMenuProject = null; + bool contextMenuIsHovered = false; private void DisplayProject(Project project) { Rect rootRect = gui.CurrentNode.LayoutData.Rect; @@ -465,6 +466,7 @@ private void DisplayProject(Project project) { gui.Draw2D.DrawRectFilled(rect, EditorStylePrefs.Instance.Highlighted, (float)EditorStylePrefs.Instance.WindowRoundness, CornerRounding.All); contextMenuProject = project; + contextMenuIsHovered = false; gui.OpenPopup("ProjectOptionsContextMenu", null, gui.CurrentNode.Parent); } else if (optionsInteract.IsHovered()) @@ -490,8 +492,21 @@ private void DrawProjectContextMenu(Project project) { using (popupHolder.Width(180).Padding(5).Layout(LayoutType.Column).Spacing(5).FitContentHeight().Enter()) { + // Getting Interactable (IsHovered) removes interaction from styled buttons? + if (popupHolder.LayoutData.Rect.Contains(gui.PointerPos)) + { + if (!contextMenuIsHovered) + contextMenuIsHovered = true; + } + else + { + if (contextMenuIsHovered) + closePopup = true; + } + // Add options // - Delete project (with popup confirmation) + if (EditorGUI.StyledButton("Show In Explorer")) { AssetDatabase.OpenPath(project.ProjectDirectory, type: FileOpenType.FileExplorer); @@ -502,6 +517,8 @@ private void DrawProjectContextMenu(Project project) ProjectCache.Instance.RemoveProject(project); closePopup = true; } + + } } if (closePopup) From 54e4872a3dbe0325aead2abaef335d8410406d45 Mon Sep 17 00:00:00 2001 From: ZeppelinGames <31507417+ZeppelinGames@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:23:52 +1100 Subject: [PATCH 4/5] Fixed build asset packing 'used assets' to include defaults --- Prowl.Editor/Assets/AssetDatabase.Utilities.cs | 18 ++++++++++++++++++ Prowl.Editor/Build/DesktopPlayerBuilder.cs | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Prowl.Editor/Assets/AssetDatabase.Utilities.cs b/Prowl.Editor/Assets/AssetDatabase.Utilities.cs index 080705361..8e050705f 100644 --- a/Prowl.Editor/Assets/AssetDatabase.Utilities.cs +++ b/Prowl.Editor/Assets/AssetDatabase.Utilities.cs @@ -3,6 +3,8 @@ using System.Diagnostics; +using CommandLine.Text; + using Prowl.Runtime; namespace Prowl.Editor.Assets; @@ -279,6 +281,22 @@ public static SubAssetCache[] GetSubAssetsCache(Guid guid) return []; } + public static bool GetDefaultAssets(out List guids) + { + guids = new List(); + if (Project.Active == null) + return false; + + foreach (FileInfo fileInfo in Project.Active?.DefaultsDirectory.EnumerateFiles()) + { + MetaFile? meta = MetaFile.Load(fileInfo); + + if (meta != null) + guids.Add(meta.guid); + } + return true; + } + #endregion #region Private Methods diff --git a/Prowl.Editor/Build/DesktopPlayerBuilder.cs b/Prowl.Editor/Build/DesktopPlayerBuilder.cs index 18ff3ce7f..5df0ce4ce 100644 --- a/Prowl.Editor/Build/DesktopPlayerBuilder.cs +++ b/Prowl.Editor/Build/DesktopPlayerBuilder.cs @@ -261,13 +261,24 @@ private void PackAssets(AssetRef[] scenes, string dataPath) } else { + // This is missing the skybox asset (and possibly other defaults) + HashSet assets = []; foreach (AssetRef scene in scenes) + { AssetDatabase.GetDependenciesDeep(scene.AssetID, ref assets); + } + if (AssetDatabase.GetDefaultAssets(out List guids)) + { + foreach (Guid assetID in guids) + assets.Add(assetID); + } + + // Get assets from /Defaults dir too // Include all Shaders in the build for the time being - foreach ((string, Guid, ushort) shader in AssetDatabase.GetAllAssetsOfType()) - assets.Add(shader.Item2); + foreach ((string name, Guid assetID, ushort fileId) shader in AssetDatabase.GetAllAssetsOfType()) + assets.Add(shader.assetID); AssetDatabase.ExportBuildPackages(assets.ToArray(), new DirectoryInfo(dataPath)); } From c8805c57a7f5f8615cc5f011702442c3768e80d5 Mon Sep 17 00:00:00 2001 From: ZeppelinGames <31507417+ZeppelinGames@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:43:55 +1100 Subject: [PATCH 5/5] Fixed parenting null and loading overlay --- Prowl.Editor/Editor/ProjectsWindow.cs | 15 ++++++++++----- Prowl.Runtime/GUI/Layout/LayoutNode.API.cs | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Prowl.Editor/Editor/ProjectsWindow.cs b/Prowl.Editor/Editor/ProjectsWindow.cs index 62afceea1..e8c13aac9 100644 --- a/Prowl.Editor/Editor/ProjectsWindow.cs +++ b/Prowl.Editor/Editor/ProjectsWindow.cs @@ -249,6 +249,10 @@ void OpenSelectedProject() // Display load info (and possibly load bar). Placed in empty space of footer // Opening project info + + // Projects list clips overlay. Ignore clipping + gui.Draw2D.PushClip(gui.ScreenRect, true); + // Text pos + offset/padding Vector2 openInfoTextPos = footer.Position + new Vector2(8f, 8f); gui.Draw2D.DrawText($"Opening '{SelectedProject.Name}'...", openInfoTextPos); @@ -256,16 +260,17 @@ void OpenSelectedProject() // Add more information about progress here (even console output) // Cover controls (fill EditorWindow) - gui.Draw2D.DrawRectFilled(this.Rect, GrayAlpha); + gui.Draw2D.DrawRectFilled(gui.ScreenRect, GrayAlpha); + gui.Draw2D.PopClip(); // Redirect output of logs to window - Debug.OnLog += OpeningProjectLog; + //Debug.OnLog += OpeningProjectLog; - // Should probably occur on a new thread to stop blocking UI + // Should probably occur on a new thread/async to stop blocking UI bool projectOpened = Project.Open(SelectedProject); - Debug.OnLog -= OpeningProjectLog; + // Debug.OnLog -= OpeningProjectLog; if (projectOpened) isOpened = false; } @@ -518,7 +523,7 @@ private void DrawProjectContextMenu(Project project) closePopup = true; } - + } } if (closePopup) diff --git a/Prowl.Runtime/GUI/Layout/LayoutNode.API.cs b/Prowl.Runtime/GUI/Layout/LayoutNode.API.cs index fdecc4974..91be3b9cc 100644 --- a/Prowl.Runtime/GUI/Layout/LayoutNode.API.cs +++ b/Prowl.Runtime/GUI/Layout/LayoutNode.API.cs @@ -172,7 +172,8 @@ public void SetNewParent(LayoutNode newParent) if (Parent != null) Parent.Children.Remove(this); Parent = newParent; - Parent.Children.Add(this); + if (Parent != null) + Parent.Children.Add(this); //Parent.GetNextNode(); _positionRelativeTo = newParent; _sizeRelativeTo = newParent;