Browse Source

Initializing window parameters before window creation.

rsredsq 10 years ago
parent
commit
a58100cf72

+ 0 - 7
Script/AtomicEditor/editor/Editor.ts

@@ -36,13 +36,6 @@ class Editor extends Atomic.ScriptObject {
 
 
         Preferences.getInstance().read();
         Preferences.getInstance().read();
 
 
-        var editorWindow = Preferences.getInstance().editorWindow;
-
-        if (editorWindow) {
-            Atomic.graphics.setWindowSize(editorWindow.width, editorWindow.height);
-            Atomic.graphics.setWindowPosition(editorWindow.x, editorWindow.y);
-        }
-
         this.initUI();
         this.initUI();
 
 
         this.editorLicense = new EditorLicense();
         this.editorLicense = new EditorLicense();

+ 38 - 0
Source/AtomicEditor/Application/AEEditorCommon.cpp

@@ -19,6 +19,8 @@
 #include <ToolCore/ToolSystem.h>
 #include <ToolCore/ToolSystem.h>
 #include <ToolCore/ToolEnvironment.h>
 #include <ToolCore/ToolEnvironment.h>
 
 
+#include <Atomic/Resource/JSONFile.h>
+
 #ifdef ATOMIC_DOTNET
 #ifdef ATOMIC_DOTNET
 #include <AtomicNET/NETCore/NETHost.h>
 #include <AtomicNET/NETCore/NETHost.h>
 #include <AtomicNET/NETCore/NETCore.h>
 #include <AtomicNET/NETCore/NETCore.h>
@@ -127,6 +129,8 @@ void AEEditorCommon::Setup()
     ToolSystem* system = new ToolSystem(context_);
     ToolSystem* system = new ToolSystem(context_);
     context_->RegisterSubsystem(system);
     context_->RegisterSubsystem(system);
 
 
+    ReadPreferences();
+
 }
 }
 
 
 void AEEditorCommon::Stop()
 void AEEditorCommon::Stop()
@@ -150,4 +154,38 @@ void AEEditorCommon::Stop()
 #endif
 #endif
 }
 }
 
 
+
+bool AEEditorCommon::ReadPreferences()
+{
+
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+
+    String preferencesPath = fileSystem->GetAppPreferencesDir("AtomicEditor", "Preferences");
+    preferencesPath += "prefs.json";
+
+    SharedPtr<File> file(new File(context_, preferencesPath, FILE_READ));
+
+    SharedPtr<JSONFile> jsonFile(new JSONFile(context_));
+
+    if (!jsonFile->BeginLoad(*file))
+        return false;
+
+    JSONValue root = jsonFile->GetRoot();
+
+    JSONValue editorWindow = root.Get("editorWindow");
+
+    if (!editorWindow.IsObject())
+        return false;
+
+    engineParameters_["WindowPositionX"] = editorWindow.Get("x").GetUInt();
+    engineParameters_["WindowPositionY"] = editorWindow.Get("y").GetUInt();
+    engineParameters_["WindowWidth"] = editorWindow.Get("width").GetUInt();
+    engineParameters_["WindowHeight"] = editorWindow.Get("height").GetUInt();
+    engineParameters_["FullScreen"] = editorWindow.Get("fullscreen").GetBool();
+
+    file->Close();
+
+    return true;
+}
+
 }
 }

+ 1 - 0
Source/AtomicEditor/Application/AEEditorCommon.h

@@ -40,6 +40,7 @@ protected:
 
 
 private:
 private:
 
 
+    bool ReadPreferences();
 
 
 };
 };
 
 

+ 1 - 1
Source/AtomicEditor/PlayerMode/AEPlayerEvents.h

@@ -19,7 +19,7 @@ EVENT(E_IPCPLAYEREXITREQUEST, IPCPlayerExitRequest)
 
 
 }
 }
 
 
-EVENT(E_IPCPLAYERWINDOW, IPCPlayerWindow)
+EVENT(E_IPCPLAYERWINDOWCHANGED, IPCPlayerWindowChanged)
 {
 {
     PARAM(P_POSX, PosX);
     PARAM(P_POSX, PosX);
     PARAM(P_POSY, PosY);
     PARAM(P_POSY, PosY);

+ 2 - 2
Source/AtomicEditor/PlayerMode/AEPlayerMode.cpp

@@ -242,13 +242,13 @@ void PlayerMode::HandleViewRender(StringHash eventType, VariantMap& eventData)
 void PlayerMode::HandleExitRequest(StringHash eventType, VariantMap& eventData)
 void PlayerMode::HandleExitRequest(StringHash eventType, VariantMap& eventData)
 {
 {
     Graphics* graphics = GetSubsystem<Graphics>();
     Graphics* graphics = GetSubsystem<Graphics>();
-    using namespace IPCPlayerWindow;
+    using namespace IPCPlayerWindowChanged;
     VariantMap data;
     VariantMap data;
     data[P_POSX] = graphics->GetWindowPosition().x_;
     data[P_POSX] = graphics->GetWindowPosition().x_;
     data[P_POSY] = graphics->GetWindowPosition().y_;
     data[P_POSY] = graphics->GetWindowPosition().y_;
     data[P_WIDTH] = graphics->GetWidth();
     data[P_WIDTH] = graphics->GetWidth();
     data[P_HEIGHT] = graphics->GetHeight();
     data[P_HEIGHT] = graphics->GetHeight();
-    ipc_->SendEventToBroker(E_IPCPLAYERWINDOW, data);
+    ipc_->SendEventToBroker(E_IPCPLAYERWINDOWCHANGED, data);
     ipc_->SendEventToBroker(E_IPCPLAYERQUIT);
     ipc_->SendEventToBroker(E_IPCPLAYERQUIT);
     SendEvent(E_IPCPLAYERQUIT);
     SendEvent(E_IPCPLAYERQUIT);
 }
 }