Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fixes #197

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Prowl.Editor/Assets/AssetDatabase.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System.Diagnostics;

using CommandLine.Text;

using Prowl.Runtime;

namespace Prowl.Editor.Assets;
Expand Down Expand Up @@ -279,6 +281,22 @@ public static SubAssetCache[] GetSubAssetsCache(Guid guid)
return [];
}

public static bool GetDefaultAssets(out List<Guid> guids)
{
guids = new List<Guid>();
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
Expand Down
38 changes: 34 additions & 4 deletions Prowl.Editor/Build/DesktopPlayerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -38,11 +40,18 @@ public enum AssetPacking
public AssetPacking assetPacking = AssetPacking.Used;


StreamWriter buildDebugWriter;
protected override void Build(AssetRef<Scene>[] 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);

Expand All @@ -58,10 +67,20 @@ protected override void Build(AssetRef<Scene>[] 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}");
}


Expand Down Expand Up @@ -242,13 +261,24 @@ private void PackAssets(AssetRef<Scene>[] scenes, string dataPath)
}
else
{
// This is missing the skybox asset (and possibly other defaults)

HashSet<Guid> assets = [];
foreach (AssetRef<Scene> scene in scenes)
{
AssetDatabase.GetDependenciesDeep(scene.AssetID, ref assets);
}
if (AssetDatabase.GetDefaultAssets(out List<Guid> 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<Shader>())
assets.Add(shader.Item2);
foreach ((string name, Guid assetID, ushort fileId) shader in AssetDatabase.GetAllAssetsOfType<Shader>())
assets.Add(shader.assetID);

AssetDatabase.ExportBuildPackages(assets.ToArray(), new DirectoryInfo(dataPath));
}
Expand Down
6 changes: 5 additions & 1 deletion Prowl.Editor/Editor/BuildWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ private void DrawPlayerList()

// Name types are formatted as "Desktop_Player" -> "Desktop"
string name = builder.GetType().Name;
name = name.Substring(0, name.IndexOf('_'));

// Make sure name does actually include underscore
int underscoreIndex = name.IndexOf('_');
if (underscoreIndex > 0)
name = name.Substring(0, underscoreIndex);
gui.Draw2D.DrawText(name, gui.CurrentNode.LayoutData.InnerRect);
}
}
Expand Down
79 changes: 61 additions & 18 deletions Prowl.Editor/Editor/ProjectsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Prowl.Runtime.GUI;
using Prowl.Runtime.GUI.Layout;

using Vortice.Direct3D11;

namespace Prowl.Editor;

public class ProjectsWindow : EditorWindow
Expand Down Expand Up @@ -81,6 +83,7 @@ protected override void Draw()
}
}

Rect footer = Rect.Empty;
private void DrawProjectsTab()
{
Rect rect = gui.CurrentNode.LayoutData.Rect;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
Expand All @@ -252,6 +241,44 @@ 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

// 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);

// Add more information about progress here (even console output)

// Cover controls (fill EditorWindow)
gui.Draw2D.DrawRectFilled(gui.ScreenRect, GrayAlpha);

gui.Draw2D.PopClip();

// Redirect output of logs to window
//Debug.OnLog += OpeningProjectLog;

// Should probably occur on a new thread/async 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<string> onComplete)
{
Expand Down Expand Up @@ -371,6 +398,7 @@ private void DrawCreateProject()
}

Project contextMenuProject = null;
bool contextMenuIsHovered = false;
private void DisplayProject(Project project)
{
Rect rootRect = gui.CurrentNode.LayoutData.Rect;
Expand All @@ -388,8 +416,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);
Expand Down Expand Up @@ -444,6 +471,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())
Expand All @@ -469,8 +497,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?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit odd, IsHovered and Interactables are just rectangles, this should work just fine with IsHovered?
Could you elaborate on what happened here? Did interaction just completely fail?

Other then this (which isn't really a problem preventing merging) everything looks good!

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);
Expand All @@ -481,6 +522,8 @@ private void DrawProjectContextMenu(Project project)
ProjectCache.Instance.RemoveProject(project);
closePopup = true;
}


}
}
if (closePopup)
Expand Down
9 changes: 9 additions & 0 deletions Prowl.Editor/Project/DotnetCompileOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct DotnetCompileOptions()
public DirectoryInfo? outputPath = null;
public DirectoryInfo? tempPath = null;

public Dictionary<string, string> additionalParameters = new Dictionary<string, string>();

public string ConstructDotnetArgs(FileInfo project)
{
Expand Down Expand Up @@ -86,6 +87,14 @@ public string ConstructDotnetArgs(FileInfo project)
});
}

if (additionalParameters.Count > 0)
{
foreach (KeyValuePair<string, string> kvp in additionalParameters)
{
args.Add($"/p:{kvp.Key}={kvp.Value}");
}
}

return string.Join(" ", args);
}
}
3 changes: 2 additions & 1 deletion Prowl.Runtime/GUI/Layout/LayoutNode.API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading