From 0a5139c2d76888ee4d0372d735a9605e12b25b9e Mon Sep 17 00:00:00 2001
From: Stefan Richter <o-s-r1993@web.de>
Date: Mon, 6 May 2024 17:29:47 +0200
Subject: [PATCH] Added Option to enable/disable Autoselect for FrameITUI
 Prefabs.

---
 .../Scripts/UI/NetwMenu/StartMenu_mobile.cs   |  6 +--
 .../UI/NetwMenu/SystemOptionsMenu_mobile.cs   | 49 ++++++++++---------
 Assets/Scripts/UI/UIconfig.cs                 |  4 +-
 .../Config/Network.JSON                       |  2 +-
 .../Config/Network_Backup.json                | 19 -------
 .../Config/Network_Backup_withAuto.JSON       | 23 +++++++++
 ...meta => Network_Backup_withAuto.JSON.meta} |  2 +-
 7 files changed, 57 insertions(+), 48 deletions(-)
 delete mode 100644 Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json
 create mode 100644 Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON
 rename Assets/StreamingAssets/StreamToPersistentDataPath/Config/{Network_Backup.json.meta => Network_Backup_withAuto.JSON.meta} (74%)

diff --git a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
index 3e4e83b7..c27ffc8c 100644
--- a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
+++ b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
@@ -110,7 +110,7 @@ void start2_CheckOS_CheckConfig()
         NetworkJSON_Save();
 
         //Debug.Log("StartAdaption");
-        if (autoSettingsAdaption)
+        if (autoSettingsAdaption>0)
         {
             changeSettingsToOS();
             NetworkJSON_Save();
@@ -199,11 +199,11 @@ void changeSettingsToOS()
         {
             case OperationSystem.Windows:
                 UIconfig.controlMode = ControlMode.Keyboard;
-                UIconfig.FrameITUIversion = 1;
+                if (autoSettingsAdaption == 2) { UIconfig.FrameITUIversion = 1; }
                 break;
             case OperationSystem.Android:
                 UIconfig.controlMode = ControlMode.Mobile;
-                UIconfig.FrameITUIversion = 2;
+                if (autoSettingsAdaption == 2) { UIconfig.FrameITUIversion = 2; }
                 break;
             default:
                 break;
diff --git a/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs b/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs
index 8b682d43..db5a5b27 100644
--- a/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs
+++ b/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs
@@ -63,19 +63,30 @@ void UpdateUI_6()
 
         switch (UIconfig.autoSettingsAdaption)
         {
-            case false:
+            case 0:
 
                 //GameObject.Find("TextSlotTOO").GetComponent<Text>().text = "Touch controls OFF";
                 AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: OFF";
                 AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for activating";
                 break;
 
-            case true:
+            case 1:
+
+                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: Input";
+                AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for changing";
+                break;
 
-                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: ON";
+            case 2:
+
+                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: Input & UI";
                 AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for deactivating";
                 break;
 
+            default:
+                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: OFF";
+                AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for activating";
+                break;
+
 
         }
 
@@ -142,44 +153,38 @@ public void ChangeAutoOSrecognition()
         {
             case false:
                 CommunicationEvents.autoOSrecognition = true;
-                AutoOSreq_ButtonT.GetComponent<Text>().text = "Operating System Recognition: ON";
-                AutoOSreq_ButtonUT.GetComponentInChildren<Text>().text = "Press for deactivating";
                 break;
 
             case true:
                 CommunicationEvents.autoOSrecognition = false;
-                //GameObject.Find("TextSlotTOO").GetComponent<Text>().text = "Touch controls OFF";
-                AutoOSreq_ButtonT.GetComponent<Text>().text = "Operating System Recognition: OFF";
-                AutoOSreq_ButtonUT.GetComponentInChildren<Text>().text = "Press for activating";
                 break;
-
-
         }
-        //updateUIpreview();
         NetworkJSON_Save();
+        UpdateUI_6();
+
     }
 
     public void ChangeAutoSettingsAdaption()
     {
         switch (UIconfig.autoSettingsAdaption)
         {
-            case false:
-                UIconfig.autoSettingsAdaption = true;
-                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: ON";
-                AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for deactivating";
+            case 0:
+                UIconfig.autoSettingsAdaption = 1;
                 break;
 
-            case true:
-                UIconfig.autoSettingsAdaption = false;
-                //GameObject.Find("TextSlotTOO").GetComponent<Text>().text = "Touch controls OFF";
-                AutoSettingsAdap_Button.GetComponent<Text>().text = "Settings Adaption: OFF";
-                AutoSettingsAdap_ButtonUT.GetComponentInChildren<Text>().text = "Press for activating";
+            case 1:
+                UIconfig.autoSettingsAdaption = 2;
+                break;
+            case 2:
+                UIconfig.autoSettingsAdaption = 0;
+                break;
+            default:
+                UIconfig.autoSettingsAdaption = 0;
                 break;
-
-
         }
         //updateUIpreview();
         NetworkJSON_Save();
+        UpdateUI_6();
     }
 
 
diff --git a/Assets/Scripts/UI/UIconfig.cs b/Assets/Scripts/UI/UIconfig.cs
index 2f056db8..4250cb10 100644
--- a/Assets/Scripts/UI/UIconfig.cs
+++ b/Assets/Scripts/UI/UIconfig.cs
@@ -11,7 +11,7 @@ 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 int autoSettingsAdaption = 0; //0=Aus, 1=OnlyInput, 2=Input&UIV
 
     public static float cursorMaxRange_fromFirstPersonView = 10f; //used in World cursor
     public static float cursorMaxRange_fromObeserverView = float.MaxValue; //used in World cursor
@@ -116,7 +116,7 @@ public class NetworkJSON
         public int TouchMode;
         public float TAvisibility;
         public bool autoOSrecognition;
-        public bool autoSettingsAdaption;
+        public int autoSettingsAdaption;
         public string Opsys;
         public int FrameITUIversion;
         public int InputManagerVersion;
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
index bd80ffd5..eb50d806 100644
--- a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
+++ b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
@@ -11,7 +11,7 @@
     "TouchMode": 1,
     "TAvisibility": 1.0,
     "autoOSrecognition": true,
-    "autoSettingsAdaption": true,
+    "autoSettingsAdaption": 1,
     "Opsys": "Android",
     "FrameITUIversion": 2,
     "InputManagerVersion": 1,
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json
deleted file mode 100644
index a261a61d..00000000
--- a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-    "lastIP": "",
-    "newIP": "",
-    "IPslot1": "uframeit.informatik.uni-erlangen.de:8085",
-    "IPslot2": "uframeit.informatik.uni-erlangen.de:8086",
-    "IPslot3": "",
-    "selecIP": "",
-    "ControlMode": "Keyboard",
-    "TouchMode": 1,
-    "TAvisibility": 1.0,
-    "autoOSrecognition": true,
-    "Opsys": "Windows",
-    "FrameITUIversion": 2,
-    "InputManagerVersion": 1,
-    "colliderScale_all": 1.200000047683716,
-    "cursorSize": 0.03125,
-    "camRotatingSensitivity": 2.0,
-    "MouseKeepingInWindow": true
-}
\ No newline at end of file
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON
new file mode 100644
index 00000000..9d3f665c
--- /dev/null
+++ b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON
@@ -0,0 +1,23 @@
+{
+    "lastIP": "",
+    "newIP": "",
+    "IPslot1": "devel.uframeit.informatik.uni-erlangen.de:8088",
+    "IPslot2": "master.uframeit.informatik.uni-erlangen.de:8087",
+    "IPslot3": "stable.uframeit.informatik.uni-erlangen.de:8086",
+    "IPslot4": "oldstable.uframeit.informatik.uni-erlangen.de:8085",
+    "IPslot5": "uframeit.informatik.uni-erlangen.de:8089",
+    "selecIP": "",
+    "ControlMode": "Keyboard",
+    "TouchMode": 1,
+    "TAvisibility": 1.0,
+    "autoOSrecognition": true,
+    "autoSettingsAdaption": 2,
+    "Opsys": "Android",
+    "FrameITUIversion": 2,
+    "InputManagerVersion": 1,
+    "colliderScale_all": 1.200000047683716,
+    "cursorSize": 0.03125,
+    "camRotatingSensitivity": 2.0,
+    "MouseKeepingInWindow": true,
+    "scrolldirection": -1
+}
\ No newline at end of file
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json.meta b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON.meta
similarity index 74%
rename from Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json.meta
rename to Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON.meta
index ca8a78dd..b73bb3f1 100644
--- a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup.json.meta
+++ b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network_Backup_withAuto.JSON.meta
@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 3315a92b25ce53341976adc3f09d173e
+guid: ffa3cc5a8ea56dc4b8c5e907de1f715a
 DefaultImporter:
   externalObjects: {}
   userData: 
-- 
GitLab