From e08ce8f0b007a90e2647b07cac6b5f1c680d2ef7 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 5 Jan 2024 22:51:27 -0500 Subject: [PATCH] Small Fixes (#609) * additive angle in rhythm rally * remove old keyboard controller compat * fix control style dropdowns * using mouse on title screen selects keyboard instead default to keyboard for invalid controllers * temporarily ditch discord RPC we need a new API key lol * remove this discord call too * certain editor shortcuts now exit fullscreen fix color hex input not locking editor shortcuts * increase max queued frames turns out this may not be an issue for audio rhythm games --- Assets/Scenes/Editor.unity | 9 ++-- .../Scripts/Games/RhythmRally/RhythmRally.cs | 20 ++++--- Assets/Scripts/GlobalGameManager.cs | 38 +++++++------- Assets/Scripts/InputSystem/PlayerInput.cs | 35 ------------- Assets/Scripts/LevelEditor/Editor.cs | 52 ++++++------------- .../PropertyPrefabs/ColorPropertyPrefab.cs | 13 +++++ .../EnumChartPropertyPrefab.cs | 17 +++--- .../Tabs/ChartInfoProperties.cs | 11 ++-- Assets/Scripts/Minigames.cs | 2 + Assets/Scripts/TitleManager.cs | 24 ++++++--- 10 files changed, 101 insertions(+), 120 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index af3a0cdc..899afd7b 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -26851,7 +26851,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1589389271} m_Direction: 2 m_Value: 1 - m_Size: 0.9989085 + m_Size: 0.9999814 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -32707,7 +32707,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 173.14249} + m_AnchoredPosition: {x: 0, y: 171.91833} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!222 &1154875945 @@ -39097,8 +39097,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 459.58514, y: -25} - m_SizeDelta: {x: 879.1703, y: 30} + m_AnchoredPosition: {x: 391.79788, y: -25} + m_SizeDelta: {x: 743.59576, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1443721748 MonoBehaviour: @@ -39119,6 +39119,7 @@ MonoBehaviour: ColorTable: {fileID: 723094753} colorTableActive: 0 colorPreview: {fileID: 1535224921} + hex: {fileID: 426555699} --- !u!1 &1443971064 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/RhythmRally/RhythmRally.cs b/Assets/Scripts/Games/RhythmRally/RhythmRally.cs index 9d08c54c..f623f93a 100644 --- a/Assets/Scripts/Games/RhythmRally/RhythmRally.cs +++ b/Assets/Scripts/Games/RhythmRally/RhythmRally.cs @@ -90,7 +90,7 @@ namespace HeavenStudio.Games.Loaders function = delegate { var e = eventCaller.currentEntity; // var rotation = new Vector3(0, e["valA"], 0); - RhythmRally.instance.ChangeCameraAngle(e.beat, e["valA"], e["valB"], e.length, (Util.EasingFunction.Ease)e["type"]); + RhythmRally.instance.ChangeCameraAngle(e.beat, e["valA"], e["valB"], e.length, (Util.EasingFunction.Ease)e["type"], e["additive"]); }, defaultLength = 4, resizable = true, @@ -98,7 +98,7 @@ namespace HeavenStudio.Games.Loaders new Param("valA", new EntityTypes.Integer(-360, 360, 0), "Angle", "The rotation of the camera around the center of the table"), new Param("valB", new EntityTypes.Float(0.5f, 4f, 1), "Zoom", "The camera's level of zoom (Lower value = Zoomed in)"), new Param("type", Util.EasingFunction.Ease.Linear, "Ease", "The easing function to use"), - // new Param("type2", RotateMode.Fast, "Rotation Mode", "The rotation mode to use") + new Param("additive", true, "Additive Rotation", "Add to current angle instead of setting target angle") } }, // todo: background recolouring @@ -407,7 +407,7 @@ namespace HeavenStudio.Games foreach (var entity in cameraEntities) { - ChangeCameraAngle(entity.beat, entity["valA"], entity["valB"], entity.length, (Util.EasingFunction.Ease)entity["type"]); + ChangeCameraAngle(entity.beat, entity["valA"], entity["valB"], entity.length, (Util.EasingFunction.Ease)entity["type"], entity["additive"]); } UpdateCamera(beat); @@ -419,6 +419,7 @@ namespace HeavenStudio.Games { Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction(cameraRotateEase); float rotProg = Conductor.instance.GetPositionFromBeat(cameraRotateBeat, cameraRotateLength, true); + rotProg = Mathf.Clamp01(rotProg); float rot = func(cameraRotateLast, cameraRotateNext, rotProg); cameraPivot.rotation = Quaternion.Euler(0, rot, 0); cameraPivot.localScale = Vector3.one * func(cameraScaleLast, cameraScaleNext, rotProg); @@ -558,15 +559,22 @@ namespace HeavenStudio.Games inPose = true; } - public void ChangeCameraAngle(double beat, float rotation, float camZoom, double length, Util.EasingFunction.Ease ease) + public void ChangeCameraAngle(double beat, float rotation, float camZoom, double length, Util.EasingFunction.Ease ease, bool additive = true) { cameraRotateBeat = beat; cameraRotateLength = length; cameraRotateEase = ease; - cameraRotateLast = cameraRotateNext; + cameraRotateLast = cameraRotateNext % 360f; cameraScaleLast = cameraScaleNext; - cameraRotateNext = rotation; cameraScaleNext = camZoom; + if (additive) + { + cameraRotateNext = cameraRotateLast + rotation; + } + else + { + cameraRotateNext = rotation; + } } public void PrepareFastRally(double beat, RallySpeed speedChange, bool muteAudio = false) diff --git a/Assets/Scripts/GlobalGameManager.cs b/Assets/Scripts/GlobalGameManager.cs index 17d4bbac..85ebaee0 100644 --- a/Assets/Scripts/GlobalGameManager.cs +++ b/Assets/Scripts/GlobalGameManager.cs @@ -115,7 +115,7 @@ namespace HeavenStudio Application.targetFrameRate = -1; QualitySettings.vSyncCount = 0; - QualitySettings.maxQueuedFrames = 1; + QualitySettings.maxQueuedFrames = 2; if (PersistentDataManager.gameSettings.isFullscreen) { Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, FullScreenMode.ExclusiveFullScreen); @@ -428,21 +428,23 @@ namespace HeavenStudio public static void UpdateDiscordStatus(string details, bool editor = false, bool updateTime = false) { - if (discordDuringTesting || !Application.isEditor) - { - if (PersistentDataManager.gameSettings.discordRPCEnable) - { - try - { - DiscordRPC.DiscordRPC.UpdateActivity(editor ? "In Editor " : "Playing ", details, updateTime); - Debug.Log("Discord status updated"); - } - catch (System.Exception e) - { - Debug.Log("Discord status update failed: " + e.Message); - } - } - } + Debug.Log("Discord Rich Presence temporarily disabled"); + return; + // if (discordDuringTesting || !Application.isEditor) + // { + // if (PersistentDataManager.gameSettings.discordRPCEnable) + // { + // try + // { + // DiscordRPC.DiscordRPC.UpdateActivity(editor ? "In Editor " : "Playing ", details, updateTime); + // Debug.Log("Discord status updated"); + // } + // catch (System.Exception e) + // { + // Debug.Log("Discord status update failed: " + e.Message); + // } + // } + // } } private static void OnQuitting() @@ -453,8 +455,8 @@ namespace HeavenStudio PlayerInput.CleanUp(); Debug.Log("Clearing RIQ Cache..."); Jukebox.RiqFileHandler.ClearCache(); - Debug.Log("Closing Discord GameSDK..."); - DiscordRPC.DiscordController.instance?.Disconnect(); + // Debug.Log("Closing Discord GameSDK..."); + // DiscordRPC.DiscordController.instance?.Disconnect(); HasShutDown = true; } diff --git a/Assets/Scripts/InputSystem/PlayerInput.cs b/Assets/Scripts/InputSystem/PlayerInput.cs index 9840b42d..6e29de66 100644 --- a/Assets/Scripts/InputSystem/PlayerInput.cs +++ b/Assets/Scripts/InputSystem/PlayerInput.cs @@ -121,17 +121,6 @@ namespace HeavenStudio public static InputController GetInputController(int player) { - // Needed so Keyboard works on MacOS and Linux -#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX - inputDevices = new List(); - if(inputDevices.Count < 1) - { - InputKeyboard keyboard = new InputKeyboard(); - keyboard.SetPlayer(1); - keyboard.InitializeController(); - inputDevices.Add(keyboard); - } -#endif //select input controller that has player field set to player //this will return the first controller that has that player number in the case of controller pairs (eg. Joy-Cons) //so such controllers should have a reference to the other controller in the pair @@ -151,19 +140,6 @@ namespace HeavenStudio //this will return the first controller that has that player number in the case of controller pairs (eg. Joy-Cons) //so such controllers should have a reference to the other controller in the pair //controller IDs are determined by connection order (the Keyboard is always first) - - - // Needed so Keyboard works on MacOS and Linux -#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX - inputDevices = new List(); - if(inputDevices.Count < 1) - { - InputKeyboard keyboard = new InputKeyboard(); - keyboard.SetPlayer(1); - keyboard.InitializeController(); - inputDevices.Add(keyboard); - } -#endif for (int i = 0; i < inputDevices.Count; i++) { if (inputDevices[i].GetPlayer() == player) @@ -176,17 +152,6 @@ namespace HeavenStudio public static void UpdateInputControllers() { - // Needed so Keyboard works on MacOS and Linux -#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX - inputDevices = new List(); - if(inputDevices.Count < 1) - { - InputKeyboard keyboard = new InputKeyboard(); - keyboard.SetPlayer(1); - keyboard.InitializeController(); - inputDevices.Add(keyboard); - } -#endif foreach (InputController i in inputDevices) { i.UpdateState(); diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 5a954f7c..66125067 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -131,6 +131,7 @@ namespace HeavenStudio.Editor public void ShowQuitPopUp(bool show) { + if (fullscreen) Fullscreen(); _confirmQuitMain.SetActive(show); SetAuthoritiveMenu(show); } @@ -167,12 +168,12 @@ namespace HeavenStudio.Editor Fullscreen(); } - if (Input.GetKeyDown(KeyCode.Delete) || Input.GetKeyDown(KeyCode.Backspace)) + if ((Input.GetKeyDown(KeyCode.Delete) || Input.GetKeyDown(KeyCode.Backspace)) && !fullscreen) { CommandManager.Instance.AddCommand(new Commands.Delete(Selections.instance.eventsSelected.Select(c => c.entity.guid).ToList())); } - if (Input.GetKey(KeyCode.LeftControl)) + if (Input.GetKey(KeyCode.LeftControl) && !fullscreen) { if (Input.GetKeyDown(KeyCode.Z)) { @@ -193,20 +194,13 @@ namespace HeavenStudio.Editor { Timeline.instance.Paste(); } - - if (Input.GetKey(KeyCode.LeftShift)) - { - if (Input.GetKeyDown(KeyCode.D)) - { - ToggleDebugCam(); - } - } } if (Input.GetKey(KeyCode.LeftControl)) { if (Input.GetKeyDown(KeyCode.N)) { + if (fullscreen) Fullscreen(); NewBTN.onClick.Invoke(); } else if (Input.GetKeyDown(KeyCode.O)) @@ -224,6 +218,14 @@ namespace HeavenStudio.Editor { SaveRemix(false); } + + if (Input.GetKey(KeyCode.LeftShift)) + { + if (Input.GetKeyDown(KeyCode.D)) + { + ToggleDebugCam(); + } + } } } #endregion @@ -247,33 +249,6 @@ namespace HeavenStudio.Editor PasteBTN.transform.GetChild(0).GetComponent().color = Color.white; else PasteBTN.transform.GetChild(0).GetComponent().color = Color.gray; - - - if (Timeline.instance.timelineState.selected && Editor.instance.canSelect) - { - /* - if (Input.GetMouseButtonUp(0)) - { - List selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true); - - if (selectedEvents.Count > 0) - { - List result = new List(); - - for (int i = 0; i < selectedEvents.Count; i++) - { - //TODO: this is in LateUpdate, so this will never run! change this to something that works properly - if (!(selectedEvents[i].isCreating || selectedEvents[i].wasDuplicated)) - { - result.Add(selectedEvents[i]); - } - selectedEvents[i].OnUp(); - } - CommandManager.instance.Execute(new Commands.Move(result)); - } - } - */ - } } public static Sprite GameIcon(string name) @@ -360,6 +335,7 @@ namespace HeavenStudio.Editor { if (dialog.GetType() == typeof(RemixPropertiesDialog)) { + if (fullscreen) Fullscreen(); GlobalGameManager.ShowErrorMessage("Set Remix Properties", "Set remix properties before saving."); (dialog as RemixPropertiesDialog).SwitchPropertiesDialog(); (dialog as RemixPropertiesDialog).SetSaveOnClose(true, saveAs); @@ -431,6 +407,7 @@ namespace HeavenStudio.Editor public void LoadRemix(bool create = false) { + if (fullscreen) Fullscreen(); if (create) { GameManager.instance.NewRemix(); @@ -446,6 +423,7 @@ namespace HeavenStudio.Editor public void OpenRemix() { + if (fullscreen) Fullscreen(); var extensions = new[] { new ExtensionFilter("Heaven Studio Remix File ", new string[] { "riq" }), diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs index 4e69b914..69b5a16e 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs @@ -20,6 +20,7 @@ namespace HeavenStudio.Editor public RectTransform ColorTable; public bool colorTableActive; public ColorPreview colorPreview; + public TMP_InputField hex; private Color _defaultColor; @@ -27,6 +28,17 @@ namespace HeavenStudio.Editor { InitProperties(propertyName, caption); + hex.onSelect.AddListener( + _ => + Editor.instance.editingInputField = true + ); + hex.onEndEdit.AddListener( + _ => + {; + Editor.instance.editingInputField = false; + } + ); + colorPreview.colorPicker.onColorChanged += _ => { parameterManager.entity[propertyName] = colorPreview.colorPicker.color; @@ -78,6 +90,7 @@ namespace HeavenStudio.Editor { ColorTable.gameObject.SetActive(false); colorTableActive = false; + Editor.instance.editingInputField = false; } } } diff --git a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs index 9a66e55c..89faf404 100644 --- a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs @@ -1,14 +1,9 @@ +using UnityEngine; +using System; using System.Collections; using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; -using System; using System.Linq; using TMPro; -using Starpelly; - -using HeavenStudio.Util; -using HeavenStudio.Editor; namespace HeavenStudio.Editor { @@ -22,9 +17,9 @@ namespace HeavenStudio.Editor { InitProperties(diag, propertyName, caption); - var enumType = type.GetType(); - var enumVals = Enum.GetValues(enumType); - var enumNames = Enum.GetNames(enumType).ToList(); + Type enumType = type.GetType(); + Array enumVals = Enum.GetValues(enumType); + List enumNames = Enum.GetNames(enumType).ToList(); // Can we assume non-holey enum? // If we can we can simplify to dropdown.value = (int) parameterManager.chart[propertyName] @@ -38,7 +33,7 @@ namespace HeavenStudio.Editor dropdown.value = selected; dropdown.onValueChanged.AddListener(_ => - parameterManager.chart[propertyName] = (int) enumVals.GetValue(dropdown.value) + parameterManager.chart[propertyName] = Enum.ToObject(enumType, (int) enumVals.GetValue(dropdown.value)) ); } diff --git a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs index 05409f74..79ebc71b 100644 --- a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs +++ b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs @@ -25,10 +25,15 @@ namespace HeavenStudio.Editor public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, bool isReadOnly = false, string tooltip = "") { + if (!Minigames.propertiesModel.ContainsKey(propertyName)) + { + Debug.LogError("Property " + propertyName + " does not exist!"); + return; + } GameObject prefab = diag.IntegerP; GameObject input; - var objType = type.GetType(); + var objType = Minigames.propertiesModel[propertyName].GetType(); if (objType == typeof(EntityTypes.Integer)) { @@ -83,13 +88,13 @@ namespace HeavenStudio.Editor property.SetProperties(diag, propertyName, type, caption); break; default: - Debug.LogError("Can't make property interface of type: " + type.GetType()); + Debug.LogError("Can't make property interface of type: " + objType); return; } } else { - Debug.LogError("Can't make property interface of type: " + type.GetType()); + Debug.LogError("Can't make property interface of type: " + objType); return; } } diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 7baf6cb2..13ce8878 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -325,6 +325,8 @@ namespace HeavenStudio { if (data.properties[prop.Key].GetType() == typeof(string)) data.properties[prop.Key] = Enum.Parse(mType, (string)data.properties[prop.Key]); + else + data.properties[prop.Key] = Enum.ToObject(mType, data.properties[prop.Key]); } // convert all JObjects to their respective types else if (data.properties[prop.Key].GetType() == typeof(Newtonsoft.Json.Linq.JObject)) diff --git a/Assets/Scripts/TitleManager.cs b/Assets/Scripts/TitleManager.cs index ad392d58..5de73269 100644 --- a/Assets/Scripts/TitleManager.cs +++ b/Assets/Scripts/TitleManager.cs @@ -141,14 +141,26 @@ namespace HeavenStudio pressAnyKeyAnim.Play("PressKeyFadeOut", 0, 0); SoundByte.PlayOneShot("ui/UIEnter"); + var nextController = newController; + + if (newController is InputMouse) + { + Debug.Log("Mouse used, selecting keyboard instead"); + nextController = controllers[0]; + } Debug.Log("Assigning controller: " + newController.GetDeviceName()); var lastController = PlayerInput.GetInputController(1); - if (lastController != newController) + if (lastController != nextController) { + if (nextController == null) + { + Debug.Log("invalid controller, using keyboard"); + nextController = controllers[0]; + } lastController.SetPlayer(null); - newController.SetPlayer(1); - PlayerInput.CurrentControlStyle = newController.GetDefaultStyle(); + nextController.SetPlayer(1); + PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle(); usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch; selectedDisplayIcon.SetActive(!usingMouse); @@ -157,10 +169,10 @@ namespace HeavenStudio (lastController as InputJoyshock)?.UnAssignOtherHalf(); } - if ((newController as InputJoyshock) != null) + if ((nextController as InputJoyshock) != null) { - newController.OnSelected(); - (newController as InputJoyshock)?.UnAssignOtherHalf(); + nextController.OnSelected(); + (nextController as InputJoyshock)?.UnAssignOtherHalf(); } } }