Browse Source

Windows preference and initial window creation improvements

JoshEngebretson 10 years ago
parent
commit
14f20e8431

+ 1 - 1
Source/Atomic/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -425,7 +425,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     // If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
     if (!width || !height)
     {
-        if (fullscreen || borderless)
+        if (fullscreen || borderless || maximize)
         {
             width = mode.w;
             height = mode.h;

+ 1 - 1
Source/Atomic/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -417,7 +417,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     // If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
     if (!width || !height)
     {
-        if (fullscreen || borderless)
+        if (fullscreen || borderless || maximize)
         {
             width = mode.w;
             height = mode.h;

+ 14 - 4
Source/AtomicEditor/Application/AEEditorCommon.cpp

@@ -156,7 +156,7 @@ void AEEditorCommon::Stop()
 #endif
 }
 
-void AEEditorCommon::CreateDefaultPreferences(String& path, JSONValue& prefs)
+bool AEEditorCommon::CreateDefaultPreferences(String& path, JSONValue& prefs)
 {
     // Note there is some duplication here with the editor's
     // TypeScript preference code, this is due to the preferences for
@@ -194,10 +194,17 @@ void AEEditorCommon::CreateDefaultPreferences(String& path, JSONValue& prefs)
 
     SharedPtr<File> file(new File(context_, path, FILE_WRITE));
 
+    if (!file->IsOpen())
+    {
+        LOGERRORF("Unable to open Atomic Editor preferences for writing: %s", path.CString());
+        return false;
+    }
+
     jsonFile->Save(*file, "   ");
 
     prefs = root;
 
+    return true;
 }
 
 bool AEEditorCommon::ReadPreferences()
@@ -210,7 +217,8 @@ bool AEEditorCommon::ReadPreferences()
 
     if (!fileSystem->FileExists(path))
     {
-        CreateDefaultPreferences(path, prefs);
+        if (!CreateDefaultPreferences(path, prefs))
+            return false;
     }
     else
     {
@@ -220,7 +228,8 @@ bool AEEditorCommon::ReadPreferences()
         if (!jsonFile->BeginLoad(*file))
         {
             file->Close();
-            CreateDefaultPreferences(path, prefs);
+            if (!CreateDefaultPreferences(path, prefs))
+                return false;
         }
         else
         {
@@ -231,7 +240,8 @@ bool AEEditorCommon::ReadPreferences()
 
     if (!prefs.IsObject() || !prefs["editorWindow"].IsObject())
     {
-        CreateDefaultPreferences(path, prefs);
+        if (!CreateDefaultPreferences(path, prefs))
+            return false;
     }
 
     JSONValue& editorWindow = prefs["editorWindow"];

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

@@ -37,7 +37,7 @@ public:
 
 protected:
 
-    void CreateDefaultPreferences(String& path, JSONValue& prefs);
+    bool CreateDefaultPreferences(String& path, JSONValue& prefs);
     bool ReadPreferences();
     
     SharedPtr<JSVM> vm_;