feat: add runtime play tick and play-mode scene editing semantics
This commit is contained in:
@@ -13,12 +13,20 @@ namespace XCEngine {
|
||||
namespace Editor {
|
||||
namespace Commands {
|
||||
|
||||
inline bool IsSceneDocumentEditingAllowed(const IEditorContext& context) {
|
||||
return IsEditorDocumentEditingAllowed(context.GetRuntimeMode());
|
||||
}
|
||||
|
||||
inline void ResetSceneEditingState(IEditorContext& context) {
|
||||
context.GetSelectionManager().ClearSelection();
|
||||
context.GetUndoManager().ClearHistory();
|
||||
}
|
||||
|
||||
inline bool NewScene(IEditorContext& context, const std::string& sceneName = "Untitled Scene") {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SceneEditorUtils::ConfirmSceneSwitch(context)) {
|
||||
return false;
|
||||
}
|
||||
@@ -29,6 +37,10 @@ inline bool NewScene(IEditorContext& context, const std::string& sceneName = "Un
|
||||
}
|
||||
|
||||
inline bool LoadScene(IEditorContext& context, const std::string& filePath, bool confirmSwitch = true) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filePath.empty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -44,6 +56,10 @@ inline bool LoadScene(IEditorContext& context, const std::string& filePath, bool
|
||||
}
|
||||
|
||||
inline bool OpenSceneWithDialog(IEditorContext& context) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SceneEditorUtils::ConfirmSceneSwitch(context)) {
|
||||
return false;
|
||||
}
|
||||
@@ -59,10 +75,18 @@ inline bool OpenSceneWithDialog(IEditorContext& context) {
|
||||
}
|
||||
|
||||
inline bool SaveCurrentScene(IEditorContext& context) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return SceneEditorUtils::SaveCurrentScene(context);
|
||||
}
|
||||
|
||||
inline bool SaveSceneAsWithDialog(IEditorContext& context) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& sceneManager = context.GetSceneManager();
|
||||
const std::string filePath = SceneEditorUtils::SaveSceneFileDialog(
|
||||
context.GetProjectPath(),
|
||||
@@ -80,6 +104,10 @@ inline bool SaveSceneAsWithDialog(IEditorContext& context) {
|
||||
}
|
||||
|
||||
inline bool LoadStartupScene(IEditorContext& context) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool loaded = context.GetSceneManager().LoadStartupScene(context.GetProjectPath());
|
||||
context.GetProjectManager().RefreshCurrentFolder();
|
||||
ResetSceneEditingState(context);
|
||||
@@ -87,6 +115,10 @@ inline bool LoadStartupScene(IEditorContext& context) {
|
||||
}
|
||||
|
||||
inline bool SaveDirtySceneWithFallback(IEditorContext& context, const std::string& fallbackPath) {
|
||||
if (!IsSceneDocumentEditingAllowed(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& sceneManager = context.GetSceneManager();
|
||||
if (!sceneManager.HasActiveScene() || !sceneManager.IsSceneDirty()) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user