Browse Source

Additional config settings

Josh Engebretson 10 years ago
parent
commit
c316ab68d6

+ 85 - 1
Source/Atomic/Engine/EngineConfig.cpp

@@ -168,6 +168,76 @@ bool EngineConfig::LoadGraphicsConfig(const JSONValue& jgraphics)
     return true;
     return true;
 }
 }
 
 
+bool EngineConfig::LoadWindowConfig(const JSONValue& jwindow)
+{
+    if (!jwindow.IsObject())
+        return false;
+
+    for (JSONObject::ConstIterator i = jwindow.Begin(); i != jwindow.End(); ++i)
+    {
+        String key = i->first_.ToLower();
+        const JSONValue& jvalue = i->second_;
+
+        if (key == "title")
+            engineConfig_["WindowTitle"] = GetStringValue(jvalue, "Atomic");
+        else if (key == "fullscreen")
+            engineConfig_["FullScreen"] = GetBoolValue(jvalue, false);
+        else if (key == "borderless")
+            engineConfig_["Borderless"] = GetBoolValue(jvalue, false);
+        else if (key == "resizable")
+            engineConfig_["WindowResizable"] = GetBoolValue(jvalue, false);
+
+    }
+
+    return true;
+
+}
+
+bool EngineConfig::LoadSoundConfig(const JSONValue& jsound)
+{
+    if (!jsound.IsObject())
+        return false;
+
+    for (JSONObject::ConstIterator i = jsound.Begin(); i != jsound.End(); ++i)
+    {
+        String key = i->first_.ToLower();
+        const JSONValue& jvalue = i->second_;
+
+        if (key == "enabled")
+            engineConfig_["Sound"] = GetBoolValue(jvalue, true);
+        else if (key == "interpolation")
+            engineConfig_["SoundInterpolation"] = GetBoolValue(jvalue, true);
+        else if (key == "stereo")
+            engineConfig_["SoundStereo"] = GetBoolValue(jvalue, true);
+        else if (key == "bufferms")
+            engineConfig_["SoundBuffer"] = GetIntValue(jvalue, 100);
+        else if (key == "mixrate")
+            engineConfig_["SoundMixRate"] = GetIntValue(jvalue, 44100);
+
+    }
+
+    return true;
+
+}
+
+bool EngineConfig::LoadInputConfig(const JSONValue& jinput)
+{
+    if (!jinput.IsObject())
+        return false;
+
+    for (JSONObject::ConstIterator i = jinput.Begin(); i != jinput.End(); ++i)
+    {
+        String key = i->first_.ToLower();
+        const JSONValue& jvalue = i->second_;
+
+        if (key == "touchemulation")
+            engineConfig_["TouchEmulation"] = GetBoolValue(jvalue, false);
+    }
+
+    return true;
+
+}
+
 
 
 bool EngineConfig::LoadDesktopConfig(JSONValue root)
 bool EngineConfig::LoadDesktopConfig(JSONValue root)
 {
 {
@@ -184,6 +254,18 @@ bool EngineConfig::LoadDesktopConfig(JSONValue root)
     if (jgraphics.IsObject())
     if (jgraphics.IsObject())
         LoadGraphicsConfig(jgraphics);
         LoadGraphicsConfig(jgraphics);
 
 
+    const JSONValue& jwindow = jdesktop["window"];
+    if (jwindow.IsObject())
+        LoadWindowConfig(jwindow);
+
+    const JSONValue& jsound = jdesktop["sound"];
+    if (jsound.IsObject())
+        LoadSoundConfig(jsound);
+
+    const JSONValue& jinput = jdesktop["input"];
+    if (jinput.IsObject())
+        LoadInputConfig(jinput);
+
     return true;
     return true;
 }
 }
 
 
@@ -199,7 +281,8 @@ bool EngineConfig::LoadFromJSON(const String& json)
     if (!jroot.IsObject())
     if (!jroot.IsObject())
         return false;
         return false;
 
 
-    LoadDesktopConfig(jroot);
+    if (!LoadDesktopConfig(jroot))
+        return false;
 
 
     return true;
     return true;
 }
 }
@@ -225,6 +308,7 @@ void EngineConfig::ApplyConfig(VariantMap& settings)
         settings.InsertNew(itr->first_, itr->second_);
         settings.InsertNew(itr->first_, itr->second_);
         itr++;
         itr++;
     }
     }
+
 }
 }
 
 
 }
 }

+ 3 - 0
Source/Atomic/Engine/EngineConfig.h

@@ -48,6 +48,9 @@ private:
 
 
     static bool LoadDesktopConfig(JSONValue root);
     static bool LoadDesktopConfig(JSONValue root);
     static bool LoadGraphicsConfig(const JSONValue& jgraphics);
     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 bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
     static int GetIntValue(const JSONValue& jvalue, int defaultValue);
     static int GetIntValue(const JSONValue& jvalue, int defaultValue);

+ 2 - 2
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -65,7 +65,7 @@ void AEPlayerApplication::Setup()
 
 
     engine_->SetAutoExit(false);
     engine_->SetAutoExit(false);
 
 
-    engineParameters_["WindowTitle"] = "AtomicPlayer";
+    engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
 
 
 #if (ATOMIC_PLATFORM_ANDROID)
 #if (ATOMIC_PLATFORM_ANDROID)
     engineParameters_["FullScreen"] = true;
     engineParameters_["FullScreen"] = true;
@@ -84,7 +84,7 @@ void AEPlayerApplication::Setup()
     engineParameters_["WindowHeight"] = 720;
     engineParameters_["WindowHeight"] = 720;
 #endif
 #endif
 
 
-    engineParameters_["LogLevel"] = LOG_DEBUG;
+    engineParameters_.InsertNew("LogLevel", LOG_DEBUG);
 
 
 #if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX
 #if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX
     engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png";
     engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png";