2023-12-26 05:22:51 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
using HeavenStudio.Common;
|
|
|
|
using HeavenStudio.InputSystem;
|
2024-02-16 06:17:16 +00:00
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using SFB;
|
|
|
|
using Jukebox;
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
namespace HeavenStudio
|
|
|
|
{
|
|
|
|
public class TitleManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private TMP_Text versionText;
|
|
|
|
[SerializeField] private Button createButton;
|
|
|
|
|
|
|
|
[SerializeField] private Animator logoAnim;
|
|
|
|
|
|
|
|
[SerializeField] private List<Animator> starAnims;
|
|
|
|
|
|
|
|
[SerializeField] private Animator pressAnyKeyAnim;
|
|
|
|
|
|
|
|
[SerializeField] private float bpm = 114f;
|
|
|
|
[SerializeField] private float offset = 0f;
|
|
|
|
|
|
|
|
[SerializeField] private RawImage bg;
|
|
|
|
|
|
|
|
[SerializeField] private float bgXSpeed;
|
|
|
|
[SerializeField] private float bgYSpeed;
|
|
|
|
|
|
|
|
[SerializeField] private Collider2D logoHoverCollider;
|
|
|
|
|
|
|
|
[SerializeField] private SettingsDialog settingsPanel;
|
|
|
|
|
|
|
|
[SerializeField] private GameObject snsPanel;
|
|
|
|
[SerializeField] private TMP_Text snsVersionText;
|
|
|
|
|
|
|
|
[SerializeField] private GameObject playPanel;
|
|
|
|
[SerializeField] private TMP_Text chartTitleText;
|
|
|
|
[SerializeField] private TMP_Text chartMapperText;
|
2024-01-14 07:18:46 +00:00
|
|
|
[SerializeField] private TMP_Text chartIdolText;
|
2023-12-26 05:22:51 +00:00
|
|
|
[SerializeField] private TMP_Text chartDescText;
|
2024-01-22 01:38:56 +00:00
|
|
|
[SerializeField] private GameObject flashWarning;
|
2023-12-26 05:22:51 +00:00
|
|
|
[SerializeField] private TMP_Text chartStyleText;
|
2024-01-15 15:54:08 +00:00
|
|
|
[SerializeField] private Image campaignOption;
|
|
|
|
[SerializeField] private Sprite campaignOn;
|
|
|
|
[SerializeField] private Sprite campaignOff;
|
2023-12-26 05:22:51 +00:00
|
|
|
|
|
|
|
[SerializeField] private Selectable[] mainSelectables;
|
|
|
|
[SerializeField] private Selectable defaultSelectable;
|
|
|
|
[SerializeField] private RectTransform selectedDisplayRect;
|
|
|
|
[SerializeField] private GameObject selectedDisplayIcon;
|
2024-01-14 07:18:46 +00:00
|
|
|
[SerializeField] private GameObject[] otherHiddenOnMouse;
|
2024-01-16 20:21:22 +00:00
|
|
|
static bool firstBoot = true;
|
2023-12-26 05:22:51 +00:00
|
|
|
|
|
|
|
private AudioSource musicSource;
|
|
|
|
|
|
|
|
private double songPosBeat;
|
|
|
|
private double songPos;
|
|
|
|
private double time;
|
|
|
|
private double targetBopBeat;
|
|
|
|
|
|
|
|
private int loops;
|
|
|
|
|
|
|
|
private double lastAbsTime;
|
|
|
|
private double startTime;
|
2024-01-22 15:58:45 +00:00
|
|
|
private float playPanelRevealTime;
|
2023-12-26 05:22:51 +00:00
|
|
|
|
|
|
|
private bool altBop;
|
|
|
|
|
|
|
|
private bool logoRevealed;
|
|
|
|
|
2024-01-22 01:10:45 +00:00
|
|
|
private bool menuMode, snsRevealed, playMenuRevealed, exiting, firstPress, usingMouse, waitingForButtonUp;
|
2023-12-26 05:22:51 +00:00
|
|
|
|
|
|
|
private Animator menuAnim, selectedDisplayAnim;
|
|
|
|
private Selectable currentSelectable, mouseSelectable;
|
|
|
|
private RectTransform currentSelectableRect, lastSelectableRect;
|
|
|
|
private float selectableLerpTimer;
|
|
|
|
|
2024-01-16 20:21:22 +00:00
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
exiting = false;
|
|
|
|
menuAnim = GetComponent<Animator>();
|
|
|
|
musicSource = GetComponent<AudioSource>();
|
|
|
|
musicSource.PlayScheduled(AudioSettings.dspTime);
|
|
|
|
startTime = Time.realtimeSinceStartupAsDouble;
|
|
|
|
var _rand = new System.Random();
|
|
|
|
starAnims = starAnims.OrderBy(_ => _rand.Next()).ToList();
|
|
|
|
selectedDisplayRect.gameObject.SetActive(false);
|
|
|
|
|
|
|
|
if (selectedDisplayRect.TryGetComponent(out Animator anim))
|
|
|
|
{
|
|
|
|
selectedDisplayAnim = anim;
|
|
|
|
}
|
|
|
|
|
2024-01-14 07:18:46 +00:00
|
|
|
#if HEAVENSTUDIO_PROD
|
|
|
|
versionText.text = GlobalGameManager.friendlyReleaseName;
|
|
|
|
#elif UNITY_EDITOR
|
2023-12-26 05:22:51 +00:00
|
|
|
versionText.text = "EDITOR";
|
|
|
|
#else
|
|
|
|
versionText.text = Application.buildGUID.Substring(0, 8) + " " + AppInfo.Date.ToString("dd/MM/yyyy hh:mm:ss");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
bg.uvRect = new Rect(bg.uvRect.position + (new Vector2(bgXSpeed, bgYSpeed) * Time.deltaTime), bg.uvRect.size);
|
|
|
|
if (songPos >= musicSource.clip.length)
|
|
|
|
{
|
|
|
|
time = 0;
|
|
|
|
targetBopBeat = 0;
|
|
|
|
loops++;
|
|
|
|
}
|
|
|
|
double absTime = Time.realtimeSinceStartupAsDouble - startTime;
|
|
|
|
double dt = absTime - lastAbsTime;
|
|
|
|
lastAbsTime = absTime;
|
|
|
|
|
|
|
|
time += dt;
|
|
|
|
|
|
|
|
songPos = time + offset;
|
|
|
|
|
|
|
|
songPosBeat = SecsToBeats(songPos);
|
|
|
|
|
|
|
|
if (selectedDisplayAnim.isActiveAndEnabled)
|
|
|
|
{
|
|
|
|
selectedDisplayAnim.DoNormalizedAnimation("Idle", GetPositionFromBeat(0, 2));
|
|
|
|
}
|
|
|
|
|
2024-01-02 15:51:44 +00:00
|
|
|
if (!menuMode && songPosBeat >= 0.5)
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
|
|
|
var controllers = PlayerInput.GetInputControllers();
|
|
|
|
foreach (var newController in controllers)
|
|
|
|
{
|
|
|
|
if (newController.GetLastButtonDown(true) > 0)
|
|
|
|
{
|
2024-01-02 15:51:44 +00:00
|
|
|
if (logoRevealed)
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
2024-01-02 15:51:44 +00:00
|
|
|
menuMode = true;
|
|
|
|
firstPress = true;
|
|
|
|
currentSelectable = defaultSelectable;
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
selectableLerpTimer = 1;
|
2023-12-26 05:22:51 +00:00
|
|
|
|
2024-01-02 15:51:44 +00:00
|
|
|
menuAnim.Play("Revealed", 0, 0);
|
|
|
|
pressAnyKeyAnim.Play("PressKeyFadeOut", 0, 0);
|
|
|
|
SoundByte.PlayOneShot("ui/UIEnter");
|
|
|
|
|
2024-01-06 03:51:27 +00:00
|
|
|
var nextController = newController;
|
2024-01-07 23:45:25 +00:00
|
|
|
var lastController = PlayerInput.GetInputController(1);
|
2024-01-06 03:51:27 +00:00
|
|
|
|
2024-01-02 15:51:44 +00:00
|
|
|
Debug.Log("Assigning controller: " + newController.GetDeviceName());
|
2023-12-26 05:22:51 +00:00
|
|
|
|
2024-02-04 06:54:32 +00:00
|
|
|
if (lastController != nextController)// && !firstBoot)
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
2024-01-16 20:21:22 +00:00
|
|
|
firstBoot = false;
|
2024-01-06 03:51:27 +00:00
|
|
|
if (nextController == null)
|
|
|
|
{
|
|
|
|
Debug.Log("invalid controller, using keyboard");
|
|
|
|
nextController = controllers[0];
|
|
|
|
}
|
2024-01-02 15:51:44 +00:00
|
|
|
lastController.SetPlayer(null);
|
2024-01-06 03:51:27 +00:00
|
|
|
nextController.SetPlayer(1);
|
2024-02-04 06:54:32 +00:00
|
|
|
nextController.OnSelected();
|
2024-01-06 03:51:27 +00:00
|
|
|
PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle();
|
2024-01-02 15:51:44 +00:00
|
|
|
usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch;
|
|
|
|
selectedDisplayIcon.SetActive(!usingMouse);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(!usingMouse);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
2024-02-04 06:54:32 +00:00
|
|
|
break;
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
2024-01-02 15:51:44 +00:00
|
|
|
else
|
|
|
|
{
|
2024-01-13 02:40:29 +00:00
|
|
|
SkipToBeat(3.5);
|
2024-01-02 15:51:44 +00:00
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loops == 0 && !logoRevealed)
|
|
|
|
{
|
2024-01-13 02:40:29 +00:00
|
|
|
float normalizedBeat = GetPositionFromBeat(3, 1);
|
2023-12-26 05:22:51 +00:00
|
|
|
if (normalizedBeat > 0 && normalizedBeat <= 1f)
|
|
|
|
{
|
|
|
|
logoAnim.DoNormalizedAnimation("Reveal", normalizedBeat);
|
|
|
|
pressAnyKeyAnim.DoNormalizedAnimation("PressKeyFadeIn", normalizedBeat);
|
|
|
|
}
|
|
|
|
else if (normalizedBeat < 0)
|
|
|
|
{
|
|
|
|
logoAnim.DoNormalizedAnimation("Reveal", 0);
|
|
|
|
}
|
|
|
|
else if (normalizedBeat > 1f)
|
|
|
|
{
|
|
|
|
logoRevealed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (songPosBeat - 1 >= targetBopBeat)
|
|
|
|
{
|
|
|
|
if (targetBopBeat <= 3 && loops == 0)
|
|
|
|
{
|
|
|
|
starAnims[(int)targetBopBeat].Play("StarAppearBop", 0, 0);
|
|
|
|
if (targetBopBeat == 3) starAnims[4].Play("StarAppearBop", 0, 0);
|
|
|
|
for (int i = 0; i < (int)targetBopBeat; i++)
|
|
|
|
{
|
|
|
|
starAnims[i].Play("StarBopNoRot", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (var star in starAnims)
|
|
|
|
{
|
|
|
|
star.Play("StarBop", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2024-01-13 02:40:29 +00:00
|
|
|
if (targetBopBeat > 2 || loops > 0)
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
|
|
|
logoAnim.Play(altBop ? "LogoBop2" : "LogoBop", 0, 0);
|
|
|
|
altBop = !altBop;
|
|
|
|
}
|
|
|
|
targetBopBeat += 1;
|
|
|
|
}
|
|
|
|
|
2024-01-22 01:10:45 +00:00
|
|
|
var controller = PlayerInput.GetInputController(1);
|
2024-01-22 01:38:56 +00:00
|
|
|
if (menuMode && !(exiting || GlobalGameManager.IsShowingDialog || waitingForButtonUp))
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
|
|
|
if (playMenuRevealed)
|
|
|
|
{
|
|
|
|
if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
|
|
|
{
|
|
|
|
switch (controller.GetLastActionDown())
|
|
|
|
{
|
|
|
|
case (int)InputController.ActionsPad.East:
|
|
|
|
PlayPanelAccept();
|
|
|
|
break;
|
|
|
|
case (int)InputController.ActionsPad.South:
|
|
|
|
PlayPanelBack();
|
|
|
|
break;
|
2024-01-15 15:54:08 +00:00
|
|
|
case (int)InputController.ActionsPad.North:
|
|
|
|
ToggleCampaign();
|
|
|
|
break;
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (snsRevealed)
|
|
|
|
{
|
|
|
|
if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
|
|
|
{
|
|
|
|
if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South)
|
|
|
|
{
|
|
|
|
SocialsClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (settingsPanel.IsOpen)
|
|
|
|
{
|
2024-02-04 06:54:32 +00:00
|
|
|
// if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
|
|
|
// {
|
|
|
|
// if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South)
|
|
|
|
// {
|
|
|
|
// SettingsClose();
|
|
|
|
// }
|
|
|
|
// }
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
2024-01-22 01:38:56 +00:00
|
|
|
else if (!firstPress)
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
|
|
|
UpdateSelectable(controller);
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 01:10:45 +00:00
|
|
|
if (waitingForButtonUp)
|
|
|
|
{
|
|
|
|
if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
|
|
|
{
|
|
|
|
if (controller.GetActionUp(PlayerInput.CurrentControlStyle, (int)InputController.ActionsPad.East, out _))
|
|
|
|
{
|
|
|
|
waitingForButtonUp = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
if (firstPress) firstPress = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateSelectable(InputController controller)
|
|
|
|
{
|
|
|
|
selectableLerpTimer += Time.deltaTime;
|
|
|
|
if (selectableLerpTimer < 0.2f)
|
|
|
|
{
|
|
|
|
float prog = Mathf.Clamp01(selectableLerpTimer / 0.2f);
|
|
|
|
prog = 1f - Mathf.Pow(1f - prog, 3);
|
|
|
|
selectedDisplayRect.position = Vector3.Lerp(lastSelectableRect.position, currentSelectableRect.position, prog);
|
|
|
|
selectedDisplayRect.sizeDelta = Vector2.Lerp(lastSelectableRect.sizeDelta, currentSelectableRect.sizeDelta, prog);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
selectedDisplayRect.position = currentSelectableRect.position;
|
|
|
|
selectedDisplayRect.sizeDelta = currentSelectableRect.sizeDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
|
|
|
{
|
|
|
|
switch (controller.GetLastActionDown())
|
|
|
|
{
|
|
|
|
case (int)InputController.ActionsPad.East:
|
|
|
|
if (currentSelectable != null)
|
|
|
|
{
|
|
|
|
if (usingMouse)
|
|
|
|
{
|
|
|
|
usingMouse = false;
|
|
|
|
selectedDisplayIcon.SetActive(true);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
|
|
|
currentSelectable.GetComponent<Button>()?.onClick.Invoke();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (int)InputController.ActionsPad.Up:
|
|
|
|
if (currentSelectable != null)
|
|
|
|
{
|
|
|
|
if (currentSelectable.FindSelectableOnUp() != null)
|
|
|
|
{
|
|
|
|
usingMouse = false;
|
|
|
|
selectedDisplayIcon.SetActive(true);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
currentSelectable = currentSelectable.FindSelectableOnUp();
|
|
|
|
currentSelectable.Select();
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (int)InputController.ActionsPad.Down:
|
|
|
|
if (currentSelectable != null)
|
|
|
|
{
|
|
|
|
if (currentSelectable.FindSelectableOnDown() != null)
|
|
|
|
{
|
|
|
|
usingMouse = false;
|
|
|
|
selectedDisplayIcon.SetActive(true);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
currentSelectable = currentSelectable.FindSelectableOnDown();
|
|
|
|
currentSelectable.Select();
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (int)InputController.ActionsPad.Left:
|
|
|
|
if (currentSelectable != null)
|
|
|
|
{
|
|
|
|
if (currentSelectable.FindSelectableOnLeft() != null)
|
|
|
|
{
|
|
|
|
usingMouse = false;
|
|
|
|
selectedDisplayIcon.SetActive(true);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
currentSelectable = currentSelectable.FindSelectableOnLeft();
|
|
|
|
currentSelectable.Select();
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (int)InputController.ActionsPad.Right:
|
|
|
|
if (currentSelectable != null)
|
|
|
|
{
|
|
|
|
if (currentSelectable.FindSelectableOnRight() != null)
|
|
|
|
{
|
|
|
|
usingMouse = false;
|
|
|
|
selectedDisplayIcon.SetActive(true);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
currentSelectable = currentSelectable.FindSelectableOnRight();
|
|
|
|
currentSelectable.Select();
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var selectable in mainSelectables)
|
|
|
|
{
|
|
|
|
// get button the mouse is hovering over
|
|
|
|
if (RectTransformUtility.RectangleContainsScreenPoint(selectable.GetComponent<RectTransform>(), Input.mousePosition, Camera.main))
|
|
|
|
{
|
|
|
|
if (mouseSelectable != selectable)
|
|
|
|
{
|
|
|
|
mouseSelectable = selectable;
|
|
|
|
usingMouse = true;
|
|
|
|
selectedDisplayIcon.SetActive(false);
|
2024-01-14 07:18:46 +00:00
|
|
|
foreach (var obj in otherHiddenOnMouse)
|
|
|
|
{
|
|
|
|
obj.SetActive(false);
|
|
|
|
}
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
|
|
|
if (currentSelectable != selectable && usingMouse)
|
|
|
|
{
|
|
|
|
currentSelectable = selectable;
|
|
|
|
SetSelectableRectTarget(currentSelectable);
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSelectableRectTarget(Selectable selectable)
|
|
|
|
{
|
|
|
|
if (selectable == null)
|
|
|
|
{
|
|
|
|
selectedDisplayRect.gameObject.SetActive(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selectedDisplayRect.gameObject.SetActive(true);
|
|
|
|
lastSelectableRect = currentSelectableRect;
|
|
|
|
currentSelectableRect = selectable.GetComponent<RectTransform>();
|
|
|
|
|
|
|
|
if (lastSelectableRect == null)
|
|
|
|
{
|
|
|
|
lastSelectableRect = currentSelectableRect;
|
|
|
|
}
|
|
|
|
selectedDisplayRect.position = lastSelectableRect.position;
|
|
|
|
selectedDisplayRect.sizeDelta = lastSelectableRect.sizeDelta;
|
|
|
|
selectableLerpTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double SecsToBeats(double s)
|
|
|
|
{
|
|
|
|
return s / 60f * bpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double BeatsToSecs(double beats, float bpm)
|
|
|
|
{
|
|
|
|
return beats / bpm * 60f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float GetPositionFromBeat(float startBeat, float length)
|
|
|
|
{
|
2024-02-16 06:17:16 +00:00
|
|
|
float a = MathUtils.Normalize((float)songPosBeat, startBeat, startBeat + length);
|
2023-12-26 05:22:51 +00:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2024-01-02 15:51:44 +00:00
|
|
|
public void SkipToBeat(double beat)
|
|
|
|
{
|
|
|
|
if (songPosBeat >= beat) return;
|
|
|
|
double seconds = BeatsToSecs(beat, bpm);
|
|
|
|
time = seconds;
|
|
|
|
songPos = time + offset;
|
|
|
|
songPosBeat = SecsToBeats(songPos);
|
|
|
|
musicSource.time = (float)time;
|
|
|
|
}
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
public void CreatePressed()
|
|
|
|
{
|
|
|
|
if (exiting) return;
|
|
|
|
exiting = true;
|
|
|
|
GlobalGameManager.PlayOpenFile = null;
|
|
|
|
GlobalGameManager.LoadScene("Editor");
|
|
|
|
SoundByte.PlayOneShot("ui/UIEnter");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayPressed()
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
// temp: open file browser then go into quickplay
|
|
|
|
OpenQuickplayFileDialog();
|
|
|
|
// go into the play mode menu
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenQuickplayFileDialog()
|
|
|
|
{
|
|
|
|
var extensions = new[]
|
|
|
|
{
|
|
|
|
new ExtensionFilter("Heaven Studio Remix File ", new string[] { "riq" }),
|
|
|
|
};
|
|
|
|
|
2024-01-15 02:47:48 +00:00
|
|
|
#if HEAVENSTUDIO_PROD && !UNITY_EDITOR
|
2024-01-16 00:55:53 +00:00
|
|
|
string lvpath = "";
|
|
|
|
if (Application.platform != RuntimePlatform.OSXPlayer)
|
2024-01-15 02:47:48 +00:00
|
|
|
{
|
2024-01-16 00:55:53 +00:00
|
|
|
lvpath = Application.dataPath + "/../Levels/";
|
|
|
|
if (!Directory.Exists(lvpath))
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(lvpath);
|
|
|
|
}
|
2024-01-15 02:47:48 +00:00
|
|
|
}
|
|
|
|
StandaloneFileBrowser.OpenFilePanelAsync("Open Remix", lvpath, extensions, false, (string[] paths) =>
|
|
|
|
#else
|
2023-12-26 05:22:51 +00:00
|
|
|
StandaloneFileBrowser.OpenFilePanelAsync("Open Remix", "", extensions, false, (string[] paths) =>
|
2024-01-15 02:47:48 +00:00
|
|
|
#endif
|
2023-12-26 05:22:51 +00:00
|
|
|
{
|
|
|
|
var path = Path.Combine(paths);
|
|
|
|
if (path == string.Empty)
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("ui/UICancel");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
RiqFileHandler.ClearCache();
|
|
|
|
string tmpDir = RiqFileHandler.ExtractRiq(path);
|
|
|
|
Debug.Log("Imported RIQ successfully!");
|
|
|
|
RiqBeatmap beatmap = RiqFileHandler.ReadRiq();
|
|
|
|
GlobalGameManager.PlayOpenFile = path;
|
|
|
|
chartTitleText.text = beatmap["remixtitle"];
|
|
|
|
chartMapperText.text = beatmap["remixauthor"];
|
|
|
|
chartDescText.text = beatmap["remixdesc"];
|
2024-01-14 07:18:46 +00:00
|
|
|
chartIdolText.text = "♪ " + beatmap["idolcredit"];
|
2023-12-26 05:22:51 +00:00
|
|
|
chartStyleText.text = $"Recommended Control Style: {beatmap["playstyle"].ToString()}";
|
2024-01-22 01:38:56 +00:00
|
|
|
flashWarning.SetActive(beatmap["accessiblewarning"]);
|
2023-12-26 05:22:51 +00:00
|
|
|
|
2024-01-15 15:54:08 +00:00
|
|
|
if (PersistentDataManager.gameSettings.perfectChallengeType == PersistentDataManager.PerfectChallengeType.On)
|
|
|
|
{
|
|
|
|
campaignOption.sprite = campaignOn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
campaignOption.sprite = campaignOff;
|
|
|
|
}
|
|
|
|
|
2024-01-22 15:58:45 +00:00
|
|
|
// waitingForButtonUp = true;
|
2024-02-04 06:54:32 +00:00
|
|
|
playPanelRevealTime = Time.realtimeSinceStartup + 0.5f;
|
2023-12-26 05:22:51 +00:00
|
|
|
playPanel.SetActive(true);
|
|
|
|
playMenuRevealed = true;
|
|
|
|
SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
catch (System.Exception e)
|
|
|
|
{
|
|
|
|
Debug.Log($"Error importing RIQ: {e.Message}");
|
|
|
|
Debug.LogException(e);
|
|
|
|
GlobalGameManager.ShowErrorMessage("Error Loading RIQ", e.Message + "\n\n" + e.StackTrace);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayPanelAccept()
|
|
|
|
{
|
2024-01-22 15:58:45 +00:00
|
|
|
if (playPanelRevealTime > Time.realtimeSinceStartup) return;
|
2023-12-26 05:22:51 +00:00
|
|
|
if (exiting) return;
|
|
|
|
exiting = true;
|
|
|
|
SoundByte.PlayOneShot("ui/UIEnter");
|
2024-01-15 15:54:08 +00:00
|
|
|
PersistentDataManager.SaveSettings();
|
2023-12-26 05:22:51 +00:00
|
|
|
GlobalGameManager.LoadScene("Game", 0.35f, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayPanelBack()
|
|
|
|
{
|
|
|
|
RiqFileHandler.ClearCache();
|
|
|
|
SoundByte.PlayOneShot("ui/UICancel");
|
2024-01-15 15:54:08 +00:00
|
|
|
PersistentDataManager.SaveSettings();
|
2023-12-26 05:22:51 +00:00
|
|
|
playPanel.SetActive(false);
|
|
|
|
playMenuRevealed = false;
|
2024-01-22 01:38:56 +00:00
|
|
|
waitingForButtonUp = false;
|
2023-12-26 05:22:51 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 15:54:08 +00:00
|
|
|
public void ToggleCampaign()
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("ui/UIOption");
|
|
|
|
if (PersistentDataManager.gameSettings.perfectChallengeType == PersistentDataManager.PerfectChallengeType.On)
|
|
|
|
{
|
|
|
|
PersistentDataManager.gameSettings.perfectChallengeType = PersistentDataManager.PerfectChallengeType.Off;
|
|
|
|
campaignOption.sprite = campaignOff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PersistentDataManager.gameSettings.perfectChallengeType = PersistentDataManager.PerfectChallengeType.On;
|
|
|
|
campaignOption.sprite = campaignOn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-26 05:22:51 +00:00
|
|
|
public void SocialsPressed()
|
|
|
|
{
|
2024-01-14 07:18:46 +00:00
|
|
|
// snsRevealed = true;
|
|
|
|
// #if HEAVENSTUDIO_PROD
|
|
|
|
// snsVersionText.text = GlobalGameManager.friendlyReleaseName;
|
|
|
|
// #else
|
|
|
|
// snsVersionText.text = GlobalGameManager.buildTime;
|
|
|
|
// #endif
|
|
|
|
// snsPanel.SetActive(true);
|
2023-12-26 05:22:51 +00:00
|
|
|
SoundByte.PlayOneShot("ui/UISelect");
|
2024-01-15 15:54:08 +00:00
|
|
|
Application.OpenURL("https://linktr.ee/RHeavenStudio");
|
2023-12-26 05:22:51 +00:00
|
|
|
// show a panel with our SNS links
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SocialsClose()
|
|
|
|
{
|
|
|
|
snsRevealed = false;
|
|
|
|
snsPanel.SetActive(false);
|
|
|
|
SoundByte.PlayOneShot("ui/UICancel");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SettingsPressed()
|
|
|
|
{
|
|
|
|
if (!settingsPanel.IsOpen)
|
|
|
|
{
|
|
|
|
settingsPanel.SwitchSettingsDialog();
|
|
|
|
SoundByte.PlayOneShot("ui/UISelect");
|
|
|
|
}
|
|
|
|
// notes:
|
|
|
|
// gameplay settings currently don't work due to the overlay preview requiring the screen composition setup from a gameplay prefab
|
|
|
|
// adding the attract screen will fix this since we'd need to add that prefab for it anyways
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SettingsClose()
|
|
|
|
{
|
|
|
|
if (settingsPanel.IsOpen)
|
|
|
|
{
|
|
|
|
settingsPanel.SwitchSettingsDialog();
|
|
|
|
SoundByte.PlayOneShot("ui/UICancel");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void QuitPressed()
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("ui/PauseQuit");
|
2024-01-15 15:54:08 +00:00
|
|
|
PersistentDataManager.SaveSettings();
|
2023-12-26 05:22:51 +00:00
|
|
|
Application.Quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|