Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsakharov committed Jan 26, 2025
2 parents a3e335a + c7e8822 commit 355df51
Show file tree
Hide file tree
Showing 73 changed files with 705 additions and 508 deletions.
2 changes: 1 addition & 1 deletion Prowl.Editor/Assets/AssetDatabase.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public static void SaveAsset(EngineObject assetInstance, bool pingAsset = true)
try
{
EchoObject serialized = Serializer.Serialize(assetInstance);
StringTagConverter.WriteToFile(serialized, fileInfo);
serialized.WriteToString(fileInfo);

if(pingAsset)
AssetDatabase.Ping(fileInfo);
Expand Down
8 changes: 4 additions & 4 deletions Prowl.Editor/Assets/Importers/MaterialImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public override void Import(SerializedAsset ctx, FileInfo assetPath)
try
{
string json = File.ReadAllText(assetPath.FullName);
var tag = StringTagConverter.Read(json);
var tag = EchoObject.ReadFromString(json);
mat = Serializer.Deserialize<Material>(tag);
}
catch
{
// something went wrong, lets just create a new material and save it
mat = Material.CreateDefaultMaterial();
string json = StringTagConverter.Write(Serializer.Serialize(mat));
string json = Serializer.Serialize(mat).WriteToString();
File.WriteAllText(assetPath.FullName, json);
}

Expand All @@ -41,7 +41,7 @@ public class MaterialImporterEditor : ScriptedEditor

public override void OnEnable()
{
EchoObject tag = StringTagConverter.ReadFromFile((target as MetaFile).AssetPath);
EchoObject tag = EchoObject.ReadFromString((target as MetaFile).AssetPath);
_editingMaterial = Serializer.Deserialize<Material>(tag);

_editor = CreateEditor(_editingMaterial);
Expand All @@ -53,7 +53,7 @@ public override void OnEnable()

private void OnChange()
{
StringTagConverter.WriteToFile(Serializer.Serialize(_editingMaterial), (target as MetaFile).AssetPath);
Serializer.Serialize(_editingMaterial).WriteToString((target as MetaFile).AssetPath);
AssetDatabase.Reimport((target as MetaFile).AssetPath);
}

Expand Down
2 changes: 1 addition & 1 deletion Prowl.Editor/Assets/Importers/MeshImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void Import(SerializedAsset ctx, FileInfo assetPath)
try
{
string json = File.ReadAllText(assetPath.FullName);
var tag = StringTagConverter.Read(json);
var tag = EchoObject.ReadFromString(json);
mesh = Serializer.Deserialize<Mesh>(tag);
}
catch
Expand Down
2 changes: 1 addition & 1 deletion Prowl.Editor/Assets/Importers/ModelImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public override void OnInspectorGUI(EditorGUI.FieldChanges changes)
}


using (gui.Node("Content").Width(Size.Percentage(1f)).MarginTop(5).Layout(LayoutType.Column).Scroll(inputstyle: EditorGUI.InputStyle).Enter())
using (gui.Node("Content").Width(Size.Percentage(1f)).PaddingTop(5).Layout(LayoutType.Column).Scroll(inputstyle: EditorGUI.InputStyle).Enter())
{
switch (_selectedTab)
{
Expand Down
9 changes: 0 additions & 9 deletions Prowl.Editor/Assets/Importers/MonoScriptImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,10 @@ namespace Prowl.Editor.Assets;
[Importer("CSharpIcon.png", typeof(MonoScript), ".cs")]
public class MonoScriptImporter : ScriptedImporter
{
static DateTime lastReload;

public override void Import(SerializedAsset ctx, FileInfo assetPath)
{
ctx.SetMainObject(new MonoScript());

if (lastReload == default)
lastReload = DateTime.UtcNow;
else if (lastReload.AddSeconds(2) > DateTime.UtcNow)
return;

Program.RegisterReloadOfExternalAssemblies();

lastReload = DateTime.UtcNow;
}
}
2 changes: 1 addition & 1 deletion Prowl.Editor/Assets/Importers/PrefabImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PrefabImporter : ScriptedImporter
{
public override void Import(SerializedAsset ctx, FileInfo assetPath)
{
var tag = StringTagConverter.ReadFromFile(assetPath);
var tag = EchoObject.ReadFromString(assetPath);
Prefab? prefab = Serializer.Deserialize<Prefab>(tag) ?? throw new Exception("Failed to Deserialize Prefab.");
ctx.SetMainObject(prefab);
}
Expand Down
2 changes: 1 addition & 1 deletion Prowl.Editor/Assets/Importers/SceneImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SceneImporter : ScriptedImporter
{
public override void Import(SerializedAsset ctx, FileInfo assetPath)
{
var tag = StringTagConverter.ReadFromFile(assetPath);
var tag = EchoObject.ReadFromString(assetPath);
Scene? scene = Serializer.Deserialize<Scene>(tag) ?? throw new Exception("Failed to Deserialize Scene.");
ctx.SetMainObject(scene);
}
Expand Down
6 changes: 3 additions & 3 deletions Prowl.Editor/Assets/Importers/ScriptableObjectImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override void Import(SerializedAsset ctx, FileInfo assetPath)
{
// Load the Texture into a TextureData Object and serialize to Asset Folder
//var scriptable = JsonUtility.Deserialize<ScriptableObject>(File.ReadAllText(assetPath.FullName));
var scriptable = Serializer.Deserialize<ScriptableObject>(StringTagConverter.ReadFromFile(assetPath));
var scriptable = Serializer.Deserialize<ScriptableObject>(EchoObject.ReadFromString(assetPath));
ctx.SetMainObject(scriptable);
}
}
Expand All @@ -28,7 +28,7 @@ public class ScriptableObjectImporterEditor : ScriptedEditor

public override void OnEnable()
{
EchoObject tag = StringTagConverter.ReadFromFile((target as MetaFile).AssetPath);
EchoObject tag = EchoObject.ReadFromString((target as MetaFile).AssetPath);
_editingObject = Serializer.Deserialize<ScriptableObject>(tag);
_objectEditor = null; // Replace this to load a Scripta
}
Expand All @@ -52,7 +52,7 @@ public override void OnInspectorGUI(EditorGUI.FieldChanges changes)
if (changed)
{
_editingObject.OnValidate();
StringTagConverter.WriteToFile(Serializer.Serialize(_editingObject), (target as MetaFile).AssetPath);
Serializer.Serialize(_editingObject).WriteToString((target as MetaFile).AssetPath);
AssetDatabase.Reimport((target as MetaFile).AssetPath);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Prowl.Editor/Assets/MetaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Save()
FileInfo file = new(AssetPath.FullName + ".meta");
version = MetaVersion;
EchoObject tag = Serializer.Serialize(this);
StringTagConverter.WriteToFile(tag, file);
tag.WriteToString(file);
}

/// <summary>Load a MetaFile from the specified file.</summary>
Expand All @@ -54,7 +54,7 @@ public void Save()
{
FileInfo file = new(assetFile + ".meta");
if (!File.Exists(file.FullName)) return null; // Doesnt Exist
EchoObject tag = StringTagConverter.ReadFromFile(file);
EchoObject tag = EchoObject.ReadFromString(file);
MetaFile? meta = Serializer.Deserialize<MetaFile>(tag);
meta!.AssetPath = assetFile;
meta.lastModified = DateTime.UtcNow;
Expand Down
2 changes: 1 addition & 1 deletion Prowl.Editor/Build/DesktopPlayerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private static void PackScenes(AssetRef<Scene>[] scenes, string dataPath)
// Debug.Log($"Packing scene_{i}.prowl.");
AssetRef<Scene> scene = scenes[i];
EchoObject tag = Serializer.Serialize(scene.Res!);
BinaryTagConverter.WriteToFile(tag, new FileInfo(Path.Combine(dataPath, $"scene_{i}.prowl")));
tag.WriteToBinary(new FileInfo(Path.Combine(dataPath, $"scene_{i}.prowl")));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Prowl.Editor/Editor/AssetSelectorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ protected override void Draw()

gui.CurrentNode.Layout(LayoutType.Column);
gui.CurrentNode.ScaleChildren();
gui.CurrentNode.Padding(0, 10, 10, 10);
gui.CurrentNode.Padding(5, 10, 10, 10);

using (gui.Node("Search").Width(Size.Percentage(1f)).MaxHeight(ItemSize).Enter())
{
gui.Search("SearchInput", ref _searchText, 0, 0, Size.Percentage(1f), ItemSize, EditorGUI.InputFieldStyle);
}

using (gui.Node("Body").Width(Size.Percentage(1f)).MarginTop(5).Layout(LayoutType.Column).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
using (gui.Node("Body").Width(Size.Percentage(1f)).PaddingTop(5).Layout(LayoutType.Column).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
{
double xPos = gui.CurrentNode.LayoutData.InnerRect.x + 3;
using (gui.Node("None", -1).Width(Size.Percentage(1f)).Height(ItemSize).Enter())
Expand Down
18 changes: 9 additions & 9 deletions Prowl.Editor/Editor/AssetsBrowserWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected override void Draw()

gui.CurrentNode.Layout(LayoutType.Column);
gui.CurrentNode.ScaleChildren();
gui.CurrentNode.Padding(0, 10, 10, 10);
gui.CurrentNode.Padding(5, 10, 10, 10);

RenderHeader();

Expand Down Expand Up @@ -198,7 +198,7 @@ public void RenderHeader()

public void RenderBody()
{
using (gui.Node("Body").Width(Size.Percentage(1f)).MarginTop(5).Layout(LayoutType.Grid).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
using (gui.Node("Body").Width(Size.Percentage(1f)).Layout(LayoutType.Grid).PaddingTop(5).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
{
gui.Draw2D.DrawRectFilled(gui.CurrentNode.LayoutData.Rect, EditorStylePrefs.Instance.WindowBGTwo, (float)EditorStylePrefs.Instance.WindowRoundness);
var dropInteract = gui.GetInteractable();
Expand All @@ -222,7 +222,7 @@ public void RenderBody()
while (File.Exists(file.FullName))
file = new FileInfo(file.FullName.Replace(".prefab", "") + " new.prefab");

StringTagConverter.WriteToFile(Serializer.Serialize(prefab), file);
Serializer.Serialize(prefab).WriteToString(file);

AssetDatabase.Update();
AssetDatabase.Ping(file);
Expand Down Expand Up @@ -256,7 +256,7 @@ public void RenderBody()

public void RenderEntry(ref int index, AssetDirectoryCache.DirNode entry)
{
using (gui.Node(entry.Directory.Name).Scale(EntrySize).Margin(itemPadding).Enter())
using (gui.Node(entry.Directory.Name).Scale(EntrySize).Padding(itemPadding).Enter())
{
var interact = gui.GetInteractable();

Expand Down Expand Up @@ -302,7 +302,7 @@ public void RenderEntry(ref int index, AssetDirectoryCache.FileNode entry)
AssetDatabase.SubAssetCache[] subAssets = entry.SubAssets;

bool expanded = false;
using (gui.Node(entry.File.Name).Scale(EntrySize).Margin(itemPadding).Enter())
using (gui.Node(entry.File.Name).Scale(EntrySize).Padding(itemPadding).Enter())
{
var interact = gui.GetInteractable();
AssetsTreeWindow.HandleFileClick(-1, interact, entry, 0, true);
Expand All @@ -320,7 +320,7 @@ public void RenderEntry(ref int index, AssetDirectoryCache.FileNode entry)
expanded = !expanded;
gui.SetNodeStorage(gui.CurrentNode.Parent.Parent, entry.File.FullName, expanded);
}
gui.Draw2D.DrawText(expanded ? FontAwesome6.ChevronRight : FontAwesome6.ChevronLeft, 20, gui.CurrentNode.LayoutData.Rect, gui.IsNodeHovered() ? Color.white : EditorStylePrefs.Instance.LesserText);
gui.Draw2D.DrawText(expanded ? FontAwesome6.ChevronRight : FontAwesome6.ChevronLeft, 20, gui.CurrentNode.LayoutData.InnerRect, gui.IsNodeHovered() ? Color.white : EditorStylePrefs.Instance.LesserText);
}
}

Expand All @@ -331,7 +331,7 @@ public void RenderEntry(ref int index, AssetDirectoryCache.FileNode entry)
{
for (ushort i = 0; i < subAssets.Length; i++)
{
using (gui.Node(subAssets[i].name, i).Scale(EntrySize * 0.75).Margin(itemPadding).Enter())
using (gui.Node(subAssets[i].name, i).Scale(EntrySize * 0.75).Padding(itemPadding).Enter())
{
var interact = gui.GetInteractable();
AssetsTreeWindow.HandleFileClick(-1, interact, entry, i, true);
Expand All @@ -344,7 +344,7 @@ public void RenderEntry(ref int index, AssetDirectoryCache.FileNode entry)

private void DrawFileEntry(int index, FileSystemInfo entry, Interactable interact, bool hasSubAsset = false, AssetDatabase.SubAssetCache? subAsset = null)
{
var rect = gui.CurrentNode.LayoutData.Rect;
var rect = gui.CurrentNode.LayoutData.InnerRect;
//if (hasSubAsset)
// rect.Expand(-10);
var entrySize = rect.width;
Expand Down Expand Up @@ -422,7 +422,7 @@ private void DrawPingEffect(string fullPath)
CurDirectoryNode = node;
//ScrollToItem();
}
var pingRect = gui.CurrentNode.LayoutData.Rect;
var pingRect = gui.CurrentNode.LayoutData.InnerRect;
pingRect.Expand(MathF.Sin(_pingTimer) * 6f);
gui.Draw2D.DrawRect(pingRect, EditorStylePrefs.Instance.Ping, 2f, 4f);
}
Expand Down
4 changes: 2 additions & 2 deletions Prowl.Editor/Editor/AssetsTreeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void Draw()

gui.CurrentNode.Layout(LayoutType.Column);
gui.CurrentNode.ScaleChildren();
gui.CurrentNode.Padding(0, 10, 10, 10);
gui.CurrentNode.Padding(5, 10, 10, 10);

using (gui.Node("Search").Width(Size.Percentage(1f)).MaxHeight(EditorStylePrefs.Instance.ItemSize).Enter())
{
Expand Down Expand Up @@ -81,7 +81,7 @@ protected override void Draw()
}


using (gui.Node("Tree").Width(Size.Percentage(1f)).MarginTop(5).Layout(LayoutType.Column, false).Spacing(entryPadding).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
using (gui.Node("Tree").Width(Size.Percentage(1f)).PaddingTop(5).Layout(LayoutType.Column, false).Spacing(entryPadding).Clip().Scroll(inputstyle: EditorGUI.InputStyle).Enter())
{
//gui.Draw2D.DrawRectFilled(gui.CurrentNode.LayoutData.InnerRect, EditorStylePrefs.Instance.WindowBGOne, 4);

Expand Down
7 changes: 5 additions & 2 deletions Prowl.Editor/Editor/ConsoleWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,12 @@ private bool DrawExpandedMessage(LogMessage message)

Vector2 msgSize = Font.DefaultFont.CalcTextSize(selMsg, font_size: 22, 0);

using (gui.Node("Header").Width(msgSize.x).Height(msgSize.y).Margin(10, 0, 0, 10).Enter())
using (gui.Node("Header").Width(msgSize.x).Height(msgSize.y).Enter())
{
Rect headerRect = gui.CurrentNode.LayoutData.Rect;
Vector2 textPos = headerRect.Position;
textPos.x += 10f;
textPos.y += 10f;

gui.Draw2D.DrawText(Font.DefaultFont, selMsg, 20, textPos, color);
}
Expand All @@ -319,7 +321,7 @@ private bool DrawExpandedMessage(LogMessage message)
string frameText = frame.ToString();
Vector2 frameSize = Font.DefaultFont.CalcTextSize(frameText, font_size: 21, 0);

using (gui.Node("StackFrame", i).Margin(0, 0, 0, 10).Width(frameSize.x).Height(15).Enter())
using (gui.Node("StackFrame", i).Width(frameSize.x).Height(15).Enter())
{
Interactable interact = gui.GetInteractable();
Color col = Color.white * 0.65f;
Expand All @@ -333,6 +335,7 @@ private bool DrawExpandedMessage(LogMessage message)
}

Rect frameRect = gui.CurrentNode.LayoutData.Rect;
frameRect.x += 10f;
gui.Draw2D.DrawText(Font.DefaultFont, frameText, 19, frameRect.Position, col, 0, frameRect);
}
}
Expand Down
Loading

0 comments on commit 355df51

Please sign in to comment.