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

feat/auto fill recipe #98

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions Editor/EcsactRuntimeBuilder.cs → Editor/EcsactBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using Ecsact.Editor;
using UnityEngine.Rendering;
using UnityEngine.UIElements;

#nullable enable

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement>
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
<ui:TextField picking-mode="Ignore" label="Recipe Path" binding-path="recipePath" />
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
</ui:VisualElement>
</ui:UXML>
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement>
<ui:TextField picking-mode="Ignore" label="Runtime Output Path" value="Assets/Plugins/EcsactRuntime" text="Assets/Plugins/EcsactRuntime" multiline="false" binding-path="runtimeBuilderOutputPath" />
<ui:VisualElement tooltip="Generated runtime dynamic library for Windows" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".dll" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for macOS" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".dylib" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for Linux" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".so" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:VisualElement tooltip="Generated runtime dynamic library for WebAssembly platforms" style="flex-direction: row;">
<ui:Label text="Assets/Plugins/EcsactRuntime" display-tooltip-when-elided="true" binding-path="runtimeBuilderOutputPath" style="padding-left: 160px; font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-right: 0;" />
<ui:Label text=".wasm" display-tooltip-when-elided="true" style="font-size: 10px; color: rgba(210, 210, 210, 0.47); padding-left: 0;" />
</ui:VisualElement>
<ui:Toggle label="Debug" binding-path="runtimeBuilderDebugBuild" />
<ui:Toggle label="Log Stderr" binding-path="runtimeBuilderPrintSubcommandStderr" />
<ui:Toggle label="Log Stdout" binding-path="runtimeBuilderPrintSubcommandStdout" />
<ui:TextField picking-mode="Ignore" label="Compiler Path" multiline="false" binding-path="runtimeBuilderCompilerPath" />
<ui:DropdownField label="Recipes" index="0" name="Recipes" binding-path="recipePath" />
<ui:TextField picking-mode="Ignore" label="Temp Directory" multiline="false" binding-path="runtimeBuilderTempDirectory" />
</ui:VisualElement>
</ui:UXML>
27 changes: 27 additions & 0 deletions Editor/EcsactSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.IO;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading.Tasks;

namespace Ecsact.Editor {

Expand Down Expand Up @@ -57,6 +59,31 @@ public static string FindExecutable(string name) {
}
return executablePath;
}

public delegate void RecipeCallback(List<string> recipeList);

public static void GetRecipeBundles(RecipeCallback callback) {
List<string> recipe_bundles = new();

string ecsactExecutablePath = EcsactSdk.FindExecutable("ecsact");

var proc = new Process();
proc.StartInfo.FileName = ecsactExecutablePath;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.Arguments = "config recipe_bundles";
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;

proc.OutputDataReceived += new DataReceivedEventHandler((sender, e) => {
if(string.IsNullOrEmpty(e.Data)) return;
recipe_bundles.Add(e.Data);
});

proc.Start();
proc.BeginOutputReadLine();
}
zaucy marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace Ecsact.Editor
15 changes: 12 additions & 3 deletions Editor/EcsactSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Collections.Generic;
using Ecsact.Editor.Internal;
using Ecsact.Editor;

#nullable enable

Expand All @@ -20,9 +21,9 @@ class EcsactSettings : ScriptableObject {
public bool runtimeBuilderDebugBuild = false;
public bool runtimeBuilderPrintSubcommandStdout = false;
public bool runtimeBuilderPrintSubcommandStderr = false;
public string recipePath = "rt_entt";

public string runtimeBuilderCompilerPath = "";
public string recipePath = "";

static EcsactSettings() {
EcsactRuntimeSettings.editorValidateEvent += OnRuntimeSettingsValidate;
Expand Down Expand Up @@ -266,11 +267,11 @@ VisualElement rootElement
"Packages/dev.ecsact.unity/Editor/EcsactSettings.uxml"
);
var ui = template.Instantiate();

BindingExtensions.Bind(ui, settings);
rootElement.Add(ui);

var builderSettingsElement =
ui.Q<TemplateContainer>("EcsactRuntimeBuilderSettings");
var builderSettingsElement = ui.Q<TemplateContainer>("EcsactBuildSettings");
var ecsactBuildToggle = ui.Q<Toggle>("EnableEcsactBuild");

ecsactBuildToggle.RegisterValueChangedCallback(evt => {
Expand Down Expand Up @@ -326,6 +327,14 @@ VisualElement rootElement
csharpSystemImplSettingsEditor.OnInspectorGUI();
}
};

EcsactSdk.GetRecipeBundles((recipeList) => {
var dropdownField = ui.Q<DropdownField>("Recipes");

foreach(var recipe in recipeList) {
dropdownField.choices.Add(recipe);
}
});
}

public override void OnDeactivate() {
Expand Down
4 changes: 2 additions & 2 deletions Editor/EcsactSettings.uxml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:Template name="EcsactRuntimeBuilderSettings" src="project://database/Packages/dev.ecsact.unity/Editor/EcsactRuntimeBuilderSettings.uxml?fileID=9197481963319205126&amp;guid=c615fbf6c52d3bd4b86ee07ef18a548b&amp;type=3#EcsactRuntimeBuilderSettings" />
<ui:Template name="EcsactBuildSettings" src="project://database/Packages/dev.ecsact.unity/Editor/EcsactBuildSettings.uxml?fileID=9197481963319205126&amp;guid=c615fbf6c52d3bd4b86ee07ef18a548b&amp;type=3#EcsactBuildSettings" />
<ui:Template name="EcsactRuntimeMethodLoadedUI" src="project://database/Packages/dev.ecsact.unity/Editor/EcsactRuntimeMethodLoadedUI.uxml?fileID=9197481963319205126&amp;guid=a2a638a8b49ec24468a126f89d509035&amp;type=3#EcsactRuntimeMethodLoadedUI" />
<ui:ScrollView>
<ui:GroupBox>
<ui:Label text="Ecsact Build Settings" display-tooltip-when-elided="true" style="font-size: 16px; -unity-font-style: bold;" />
<ui:Toggle label="Enable Ecsact Build" value="false" name="EnableEcsactBuild" binding-path="ecsactBuildEnabled" />
<ui:Instance template="EcsactRuntimeBuilderSettings" name="EcsactRuntimeBuilderSettings" style="visibility: visible;" />
<ui:Instance template="EcsactBuildSettings" name="EcsactBuildSettings" style="visibility: visible;" />
</ui:GroupBox>
<ui:GroupBox>
<ui:Label text="Runtime Settings" display-tooltip-when-elided="true" style="font-size: 16px; -unity-font-style: bold;" />
Expand Down