From 1ea1ff7550047ae2115b1960fc84334c11f2e609 Mon Sep 17 00:00:00 2001
From: Stefan Richter <o-s-r1993@web.de>
Date: Sat, 11 Mar 2023 21:03:44 +0100
Subject: [PATCH] changed Network Jason and Loading it

---
 Assets/Scenes/Worlds/RiverWorld.unity         |  57 +++++++-
 .../Scripts/Loading/StreamingAssetLoader.cs   |  17 ++-
 .../Scripts/UI/NetwMenue/StartMenue_mobile.cs | 136 ++++++------------
 Assets/Scripts/UI/UIconfig.cs                 |   4 +
 .../Config/Network.JSON                       |   5 +-
 UserSettings/EditorUserSettings.asset         |   4 +-
 6 files changed, 126 insertions(+), 97 deletions(-)

diff --git a/Assets/Scenes/Worlds/RiverWorld.unity b/Assets/Scenes/Worlds/RiverWorld.unity
index 61becd5d..6e8dbef6 100644
--- a/Assets/Scenes/Worlds/RiverWorld.unity
+++ b/Assets/Scenes/Worlds/RiverWorld.unity
@@ -38,7 +38,7 @@ RenderSettings:
   m_ReflectionIntensity: 1
   m_CustomReflection: {fileID: 0}
   m_Sun: {fileID: 0}
-  m_IndirectSpecularColor: {r: 0.44100717, g: 0.4898312, b: 0.5698877, a: 1}
+  m_IndirectSpecularColor: {r: 0.4410865, g: 0.48984045, b: 0.5699203, a: 1}
   m_UseRadianceAmbientProbe: 0
 --- !u!157 &3
 LightmapSettings:
@@ -59582,6 +59582,16 @@ PrefabInstance:
       propertyPath: m_AnchoredPosition.y
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 1734510802251275973, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 690
+      objectReference: {fileID: 0}
+    - target: {fileID: 1734510802251275974, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_Name
+      value: "Scrollscreen - npf\xDC"
+      objectReference: {fileID: 0}
     - target: {fileID: 1823131411472254337, guid: b07552db700124a4680401e6fb94c186,
         type: 3}
       propertyPath: m_AnchorMax.y
@@ -60644,6 +60654,16 @@ PrefabInstance:
       propertyPath: m_AnchoredPosition.y
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 3256699174731649202, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 3256699174731649202, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: 690
+      objectReference: {fileID: 0}
     - target: {fileID: 3282753201910983826, guid: b07552db700124a4680401e6fb94c186,
         type: 3}
       propertyPath: m_AnchorMax.y
@@ -61114,6 +61134,11 @@ PrefabInstance:
       propertyPath: m_AnchoredPosition.y
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 4467612396593514728, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_Name
+      value: "GadgetBackground - N.Pf.\xDC.!"
+      objectReference: {fileID: 0}
     - target: {fileID: 4474961685855124046, guid: b07552db700124a4680401e6fb94c186,
         type: 3}
       propertyPath: m_AnchorMax.y
@@ -61969,6 +61994,36 @@ PrefabInstance:
       propertyPath: m_AnchoredPosition.y
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchorMax.x
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchorMax.y
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchorMin.x
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchorMin.y
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: -220
+      objectReference: {fileID: 0}
+    - target: {fileID: 6674138263813566047, guid: b07552db700124a4680401e6fb94c186,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: -230
+      objectReference: {fileID: 0}
     - target: {fileID: 6716680220403242463, guid: b07552db700124a4680401e6fb94c186,
         type: 3}
       propertyPath: m_AnchorMax.y
diff --git a/Assets/Scripts/Loading/StreamingAssetLoader.cs b/Assets/Scripts/Loading/StreamingAssetLoader.cs
index f733a2da..61b560cc 100644
--- a/Assets/Scripts/Loading/StreamingAssetLoader.cs
+++ b/Assets/Scripts/Loading/StreamingAssetLoader.cs
@@ -230,13 +230,22 @@ public static void ReReadFiles(string rootPath, string targetFolder)//ID_toPath
         }
     }
 
+    public static void NetworkJSON_Load()
+    {
+        NetworkJSON_Load_x(Application.persistentDataPath);
+    }
 
 
+    public static void NetworkJSON_Load_0()
+    {
+        var x = Path.Combine(Application.streamingAssetsPath, StreamToPersistentDataPath_Folder);
 
+        NetworkJSON_Load_x(x);
+    }
 
-        public static void NetworkJSON_Load()
+    public static void NetworkJSON_Load_x(string path)
     {
-        var reader = new StreamReader(Path.Combine(Application.persistentDataPath, ConfigDir, ConfigFile_Network));
+            var reader = new StreamReader(Path.Combine(path, ConfigDir, ConfigFile_Network));
         string json = reader.ReadToEnd();
         reader.Close();
 
@@ -288,6 +297,10 @@ public static void NetworkJSON_Load()
         } else {
             CommunicationEvents.autoOSrecognition = myObjs.autoOSrecognition;
         }
+        if (string.IsNullOrEmpty(myObjsOnlyStrings.autoOSrecognition)){        
+        } else {
+            UIconfig.autoSettingsAdaption = myObjs.autoSettingsAdaption;
+        }
         if (string.IsNullOrEmpty(myObjsOnlyStrings.Opsys)) {
         } else {
             CommunicationEvents.Opsys = (OperationSystem)Enum.Parse(typeof(OperationSystem), myObjs.Opsys);
diff --git a/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs b/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs
index 28124483..12eaa520 100644
--- a/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs
+++ b/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs
@@ -56,97 +56,36 @@ void Start()
 
     void start2_CheckOS_CheckConfig()
     {
-        //Debug.Log("start2: " + CommunicationEvents.Opsys);
-        switch (CommunicationEvents.Opsys)
-        {         
-            
-            case OperationSystem.Windows:
-
-                //Debug.Log(checkPersistentDataPath());
-                if (!checkPersistentDataPath())
-                {
-                    //Debug.Log("initialReset_PDP");
-                    ResetPersistentDataPath();
-                    switch (Opsys)
-                    {
-                        case OperationSystem.Windows:
-                            UIconfig.controlMode = ControlMode.Keyboard;
-                            break;
-                        case OperationSystem.Android:
-                            UIconfig.controlMode = ControlMode.Mobile;
-                            break;
-                        default:
-                            break;
-                    }
-                        
-                    NetworkJSON_Save();
-                }
-                NetworkJSON_Load();
-                checkOS();
-                if (!checkDataPath())
-                {
-                    ResetDataPath();
-                }
-                setMouse();
-                break;
-            case OperationSystem.Android:
-
-                if (!checkPersistentDataPath())
-                {
-                    //Debug.Log("initialReset_PDP");
-                    ResetPersistentDataPath();
-                    switch (Opsys)
-                    {
-                        case OperationSystem.Windows:
-                            UIconfig.controlMode = ControlMode.Keyboard;
-                            break;
-                        case OperationSystem.Android:
-                            UIconfig.controlMode = ControlMode.Mobile;
-                            break;
-                        default:
-                            break;
-                    }
-
-                    NetworkJSON_Save();
-                }
-                NetworkJSON_Load();
-                checkOS();
-                if (!checkDataPath())
-                {
-                    ResetDataPath();
-                };
-                setMouse();
-                break;
-
-            default:
+        //Default Settings:
+        NetworkJSON_Load_0();
+        //Debug.Log(checkPersistentDataPath());
+        if (checkPersistentDataPath())
+        {
+            NetworkJSON_Load();
+        }
+        //Welches Betriebssystem?
+        checkOS();
 
-                if (!checkPersistentDataPath())
-                {
-                   //Debug.Log("initialReset_PDP");
-                    ResetPersistentDataPath();
-                    switch (Opsys)
-                    {
-                        case OperationSystem.Windows:
-                            UIconfig.controlMode = ControlMode.Keyboard;
-                            break;
-                        case OperationSystem.Android:
-                            UIconfig.controlMode = ControlMode.Mobile;
-                            break;
-                        default:
-                            break;
-                    }
-
-                    NetworkJSON_Save();
-                }
-                NetworkJSON_Load();
-                checkOS();
-                if (!checkDataPath())
-                {
-                    ResetDataPath();
-                }
-                setMouse();
-                break;
+        //Entpacken
+        if (!checkPersistentDataPath())
+        {
+            //Debug.Log("initialReset_PDP");
+            ResetPersistentDataPath();
+            changeSettingsToOS();
+            NetworkJSON_Save();
+        }
+        if (autoSettingsAdaption)
+        {
+            changeSettingsToOS();
+            NetworkJSON_Save();
         }
+        NetworkJSON_Load();
+        if (!checkDataPath())
+        {
+            ResetDataPath();
+        };
+        setMouse();
+        
         if (UIconfig.MouseKeepingInWindow == true)
         {
             Cursor.lockState = CursorLockMode.Confined;
@@ -203,8 +142,25 @@ void checkOS2()
     }
 
 
+    void changeSettingsToOS()
+    {
+        switch (Opsys)
+        {
+            case OperationSystem.Windows:
+                UIconfig.controlMode = ControlMode.Keyboard;
+                UIconfig.FrameITUIversion = 1;
+                break;
+            case OperationSystem.Android:
+                UIconfig.controlMode = ControlMode.Mobile;
+                UIconfig.FrameITUIversion = 2;
+                break;
+            default:
+                break;
+        }
+    }
+
 
-    public void setMouse()
+public void setMouse()
     {
         updateMouseCursor.setMouse();          
     }
diff --git a/Assets/Scripts/UI/UIconfig.cs b/Assets/Scripts/UI/UIconfig.cs
index 85c67658..883c9612 100644
--- a/Assets/Scripts/UI/UIconfig.cs
+++ b/Assets/Scripts/UI/UIconfig.cs
@@ -12,6 +12,8 @@ public static class UIconfig
     public static int GameplayMode = 5; //5=First Person, 4=third, 3=third+, 2=Escaperoom, 1=Sidescroller, 0=Sidescroller+
     public static bool InputDisable = false; //deactivate all Objects with access to the input system, so Bindings can be rebinded.
 
+    public static bool autoSettingsAdaption = false;
+
     public static float cursorMaxRange_fromFirstPersonView = 10f; //used in World cursor
     public static float cursorMaxRange_fromObeserverView = float.MaxValue; //used in World cursor
     public static InteractingRangeMode interactingRangeMode = InteractingRangeMode.fromCharacterView;
@@ -105,6 +107,7 @@ public class NetworkJSON
         public int TouchMode;
         public float TAvisibility;
         public bool autoOSrecognition;
+        public bool autoSettingsAdaption;
         public string Opsys;     
         public int FrameITUIversion;
         public int InputManagerVersion;
@@ -126,6 +129,7 @@ public class NetworkJSONonlyString
         public string TouchMode;
         public string TAvisibility;
         public string autoOSrecognition;
+        public string autoSettingsAdaption;
         public string Opsys;
         public string FrameITUIversion;
         public string InputManagerVersion;
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
index a261a61d..cdcf47f0 100644
--- a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
+++ b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
@@ -8,8 +8,9 @@
     "ControlMode": "Keyboard",
     "TouchMode": 1,
     "TAvisibility": 1.0,
-    "autoOSrecognition": true,
-    "Opsys": "Windows",
+    "autoOSrecognition": false,
+    "autoSettingsAdaption": false,
+    "Opsys": "Android",
     "FrameITUIversion": 2,
     "InputManagerVersion": 1,
     "colliderScale_all": 1.200000047683716,
diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset
index c43cd693..79deb82a 100644
--- a/UserSettings/EditorUserSettings.asset
+++ b/UserSettings/EditorUserSettings.asset
@@ -18,10 +18,10 @@ EditorUserSettings:
       value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
       flags: 0
     RecentlyUsedSceneGuid-4:
-      value: 0502505152005e020c0d0e2446275e44144f19287f707e362c7c4b60b2b9353c
+      value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d
       flags: 0
     RecentlyUsedSceneGuid-5:
-      value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d
+      value: 0502505152005e020c0d0e2446275e44144f19287f707e362c7c4b60b2b9353c
       flags: 0
     RecentlyUsedScenePath-0:
       value: 22424703114646680e0b0227036c681f041b1c39631c3435281e1221eee47a2decee22f0
-- 
GitLab