Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed May 13, 2023
1 parent 96dbca3 commit 3279990
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 42 deletions.
22 changes: 9 additions & 13 deletions Assets/Script/UI/PlayResultScreen/PlayResultScreen.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

using DG.Tweening;

using YARG.Data;
using YARG.Input;
using YARG.PlayMode;

namespace YARG.UI.PlayResultScreen {
public class PlayResultScreen : MonoBehaviour {
public class PlayResultScreen : MonoBehaviour {
private readonly Color PASS = new(.18f, .85f, 1f);
private readonly Color FAIL = new(.95f, .17f, .22f);
private readonly Color PASS_TRANSLUCENT = new(.18f, .85f, 1f, .2f);
private readonly Color FAIL_TRANSLUCENT = new(.95f, .17f, .22f, .2f);

[SerializeField]
private GameObject playerCardPrefab;
Expand All @@ -36,7 +32,7 @@ public class PlayResultScreen : MonoBehaviour {
private CanvasGroup songInfoCG;
[SerializeField]
private TextMeshProUGUI songTitle;
[SerializeField]
[SerializeField]
private TextMeshProUGUI songArtist;
[SerializeField]
private CanvasGroup starScoreCG;
Expand Down Expand Up @@ -76,7 +72,7 @@ void OnEnable() {

// change graphics depending on clear/fail
backgroundBorderFail.gameObject.SetActive(hasFailed);
backgroundBorderPass.gameObject.SetActive(!hasFailed);
backgroundBorderPass.gameObject.SetActive(!hasFailed);
headerBackgroundPassed.gameObject.SetActive(!hasFailed);
songArtist.color = hasFailed ? FAIL : PASS;

Expand Down Expand Up @@ -139,7 +135,7 @@ private void ProcessScores() {
if (oldScore == null || oldScore.highestScore == null ||
!oldScore.highestScore.TryGetValue(player.chosenInstrument, out var oldHighestSc) ||
lastScore.score > oldHighestSc) {

songScore.highestPercent[player.chosenInstrument] = lastScore.percentage;
songScore.highestScore[player.chosenInstrument] = lastScore.score;
highScores.Add(player);
Expand All @@ -164,7 +160,7 @@ private void CreatePlayerCards() {
if (player.chosenInstrument == null) continue;

var pc = Instantiate(playerCardPrefab, playerCardsContainer.transform).GetComponent<PlayerCard>();

ClearStatus clr;
if (bot.Contains(player)) {
clr = ClearStatus.Bot;
Expand Down Expand Up @@ -228,7 +224,7 @@ IEnumerator EnableAnimation() {


OnEnableAnimationFinish();

// slide in helpbar
helpBarRT
.DOAnchorMin(new Vector2(helpBarRT.anchorMin.x, hbYMinTgt), .75f)
Expand Down Expand Up @@ -281,7 +277,7 @@ private void OnDisable() {
foreach (var p in PlayerManager.players) {
p.inputStrategy.GenericNavigationEvent -= OnGenericNavigation;
}
} catch {}
} catch { }
}
}
}
}
56 changes: 27 additions & 29 deletions Assets/Script/UI/PlayResultScreen/PlayerCard.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
using System;
using System.Collections.Generic;
using DG.Tweening;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UI;
using Unity.Mathematics;

using DG.Tweening;

using YARG.Data;
using YARG.Input;

namespace YARG.UI.PlayResultScreen {
// TODO: move into more appropriate spot?
public enum ClearStatus {
Disqualified, Cleared, FullCombo, Brutal, Bot
}
public enum ClearStatus {
Disqualified, Cleared, FullCombo, Brutal, Bot
}

public class PlayerCard : MonoBehaviour {
public class PlayerCard : MonoBehaviour {

public static readonly Dictionary<ClearStatus, Color> statusColor = new() {
{ClearStatus.Disqualified, new Color(.322f, .345f, .377f)},
{ClearStatus.Bot, new Color(.322f, .345f, .377f)},
{ClearStatus.Cleared, new Color(.18f, .85f, 1f)},
{ClearStatus.FullCombo, new Color(1f, .76f, .16f)},
{ClearStatus.Brutal, new Color(.82f, 0f, .8f)},
{ClearStatus.Disqualified, new Color(.322f, .345f, .377f)},
{ClearStatus.Bot, new Color(.322f, .345f, .377f)},
{ClearStatus.Cleared, new Color(.18f, .85f, 1f)},
{ClearStatus.FullCombo, new Color(1f, .76f, .16f)},
{ClearStatus.Brutal, new Color(.82f, 0f, .8f)},
};

private PlayerManager.Player player;
Expand Down Expand Up @@ -51,12 +49,12 @@ public class PlayerCard : MonoBehaviour {
private ScrollRect scrollContainer;

[Space]
[Header("Main Page")]
[SerializeField]
[Header("Main Page")]
[SerializeField]
private TextMeshProUGUI playerName;
[SerializeField]
[SerializeField]
private TextMeshProUGUI percentage;
[SerializeField]
[SerializeField]
private TextMeshProUGUI difficulty;
[SerializeField]
private TextMeshProUGUI score;
Expand All @@ -73,9 +71,9 @@ public class PlayerCard : MonoBehaviour {
[Header("Color Elements")]
[SerializeField]
private RawImage separator0;
[SerializeField]
[SerializeField]
private RawImage separator1;
[SerializeField]
[SerializeField]
private RawImage bottomBanner;

public void Setup(PlayerManager.Player player, ClearStatus cs, bool isHighScore) {
Expand All @@ -84,16 +82,16 @@ public void Setup(PlayerManager.Player player, ClearStatus cs, bool isHighScore)

// set window frame
containerImg.sprite = cs switch {
ClearStatus.Bot or ClearStatus.Disqualified =>
ClearStatus.Bot or ClearStatus.Disqualified =>
backgroundDisqualified,
ClearStatus.FullCombo => backgroundFullCombo,
_ => backgroundCleared
ClearStatus.FullCombo => backgroundFullCombo,
_ => backgroundCleared
};

/* Set Content */
/* Set Content */
fcSymbol.gameObject.SetActive(cs == ClearStatus.FullCombo);
playerName.text = player.DisplayName;
difficulty.text = player.chosenDifficulty switch {
difficulty.text = player.chosenDifficulty switch {
Difficulty.EXPERT_PLUS => "EXPERT+",
_ => player.chosenDifficulty.ToString()
};
Expand All @@ -106,7 +104,7 @@ public void Setup(PlayerManager.Player player, ClearStatus cs, bool isHighScore)
var scr = player.lastScore.Value;
percentage.text = $"{Mathf.FloorToInt(scr.percentage.percent * 100f)}%";
score.text = $"{scr.score.score:N0}";
starDisplay.SetStars (
starDisplay.SetStars(
scr.score.stars,
scr.score.stars <= 5 ? StarType.Standard : StarType.Gold
);
Expand All @@ -125,11 +123,11 @@ public void Setup(PlayerManager.Player player, ClearStatus cs, bool isHighScore)
} else if (isHighScore) {
bottomBannerText.text = "HIGH SCORE";
} else {
bottomBannerText.text = String.Empty;
bottomBannerText.text = string.Empty;
}

// only compress banner if nothing or to prep for animation (high score)
if (bottomBannerText.text == String.Empty || bottomBannerText.text == "HIGH SCORE") {
if (bottomBannerText.text == string.Empty || bottomBannerText.text == "HIGH SCORE") {
bottomBanner.gameObject.GetComponent<LayoutElement>().flexibleHeight = 0f;
}

Expand Down Expand Up @@ -203,5 +201,5 @@ private void OnDisable() {
player.inputStrategy.GenericNavigationEvent -= OnGenericNavigation;
}
}
}
}
}

0 comments on commit 3279990

Please sign in to comment.