mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
make all dialogs inherit one base class
- opening a new dialog closes the previous one
This commit is contained in:
28
Assets/Scripts/LevelEditor/DialogHelpers/Dialog.cs
Normal file
28
Assets/Scripts/LevelEditor/DialogHelpers/Dialog.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class Dialog : MonoBehaviour
|
||||
{
|
||||
[SerializeField] protected GameObject dialog;
|
||||
public void ForceState(bool onoff = false)
|
||||
{
|
||||
Editor.instance.canSelect = onoff;
|
||||
Editor.instance.inAuthorativeMenu = !onoff;
|
||||
dialog.SetActive(onoff);
|
||||
}
|
||||
|
||||
public static void ResetAllDialogs()
|
||||
{
|
||||
foreach(var dialog in FindObjectsOfType<Dialog>())
|
||||
{
|
||||
dialog.ForceState(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/DialogHelpers/Dialog.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/DialogHelpers/Dialog.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e317d304732b562489c993ae93ce2265
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -52,10 +52,14 @@ namespace HeavenStudio.Editor
|
||||
[SerializeField] private Button FullScreenBTN;
|
||||
[SerializeField] private Button TempoFinderBTN;
|
||||
[SerializeField] private Button SnapDiagBTN;
|
||||
[SerializeField] private Button ChartParamBTN;
|
||||
|
||||
[SerializeField] private Button EditorThemeBTN;
|
||||
[SerializeField] private Button EditorSettingsBTN;
|
||||
|
||||
[Header("Dialogs")]
|
||||
[SerializeField] private Dialog[] Dialogs;
|
||||
|
||||
[Header("Tooltip")]
|
||||
public TMP_Text tooltipText;
|
||||
|
||||
@ -68,8 +72,11 @@ namespace HeavenStudio.Editor
|
||||
public bool discordDuringTesting = false;
|
||||
public bool canSelect = true;
|
||||
public bool editingInputField = false;
|
||||
public bool inAuthorativeMenu = false;
|
||||
public bool isCursorEnabled = true;
|
||||
|
||||
public bool isShortcutsEnabled { get { return (!inAuthorativeMenu) && (!editingInputField); } }
|
||||
|
||||
private byte[] MusicBytes;
|
||||
|
||||
public static Editor instance { get; private set; }
|
||||
@ -111,6 +118,7 @@ namespace HeavenStudio.Editor
|
||||
Tooltip.AddTooltip(FullScreenBTN.gameObject, "Preview <color=#adadad>[Tab]</color>");
|
||||
Tooltip.AddTooltip(TempoFinderBTN.gameObject, "Tempo Finder");
|
||||
Tooltip.AddTooltip(SnapDiagBTN.gameObject, "Snap Settings");
|
||||
Tooltip.AddTooltip(ChartParamBTN.gameObject, "Remix Properties");
|
||||
|
||||
Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
|
||||
UpdateEditorStatus(true);
|
||||
@ -119,7 +127,7 @@ namespace HeavenStudio.Editor
|
||||
public void LateUpdate()
|
||||
{
|
||||
#region Keyboard Shortcuts
|
||||
if (!editingInputField)
|
||||
if (isShortcutsEnabled)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
@ -160,7 +168,7 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
NewRemix();
|
||||
NewBTN.onClick.Invoke();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
|
@ -4,24 +4,23 @@ using UnityEngine;
|
||||
|
||||
using HeavenStudio.Editor;
|
||||
|
||||
public class NewRemixDialog : MonoBehaviour
|
||||
public class NewRemixDialog : Dialog
|
||||
{
|
||||
[SerializeField] private GameObject diag;
|
||||
|
||||
public void SwitchNewDialog()
|
||||
{
|
||||
if(diag.activeSelf) {
|
||||
diag.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
dialog.SetActive(false);
|
||||
} else {
|
||||
diag.SetActive(true);
|
||||
ResetAllDialogs();
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void Confirm()
|
||||
{
|
||||
Editor.instance.NewRemix();
|
||||
if(diag.activeSelf) {
|
||||
diag.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
dialog.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,18 +7,21 @@ using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class RemixPropertiesDialog : MonoBehaviour
|
||||
public class RemixPropertiesDialog : Dialog
|
||||
{
|
||||
[SerializeField] private GameObject propertiesMenu;
|
||||
|
||||
private void Start() {}
|
||||
|
||||
public void SwitchSettingsDialog()
|
||||
public void SwitchPropertiesDialog()
|
||||
{
|
||||
if(propertiesMenu.activeSelf) {
|
||||
propertiesMenu.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
Editor.instance.canSelect = true;
|
||||
Editor.instance.inAuthorativeMenu = false;
|
||||
dialog.SetActive(false);
|
||||
} else {
|
||||
propertiesMenu.SetActive(true);
|
||||
ResetAllDialogs();
|
||||
Editor.instance.canSelect = false;
|
||||
Editor.instance.inAuthorativeMenu = true;
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,19 +7,21 @@ using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SettingsDialog : MonoBehaviour
|
||||
public class SettingsDialog : Dialog
|
||||
{
|
||||
[SerializeField] private GameObject settingsMenu;
|
||||
//this may all be moved to a different script in the future
|
||||
|
||||
private void Start() {}
|
||||
|
||||
public void SwitchSettingsDialog()
|
||||
{
|
||||
if(settingsMenu.activeSelf) {
|
||||
settingsMenu.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
Editor.instance.canSelect = true;
|
||||
Editor.instance.inAuthorativeMenu = false;
|
||||
dialog.SetActive(false);
|
||||
} else {
|
||||
settingsMenu.SetActive(true);
|
||||
ResetAllDialogs();
|
||||
Editor.instance.canSelect = false;
|
||||
Editor.instance.inAuthorativeMenu = true;
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,8 @@ using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SnapDialog : MonoBehaviour
|
||||
public class SnapDialog : Dialog
|
||||
{
|
||||
[SerializeField] private GameObject snapSetter;
|
||||
[SerializeField] private TMP_Text snapText;
|
||||
private Timeline timeline;
|
||||
|
||||
@ -22,10 +21,11 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public void SwitchSnapDialog()
|
||||
{
|
||||
if(snapSetter.activeSelf) {
|
||||
snapSetter.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
dialog.SetActive(false);
|
||||
} else {
|
||||
snapSetter.SetActive(true);
|
||||
ResetAllDialogs();
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,8 @@ using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class TempoFinder : MonoBehaviour
|
||||
public class TempoFinder : Dialog
|
||||
{
|
||||
[SerializeField] private GameObject tempoFinder;
|
||||
private bool pressed;
|
||||
private float timePressed;
|
||||
[SerializeField] private BPMText bpmText;
|
||||
@ -17,12 +16,13 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
public void SwitchTempoDialog()
|
||||
{
|
||||
if(tempoFinder.activeSelf) {
|
||||
tempoFinder.SetActive(false);
|
||||
if(dialog.activeSelf) {
|
||||
dialog.SetActive(false);
|
||||
timePressed = 0;
|
||||
bpmText.ResetText();
|
||||
} else {
|
||||
tempoFinder.SetActive(true);
|
||||
ResetAllDialogs();
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void TapBPM()
|
||||
|
@ -273,7 +273,7 @@ namespace HeavenStudio.Editor.Track
|
||||
SliderControl();
|
||||
|
||||
#region Keyboard Shortcuts
|
||||
if (!userIsEditingInputField)
|
||||
if ((!userIsEditingInputField) && Editor.instance.isShortcutsEnabled)
|
||||
{
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
|
Reference in New Issue
Block a user