HeavenStudioPlus/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs
Zeo f861be86a3 Delayed Property Tooltips (#886)
* add dropdown

yes im really making a pr for something as tiny as this

* can now turn on/off

now for the hard part

* can turn on and off much better

now i can ACTUALLY get the delay working

* it works!!!

currently waits for 400 frames regardless of fps, should probably be changed in the future but it works well enough rn

* Timer waits 1.5 seconds

much better, thanks astrl
2024-04-21 21:39:19 +00:00

108 lines
No EOL
3.7 KiB
C#

using UnityEngine;
using UnityEngine.UI;
using TMPro;
using HeavenStudio.Common;
using System.Runtime.InteropServices;
namespace HeavenStudio.Editor
{
public class EditorSettings : TabsContent
{
[SerializeField] Toggle cursorCheckbox;
[SerializeField] Toggle discordRPCCheckbox;
[SerializeField] Button editorScaleDecre, editorScaleIncre;
[SerializeField] Toggle scaleWSS;
[SerializeField] TMP_Dropdown paramTooltipsDropdown;
[SerializeField] Toggle previewNoteSoundsToggle;
// [SerializeField] Toggle cornerTooltipsToggle;
private void Start()
{
cursorCheckbox.isOn = PersistentDataManager.gameSettings.editorCursorEnable;
discordRPCCheckbox.isOn = PersistentDataManager.gameSettings.discordRPCEnable;
scaleWSS.isOn = PersistentDataManager.gameSettings.scaleWScreenSize;
paramTooltipsDropdown.value = PersistentDataManager.gameSettings.showParamTooltips;
previewNoteSoundsToggle.isOn = PersistentDataManager.gameSettings.previewNoteSounds;
SetDecreIncreInteractable();
}
public void OnCursorCheckboxChanged()
{
Editor.instance.isCursorEnabled = cursorCheckbox.isOn;
PersistentDataManager.gameSettings.editorCursorEnable = cursorCheckbox.isOn;
if (Editor.instance != null && !Editor.instance.fullscreen)
{
GameManager.instance.CursorCam.enabled = Editor.instance.isCursorEnabled;
}
}
public void OnRPCCheckboxChanged()
{
PersistentDataManager.gameSettings.discordRPCEnable = discordRPCCheckbox.isOn;
Editor.instance.isDiscordEnabled = discordRPCCheckbox.isOn;
}
public override void OnOpenTab()
{
Start();
}
public override void OnCloseTab()
{
}
public void OnSWSSChanged()
{
PersistentDataManager.gameSettings.scaleWScreenSize = scaleWSS.isOn;
scaleWSS.isOn = PersistentDataManager.gameSettings.scaleWScreenSize;
}
public void OnParamTooltipsChanged()
{
// tooltip types: 0 = only corner, 1 = delayed on mouse, 2 = instant on mouse
PersistentDataManager.gameSettings.showParamTooltips = paramTooltipsDropdown.value;
}
public void OnPreviewNoteSoundsChanged()
{
PersistentDataManager.gameSettings.previewNoteSounds = previewNoteSoundsToggle.isOn;
}
// public void OnCornerTooltipsChanged()
// {
// PersistentDataManager.gameSettings.showParamTooltips = cornerTooltipsToggle.isOn;
// }
public void OnEditorScaleDecre()
{
PersistentDataManager.gameSettings.editorScale--;
if (PersistentDataManager.gameSettings.editorScale < -3)
PersistentDataManager.gameSettings.editorScale = -3;
SetDecreIncreInteractable();
}
public void OnEditorScaleIncre()
{
PersistentDataManager.gameSettings.editorScale++;
if (PersistentDataManager.gameSettings.editorScale > 5)
PersistentDataManager.gameSettings.editorScale = 5;
SetDecreIncreInteractable();
}
public void OnEditorScaleReset()
{
PersistentDataManager.gameSettings.editorScale = 0;
SetDecreIncreInteractable();
}
private void SetDecreIncreInteractable()
{
editorScaleDecre.interactable = PersistentDataManager.gameSettings.editorScale > -3; // hardcoded? We might not change.
editorScaleIncre.interactable = PersistentDataManager.gameSettings.editorScale < 5;
}
}
}