mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Dev settings for using ScriptCore as either dll or csproj
This commit is contained in:
@@ -63,8 +63,6 @@ namespace GlitchyEditor
|
|||||||
RenderTargetGroup _editorViewportTarget ~ _.ReleaseRef();
|
RenderTargetGroup _editorViewportTarget ~ _.ReleaseRef();
|
||||||
RenderTargetGroup _gameViewportTarget ~ _.ReleaseRef();
|
RenderTargetGroup _gameViewportTarget ~ _.ReleaseRef();
|
||||||
|
|
||||||
ProjectUserSettings _projectUserSettings;
|
|
||||||
|
|
||||||
EditorCamera _camera ~ _.Dispose();
|
EditorCamera _camera ~ _.Dispose();
|
||||||
|
|
||||||
EditorIcons _editorIcons ~ _.ReleaseRef();
|
EditorIcons _editorIcons ~ _.ReleaseRef();
|
||||||
@@ -1549,6 +1547,7 @@ namespace GlitchyEditor
|
|||||||
dispatcher.Dispatch<KeyPressedEvent>(scope (e) => OnKeyPressed(e));
|
dispatcher.Dispatch<KeyPressedEvent>(scope (e) => OnKeyPressed(e));
|
||||||
dispatcher.Dispatch<MouseScrolledEvent>(scope (e) => OnMouseScrolled(e));
|
dispatcher.Dispatch<MouseScrolledEvent>(scope (e) => OnMouseScrolled(e));
|
||||||
dispatcher.Dispatch<DragDropEvent>(scope (e) => OnDragDrop(e));
|
dispatcher.Dispatch<DragDropEvent>(scope (e) => OnDragDrop(e));
|
||||||
|
dispatcher.Dispatch<SettingsAppliedEvent>(scope (e) => OnSettingsApplied(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnWindowResize(WindowResizeEvent e)
|
private bool OnWindowResize(WindowResizeEvent e)
|
||||||
@@ -1726,5 +1725,15 @@ namespace GlitchyEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
bool OnSettingsApplied(SettingsAppliedEvent settingsAppliedEvent)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
// In DEBUG we can change whether we use ScriptCore as .dll or .csproj
|
||||||
|
_currentProject?.FixupScriptCorePath();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ namespace GlitchyEngine
|
|||||||
{
|
{
|
||||||
extension Settings
|
extension Settings
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
[SettingContainer, BonInclude]
|
||||||
|
public readonly DevSettings DevSettings = new .() ~ delete _;
|
||||||
|
#endif
|
||||||
|
|
||||||
[SettingContainer, BonInclude]
|
[SettingContainer, BonInclude]
|
||||||
public readonly EditorSettings EditorSettings = new .() ~ delete _;
|
public readonly EditorSettings EditorSettings = new .() ~ delete _;
|
||||||
|
|
||||||
@@ -18,6 +23,9 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
protected override void RegisterEventListeners()
|
protected override void RegisterEventListeners()
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
OnApplySettings.Add(new (s, e) => DevSettings.Apply());
|
||||||
|
#endif
|
||||||
OnApplySettings.Add(new (s, e) => EditorSettings.Apply());
|
OnApplySettings.Add(new (s, e) => EditorSettings.Apply());
|
||||||
OnApplySettings.Add(new (s, e) => ScriptSettings.Apply());
|
OnApplySettings.Add(new (s, e) => ScriptSettings.Apply());
|
||||||
}
|
}
|
||||||
@@ -26,6 +34,20 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
namespace GlitchyEditor;
|
namespace GlitchyEditor;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
[Reflect]
|
||||||
|
class DevSettings
|
||||||
|
{
|
||||||
|
[Setting("Dev", "Use ScriptCore csproj", "If enabled the Editor will include the csproj of the ScriptCore instead of the compiled dll."), BonInclude]
|
||||||
|
public bool UseScriptCoreDll = true;
|
||||||
|
|
||||||
|
public void Apply()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
[Reflect]
|
[Reflect]
|
||||||
enum ScriptIde
|
enum ScriptIde
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ class Project
|
|||||||
{
|
{
|
||||||
PathInProject(outTarget, scope $"{Name}.csproj");
|
PathInProject(outTarget, scope $"{Name}.csproj");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void GetScriptCoreProjectFilePath(String outTarget)
|
||||||
|
{
|
||||||
|
Directory.GetCurrentDirectory(outTarget);
|
||||||
|
Path.Combine(outTarget, "../ScriptCore/ScriptCore.csproj");
|
||||||
|
Path.ToActualPath(outTarget);
|
||||||
|
}
|
||||||
|
|
||||||
/// Loads or creates the user specific settings for this project.
|
/// Loads or creates the user specific settings for this project.
|
||||||
private void InitUserSettings()
|
private void InitUserSettings()
|
||||||
@@ -266,21 +273,8 @@ class Project
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
static bool referenceScriptCoreProject = true;
|
|
||||||
#else
|
|
||||||
static bool referenceScriptCoreProject = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private static void GetScriptCoreProjectFilePath(String outTarget)
|
|
||||||
{
|
|
||||||
Directory.GetCurrentDirectory(outTarget);
|
|
||||||
Path.Combine(outTarget, "../ScriptCore/ScriptCore.csproj");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// If necessary adds or removes the reference to ScriptCore.csproj from the solution (.slnx) file.
|
/// If necessary adds or removes the reference to ScriptCore.csproj from the solution (.slnx) file.
|
||||||
private Result<void> FixupScriptSolutionFile()
|
private Result<void> FixupScriptSolutionFile(bool referenceScriptCoreProject)
|
||||||
{
|
{
|
||||||
String solutionPath = scope .();
|
String solutionPath = scope .();
|
||||||
GetPathToScriptSolutionFile(solutionPath);
|
GetPathToScriptSolutionFile(solutionPath);
|
||||||
@@ -345,7 +339,7 @@ class Project
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// If necessary adds or removes the reference to ScriptCore.dll from the project (.csproj) file.
|
/// If necessary adds or removes the reference to ScriptCore.dll from the project (.csproj) file.
|
||||||
private Result<void> FixupScriptProjectFile()
|
private Result<void> FixupScriptProjectFile(bool referenceScriptCoreProject)
|
||||||
{
|
{
|
||||||
String csprojPath = scope .();
|
String csprojPath = scope .();
|
||||||
GetPathToScriptProjectFile(csprojPath);
|
GetPathToScriptProjectFile(csprojPath);
|
||||||
@@ -401,6 +395,7 @@ class Project
|
|||||||
String scriptCoreProjectPath = scope .();
|
String scriptCoreProjectPath = scope .();
|
||||||
Directory.GetCurrentDirectory(scriptCoreProjectPath);
|
Directory.GetCurrentDirectory(scriptCoreProjectPath);
|
||||||
Path.Combine(scriptCoreProjectPath, "../ScriptCore/ScriptCore.csproj");
|
Path.Combine(scriptCoreProjectPath, "../ScriptCore/ScriptCore.csproj");
|
||||||
|
Path.ToActualPath(scriptCoreProjectPath);
|
||||||
|
|
||||||
scriptCoreProjectReference.SetAttribute("Include", scriptCoreProjectPath);
|
scriptCoreProjectReference.SetAttribute("Include", scriptCoreProjectPath);
|
||||||
scriptCoreProjectReference.SetAttribute("OutputItemType", "Analyzer");
|
scriptCoreProjectReference.SetAttribute("OutputItemType", "Analyzer");
|
||||||
@@ -437,6 +432,7 @@ class Project
|
|||||||
String pathToScriptCoreDll = scope .();
|
String pathToScriptCoreDll = scope .();
|
||||||
Directory.GetCurrentDirectory(pathToScriptCoreDll);
|
Directory.GetCurrentDirectory(pathToScriptCoreDll);
|
||||||
Path.Combine(pathToScriptCoreDll, ScriptEngine.ScriptCorePath);
|
Path.Combine(pathToScriptCoreDll, ScriptEngine.ScriptCorePath);
|
||||||
|
Path.ToActualPath(pathToScriptCoreDll);
|
||||||
|
|
||||||
if (!File.Exists(pathToScriptCoreDll))
|
if (!File.Exists(pathToScriptCoreDll))
|
||||||
{
|
{
|
||||||
@@ -459,11 +455,18 @@ class Project
|
|||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<void> FixupScriptCorePath()
|
/// Fixes the references to ScriptCore in the script-project and solution file.
|
||||||
|
public Result<void> FixupScriptCorePath()
|
||||||
{
|
{
|
||||||
Try!(FixupScriptSolutionFile());
|
bool referenceScriptCoreProject = false;
|
||||||
|
|
||||||
Try!(FixupScriptProjectFile());
|
#if DEBUG
|
||||||
|
Settings settings = Application.Instance.Settings;
|
||||||
|
referenceScriptCoreProject = settings.DevSettings.UseScriptCoreDll;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Try!(FixupScriptSolutionFile(referenceScriptCoreProject));
|
||||||
|
Try!(FixupScriptProjectFile(referenceScriptCoreProject));
|
||||||
|
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace GlitchyEditor
|
|||||||
{
|
{
|
||||||
_open = false;
|
_open = false;
|
||||||
|
|
||||||
_settings = Application.Get().Settings;
|
_settings = Application.Instance.Settings;
|
||||||
|
|
||||||
Create();
|
Create();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ namespace GlitchyEngine
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
GlitchyEngine.Settings.Load();
|
GlitchyEngine.Settings.Load();
|
||||||
|
Settings.OnApplySettings.Add(new (s, e) => {
|
||||||
|
OnEvent(scope SettingsAppliedEvent());
|
||||||
|
});
|
||||||
Settings.Apply();
|
Settings.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,4 +129,24 @@ namespace GlitchyEngine.Events
|
|||||||
strBuffer.AppendF("WindowDeactivatedEvent");
|
strBuffer.AppendF("WindowDeactivatedEvent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SettingsAppliedEvent : Event, IEvent
|
||||||
|
{
|
||||||
|
public override EventType EventType => .SettingsApplied;
|
||||||
|
|
||||||
|
public override StringView Name => "SettingsApplied";
|
||||||
|
|
||||||
|
public override EventCategory Category => .Application;
|
||||||
|
|
||||||
|
public static EventType StaticType => .SettingsApplied;
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ToString(String strBuffer)
|
||||||
|
{
|
||||||
|
strBuffer.AppendF("SettingsAppliedEvent");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace GlitchyEngine.Events
|
|||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved, WindowActivated, WindowDeactivated,
|
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved, WindowActivated, WindowDeactivated,
|
||||||
AppTick, AppUpdate, AppRender,
|
AppTick, AppUpdate, AppRender, SettingsApplied,
|
||||||
KeyPressed, KeyReleased, KeyTyped,
|
KeyPressed, KeyReleased, KeyTyped,
|
||||||
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
|
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ extension Path
|
|||||||
path.Remove(0, 1);
|
path.Remove(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ToActualPath(String path)
|
||||||
|
{
|
||||||
|
String tmp = scope .(path);
|
||||||
|
path.Clear();
|
||||||
|
Path.GetActualPathName(tmp, path);
|
||||||
|
}
|
||||||
|
|
||||||
// Compared to the original Combine, this one makes sure we don't add multiple seperators. Also makes sure, the path contains only the main Separator char.
|
// Compared to the original Combine, this one makes sure we don't add multiple seperators. Also makes sure, the path contains only the main Separator char.
|
||||||
new public static void Combine(String target, params StringView[] components)
|
new public static void Combine(String target, params StringView[] components)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ class EngineClasses
|
|||||||
|
|
||||||
static class ScriptEngine
|
static class ScriptEngine
|
||||||
{
|
{
|
||||||
|
// TODO: Maybe make it possible to set the path to ScriptCore just like for the script project?
|
||||||
|
// This would probably require a separate small project that just handles the script-engine interface.
|
||||||
public const String ScriptCorePath = "Resources/Scripts/ScriptCore.dll";
|
public const String ScriptCorePath = "Resources/Scripts/ScriptCore.dll";
|
||||||
|
|
||||||
private static Scene s_Context ~ _?.ReleaseRef();
|
private static Scene s_Context ~ _?.ReleaseRef();
|
||||||
|
|||||||
Reference in New Issue
Block a user