mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Editor: Prevent saving while in not in edit mode
This commit is contained in:
@@ -106,6 +106,9 @@ namespace GlitchyEditor
|
|||||||
|
|
||||||
public bool IsProjectLoaded => _currentProject != null;
|
public bool IsProjectLoaded => _currentProject != null;
|
||||||
|
|
||||||
|
/// Returns whether or not the current scene can be saved.
|
||||||
|
public bool CanSaveScene => _sceneState == .Edit;
|
||||||
|
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(String[] args, EditorContentManager contentManager) : base("Editor")
|
public this(String[] args, EditorContentManager contentManager) : base("Editor")
|
||||||
{
|
{
|
||||||
@@ -1083,6 +1086,12 @@ namespace GlitchyEditor
|
|||||||
/// Saves the scene in the file that is was loaded from or saved to last. If there is no such path (i.e. it is a new scene) the save file dialog will open.
|
/// Saves the scene in the file that is was loaded from or saved to last. If there is no such path (i.e. it is a new scene) the save file dialog will open.
|
||||||
private void SaveCurrentScene()
|
private void SaveCurrentScene()
|
||||||
{
|
{
|
||||||
|
if (!CanSaveScene)
|
||||||
|
{
|
||||||
|
Log.ClientLogger.Error("Scene can't be saved while playing the game!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (SceneFilePath.IsWhiteSpace)
|
if (SceneFilePath.IsWhiteSpace)
|
||||||
{
|
{
|
||||||
SaveCurrentSceneAs();
|
SaveCurrentSceneAs();
|
||||||
@@ -1108,6 +1117,12 @@ namespace GlitchyEditor
|
|||||||
/// Opens a save file dialog and saves the scene at the user specified location.
|
/// Opens a save file dialog and saves the scene at the user specified location.
|
||||||
private void SaveCurrentSceneAs()
|
private void SaveCurrentSceneAs()
|
||||||
{
|
{
|
||||||
|
if (!CanSaveScene)
|
||||||
|
{
|
||||||
|
Log.ClientLogger.Error("Scene can't be saved while playing the game!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SaveFileDialog sfd = scope .();
|
SaveFileDialog sfd = scope .();
|
||||||
sfd.InitialDirectory = _currentProject.AssetsFolder;
|
sfd.InitialDirectory = _currentProject.AssetsFolder;
|
||||||
|
|
||||||
@@ -1415,6 +1430,8 @@ namespace GlitchyEditor
|
|||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
|
ImGui.BeginDisabled(!CanSaveScene);
|
||||||
|
|
||||||
if (ImGui.MenuItem("Save Scene", "Ctrl+S"))
|
if (ImGui.MenuItem("Save Scene", "Ctrl+S"))
|
||||||
SaveCurrentScene();
|
SaveCurrentScene();
|
||||||
|
|
||||||
@@ -1425,6 +1442,8 @@ namespace GlitchyEditor
|
|||||||
|
|
||||||
ImGui.AttachTooltip("Saves the scene under the given file name.");
|
ImGui.AttachTooltip("Saves the scene under the given file name.");
|
||||||
|
|
||||||
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
if (ImGui.MenuItem("Create new Project...", "Ctrl+ALT+N"))
|
if (ImGui.MenuItem("Create new Project...", "Ctrl+ALT+N"))
|
||||||
|
|||||||
Reference in New Issue
Block a user