Show popup when opening script and no IDE is configured

This commit is contained in:
Simon Lübeß
2026-09-20 16:46:27 +02:00
parent a6d4aa047b
commit 125872a157
2 changed files with 36 additions and 4 deletions
+4 -4
View File
@@ -9,6 +9,7 @@ using GlitchyEngine.Renderer;
using GlitchyEngine;
using GlitchyEditor.CodeEditors;
using System.IO;
using GlitchyEditor.Settings;
namespace GlitchyEditor.EditWindows;
@@ -316,8 +317,7 @@ class LogWindow : EditorWindow
float width = ImGui.CalcTextSize(lineBuffer.CStr()).x;
if (ImGui.Selectable(lineBuffer, false, .None, .(width, 0)))
{
// TODO: Columns?
Editor.Instance.IdeAdapter.OpenScript(frameInfo.FileName, frameInfo.Line, frameInfo.Column);
Editor.Instance.OpenScript(frameInfo.FileName, frameInfo.Line, frameInfo.Column);
}
}
@@ -336,13 +336,13 @@ class LogWindow : EditorWindow
{
if (message.Source.MessageOrigin != null)
{
Editor.Instance.IdeAdapter.OpenScript(message.Source.MessageOrigin.FileName, message.Source.MessageOrigin.LineNumber);
Editor.Instance.OpenScript(message.Source.MessageOrigin.FileName, message.Source.MessageOrigin.LineNumber);
}
else if (message.Source.Exception != null)
{
// TODO: Column?
let firstFrame = message.Source.Exception.StackTrace.Frames[0];
Editor.Instance.IdeAdapter.OpenScript(firstFrame.FileName, firstFrame.Line);
Editor.Instance.OpenScript(firstFrame.FileName, firstFrame.Line);
//message.Source.Exception.StackTrace
}
}
+32
View File
@@ -177,5 +177,37 @@ namespace GlitchyEditor
{
_settingsWindow.Open = true;
}
/// Wrapper for IdeAdapter.OpenScript that check whether or not an IDE Adapter is configured.
/// If not, a popup will be show.
public void OpenScript(StringView fileName, int lineNumber = 0, int columnNumber = 0)
{
if (IdeAdapter == null)
{
PopupService.Instance.OpenPopup("No IDE configured.", new (close) => {
close = false;
ImGui.TextUnformatted("In order to open a source file you need to configure an IDE to use.");
if (ImGui.Button("Go to settings..."))
{
ShowSettings();
SettingsWindow.HighlightSetting("Tools", "ide");
close = true;
}
ImGui.SameLine();
if (ImGui.Button("Cancel"))
{
close = true;
}
});
}
else
{
IdeAdapter.OpenScript(fileName, lineNumber, columnNumber);
}
}
}
}