fixed Settings-File not being created and start of Recent-Projects-Menu

This commit is contained in:
Simon Lübeß
2023-06-18 16:05:03 +02:00
parent e8e6207bc1
commit 3becc1e25b
3 changed files with 39 additions and 1 deletions
+1
View File
@@ -7,3 +7,4 @@ vendor/directx
imgui.ini
GlitchyEditor/resources/scripts/ScriptCore.dll
GlitchyEditor/resources/scripts/ScriptCore.pdb
GlitchyEditor/settings.bon
+33 -1
View File
@@ -70,6 +70,14 @@ namespace GlitchyEditor
SceneState _sceneState = .Edit;
bool _isPaused = false;
append List<(String Name, String Path)> _recentProjectPaths = .() ~ {
for (var item in _)
{
delete item.Name;
delete item.Path;
}
};
/// Gets or sets the path of the current scene.
public StringView SceneFilePath
{
@@ -623,6 +631,23 @@ namespace GlitchyEditor
SetReference!(_activeScene, _editorScene);
}
private void DrawOpenRecentProjectMenu()
{
int i = 0;
for (let (name, path) in _recentProjectPaths)
{
i++;
if (i >= 10)
break;
if (ImGui.MenuItem(scope $"{i}: {name} ({path})"))
{
LoadSceneFile(path);
}
}
}
private void DrawMainMenuBar()
{
ImGui.BeginMainMenuBar();
@@ -635,11 +660,18 @@ namespace GlitchyEditor
if (ImGui.MenuItem("Save", "Ctrl+S"))
SaveScene();
if (ImGui.MenuItem("Save as...", "Ctrl+Shift+N"))
if (ImGui.MenuItem("Save as...", "Ctrl+Shift+S"))
SaveSceneAs();
if (ImGui.MenuItem("Open...", "Ctrl+O"))
OpenScene();
if (ImGui.BeginMenu("Open Recent"))
{
DrawOpenRecentProjectMenu();
ImGui.EndMenu();
}
ImGui.Separator();
+5
View File
@@ -67,6 +67,11 @@ namespace GlitchyEngine
{
Settings settings = Application.Get().Settings;
if (!File.Exists("./settings.bon"))
{
settings.Save();
}
var result = Bon.DeserializeFromFile(ref settings, "./settings.bon");
if (result case .Err)