Przeglądaj źródła

Some cleanups. Overwrite config file if it is invalid. Added resizable argument to the player

rsredsq 10 lat temu
rodzic
commit
0bd7f4b067

+ 7 - 10
Script/AtomicEditor/editor/Preferences.ts

@@ -15,7 +15,6 @@ class Preferences {
 
     private static instance: Preferences;
     private _prefs: PreferencesFormat;
-    private _configCorrupted: boolean;
 
     constructor() {
         this.fileSystem = Atomic.getFileSystem();
@@ -73,9 +72,8 @@ class Preferences {
         try {
           prefs = <PreferencesFormat>JSON.parse(jsonFile.readText());
         } catch (e){
-          console.log("Config file is corrupted");
+          console.log("Editor preference file invalid, regenerating default configuration");
           prefs = null;
-          this._configCorrupted = true;
           this.useDefaultConfig();
         }
         if (prefs) {
@@ -86,7 +84,6 @@ class Preferences {
     }
 
     write(): void {
-        if (this._configCorrupted) return;
         var filePath = this.getPreferencesFullPath();
         var jsonFile = new Atomic.File(filePath, Atomic.FILE_WRITE);
         if (!jsonFile.isOpen()) return;
@@ -126,12 +123,12 @@ class Preferences {
     }
 }
 
-class WindowData {
-  x: number;
-  y: number;
-  width: number;
-  height: number;
-  fullscreen: boolean;
+interface WindowData {
+    x: number;
+    y: number;
+    width: number;
+    height: number;
+    fullscreen?: boolean;
 }
 
 class PreferencesFormat {

+ 4 - 4
Script/AtomicEditor/ui/Shortcuts.ts

@@ -29,10 +29,10 @@ class Shortcuts extends Atomic.ScriptObject {
 
         var playerWindow = Preferences.getInstance().playerWindow;
         if (playerWindow) {
-            var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height;
+            var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable";
             Atomic.editorMode.playProject(args, false);
         } else {
-            Atomic.editorMode.playProject("");
+            Atomic.editorMode.playProject("", false);
         }
     }
 
@@ -42,10 +42,10 @@ class Shortcuts extends Atomic.ScriptObject {
 
         var playerWindow = Preferences.getInstance().playerWindow;
         if (playerWindow) {
-            var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height;
+            var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable";
             Atomic.editorMode.playProject(args, true);
         } else {
-          Atomic.editorMode.playProjectDebug();
+            Atomic.editorMode.playProject("", true);
         }
 
     }

+ 4 - 0
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -170,6 +170,10 @@ void AEPlayerApplication::Setup()
             {
                 engineParameters_["WindowHeight"] = atoi(value.CString());
             }
+            else if (argument == "--resizable") 
+            {
+                engineParameters_["WindowResizable"] = true;
+            }
         }
     }
 

+ 0 - 5
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -151,11 +151,6 @@ bool EditorMode::PlayProject(String addArgs, bool debug)
 
 }
 
-bool EditorMode::PlayProjectDebug()
-{
-    return PlayProject("", true);
-}
-
 void EditorMode::HandleIPCPlayerExitRequest(StringHash eventType, VariantMap& eventData)
 {
     if (!playerBroker_) return;

+ 0 - 1
Source/AtomicEditor/EditorMode/AEEditorMode.h

@@ -33,7 +33,6 @@ public:
     virtual ~EditorMode();
 
     bool PlayProject(String addArgs = "", bool debug = false);
-    bool PlayProjectDebug();
     bool IsPlayerEnabled();
 
 private: