From 8455f7d9771b83406f43a2e3cf11cea089540c4f Mon Sep 17 00:00:00 2001
From: Bjoern Esswein <692-bessw@users.noreply.gl.kwarc.info>
Date: Wed, 17 Jul 2024 18:10:53 +0200
Subject: [PATCH] Add config option to switch between the old scrollShow UI and
 the new ScrollWebView UI

---
 Assets/Resources/Prefabs/UI/FrameITUI.prefab  |  4 +--
 .../Prefabs/UI/Ingame/FrameITUI_mobile.prefab |  8 +++---
 .../Prefabs/UI/Ingame/GadgetCanvas.prefab     |  4 +--
 .../Prefabs/UI/Ingame/HidingCanvas.prefab     | 21 ++++++++++++---
 .../Scripts/Loading/StreamingAssetLoader.cs   |  5 ++++
 Assets/Scripts/UI/InGame/SwitchScrollUI.cs    | 27 +++++++++++++++++++
 .../Scripts/UI/InGame/SwitchScrollUI.cs.meta  | 11 ++++++++
 Assets/Scripts/UI/InGame/WebViewController.cs |  2 +-
 .../Scripts/UI/NetwMenu/StartMenu_mobile.cs   |  4 ++-
 Assets/Scripts/UI/UIconfig.cs                 |  8 ++++++
 .../Config/Network.JSON                       |  3 ++-
 11 files changed, 83 insertions(+), 14 deletions(-)
 create mode 100644 Assets/Scripts/UI/InGame/SwitchScrollUI.cs
 create mode 100644 Assets/Scripts/UI/InGame/SwitchScrollUI.cs.meta

diff --git a/Assets/Resources/Prefabs/UI/FrameITUI.prefab b/Assets/Resources/Prefabs/UI/FrameITUI.prefab
index 9130e4e6..65acbc15 100644
--- a/Assets/Resources/Prefabs/UI/FrameITUI.prefab
+++ b/Assets/Resources/Prefabs/UI/FrameITUI.prefab
@@ -556,7 +556,7 @@ PrefabInstance:
     - target: {fileID: 6500467619489830996, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: 3240
+      value: 443880
       objectReference: {fileID: 0}
     - target: {fileID: 7849991042685492731, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
@@ -606,7 +606,7 @@ PrefabInstance:
     - target: {fileID: 7989559431199338490, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: -179.99953
+      value: -24660
       objectReference: {fileID: 0}
     - target: {fileID: 8004702056544321748, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
diff --git a/Assets/Resources/Prefabs/UI/Ingame/FrameITUI_mobile.prefab b/Assets/Resources/Prefabs/UI/Ingame/FrameITUI_mobile.prefab
index 2e886ae5..bce53f30 100644
--- a/Assets/Resources/Prefabs/UI/Ingame/FrameITUI_mobile.prefab
+++ b/Assets/Resources/Prefabs/UI/Ingame/FrameITUI_mobile.prefab
@@ -4952,7 +4952,7 @@ PrefabInstance:
     - target: {fileID: 7989559431199338490, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: -100.000046
+      value: -1700
       objectReference: {fileID: 0}
     - target: {fileID: 8004702056544321748, guid: 292834880e6f0e54186b873acc62d3f2,
         type: 3}
@@ -5319,12 +5319,12 @@ PrefabInstance:
     - target: {fileID: 8553388048532215990, guid: 884ac57de337c364391b247761071fb1,
         type: 3}
       propertyPath: m_AnchorMax.y
-      value: 1
+      value: 0
       objectReference: {fileID: 0}
     - target: {fileID: 8553388048532215990, guid: 884ac57de337c364391b247761071fb1,
         type: 3}
       propertyPath: m_AnchorMin.y
-      value: 1
+      value: 0
       objectReference: {fileID: 0}
     - target: {fileID: 8553388048532215990, guid: 884ac57de337c364391b247761071fb1,
         type: 3}
@@ -5339,7 +5339,7 @@ PrefabInstance:
     - target: {fileID: 8553388048532215990, guid: 884ac57de337c364391b247761071fb1,
         type: 3}
       propertyPath: m_AnchoredPosition.x
-      value: 30
+      value: 650
       objectReference: {fileID: 0}
     - target: {fileID: 8553388048532215990, guid: 884ac57de337c364391b247761071fb1,
         type: 3}
diff --git a/Assets/Resources/Prefabs/UI/Ingame/GadgetCanvas.prefab b/Assets/Resources/Prefabs/UI/Ingame/GadgetCanvas.prefab
index f4fa3f78..b67e0e69 100644
--- a/Assets/Resources/Prefabs/UI/Ingame/GadgetCanvas.prefab
+++ b/Assets/Resources/Prefabs/UI/Ingame/GadgetCanvas.prefab
@@ -174,7 +174,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 940, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &6662492270148709753
@@ -538,7 +538,7 @@ MonoBehaviour:
   m_FallbackScreenDPI: 96
   m_DefaultSpriteDPI: 96
   m_DynamicPixelsPerUnit: 1
-  m_PresetInfoIsWorld: 0
+  m_PresetInfoIsWorld: 1
 --- !u!1001 &3122257488954702478
 PrefabInstance:
   m_ObjectHideFlags: 0
diff --git a/Assets/Resources/Prefabs/UI/Ingame/HidingCanvas.prefab b/Assets/Resources/Prefabs/UI/Ingame/HidingCanvas.prefab
index b64e98e9..c78ab03b 100644
--- a/Assets/Resources/Prefabs/UI/Ingame/HidingCanvas.prefab
+++ b/Assets/Resources/Prefabs/UI/Ingame/HidingCanvas.prefab
@@ -35,7 +35,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: 0.0009765625}
+  m_AnchoredPosition: {x: 0, y: 1080}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 1, y: 1}
 --- !u!114 &6592514254180342026
@@ -2828,6 +2828,7 @@ GameObject:
   - component: {fileID: 8004702057932254678}
   - component: {fileID: 8004702057932254679}
   - component: {fileID: 8004702057932254676}
+  - component: {fileID: 3671007757941716709}
   m_Layer: 5
   m_Name: HidingCanvas
   m_TagString: Untagged
@@ -2907,7 +2908,7 @@ MonoBehaviour:
   m_FallbackScreenDPI: 96
   m_DefaultSpriteDPI: 96
   m_DynamicPixelsPerUnit: 1
-  m_PresetInfoIsWorld: 0
+  m_PresetInfoIsWorld: 1
 --- !u!114 &8004702057932254676
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -2925,6 +2926,20 @@ MonoBehaviour:
   m_BlockingMask:
     serializedVersion: 2
     m_Bits: 4294967295
+--- !u!114 &3671007757941716709
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8004702057932254674}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 90c1c0815499367409841816e1485ec7, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  ScrollShowUI: {fileID: 8004702057540368332}
+  ScrollWebView: {fileID: 5843063412347785762}
 --- !u!1 &8004702058016740896
 GameObject:
   m_ObjectHideFlags: 0
@@ -3701,7 +3716,7 @@ PrefabInstance:
     - target: {fileID: 4838871000058222821, guid: 49deb83b881477047bfac0ee629a7ae9,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: 0
+      value: -59.99997
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 49deb83b881477047bfac0ee629a7ae9, type: 3}
diff --git a/Assets/Scripts/Loading/StreamingAssetLoader.cs b/Assets/Scripts/Loading/StreamingAssetLoader.cs
index 0f5d00a1..e8ad2dfa 100644
--- a/Assets/Scripts/Loading/StreamingAssetLoader.cs
+++ b/Assets/Scripts/Loading/StreamingAssetLoader.cs
@@ -142,6 +142,7 @@ public static void NetworkJSON_Save()
         myObject.camRotatingSensitivity = UIconfig.camRotatingSensitivity;
         myObject.MouseKeepingInWindow = UIconfig.MouseKeepingInWindow;
         myObject.scrolldirection = UIconfig.scrolldirection;
+        myObject.scrollViewVersion = UIconfig.scrollViewVersion;
 
 
 
@@ -478,6 +479,10 @@ public static void NetworkJSON_Load_x(string path)
         {
             UIconfig.scrolldirection = myObjs.scrolldirection;
         }
+        if (! string.IsNullOrEmpty(myObjsOnlyStrings.scrollViewVersion))
+        {
+            UIconfig.scrollViewVersion = myObjs.scrollViewVersion;
+        }
 
     }
 
diff --git a/Assets/Scripts/UI/InGame/SwitchScrollUI.cs b/Assets/Scripts/UI/InGame/SwitchScrollUI.cs
new file mode 100644
index 00000000..b2575601
--- /dev/null
+++ b/Assets/Scripts/UI/InGame/SwitchScrollUI.cs
@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class SwitchScrollUI : MonoBehaviour
+{
+    public GameObject ScrollShowUI;
+    public GameObject ScrollWebView;
+    void OnEnable()
+    {
+        switch (UIconfig.scrollViewVersion)
+        {
+            case UIconfig.ScrollViewVersion.ScrollShow:
+                ScrollWebView.SetActive(false);
+                ScrollShowUI.SetActive(true);
+                break;
+            case UIconfig.ScrollViewVersion.ScrollWebView:
+                ScrollShowUI.SetActive(false);
+                ScrollWebView.SetActive(true);
+                break;
+            default:
+                ScrollShowUI.SetActive(false);
+                ScrollWebView.SetActive(true);
+                break;
+        }
+    }
+}
diff --git a/Assets/Scripts/UI/InGame/SwitchScrollUI.cs.meta b/Assets/Scripts/UI/InGame/SwitchScrollUI.cs.meta
new file mode 100644
index 00000000..4adc3448
--- /dev/null
+++ b/Assets/Scripts/UI/InGame/SwitchScrollUI.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 90c1c0815499367409841816e1485ec7
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Scripts/UI/InGame/WebViewController.cs b/Assets/Scripts/UI/InGame/WebViewController.cs
index e0069563..f312d971 100644
--- a/Assets/Scripts/UI/InGame/WebViewController.cs
+++ b/Assets/Scripts/UI/InGame/WebViewController.cs
@@ -20,7 +20,7 @@ public class WebViewController : MonoBehaviour
     // TODO: implement onHintRequested event
     public UnityEvent<DomNodeWrapper, string> onHintRequested;
     // TODO: click events (option for custom buttons for a scroll)
-    public UnityEvent<DomNodeWrapper, string> onClick;
+    public UnityEvent<DomNodeWrapper> onClick;
     private WebViewComponent webViewComponent;
     private DomNodeWrapper[] dropzones;
 
diff --git a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
index c844693e..878b339f 100644
--- a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
+++ b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs
@@ -119,7 +119,7 @@ void start2_CheckOS_CheckConfig()
         NetworkJSON_Load();
 
         if (!checkDataPath() && false)
-            Debug.Log("Todo: Pr�fen auf Bugs bzl DataPath");
+            Debug.Log("Todo: Pr�fen auf Bugs bzl DataPath");
 
         if (!checkDataPath() || true)
         {
@@ -211,10 +211,12 @@ void changeSettingsToOS()
             case OperationSystem.Windows:
                 UIconfig.controlMode = ControlMode.Keyboard;
                 if (autoSettingsAdaption == 2) { UIconfig.FrameITUIversion = 1; }
+                UIconfig.scrollViewVersion = ScrollViewVersion.ScrollWebView;
                 break;
             case OperationSystem.Android:
                 UIconfig.controlMode = ControlMode.Mobile;
                 if (autoSettingsAdaption == 2) { UIconfig.FrameITUIversion = 2; }
+                UIconfig.scrollViewVersion = ScrollViewVersion.ScrollShow;
                 break;
             default:
                 break;
diff --git a/Assets/Scripts/UI/UIconfig.cs b/Assets/Scripts/UI/UIconfig.cs
index 4250cb10..a9fe37ca 100644
--- a/Assets/Scripts/UI/UIconfig.cs
+++ b/Assets/Scripts/UI/UIconfig.cs
@@ -6,6 +6,12 @@ public static class UIconfig
 {
 
     public static int FrameITUIversion = 2; // 1= FrameITUI; 2= FrameITUI_mobil
+    public static ScrollViewVersion scrollViewVersion = ScrollViewVersion.ScrollShow;
+    public enum ScrollViewVersion
+    {
+        ScrollShow = 1,
+        ScrollWebView = 2,
+    }
     public static int InputManagerVersion = 1; // 1= InputManager, 2=InputSystemPackage ; 3=overConfigfile
     public static int EventSystemModule = 2;// 1= InputManager, 2=InputSystemPackage ; 3=overConfigfile
     public static int GameplayMode = 5; //5=First Person, 4=third, 3=third+, 2=Escaperoom, 1=Sidescroller, 0=Sidescroller+
@@ -125,6 +131,7 @@ public class NetworkJSON
         public float camRotatingSensitivity; //Sensitivity to inputs.
         public bool MouseKeepingInWindow;
         public int scrolldirection;
+        public ScrollViewVersion scrollViewVersion;
 
     }
     public class NetworkJSONonlyString
@@ -150,6 +157,7 @@ public class NetworkJSONonlyString
         public string camRotatingSensitivity; //Sensitivity to inputs.
         public string MouseKeepingInWindow;
         public string scrolldirection;
+        public string scrollViewVersion;
 
     }
     //------------------------------------------------------------------------------------------------------
diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
index eb50d806..14c02347 100644
--- a/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
+++ b/Assets/StreamingAssets/StreamToPersistentDataPath/Config/Network.JSON
@@ -19,5 +19,6 @@
     "cursorSize": 0.03125,
     "camRotatingSensitivity": 2.0,
     "MouseKeepingInWindow": true,
-    "scrolldirection": -1
+    "scrolldirection": -1,
+    "scrollViewVersion": 2
 }
\ No newline at end of file
-- 
GitLab