Browse Source

- Created a SuperClass to hold the repeated Config methods.
- Has default settings if the Import.json does not exist.
- Import.json must be saved in the Settings folder of the project along with Engine.config

raheelx 9 years ago
parent
commit
648b69e5a9

+ 42 - 140
Source/Atomic/Engine/EngineConfig.cpp

@@ -31,38 +31,7 @@
 namespace Atomic
 {
 
-VariantMap EngineConfig::engineConfig_;
-String EngineConfig::engineConfigFilename_;
-
-bool EngineConfig::GetBoolValue(const JSONValue& jvalue, bool defaultValue)
-{
-    bool value = defaultValue;
-
-    if (jvalue.IsBool())
-        value = jvalue.GetBool();
-
-    return value;
-}
-
-int EngineConfig::GetIntValue(const JSONValue& jvalue, int defaultValue)
-{
-    int value = defaultValue;
-
-    if (jvalue.IsNumber())
-        value = jvalue.GetInt();
-
-    return value;
-}
-
-String EngineConfig::GetStringValue(const JSONValue& jvalue, const String& defaultValue)
-{
-    String value = defaultValue;
-
-    if (jvalue.IsString())
-        value = jvalue.GetString();
-
-    return value;
-}
+EngineConfig EngineConfig::engineConfig_;
 
 bool EngineConfig::LoadEngineConfig(const JSONValue& jengine)
 {
@@ -75,11 +44,11 @@ bool EngineConfig::LoadEngineConfig(const JSONValue& jengine)
         const JSONValue& jvalue = i->second_;
 
         if (key == "workerthreads")
-            engineConfig_["WorkerThreads"] = GetBoolValue(jvalue, true);
+            valueMap_["WorkerThreads"] = GetBoolValue(jvalue, true);
         else if (key == "logquiet")
-            engineConfig_["LogQuiet"] = GetBoolValue(jvalue, false);
+            valueMap_["LogQuiet"] = GetBoolValue(jvalue, false);
         else if (key == "loglevel")
-            engineConfig_["LogLevel"] = GetIntValue(jvalue, 1);
+            valueMap_["LogLevel"] = GetIntValue(jvalue, 1);
     }
 
     return true;
@@ -96,74 +65,74 @@ bool EngineConfig::LoadGraphicsConfig(const JSONValue& jgraphics)
         const JSONValue& jvalue = i->second_;
 
         if (key == "headless")
-            engineConfig_["Headless"] = GetBoolValue(jvalue, false);
+            valueMap_["Headless"] = GetBoolValue(jvalue, false);
         else if (key == "framelimiter")
-            engineConfig_["FrameLimiter"] = GetBoolValue(jvalue, true);
+            valueMap_["FrameLimiter"] = GetBoolValue(jvalue, true);
         else if (key == "flushgpu")
-            engineConfig_["FlushGPU"] = GetBoolValue(jvalue, false);
+            valueMap_["FlushGPU"] = GetBoolValue(jvalue, false);
         else if (key == "forcegl2")
-            engineConfig_["ForceGL2"] = GetBoolValue(jvalue, false);
+            valueMap_["ForceGL2"] = GetBoolValue(jvalue, false);
         else if (key == "orientations")
-            engineConfig_["Orientations"] = GetStringValue(jvalue, "LandscapeLeft LandscapeRight");
+            valueMap_["Orientations"] = GetStringValue(jvalue, "LandscapeLeft LandscapeRight");
         else if (key == "vsync")
-            engineConfig_["VSync"] = GetBoolValue(jvalue, false);
+            valueMap_["VSync"] = GetBoolValue(jvalue, false);
         else if (key == "triplebuffer")
-            engineConfig_["TripleBuffer"] = GetBoolValue(jvalue, false);
+            valueMap_["TripleBuffer"] = GetBoolValue(jvalue, false);
         else if (key == "multisample")
-            engineConfig_["Multisample"] = GetIntValue(jvalue, 1);
+            valueMap_["Multisample"] = GetIntValue(jvalue, 1);
         else if (key == "renderpath")
         {
             String renderPath = GetStringValue(jvalue, "forward").ToLower();
 
             if (renderPath == "forward")
-                engineConfig_["RenderPath"] = "RenderPaths/Forward.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Forward.xml";
             else if (renderPath == "prepass")
-                engineConfig_["RenderPath"] = "RenderPaths/Prepass.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Prepass.xml";
             else if (renderPath == "deferred")
-                engineConfig_["RenderPath"] = "RenderPaths/Deferred.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Deferred.xml";
         }
         else if (key == "shadows")
-            engineConfig_["Shadows"] = GetBoolValue(jvalue, true);
+            valueMap_["Shadows"] = GetBoolValue(jvalue, true);
         else if (key == "lowqualityshadows")
-            engineConfig_["LowQualityShadows"] = GetBoolValue(jvalue, false);
+            valueMap_["LowQualityShadows"] = GetBoolValue(jvalue, false);
         else if (key == "materialquality")
         {
             String quality = GetStringValue(jvalue, "high").ToLower();
 
             if (quality == "high")
-                engineConfig_["MaterialQuality"] = QUALITY_HIGH;
+                valueMap_["MaterialQuality"] = QUALITY_HIGH;
             else if (quality == "medium")
-                engineConfig_["MaterialQuality"] = QUALITY_MEDIUM;
+                valueMap_["MaterialQuality"] = QUALITY_MEDIUM;
             else if (quality == "low")
-                engineConfig_["MaterialQuality"] = QUALITY_LOW;
+                valueMap_["MaterialQuality"] = QUALITY_LOW;
         }
         else if (key == "texturequality")
         {
             String quality = GetStringValue(jvalue, "high").ToLower();
 
             if (quality == "high")
-                engineConfig_["TextureQuality"] = QUALITY_HIGH;
+                valueMap_["TextureQuality"] = QUALITY_HIGH;
             else if (quality == "medium")
-                engineConfig_["TextureQuality"] = QUALITY_MEDIUM;
+                valueMap_["TextureQuality"] = QUALITY_MEDIUM;
             else if (quality == "low")
-                engineConfig_["TextureQuality"] = QUALITY_LOW;
+                valueMap_["TextureQuality"] = QUALITY_LOW;
         }
         else if (key == "texturefiltermode")
         {
             String mode = GetStringValue(jvalue, "trilinear").ToLower();
 
             if (mode == "trilinear")
-                engineConfig_["TextureFilterMode"] = FILTER_TRILINEAR;
+                valueMap_["TextureFilterMode"] = FILTER_TRILINEAR;
             else if (mode == "bilinear")
-                engineConfig_["TextureFilterMode"] = FILTER_BILINEAR;
+                valueMap_["TextureFilterMode"] = FILTER_BILINEAR;
             else if (mode == "nearest")
-                engineConfig_["TextureFilterMode"] = FILTER_NEAREST;
+                valueMap_["TextureFilterMode"] = FILTER_NEAREST;
             else if (mode == "anisotropic")
-                engineConfig_["TextureFilterMode"] = FILTER_ANISOTROPIC;
+                valueMap_["TextureFilterMode"] = FILTER_ANISOTROPIC;
         }
         else if (key == "textureanisotropy")
         {
-            engineConfig_["TextureAnisotropy"] = GetIntValue(jvalue, 4);
+            valueMap_["TextureAnisotropy"] = GetIntValue(jvalue, 4);
         }
 
 
@@ -183,21 +152,21 @@ bool EngineConfig::LoadWindowConfig(const JSONValue& jwindow)
         const JSONValue& jvalue = i->second_;
 
         if (key == "title")
-            engineConfig_["WindowTitle"] = GetStringValue(jvalue, "Atomic");
+            valueMap_["WindowTitle"] = GetStringValue(jvalue, "Atomic");
         else if (key == "fullscreen")
-            engineConfig_["FullScreen"] = GetBoolValue(jvalue, false);
+            valueMap_["FullScreen"] = GetBoolValue(jvalue, false);
         else if (key == "borderless")
-            engineConfig_["Borderless"] = GetBoolValue(jvalue, false);
+            valueMap_["Borderless"] = GetBoolValue(jvalue, false);
         else if (key == "resizable")
-            engineConfig_["WindowResizable"] = GetBoolValue(jvalue, false);
+            valueMap_["WindowResizable"] = GetBoolValue(jvalue, false);
         else if (key == "width")
-            engineConfig_["WindowWidth"] = GetIntValue(jvalue, false);
+            valueMap_["WindowWidth"] = GetIntValue(jvalue, false);
         else if (key == "height")
-            engineConfig_["WindowHeight"] = GetIntValue(jvalue, false);
+            valueMap_["WindowHeight"] = GetIntValue(jvalue, false);
         else if (key == "positionx")
-            engineConfig_["WindowPositionX"] = GetIntValue(jvalue, false);
+            valueMap_["WindowPositionX"] = GetIntValue(jvalue, false);
         else if (key == "positiony")
-            engineConfig_["WindowPositionY"] = GetIntValue(jvalue, false);
+            valueMap_["WindowPositionY"] = GetIntValue(jvalue, false);
 
     }
 
@@ -216,15 +185,15 @@ bool EngineConfig::LoadSoundConfig(const JSONValue& jsound)
         const JSONValue& jvalue = i->second_;
 
         if (key == "enabled")
-            engineConfig_["Sound"] = GetBoolValue(jvalue, true);
+            valueMap_["Sound"] = GetBoolValue(jvalue, true);
         else if (key == "interpolation")
-            engineConfig_["SoundInterpolation"] = GetBoolValue(jvalue, true);
+            valueMap_["SoundInterpolation"] = GetBoolValue(jvalue, true);
         else if (key == "stereo")
-            engineConfig_["SoundStereo"] = GetBoolValue(jvalue, true);
+            valueMap_["SoundStereo"] = GetBoolValue(jvalue, true);
         else if (key == "bufferms")
-            engineConfig_["SoundBuffer"] = GetIntValue(jvalue, 100);
+            valueMap_["SoundBuffer"] = GetIntValue(jvalue, 100);
         else if (key == "mixrate")
-            engineConfig_["SoundMixRate"] = GetIntValue(jvalue, 44100);
+            valueMap_["SoundMixRate"] = GetIntValue(jvalue, 44100);
 
     }
 
@@ -243,7 +212,7 @@ bool EngineConfig::LoadInputConfig(const JSONValue& jinput)
         const JSONValue& jvalue = i->second_;
 
         if (key == "touchemulation")
-            engineConfig_["TouchEmulation"] = GetBoolValue(jvalue, false);
+            valueMap_["TouchEmulation"] = GetBoolValue(jvalue, false);
     }
 
     return true;
@@ -281,71 +250,4 @@ bool EngineConfig::LoadDesktopConfig(JSONValue root)
     return true;
 }
 
-bool EngineConfig::LoadFromJSON(const String& json)
-{
-    engineConfig_.Clear();
-
-    JSONValue jroot;
-
-    if (!JSONFile::ParseJSON(json, jroot))
-    {
-        LOGERRORF("EngineConfig::LoadFromJSON - Unable to parse config file JSON: %s", engineConfigFilename_.CString());
-        return false;
-    }
-
-    if (!jroot.IsObject())
-        return false;
-
-    if (!LoadDesktopConfig(jroot))
-        return false;
-
-    return true;
-}
-
-bool EngineConfig::LoadFromFile(Context *context, const String& filename)
-{
-
-    FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
-
-    if (!fileSystem->FileExists(filename))
-        return false;
-
-    engineConfigFilename_ = filename;
-
-    SharedPtr<File> file(new File(context));
-
-    if (!file->Open(filename))
-    {
-        LOGERRORF("EngineConfig::LoadFromFile - Unable to open config file %s", filename.CString());
-        return false;
-    }
-
-    String json;
-    file->ReadText(json);
-
-    return LoadFromJSON(json);
-}
-
-void EngineConfig::ApplyConfig(VariantMap& settings, bool overwrite)
-{
-    VariantMap::ConstIterator itr = engineConfig_.Begin();
-    if (overwrite)
-    { 
-        while (itr != engineConfig_.End())
-        {
-            settings[itr->first_] = itr->second_;
-            itr++;
-        }
-    }
-    else
-    {
-        while (itr != engineConfig_.End())
-        {
-            settings.InsertNew(itr->first_, itr->second_);
-            itr++;
-        }
-    }
-
-}
-
 }

+ 13 - 19
Source/Atomic/Engine/EngineConfig.h

@@ -24,6 +24,7 @@
 
 #include "../Core/Variant.h"
 #include "../Resource/JSONValue.h"
+#include "../Resource/Configuration.h"
 
 namespace Atomic
 {
@@ -31,36 +32,29 @@ namespace Atomic
 class Context;
 
 /// Atomic engine configuration
-class EngineConfig
+class EngineConfig :
+    Configuration
 {
 
 public:
 
-    static bool LoadFromFile(Context* context, const String& filename);
-    static bool LoadFromJSON(const String& json);
+    static bool LoadFromFile(Context* context, const String& filename) { return engineConfig_.Configuration::LoadFromFile(context, filename); }
+    static bool LoadFromJSON(const String& json) { return engineConfig_.Configuration::LoadFromJSON(json); }
 
     /// Apply the configuration to a setting variant map, values that exist will not be overriden
-    static void ApplyConfig(VariantMap& settings, bool overwrite = false);
-
-    static const VariantMap& GetConfig() { return engineConfig_; }
+    static void ApplyConfig(VariantMap& settings, bool overwrite = false) { return engineConfig_.Configuration::ApplyConfig(settings, overwrite); }
 
 private:
 
-    static bool LoadDesktopConfig(JSONValue root);
-    static bool LoadGraphicsConfig(const JSONValue& jgraphics);
-    static bool LoadWindowConfig(const JSONValue& jwindow);
-    static bool LoadSoundConfig(const JSONValue& jsound);
-    static bool LoadInputConfig(const JSONValue& jinput);
-
-    static bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
-    static int GetIntValue(const JSONValue& jvalue, int defaultValue);
-    static String GetStringValue(const JSONValue& jvalue, const String& defaultValue);
-
-    static bool LoadEngineConfig(const JSONValue& jengine);
+    virtual bool LoadDesktopConfig(JSONValue root);
+    bool LoadGraphicsConfig(const JSONValue& jgraphics);
+    bool LoadWindowConfig(const JSONValue& jwindow);
+    bool LoadSoundConfig(const JSONValue& jsound);
+    bool LoadInputConfig(const JSONValue& jinput);
 
-    static VariantMap engineConfig_;
-    static String engineConfigFilename_;
+    bool LoadEngineConfig(const JSONValue& jengine);
 
+    static EngineConfig engineConfig_;
 };
 
 }

+ 133 - 0
Source/Atomic/Resource/Configuration.cpp

@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+
+#include "../Core/Context.h"
+#include "../IO/Log.h"
+#include "../IO/File.h"
+#include "../IO/FileSystem.h"
+#include "../Resource/JSONFile.h"
+#include "../Graphics/GraphicsDefs.h"
+#include "Configuration.h"
+
+namespace Atomic
+{
+
+    bool Configuration::GetBoolValue(const JSONValue& jvalue, bool defaultValue)
+    {
+        bool value = defaultValue;
+
+        if (jvalue.IsBool())
+            value = jvalue.GetBool();
+
+        return value;
+    }
+
+    int Configuration::GetIntValue(const JSONValue& jvalue, int defaultValue)
+    {
+        int value = defaultValue;
+
+        if (jvalue.IsNumber())
+            value = jvalue.GetInt();
+
+        return value;
+    }
+
+    String Configuration::GetStringValue(const JSONValue& jvalue, const String& defaultValue)
+    {
+        String value = defaultValue;
+
+        if (jvalue.IsString())
+            value = jvalue.GetString();
+
+        return value;
+    }
+
+
+    bool Configuration::LoadFromFile(Context *context, const String& filename)
+    {
+
+        FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
+
+        if (!fileSystem->FileExists(filename))
+            return false;
+
+        filename_ = filename;
+
+        SharedPtr<File> file(new File(context));
+
+        if (!file->Open(filename))
+        {
+            LOGERRORF("Configuration::LoadFromFile - Unable to open config file %s", filename.CString());
+            return false;
+        }
+
+        String json;
+        file->ReadText(json);
+
+        return LoadFromJSON(json);
+    }
+
+    void Configuration::ApplyConfig(VariantMap& settings, bool overwrite)
+    {
+        VariantMap::ConstIterator itr = valueMap_.Begin();
+        if (overwrite)
+        {
+            while (itr != valueMap_.End())
+            {
+                settings[itr->first_] = itr->second_;
+                itr++;
+            }
+        }
+        else
+        {
+            while (itr != valueMap_.End())
+            {
+                settings.InsertNew(itr->first_, itr->second_);
+                itr++;
+            }
+        }
+
+    }
+
+    bool Configuration::LoadFromJSON(const String& json)
+    {
+        valueMap_.Clear();
+
+        JSONValue jroot;
+
+        if (!JSONFile::ParseJSON(json, jroot))
+        {
+            LOGERRORF("Configuration::LoadFromJSON - Unable to parse config file JSON: %s", filename_.CString());
+            return false;
+        }
+
+        if (!jroot.IsObject())
+            return false;
+
+        if (!LoadDesktopConfig(jroot))
+            return false;
+
+        return true;
+    }
+
+}

+ 60 - 0
Source/Atomic/Resource/Configuration.h

@@ -0,0 +1,60 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "../Core/Variant.h"
+#include "JSONValue.h"
+
+namespace Atomic
+{
+
+class Context;
+
+class Configuration
+{
+public:
+
+    bool LoadFromFile(Context* context, const String& filename);
+    bool LoadFromJSON(const String& json);
+
+    /// Apply the configuration to a setting variant map, values that exist will not be overriden
+    void ApplyConfig(VariantMap& settings, bool overwrite = false);
+
+    const VariantMap& GetConfig() { return valueMap_; }
+
+protected:
+    static bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
+    static int GetIntValue(const JSONValue& jvalue, int defaultValue);
+    static String GetStringValue(const JSONValue& jvalue, const String& defaultValue);
+
+    virtual bool LoadDesktopConfig(JSONValue root) { return true; };
+
+    VariantMap valueMap_;
+
+private:
+    String filename_;
+};
+}
+
+
+

+ 13 - 91
Source/Atomic/Resource/ImportConfig.cpp

@@ -31,85 +31,7 @@
 namespace Atomic
 {
 
-VariantMap ImportConfig::importConfig_;
-String ImportConfig::importConfigFilename_;
-
-bool ImportConfig::GetBoolValue(const JSONValue& jvalue, bool defaultValue)
-{
-    bool value = defaultValue;
-
-    if (jvalue.IsBool())
-        value = jvalue.GetBool();
-
-    return value;
-}
-
-bool ImportConfig::LoadFromJSON(const String& json)
-{
-    importConfig_.Clear();
-
-    JSONValue jroot;
-
-    if (!JSONFile::ParseJSON(json, jroot))
-    {
-        LOGERRORF("ImportConfig::LoadFromJSON - Unable to parse config file JSON: %s", importConfigFilename_.CString());
-        return false;
-    }
-
-    if (!jroot.IsObject())
-        return false;
-
-    if (!LoadDesktopConfig(jroot))
-        return false;
-
-    return true;
-}
-
-bool ImportConfig::LoadFromFile(Context *context, const String& filename)
-{
-
-    FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
-
-    if (!fileSystem->FileExists(filename))
-        return false;
-
-    importConfigFilename_ = filename;
-
-    SharedPtr<File> file(new File(context));
-
-    if (!file->Open(filename))
-    {
-        LOGERRORF("ImportConfig::LoadFromFile - Unable to open config file %s", filename.CString());
-        return false;
-    }
-
-    String json;
-    file->ReadText(json);
-
-    return LoadFromJSON(json);
-}
-
-void ImportConfig::ApplyConfig(VariantMap& settings, bool overwrite)
-{
-    VariantMap::ConstIterator itr = importConfig_.Begin();
-    if (overwrite)
-    {
-        while (itr != importConfig_.End())
-        {
-            settings[itr->first_] = itr->second_;
-            itr++;
-        }
-    }
-    else
-    {
-        while (itr != importConfig_.End())
-        {
-            settings.InsertNew(itr->first_, itr->second_);
-            itr++;
-        }
-    }
-
-}
+ImportConfig ImportConfig::importConfig_;
 
 bool ImportConfig::LoadAIFlagsDefaultConfig(const JSONValue& jflags)
 {
@@ -122,29 +44,29 @@ bool ImportConfig::LoadAIFlagsDefaultConfig(const JSONValue& jflags)
         const JSONValue& jvalue = i->second_;
 
         if (key == "convertToLeftHanded")
-            importConfig_["aiProcess_ConvertToLeftHanded"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_ConvertToLeftHanded"] = GetBoolValue(jvalue, true);
         else if (key == "joinIdenticalVertices")
-            importConfig_["aiProcess_JoinIdenticalVertices"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_JoinIdenticalVertices"] = GetBoolValue(jvalue, true);
         else if (key == "triangulate")
-            importConfig_["aiProcess_Triangulate"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_Triangulate"] = GetBoolValue(jvalue, true);
         else if (key == "genSmoothNormals")
-            importConfig_["aiProcess_GenSmoothNormals"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_GenSmoothNormals"] = GetBoolValue(jvalue, true);
         else if (key == "limitBoneWeights")
-            importConfig_["aiProcess_LimitBoneWeights"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_LimitBoneWeights"] = GetBoolValue(jvalue, true);
         else if (key == "improveCacheLocality")
-            importConfig_["aiProcess_ImproveCacheLocality"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_ImproveCacheLocality"] = GetBoolValue(jvalue, true);
         else if (key == "fixInFacingNormals")
-            importConfig_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
         else if (key == "fixInfacingNormals")
-            importConfig_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
         else if (key == "findInvalidData")
-            importConfig_["aiProcess_FindInvalidData"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_FindInvalidData"] = GetBoolValue(jvalue, true);
         else if (key == "genUVCoords")
-            importConfig_["aiProcess_GenUVCoords"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_GenUVCoords"] = GetBoolValue(jvalue, true);
         else if (key == "findInstances")
-            importConfig_["aiProcess_FindInstances"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_FindInstances"] = GetBoolValue(jvalue, true);
         else if (key == "optimizeMeshes")
-            importConfig_["aiProcess_OptimizeMeshes"] = GetBoolValue(jvalue, true);
+            valueMap_["aiProcess_OptimizeMeshes"] = GetBoolValue(jvalue, true);
     }
 
     return true;

+ 9 - 12
Source/Atomic/Resource/ImportConfig.h

@@ -24,34 +24,31 @@
 
 #include "../Core/Variant.h"
 #include "JSONValue.h"
+#include "Configuration.h"
 
 namespace Atomic
 {
 
 class Context;
 
-class ImportConfig
+class ImportConfig :
+    Configuration
 {
 
 public:
 
-    static bool LoadFromFile(Context* context, const String& filename);
-    static bool LoadFromJSON(const String& json);
+    static bool LoadFromFile(Context* context, const String& filename) { return importConfig_.Configuration::LoadFromFile(context, filename); }
+    static bool LoadFromJSON(const String& json) { return importConfig_.Configuration::LoadFromJSON(json); }
 
     /// Apply the configuration to a setting variant map, values that exist will not be overriden
-    static void ApplyConfig(VariantMap& settings, bool overwrite = false);
-
-    static const VariantMap& GetConfig() { return importConfig_; }
+    static void ApplyConfig(VariantMap& settings, bool overwrite = false) { return importConfig_.Configuration::ApplyConfig(settings, overwrite); }
 
 private:
 
-    static bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
-
-    static bool LoadDesktopConfig(JSONValue root);
-    static bool LoadAIFlagsDefaultConfig(const JSONValue& jflags);
+    virtual bool LoadDesktopConfig(JSONValue root);
+    bool LoadAIFlagsDefaultConfig(const JSONValue& jflags);
 
-    static VariantMap importConfig_;
-    static String importConfigFilename_;
+    static ImportConfig importConfig_;
 };
 
 }

+ 51 - 30
Source/ToolCore/Import/OpenAssetImporter.cpp

@@ -74,46 +74,66 @@ OpenAssetImporter::OpenAssetImporter(Context* context) : Object(context) ,
     maxBones_(64),
     defaultTicksPerSecond_(4800.0f),
     startTime_(-1),
-    endTime_(-1)
+    endTime_(-1), 
+    configSettingsAvailable_(false)
 {
 
     ReadImportConfig();
 
-    VariantMap::ConstIterator itr = aiFlagParameters_.Begin();
+    if (configSettingsAvailable_)
+    {
+        VariantMap::ConstIterator itr = aiFlagParameters_.Begin();
 
-    aiFlagsDefault_ = 0;
+        aiFlagsDefault_ = 0;
 
-    while (itr != aiFlagParameters_.End())
-    {
-        if (itr->second_ == true)
+        while (itr != aiFlagParameters_.End())
         {
-            if (itr->first_ == "aiProcess_ConvertToLeftHanded")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_ConvertToLeftHanded;
-            else if (itr->first_ == "aiProcess_JoinIdenticalVertices")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_JoinIdenticalVertices;
-            else if (itr->first_ == "aiProcess_Triangulate")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_Triangulate;
-            else if (itr->first_ == "aiProcess_GenSmoothNormals")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_GenSmoothNormals;
-            else if (itr->first_ == "aiProcess_LimitBoneWeights")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_LimitBoneWeights;
-            else if (itr->first_ == "aiProcess_ImproveCacheLocality")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_ImproveCacheLocality;
-            else if (itr->first_ == "aiProcess_FixInfacingNormals")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FixInfacingNormals;
-            else if (itr->first_ == "aiProcess_FindInvalidData")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FindInvalidData;
-            else if (itr->first_ == "aiProcess_GenUVCoords")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_GenUVCoords;
-            else if (itr->first_ == "aiProcess_FindInstances")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FindInstances;
-            else if (itr->first_ == "aiProcess_OptimizeMeshes")
-                aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_OptimizeMeshes;
+            if (itr->second_ == true)
+            {
+                if (itr->first_ == "aiProcess_ConvertToLeftHanded")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_ConvertToLeftHanded;
+                else if (itr->first_ == "aiProcess_JoinIdenticalVertices")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_JoinIdenticalVertices;
+                else if (itr->first_ == "aiProcess_Triangulate")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_Triangulate;
+                else if (itr->first_ == "aiProcess_GenSmoothNormals")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_GenSmoothNormals;
+                else if (itr->first_ == "aiProcess_LimitBoneWeights")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_LimitBoneWeights;
+                else if (itr->first_ == "aiProcess_ImproveCacheLocality")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_ImproveCacheLocality;
+                else if (itr->first_ == "aiProcess_FixInfacingNormals")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FixInfacingNormals;
+                else if (itr->first_ == "aiProcess_FindInvalidData")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FindInvalidData;
+                else if (itr->first_ == "aiProcess_GenUVCoords")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_GenUVCoords;
+                else if (itr->first_ == "aiProcess_FindInstances")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_FindInstances;
+                else if (itr->first_ == "aiProcess_OptimizeMeshes")
+                    aiFlagsDefault_ = aiFlagsDefault_ | aiProcess_OptimizeMeshes;
+            }
+
+            itr++;
         }
 
-        itr++;
+        configSettingsAvailable_ = false;
+    } 
+    else
+    {
+        aiFlagsDefault_ =
+            aiProcess_ConvertToLeftHanded |
+            aiProcess_JoinIdenticalVertices |
+            aiProcess_Triangulate |
+            aiProcess_GenSmoothNormals |
+            aiProcess_LimitBoneWeights |
+            aiProcess_ImproveCacheLocality |
+            aiProcess_FixInfacingNormals |
+            aiProcess_FindInvalidData |
+            aiProcess_GenUVCoords |
+            aiProcess_FindInstances |
+            aiProcess_OptimizeMeshes;
     }
-
     // TODO:  make this an option on importer
 
     aiFlagsDefault_ |= aiProcess_CalcTangentSpace;
@@ -903,6 +923,7 @@ void OpenAssetImporter::ReadImportConfig()
 
     if (ImportConfig::LoadFromFile(context_, filename))
     {
+        configSettingsAvailable_ = true;
         ImportConfig::ApplyConfig(aiFlagParameters_);
     }
 

+ 1 - 0
Source/ToolCore/Import/OpenAssetImporter.h

@@ -143,6 +143,7 @@ private:
     float endTime_;
 
     VariantMap aiFlagParameters_;
+    bool configSettingsAvailable_;
 
 };