From 54aae6f529b7a7b96c95606617d52d7da00d0c98 Mon Sep 17 00:00:00 2001 From: Stefan Richter <o-s-r1993@web.de> Date: Fri, 22 Jul 2022 08:27:30 +0200 Subject: [PATCH] =?UTF-8?q?QoL:=20Enums=20f=C3=BCr=20Opsys=20und=20Control?= =?UTF-8?q?mode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InteractionEngine/CommunicationEvents.cs | 16 ++-- .../Scripts/Loading/StreamingAssetLoader.cs | 11 +-- .../Scripts/FirstPersonController1.cs | 4 +- .../Scripts/MouseLook1.cs | 3 +- Assets/Scripts/UI/HideUI_mobile.cs | 17 +++- .../InGame/IngameUI_OnOff_TouchControlMode.cs | 6 +- Assets/Scripts/UI/InGame/ScalingCollider.cs | 4 +- .../ControlOptionsMenuePreview_mobile.cs | 2 +- .../NetwMenue/ControlOptionsMenue_mobile.cs | 16 ++-- .../Scripts/UI/NetwMenue/StartMenue_mobile.cs | 48 +++++++++-- .../UI/NetwMenue/SystemOptionsMenue_mobile.cs | 16 ++-- .../Scripts/UI/NetwMenue/updateMouseCursor.cs | 4 +- .../Scripts/UI/NetwMenue/uploadMouseCursor.cs | 85 +------------------ Assets/Scripts/UI/UIconfig.cs | 17 ++-- UserSettings/EditorUserSettings.asset | 7 ++ 15 files changed, 119 insertions(+), 137 deletions(-) diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs index 772176da..df939318 100644 --- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs +++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs @@ -87,11 +87,14 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { } public static int[] CheckServerA = new int[7] { 0, 0, 0, 0, 0, 0, 0 }; public static bool autoOSrecognition = true; - //int Opsys =1 Android. - //int Opsys =0 Windows; - //public static int Opsys_Default = 0; - public static int Opsys = 0; //Script + public static OperationSystem Opsys = OperationSystem.Windows; //Scripts + + public enum OperationSystem + { + Windows=0, + Android=1, + } public static bool CursorVisDefault = true; //Script. public static bool GadgetCanBeUsed = false; @@ -100,6 +103,7 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { } + // Configs public static bool VerboseURI = false; @@ -139,7 +143,7 @@ public static string CreatePathToFile(out bool file_exists, string name, string //is set above; switch (Opsys) { - case 0: + case OperationSystem.Windows: path = use_install_folder ? Application.dataPath : Application.persistentDataPath; @@ -154,7 +158,7 @@ public static string CreatePathToFile(out bool file_exists, string name, string return path; - case 1: + case OperationSystem.Android: path = Application.persistentDataPath; if (hierarchie != null) diff --git a/Assets/Scripts/Loading/StreamingAssetLoader.cs b/Assets/Scripts/Loading/StreamingAssetLoader.cs index db78c65a..cfc4b5d8 100644 --- a/Assets/Scripts/Loading/StreamingAssetLoader.cs +++ b/Assets/Scripts/Loading/StreamingAssetLoader.cs @@ -8,6 +8,7 @@ using UnityEngine.Networking; using static CommunicationEvents; using static UIconfig; +using System; //Uploading Files from StreamingAsset folder to the Persistent Folder for Android Devices @@ -78,11 +79,11 @@ public static void NetworkJSON_Save() myObject.IPslot2 = CommunicationEvents.IPslot2; myObject.IPslot3 = CommunicationEvents.IPslot3; myObject.selecIP = CommunicationEvents.selecIP; - myObject.ControlMode = UIconfig.controlMode; + myObject.ControlMode = UIconfig.controlMode.ToString(); myObject.TouchMode = UIconfig.touchControlMode; myObject.TAvisibility = UIconfig.TAvisibility; myObject.autoOSrecognition = CommunicationEvents.autoOSrecognition; - myObject.Opsys = CommunicationEvents.Opsys; + myObject.Opsys = CommunicationEvents.Opsys.ToString(); myObject.FrameITUIversion = UIconfig.FrameITUIversion; myObject.InputManagerVersion = UIconfig.InputManagerVersion; myObject.colliderScale_all = UIconfig.colliderScale_all; @@ -196,7 +197,7 @@ public static void NetworkJSON_Load() } if (string.IsNullOrEmpty(myObjsOnlyStrings.ControlMode)) { } else { - UIconfig.controlMode = myObjs.ControlMode; + UIconfig.controlMode = (ControlMode)Enum.Parse(typeof(ControlMode), myObjs.ControlMode); } if (string.IsNullOrEmpty(myObjsOnlyStrings.TouchMode)) { } else { @@ -212,7 +213,7 @@ public static void NetworkJSON_Load() } if (string.IsNullOrEmpty(myObjsOnlyStrings.Opsys)) { } else { - CommunicationEvents.Opsys = myObjs.Opsys; + CommunicationEvents.Opsys = (OperationSystem)Enum.Parse(typeof(OperationSystem), myObjs.Opsys); } if (string.IsNullOrEmpty(myObjsOnlyStrings.FrameITUIversion)) { } else { @@ -271,7 +272,7 @@ public static void RereadFileUWR(string pathfolders, string fileName, int toMain { //copies and unpacks file from apk to persistentDataPath where it can be accessed string destinationPath = ""; - if (toMainpath == 0 && CommunicationEvents.Opsys != 1) { destinationPath = Path.Combine(Application.dataPath, destpathf); } + if (toMainpath == 0 && CommunicationEvents.Opsys != OperationSystem.Android) { destinationPath = Path.Combine(Application.dataPath, destpathf); } else { destinationPath = Path.Combine(Application.persistentDataPath, destpathf); diff --git a/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/FirstPersonController1.cs b/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/FirstPersonController1.cs index 2aac5598..a4c525ba 100644 --- a/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/FirstPersonController1.cs +++ b/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/FirstPersonController1.cs @@ -282,7 +282,7 @@ private void GetInput(out float speed) //m_IsWalking = !Input.GetKey(Running_keyBind); #endif m_IsWalking = !Input.GetKey(KeyCode.LeftShift); - if (UIconfig.controlMode!=2) + if (UIconfig.controlMode!= ControlMode.Mobile ) { //m_IsWalking = !Input.GetKey(Running_keyBind); } @@ -293,7 +293,7 @@ private void GetInput(out float speed) if (UIconfig.InputManagerVersion == 2) { Vector2 a = Vector2.zero; - if (CommunicationEvents.Opsys == 1) + if (CommunicationEvents.Opsys == CommunicationEvents.OperationSystem.Android) { switch (UIconfig.touchControlMode) { diff --git a/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/MouseLook1.cs b/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/MouseLook1.cs index b0d6fc44..5e043826 100644 --- a/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/MouseLook1.cs +++ b/Assets/Scripts/UI/Characters/FirstPersonCharacter/Scripts/MouseLook1.cs @@ -3,6 +3,7 @@ //using UnityStandardAssets.CrossPlatformInput; using PlayerCtrl; using static UIconfig; +using static CommunicationEvents; //namespace UnityStandardAssets.Characters.FirstPerson namespace Characters.FirstPerson @@ -72,7 +73,7 @@ public void LookRotation(Transform character, Transform camera) { - if (CommunicationEvents.Opsys == 1) + if (CommunicationEvents.Opsys == OperationSystem.Android) { a = input_ControlMapping.Actnmp_HC.LookCamera.ReadValue<Vector2>(); diff --git a/Assets/Scripts/UI/HideUI_mobile.cs b/Assets/Scripts/UI/HideUI_mobile.cs index 66ea2338..92748262 100644 --- a/Assets/Scripts/UI/HideUI_mobile.cs +++ b/Assets/Scripts/UI/HideUI_mobile.cs @@ -177,7 +177,22 @@ void Update3() void CheckUI_Vis_walk() { - int uiccm = UIconfig.controlMode - 1; + + int uiccm=0; + switch (UIconfig.controlMode) + { + case ControlMode.Keyboard: + uiccm = 0; + break; + case ControlMode.Mobile: + uiccm = 1; + break; + default: + uiccm = 0; + break; + } + + UIconfig.CanvasOnOff_Array[11] = uiccm; UIconfig.CanvasOnOff_Array[12] = uiccm; UIconfig.CanvasOnOff_Array[13] = uiccm; diff --git a/Assets/Scripts/UI/InGame/IngameUI_OnOff_TouchControlMode.cs b/Assets/Scripts/UI/InGame/IngameUI_OnOff_TouchControlMode.cs index 2f590e88..0ef452af 100644 --- a/Assets/Scripts/UI/InGame/IngameUI_OnOff_TouchControlMode.cs +++ b/Assets/Scripts/UI/InGame/IngameUI_OnOff_TouchControlMode.cs @@ -16,7 +16,7 @@ public class IngameUI_OnOff_TouchControlMode : MonoBehaviour { public GameObject myself_GObj; - public int myControlMode_ID; + public ControlMode myControlMode_ID; public int myTouchControlMode_ID; @@ -25,8 +25,8 @@ public class IngameUI_OnOff_TouchControlMode : MonoBehaviour void Start() { - - + + print("hey"); Update(); } diff --git a/Assets/Scripts/UI/InGame/ScalingCollider.cs b/Assets/Scripts/UI/InGame/ScalingCollider.cs index 88d3f5df..4da5d6ac 100644 --- a/Assets/Scripts/UI/InGame/ScalingCollider.cs +++ b/Assets/Scripts/UI/InGame/ScalingCollider.cs @@ -45,10 +45,10 @@ private void scalingCollider() { switch (Opsys) { - case 1: + case OperationSystem.Android: scale=colliderScale_all* UIconfig.colliderScale_Mobile_default; ; break; - case 0: + case OperationSystem.Windows: scale = colliderScale_all * UIconfig.colliderScale_PC_default; diff --git a/Assets/Scripts/UI/NetwMenue/ControlOptionsMenuePreview_mobile.cs b/Assets/Scripts/UI/NetwMenue/ControlOptionsMenuePreview_mobile.cs index a14e0004..950c28c0 100644 --- a/Assets/Scripts/UI/NetwMenue/ControlOptionsMenuePreview_mobile.cs +++ b/Assets/Scripts/UI/NetwMenue/ControlOptionsMenuePreview_mobile.cs @@ -45,7 +45,7 @@ private void Update() public void updateUIpreview() { - if (UIconfig.controlMode == 2) + if (UIconfig.controlMode == ControlMode.Mobile) { colChangeable.a = UIconfig.TAvisibility; diff --git a/Assets/Scripts/UI/NetwMenue/ControlOptionsMenue_mobile.cs b/Assets/Scripts/UI/NetwMenue/ControlOptionsMenue_mobile.cs index ff3e37dc..49e247ed 100644 --- a/Assets/Scripts/UI/NetwMenue/ControlOptionsMenue_mobile.cs +++ b/Assets/Scripts/UI/NetwMenue/ControlOptionsMenue_mobile.cs @@ -102,9 +102,9 @@ public void InputTXTupdate() private void UpdateUI_6() { - switch (UIconfig.controlMode) + switch (UIconfig.controlMode ) { - case 1: + case ControlMode.Keyboard: //TouchControlButtonT.GetComponent<Text>().text = "Touch controls: OFF"; //TouchControlButtonUT.GetComponent<Text>().text = "Press for activating"; @@ -112,7 +112,7 @@ private void UpdateUI_6() TouchControlButtonUT.GetComponent<Text>().text = "Press for changing mode"; break; - case 2: + case ControlMode.Mobile: //TouchControlButtonT.GetComponent<Text>().text = "Touch controls: ON"; //TouchControlButtonUT.GetComponent<Text>().text = "Press for deactivating"; @@ -191,17 +191,17 @@ public void TouchControls() { switch (UIconfig.controlMode) { - case 1: - UIconfig.controlMode = 2; + case ControlMode.Keyboard: + UIconfig.controlMode = ControlMode.Mobile; break; - case 2: - UIconfig.controlMode = 1; + case ControlMode.Mobile: + UIconfig.controlMode = ControlMode.Keyboard; break; default: - UIconfig.controlMode = 2; + UIconfig.controlMode = ControlMode.Keyboard; break; diff --git a/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs b/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs index 2346d57b..642c394b 100644 --- a/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs +++ b/Assets/Scripts/UI/NetwMenue/StartMenue_mobile.cs @@ -59,7 +59,7 @@ void start2_CheckOS_CheckConfig() { switch (CommunicationEvents.Opsys) { - case 0: + case OperationSystem.Windows: @@ -68,8 +68,18 @@ void start2_CheckOS_CheckConfig() { ResetStreamingAsset(); - - UIconfig.controlMode = CommunicationEvents.Opsys + 1; + switch (Opsys) + { + case OperationSystem.Windows: + UIconfig.controlMode = ControlMode.Keyboard; + break; + case OperationSystem.Android: + UIconfig.controlMode = ControlMode.Mobile; + break; + default: + break; + } + NetworkJSON_Save(); } @@ -78,13 +88,23 @@ void start2_CheckOS_CheckConfig() ResetDataPath(); setMouse(); break; - case 1: + case OperationSystem.Android: if (!checkPDP()) { ResetStreamingAsset(); - UIconfig.controlMode = CommunicationEvents.Opsys + 1; + switch (Opsys) + { + case OperationSystem.Windows: + UIconfig.controlMode = ControlMode.Keyboard; + break; + case OperationSystem.Android: + UIconfig.controlMode = ControlMode.Mobile; + break; + default: + break; + } NetworkJSON_Save(); } NetworkJSON_Load(); @@ -101,7 +121,17 @@ void start2_CheckOS_CheckConfig() ResetStreamingAsset(); - UIconfig.controlMode = CommunicationEvents.Opsys + 1; + switch (Opsys) + { + case OperationSystem.Windows: + UIconfig.controlMode = ControlMode.Keyboard; + break; + case OperationSystem.Android: + UIconfig.controlMode = ControlMode.Mobile; + break; + default: + break; + } NetworkJSON_Save(); } @@ -134,7 +164,7 @@ void checkOS() { //CommunicationEvents.Opsys = CommunicationEvents.Opsys_Default; } - if(Opsys == 1) + if(Opsys == OperationSystem.Android) { ServerAutoStart = false; } @@ -147,14 +177,14 @@ void checkOS2() { Debug.Log("Windows OS detected"); - CommunicationEvents.Opsys = 0; + CommunicationEvents.Opsys = OperationSystem.Windows; return; } if (Application.platform == RuntimePlatform.Android) { Debug.Log("Android OS detected"); - CommunicationEvents.Opsys = 1; + CommunicationEvents.Opsys = OperationSystem.Windows; return; } diff --git a/Assets/Scripts/UI/NetwMenue/SystemOptionsMenue_mobile.cs b/Assets/Scripts/UI/NetwMenue/SystemOptionsMenue_mobile.cs index acfb8615..9d68153f 100644 --- a/Assets/Scripts/UI/NetwMenue/SystemOptionsMenue_mobile.cs +++ b/Assets/Scripts/UI/NetwMenue/SystemOptionsMenue_mobile.cs @@ -9,7 +9,7 @@ using static UIconfig; using static StreamingAssetLoader; - +using static CommunicationEvents; public class SystemOptionsMenue_mobile : MonoBehaviour { @@ -68,14 +68,14 @@ void UpdateUI_6() switch (CommunicationEvents.Opsys) { - case 0: + case OperationSystem.Windows: Opsys_ButtonT.GetComponent<Text>().text = "Windows optimized"; Opsys_ButtonUT.GetComponent<Text>().text = "Press for changing optimzation"; setMouse(); break; - case 1: + case OperationSystem.Android: Opsys_ButtonT.GetComponent<Text>().text = "Android optimized: No mouse"; @@ -146,15 +146,15 @@ public void ChangeOpsysModes() { switch (CommunicationEvents.Opsys) { - case 0: - CommunicationEvents.Opsys = 1; + case OperationSystem.Windows: + CommunicationEvents.Opsys = OperationSystem.Android; Opsys_ButtonT.GetComponent<Text>().text = "Android optimized: No Mouse"; Opsys_ButtonUT.GetComponentInChildren<Text>().text = "Press for changing optimzation"; break; - case 1: - CommunicationEvents.Opsys = 0; + case OperationSystem.Android: + CommunicationEvents.Opsys = OperationSystem.Windows; Opsys_ButtonT.GetComponent<Text>().text = "Windows optimized"; Opsys_ButtonUT.GetComponentInChildren<Text>().text = "Press for changing optimzation"; if (UIconfig.MouseKeepingInWindow == true) @@ -169,7 +169,7 @@ public void ChangeOpsysModes() break; default: - CommunicationEvents.Opsys = 1; + CommunicationEvents.Opsys = OperationSystem.Android; Opsys_ButtonT.GetComponent<Text>().text = "Not optimized"; Opsys_ButtonUT.GetComponentInChildren<Text>().text = "Press for changing optimzation"; break; diff --git a/Assets/Scripts/UI/NetwMenue/updateMouseCursor.cs b/Assets/Scripts/UI/NetwMenue/updateMouseCursor.cs index aa6ae173..33672a1e 100644 --- a/Assets/Scripts/UI/NetwMenue/updateMouseCursor.cs +++ b/Assets/Scripts/UI/NetwMenue/updateMouseCursor.cs @@ -24,7 +24,7 @@ public static void setMouse() //updateMouseCursor.setMouse(); - if (CommunicationEvents.Opsys == 1) + if (CommunicationEvents.Opsys == CommunicationEvents.OperationSystem.Android) { CommunicationEvents.CursorVisDefault = false; //Cursor.visible = false; @@ -39,7 +39,7 @@ public static void setMouse() //Android crashes in level scene; - if (CommunicationEvents.Opsys != 1) + if (CommunicationEvents.Opsys!= CommunicationEvents.OperationSystem.Windows) { double curssz = 1 / (UIconfig.cursorSize); diff --git a/Assets/Scripts/UI/NetwMenue/uploadMouseCursor.cs b/Assets/Scripts/UI/NetwMenue/uploadMouseCursor.cs index f4b43354..e72f8e4f 100644 --- a/Assets/Scripts/UI/NetwMenue/uploadMouseCursor.cs +++ b/Assets/Scripts/UI/NetwMenue/uploadMouseCursor.cs @@ -11,6 +11,7 @@ using static StreamingAssetLoader; + public class uploadMouseCursor : MonoBehaviour { @@ -86,88 +87,4 @@ public void setMouse() updateMouseCursor.setMouse(); } - - //Backup von UpdateMouseCursor.cs - public void setMouse_01() - { - - //print("OPSYS: " + CommunicationEvents.Opsys); - if (CommunicationEvents.Opsys == 1) - { - CommunicationEvents.CursorVisDefault = false; - //Cursor.visible = false; - } - else - { - Cursor.visible = true; - CommunicationEvents.CursorVisDefault = true; - } - - //Android crashes in level scene; - if (CommunicationEvents.Opsys != 1) - { - double curssz = 1 / (UIconfig.cursorSize); - // print(UIconfig.cursorSize); - - if (UIconfig.screWidth / 35 < curssz) - { - Cursor.SetCursor(cursorArrow_35, Vector2.zero, CursorMode.ForceSoftware); - print("m35"); - } - else - { - if (UIconfig.screWidth / 50 < curssz) - { - Cursor.SetCursor(cursorArrow_50, Vector2.zero, CursorMode.ForceSoftware); - print("m50"); - } - else - { - - if (UIconfig.screWidth / 60 < curssz) - { - Cursor.SetCursor(cursorArrow_60, Vector2.zero, CursorMode.ForceSoftware); - print("m60"); - } - else - { - if (UIconfig.screWidth / 70 < curssz) - { - Cursor.SetCursor(cursorArrow_70, Vector2.zero, CursorMode.ForceSoftware); - print("m70"); - } - else - { - if (UIconfig.screWidth / 100 < curssz) - { - Cursor.SetCursor(cursorArrow_100, Vector2.zero, CursorMode.ForceSoftware); - print("m100"); - } - else - { - if (UIconfig.screWidth / 140 < curssz) - { - Cursor.SetCursor(cursorArrow_140, Vector2.zero, CursorMode.ForceSoftware); - print("m140"); - } - else - { - if (UIconfig.screWidth / 200 < curssz) - { - Cursor.SetCursor(cursorArrow_200, Vector2.zero, CursorMode.ForceSoftware); - print("m200"); - } - else - { - Cursor.SetCursor(cursorArrow_300, Vector2.zero, CursorMode.ForceSoftware); - print("m300"); - } - } - } - } - } - } - } - } - } } \ No newline at end of file diff --git a/Assets/Scripts/UI/UIconfig.cs b/Assets/Scripts/UI/UIconfig.cs index c2c89df1..b9f25769 100644 --- a/Assets/Scripts/UI/UIconfig.cs +++ b/Assets/Scripts/UI/UIconfig.cs @@ -40,9 +40,16 @@ public static class UIconfig public static int Andr_Start_menue_counter = 1; //public static int Andr_Start_menue_counter = 1; - public static int controlMode = 1; //1=keyboard 2=mobile - - + public static ControlMode controlMode = ControlMode.Keyboard; //1=keyboard 2=mobile + + public enum ControlMode + { + Keyboard = 1, + Mobile = 2, + } + + + public static int touchControlMode = 1; //1=buttons, 2, 3 public static float TAvisibility = 1; @@ -81,11 +88,11 @@ public class NetworkJSON public string IPslot2; public string IPslot3; public string selecIP; - public int ControlMode; + public string ControlMode; public int TouchMode; public float TAvisibility; public bool autoOSrecognition; - public int Opsys; + public string Opsys; public int FrameITUIversion; public int InputManagerVersion; public double colliderScale_all; diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 0a74b62c..d5b75b13 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -5,6 +5,9 @@ EditorUserSettings: m_ObjectHideFlags: 0 serializedVersion: 4 m_ConfigSettings: + RecentlyUsedSceneGuid-0: + value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d + flags: 0 RecentlyUsedScenePath-0: value: 22424703114646680e0b0227036c721518021d39630928343f162e27e3f22076f7e93ffdfe flags: 0 @@ -43,9 +46,13 @@ EditorUserSettings: m_VCDebugCmd: 0 m_VCDebugOut: 0 m_SemanticMergeMode: 2 + m_DesiredImportWorkerCount: 1 + m_StandbyImportWorkerCount: 1 + m_IdleImportWorkerShutdownDelay: 60000 m_VCShowFailedCheckout: 1 m_VCOverwriteFailedCheckoutAssets: 1 m_VCProjectOverlayIcons: 1 m_VCHierarchyOverlayIcons: 1 m_VCOtherOverlayIcons: 1 m_VCAllowAsyncUpdate: 1 + m_ArtifactGarbageCollection: 1 -- GitLab