HeavenStudioPlus/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs

92 lines
3 KiB
C#
Raw Normal View History

2022-07-10 21:39:14 +00:00
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using HeavenStudio.Common;
2022-07-10 21:39:14 +00:00
namespace HeavenStudio.Editor
{
2022-09-02 00:57:47 +00:00
public class EditorSettings : TabsContent
2022-07-10 21:39:14 +00:00
{
public Toggle cursorCheckbox;
public Toggle discordRPCCheckbox;
2023-10-27 20:19:16 +00:00
public Button editorScaleDecre, editorScaleIncre;
public Toggle scaleWSS;
2023-10-27 20:19:16 +00:00
private void Start()
{
cursorCheckbox.isOn = PersistentDataManager.gameSettings.editorCursorEnable;
discordRPCCheckbox.isOn = PersistentDataManager.gameSettings.discordRPCEnable;
2023-10-27 20:19:16 +00:00
scaleWSS.isOn = PersistentDataManager.gameSettings.scaleWScreenSize;
SetDecreIncreInteractable();
}
2022-07-10 21:39:14 +00:00
public void OnCursorCheckboxChanged()
{
Editor.instance.isCursorEnabled = cursorCheckbox.isOn;
PersistentDataManager.gameSettings.editorCursorEnable = cursorCheckbox.isOn;
if (Editor.instance != null && !Editor.instance.fullscreen)
2022-07-10 21:39:14 +00:00
{
GameManager.instance.CursorCam.enabled = Editor.instance.isCursorEnabled;
}
}
2022-09-02 00:57:47 +00:00
public void OnRPCCheckboxChanged()
{
PersistentDataManager.gameSettings.discordRPCEnable = discordRPCCheckbox.isOn;
Editor.instance.isDiscordEnabled = discordRPCCheckbox.isOn;
}
2022-09-02 00:57:47 +00:00
public override void OnOpenTab()
{
cursorCheckbox.isOn = PersistentDataManager.gameSettings.editorCursorEnable;
discordRPCCheckbox.isOn = PersistentDataManager.gameSettings.discordRPCEnable;
2023-10-27 20:19:16 +00:00
scaleWSS.isOn = PersistentDataManager.gameSettings.scaleWScreenSize;
SetDecreIncreInteractable();
2022-09-02 00:57:47 +00:00
}
public override void OnCloseTab()
{
}
2023-10-27 20:19:16 +00:00
public void OnSWSSChanged()
{
PersistentDataManager.gameSettings.scaleWScreenSize = scaleWSS.isOn;
scaleWSS.isOn = PersistentDataManager.gameSettings.scaleWScreenSize;
}
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;
}
2022-07-10 21:39:14 +00:00
}
}