Browse Source

Save the maximized state for the player too

rsredsq 10 years ago
parent
commit
68f13489b2

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

@@ -54,10 +54,16 @@ class Editor extends Atomic.ScriptObject {
         });
         });
 
 
         this.subscribeToEvent("IPCPlayerWindowChanged", (data) => {
         this.subscribeToEvent("IPCPlayerWindowChanged", (data) => {
+            //if player window is maximized, then we want keep the window size from the previous state
+            if (data.maximized) {
+                Preferences.getInstance().playerWindow.maximized = true;
+                return;
+            }
             Preferences.getInstance().savePlayerWindowData({x: data.posX, y: data.posY, width: data.width, height: data.height, monitor: data.monitor, maximized: data.maximized});
             Preferences.getInstance().savePlayerWindowData({x: data.posX, y: data.posY, width: data.width, height: data.height, monitor: data.monitor, maximized: data.maximized});
         });
         });
 
 
         this.subscribeToEvent("ScreenMode", (data:Atomic.ScreenModeEvent) => this.saveWindowPreferences(data));
         this.subscribeToEvent("ScreenMode", (data:Atomic.ScreenModeEvent) => this.saveWindowPreferences(data));
+        this.subscribeToEvent("WindowPos", (data:Atomic.ScreenModeEvent) => this.saveWindowPreferences(data));
 
 
         this.subscribeToEvent("ExitRequested", (data) => this.handleExitRequested(data));
         this.subscribeToEvent("ExitRequested", (data) => this.handleExitRequested(data));
 
 

+ 3 - 0
Script/AtomicEditor/ui/Shortcuts.ts

@@ -36,6 +36,9 @@ class Shortcuts extends Atomic.ScriptObject {
                     Atomic.editorMode.playProject(args, debug);
                     Atomic.editorMode.playProject(args, debug);
                 } else {
                 } else {
                     var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable";
                     var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable";
+                    if (playerWindow.maximized) {
+                        args += " --maximize";
+                    }
                     Atomic.editorMode.playProject(args, debug);
                     Atomic.editorMode.playProject(args, debug);
                 }
                 }
             } else {
             } else {

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

@@ -173,6 +173,10 @@ void AEPlayerApplication::Setup()
             else if (argument == "--resizable") 
             else if (argument == "--resizable") 
             {
             {
                 engineParameters_["WindowResizable"] = true;
                 engineParameters_["WindowResizable"] = true;
+            } 
+            else if (argument == "--maximize")
+            {
+                engineParameters_["WindowMaximized"] = true;
             }
             }
         }
         }
     }
     }

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

@@ -26,6 +26,7 @@ EVENT(E_IPCPLAYERWINDOWCHANGED, IPCPlayerWindowChanged)
     PARAM(P_WIDTH, Width);
     PARAM(P_WIDTH, Width);
     PARAM(P_HEIGHT, Height);
     PARAM(P_HEIGHT, Height);
     PARAM(P_MONITOR, Monitor);
     PARAM(P_MONITOR, Monitor);
+    PARAM(P_MAXIMIZED, Maximized);
 }
 }
 
 
 EVENT(E_PLAYERQUIT, PlayerQuit)
 EVENT(E_PLAYERQUIT, PlayerQuit)

+ 8 - 1
Source/AtomicEditor/PlayerMode/AEPlayerMode.cpp

@@ -47,6 +47,8 @@ PlayerMode::PlayerMode(Context* context) :
     SubscribeToEvent(E_LOGMESSAGE, HANDLER(PlayerMode, HandleLogMessage));
     SubscribeToEvent(E_LOGMESSAGE, HANDLER(PlayerMode, HandleLogMessage));
     SubscribeToEvent(E_JSERROR, HANDLER(PlayerMode, HandleJSError));
     SubscribeToEvent(E_JSERROR, HANDLER(PlayerMode, HandleJSError));
     SubscribeToEvent(E_EXITREQUESTED, HANDLER(PlayerMode, HandleExitRequest));
     SubscribeToEvent(E_EXITREQUESTED, HANDLER(PlayerMode, HandleExitRequest));
+    SubscribeToEvent(E_SCREENMODE, HANDLER(PlayerMode, HandlePlayerWindowChanged));
+    SubscribeToEvent(E_WINDOWPOS, HANDLER(PlayerMode, HandlePlayerWindowChanged));
 
 
     // BEGIN LICENSE MANAGEMENT
     // BEGIN LICENSE MANAGEMENT
     SubscribeToEvent(E_BEGINVIEWRENDER, HANDLER(PlayerMode, HandleViewRender));
     SubscribeToEvent(E_BEGINVIEWRENDER, HANDLER(PlayerMode, HandleViewRender));
@@ -239,7 +241,7 @@ void PlayerMode::HandleViewRender(StringHash eventType, VariantMap& eventData)
 
 
 }
 }
 
 
-void PlayerMode::HandleExitRequest(StringHash eventType, VariantMap& eventData)
+void PlayerMode::HandlePlayerWindowChanged(StringHash eventType, VariantMap& eventData)
 {
 {
     Graphics* graphics = GetSubsystem<Graphics>();
     Graphics* graphics = GetSubsystem<Graphics>();
     using namespace IPCPlayerWindowChanged;
     using namespace IPCPlayerWindowChanged;
@@ -249,7 +251,12 @@ void PlayerMode::HandleExitRequest(StringHash eventType, VariantMap& eventData)
     data[P_WIDTH] = graphics->GetWidth();
     data[P_WIDTH] = graphics->GetWidth();
     data[P_HEIGHT] = graphics->GetHeight();
     data[P_HEIGHT] = graphics->GetHeight();
     data[P_MONITOR] = graphics->GetCurrentMonitor();
     data[P_MONITOR] = graphics->GetCurrentMonitor();
+    data[P_MAXIMIZED] = graphics->GetMaximized();
     ipc_->SendEventToBroker(E_IPCPLAYERWINDOWCHANGED, data);
     ipc_->SendEventToBroker(E_IPCPLAYERWINDOWCHANGED, data);
+}
+
+void PlayerMode::HandleExitRequest(StringHash eventType, VariantMap& eventData)
+{
     SendEvent(E_PLAYERQUIT);
     SendEvent(E_PLAYERQUIT);
 }
 }
 
 

+ 1 - 0
Source/AtomicEditor/PlayerMode/AEPlayerMode.h

@@ -42,6 +42,7 @@ private:
     void HandleIPCInitialize(StringHash eventType, VariantMap& eventData);
     void HandleIPCInitialize(StringHash eventType, VariantMap& eventData);
     void HandleViewRender(StringHash eventType, VariantMap& eventData);
     void HandleViewRender(StringHash eventType, VariantMap& eventData);
     void HandleExitRequest(StringHash eventType, VariantMap& eventData);
     void HandleExitRequest(StringHash eventType, VariantMap& eventData);
+    void HandlePlayerWindowChanged(StringHash eventType, VariantMap& eventData);
 
 
 // BEGIN LICENSE MANAGEMENT
 // BEGIN LICENSE MANAGEMENT
     void HandleMessageAck(StringHash eventType, VariantMap& eventData);
     void HandleMessageAck(StringHash eventType, VariantMap& eventData);