Skip to content

Commit

Permalink
Added "Show Player Name When Starting Song" option, and prevent it fr…
Browse files Browse the repository at this point in the history
…om showing up when in practice mode
  • Loading branch information
EliteAsian123 committed Jan 6, 2025
1 parent 414d0cb commit 6036757
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
37 changes: 27 additions & 10 deletions Assets/Script/Gameplay/HUD/PlayerNameDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
using YARG.Gameplay.Player;
using YARG.Helpers.Extensions;
using YARG.Player;
using YARG.Settings;

namespace YARG.Gameplay.HUD
{
public class PlayerNameDisplay : MonoBehaviour
public class PlayerNameDisplay : GameplayBehaviour
{
[SerializeField]
private TextMeshProUGUI _playerName;
Expand All @@ -27,13 +28,19 @@ public class PlayerNameDisplay : MonoBehaviour
public float DisplayTime = 3.0f;
public float FadeDuration = 0.5f;

void Awake()
protected override void GameplayAwake()
{
_canvasGroup = GetComponent<CanvasGroup>();
_canvasGroup.alpha = 0f;
}

public void ShowPlayer(YargPlayer player)
{
if (!ShouldShowPlayer())
{
return;
}

var profile = player.Profile;
_playerName.text = profile.Name;

Expand All @@ -45,24 +52,34 @@ public void ShowPlayer(YargPlayer player)
StartCoroutine(FadeoutCoroutine());
}

private string GetSpriteName(Instrument currentInstrument, byte harmonyIndex)
public void ShowPlayer(YargPlayer player, int needleId)
{
if (currentInstrument == Instrument.Harmony)
if (!ShouldShowPlayer())
{
return $"HarmonyVocalsIcons[{harmonyIndex + 1}]";
return;
}

return $"InstrumentIcons[{currentInstrument.ToResourceName()}]";
}

public void ShowPlayer(YargPlayer player, int needleId)
{
var textureNeedle = $"VocalNeedleTexture/{needleId}";
_needleIcon.texture = Addressables.LoadAssetAsync<Texture2D>(textureNeedle).WaitForCompletion();
_instrumentIcon.color = GetHarmonyColor(player);
ShowPlayer(player);
}

private bool ShouldShowPlayer()
{
return !GameManager.IsPractice && SettingsManager.Settings.ShowPlayerNameWhenStartingSong.Value;
}

private string GetSpriteName(Instrument currentInstrument, byte harmonyIndex)
{
if (currentInstrument == Instrument.Harmony)
{
return $"HarmonyVocalsIcons[{harmonyIndex + 1}]";
}

return $"InstrumentIcons[{currentInstrument.ToResourceName()}]";
}

private Color GetHarmonyColor(YargPlayer player)
{
if (player.Profile.CurrentInstrument != Instrument.Harmony)
Expand Down
2 changes: 2 additions & 0 deletions Assets/Script/Settings/SettingsManager.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ public void OpenVenueFolder()
CountdownDisplayMode.Disabled
};

public ToggleSetting ShowPlayerNameWhenStartingSong { get; } = new(true);

#endregion

#region File Management
Expand Down
3 changes: 2 additions & 1 deletion Assets/Script/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public static partial class SettingsManager
nameof(Settings.SongTimeOnScoreBox),
nameof(Settings.GraphicalProgressOnScoreBox),
nameof(Settings.KeepSongInfoVisible),
nameof(Settings.CountdownDisplay)
nameof(Settings.CountdownDisplay),
nameof(Settings.ShowPlayerNameWhenStartingSong)
},
new PresetsTab("Presets", icon: "Customization"),
new AllSettingsTab(),
Expand Down
4 changes: 4 additions & 0 deletions Assets/StreamingAssets/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,10 @@
"ReduceNoteSpeedByDifficulty": {
"Name": "Reduce Note Speed by Difficulty",
"Description": "Reduces the note speed if playing on a lower difficulty than Expert. The specified note speed is applied to Expert, and lower difficulties receive a reduction in speed. This setting does not affect vocal tracks."
},
"ShowPlayerNameWhenStartingSong": {
"Name": "Show Player Name When Starting Song",
"Description": "If enabled, the player name and instrument icon will appear when the song starts."
}
},
"PresetType": {
Expand Down

0 comments on commit 6036757

Please sign in to comment.