mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Friendship ended with VISUAL STUDIO, Now RIDER is my best friend
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
namespace GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
|
interface IIdeAdapter
|
||||||
|
{
|
||||||
|
static void OpenScript(StringView fileName);
|
||||||
|
|
||||||
|
static void OpenScript(StringView fileName, int lineNumber);
|
||||||
|
|
||||||
|
static void OpenScriptProject();
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using GlitchyEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
|
class RiderIdeAdapter : IIdeAdapter
|
||||||
|
{
|
||||||
|
public static void OpenScript(StringView fileName)
|
||||||
|
{
|
||||||
|
OpenScript(fileName, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OpenScript(StringView fileName, int lineNumber)
|
||||||
|
{
|
||||||
|
String solutionPath = scope .();
|
||||||
|
Editor.Instance.CurrentProject.PathInProject(solutionPath, scope $"{Editor.Instance.CurrentProject.Name}.sln");
|
||||||
|
|
||||||
|
ProcessStartInfo startInfo = scope .();
|
||||||
|
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.RiderPath);
|
||||||
|
startInfo.SetArguments(scope $"{solutionPath} --line {lineNumber} {fileName}");
|
||||||
|
|
||||||
|
scope SpawnedProcess().Start(startInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OpenScriptProject()
|
||||||
|
{
|
||||||
|
String solutionPath = scope .();
|
||||||
|
Editor.Instance.CurrentProject.PathInProject(solutionPath, scope $"{Editor.Instance.CurrentProject.Name}.sln");
|
||||||
|
|
||||||
|
ProcessStartInfo startInfo = scope .();
|
||||||
|
startInfo.SetFileName(Application.Instance.Settings.ScriptSettings.RiderPath);
|
||||||
|
startInfo.SetArguments(solutionPath);
|
||||||
|
|
||||||
|
scope SpawnedProcess().Start(startInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -3,9 +3,9 @@ using System.Diagnostics;
|
|||||||
using GlitchyEngine;
|
using GlitchyEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace GlitchyEditor;
|
namespace GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
class VisualStudioUtility
|
class VisualStudioIdeAdapter : IIdeAdapter
|
||||||
{
|
{
|
||||||
public static bool IsRunning()
|
public static bool IsRunning()
|
||||||
{
|
{
|
||||||
@@ -10,6 +10,7 @@ using GlitchyEngine.Content;
|
|||||||
using GlitchyEngine;
|
using GlitchyEngine;
|
||||||
using GlitchyEditor.Assets;
|
using GlitchyEditor.Assets;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
namespace GlitchyEditor.EditWindows
|
namespace GlitchyEditor.EditWindows
|
||||||
{
|
{
|
||||||
@@ -242,7 +243,7 @@ namespace GlitchyEditor.EditWindows
|
|||||||
|
|
||||||
if (ImGui.MenuItem("Open C# Project..."))
|
if (ImGui.MenuItem("Open C# Project..."))
|
||||||
{
|
{
|
||||||
VisualStudioUtility.OpenScriptProject();
|
RiderIdeAdapter.OpenScriptProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.AttachTooltip("Opens the C# Solution of this project.");
|
ImGui.AttachTooltip("Opens the C# Solution of this project.");
|
||||||
@@ -865,7 +866,7 @@ namespace GlitchyEditor.EditWindows
|
|||||||
if (entry->Path.EndsWith(".cs"))
|
if (entry->Path.EndsWith(".cs"))
|
||||||
{
|
{
|
||||||
// Obviously windows only
|
// Obviously windows only
|
||||||
VisualStudioUtility.OpenScript(entry->Path);
|
RiderIdeAdapter.OpenScript(entry->Path);
|
||||||
}
|
}
|
||||||
else if (Path.OpenFolder(entry->Path) case .Err)
|
else if (Path.OpenFolder(entry->Path) case .Err)
|
||||||
Log.EngineLogger.Error("Failed to open file.");
|
Log.EngineLogger.Error("Failed to open file.");
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using GlitchLog;
|
|||||||
using GlitchyEngine.Scripting;
|
using GlitchyEngine.Scripting;
|
||||||
using GlitchyEngine.Renderer;
|
using GlitchyEngine.Renderer;
|
||||||
using GlitchyEngine;
|
using GlitchyEngine;
|
||||||
|
using GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
namespace GlitchyEditor.EditWindows;
|
namespace GlitchyEditor.EditWindows;
|
||||||
|
|
||||||
@@ -315,7 +316,7 @@ class LogWindow : EditorWindow
|
|||||||
{
|
{
|
||||||
if (message.Source.MessageOrigin != null)
|
if (message.Source.MessageOrigin != null)
|
||||||
{
|
{
|
||||||
VisualStudioUtility.OpenScript(message.Source.MessageOrigin.FileName);
|
RiderIdeAdapter.OpenScript(message.Source.MessageOrigin.FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,25 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
namespace GlitchyEditor;
|
namespace GlitchyEditor;
|
||||||
|
|
||||||
|
[Reflect]
|
||||||
|
enum ScriptIde
|
||||||
|
{
|
||||||
|
Rider,
|
||||||
|
VisualStudio
|
||||||
|
}
|
||||||
|
|
||||||
[Reflect]
|
[Reflect]
|
||||||
class ScriptSettings
|
class ScriptSettings
|
||||||
{
|
{
|
||||||
[Setting("Script", "Visual Studio path", "The path of the Visual Studio devenv.exe"), BonInclude]
|
[Setting("Tools", "Visual Studio path", "The path of Visual Studio's \"devenv.exe\""), BonInclude]
|
||||||
public String VisualStudioPath ~ delete _;
|
public String VisualStudioPath ~ delete _;
|
||||||
|
|
||||||
|
[Setting("Tools", "Rider path", "The path to JetBrains Rider IDE (rider64.exe)"), BonInclude]
|
||||||
|
public String RiderPath ~ delete _;
|
||||||
|
|
||||||
|
[Setting("Tools", "IDE", "The IDE that will be used to open scripts for editing."), BonInclude]
|
||||||
|
public ScriptIde SelectedIde;
|
||||||
|
|
||||||
public void Apply()
|
public void Apply()
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(VisualStudioPath))
|
if (String.IsNullOrWhiteSpace(VisualStudioPath))
|
||||||
|
|||||||
@@ -264,15 +264,110 @@ namespace GlitchyEditor
|
|||||||
|
|
||||||
char8[256] buffer = .();
|
char8[256] buffer = .();
|
||||||
|
|
||||||
value.CopyTo(buffer);
|
value?.CopyTo(buffer);
|
||||||
|
|
||||||
if (ImGui.InputText(scope $"##{setting.Name}", &buffer, buffer.Count))
|
if (ImGui.InputText(scope $"##{setting.Name}", &buffer, buffer.Count))
|
||||||
{
|
{
|
||||||
|
if (value != null)
|
||||||
value..Clear().Append(&buffer);
|
value..Clear().Append(&buffer);
|
||||||
|
else
|
||||||
|
SetSettingValue!(new String(&buffer));
|
||||||
|
|
||||||
_settingsChanged = true;
|
_settingsChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*if (fieldInfo.FieldType.IsEnum)
|
||||||
|
{
|
||||||
|
uint64 enumValue = 0;
|
||||||
|
|
||||||
|
fieldInfo.GetValueReference(setting.SettingsObject);
|
||||||
|
|
||||||
|
// Assign value
|
||||||
|
switch (fieldInfo.FieldType.Size)
|
||||||
|
{
|
||||||
|
case 1: enumValue = *(uint8*)&enumValue;
|
||||||
|
case 2: *(uint16*)&enumValue = *(uint16*)&enumValue;
|
||||||
|
case 4: *(uint32*)&enumValue = *(uint32*)&enumValue;
|
||||||
|
case 8: *(uint64*)&enumValue = *(uint64*)&enumValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
for (var field in valType.GetFields())
|
||||||
|
{
|
||||||
|
if (field.[Friend]mFieldData.mFlags.HasFlag(.EnumCase) &&
|
||||||
|
*(int64*)&field.[Friend]mFieldData.[Friend]mData == valueData)
|
||||||
|
{
|
||||||
|
writer.Enum(field.Name);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find field on enum
|
||||||
|
bool found = false;
|
||||||
|
for (var field in valType.GetFields())
|
||||||
|
if (field.[Friend]mFieldData.mFlags.HasFlag(.EnumCase)
|
||||||
|
&& name == field.Name)
|
||||||
|
{
|
||||||
|
// Add value of enum case to current enum value
|
||||||
|
enumValue |= *(int64*)&field.[Friend]mFieldData.[Friend]mData;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
Error!("Enum case not found", reader, valType);
|
||||||
|
|
||||||
|
|
||||||
|
uint64 value = 0;
|
||||||
|
StringView selectedValue;
|
||||||
|
|
||||||
|
for (FieldInfo enumField in fieldInfo.FieldType.GetFields())
|
||||||
|
{
|
||||||
|
if (enumField.[Friend]mFieldData.mFlags.HasFlag(.EnumCase))
|
||||||
|
{
|
||||||
|
hasCaseData = true;
|
||||||
|
|
||||||
|
if (name == enumField.Name)
|
||||||
|
{
|
||||||
|
unionPayload = ValueView(enumField.FieldType, val.dataPtr);
|
||||||
|
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
unionDiscrIndex++;
|
||||||
|
}
|
||||||
|
else if (enumField.[Friend]mFieldData.mFlags.HasFlag(.EnumDiscriminator))
|
||||||
|
{
|
||||||
|
let discrType = enumField.FieldType;
|
||||||
|
Debug.Assert(discrType.IsInteger);
|
||||||
|
discrVal = ValueView(discrType, (uint8*)val.dataPtr + enumField.[Friend]mFieldData.mData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.BeginCombo(scope $"##{setting.Name}", null);
|
||||||
|
|
||||||
|
for (var v in Enum.GetValues(fieldInfo.FieldType))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndCombo();
|
||||||
|
|
||||||
|
/*// Find field on enum
|
||||||
|
bool found = false;
|
||||||
|
for (var field in valType.GetFields())
|
||||||
|
if (field.[Friend]mFieldData.mFlags.HasFlag(.EnumCase)
|
||||||
|
&& name == field.Name)
|
||||||
|
{
|
||||||
|
// Add value of enum case to current enum value
|
||||||
|
enumValue |= *(int64*)&field.[Friend]mFieldData.[Friend]mData;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}*/
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTable();
|
ImGui.EndTable();
|
||||||
|
|||||||
Reference in New Issue
Block a user