Skip to content

Commit

Permalink
Apply AvailableParts changes
Browse files Browse the repository at this point in the history
+ Update YARG.Core
  • Loading branch information
sonicfind committed Feb 20, 2024
1 parent 166d7b9 commit 9a5db10
Showing 3 changed files with 37 additions and 37 deletions.
28 changes: 14 additions & 14 deletions Assets/Script/Menu/DifficultySelect/DifficultySelectMenu.cs
Original file line number Diff line number Diff line change
@@ -384,14 +384,14 @@ private void ChangePlayer(int add)
}

var profile = CurrentPlayer.Profile;
var songParts = GlobalVariables.Instance.CurrentSong.Parts;
var song = GlobalVariables.Instance.CurrentSong;

// Get the possible instruments for this song and player
_possibleInstruments.Clear();
var allowedInstruments = profile.GameMode.PossibleInstruments();
foreach (var instrument in allowedInstruments)
{
if (!HasPlayableInstrument(songParts, instrument)) continue;
if (!HasPlayableInstrument(song, instrument)) continue;

_possibleInstruments.Add(instrument);
}
@@ -403,7 +403,7 @@ private void ChangePlayer(int add)
}

// Get the possible harmonies for this song
_maxHarmonyIndex = songParts.VocalsCount;
_maxHarmonyIndex = song.VocalsCount;

// Set the harmony index to a valid one
if (profile.HarmonyIndex >= _maxHarmonyIndex)
@@ -451,12 +451,12 @@ private void UpdatePossibleDifficulties()
_possibleDifficulties.Clear();

var profile = CurrentPlayer.Profile;
var songParts = GlobalVariables.Instance.CurrentSong.Parts;
var song = GlobalVariables.Instance.CurrentSong;

// Get the possible difficulties for the player's instrument in the song
foreach (var difficulty in EnumExtensions<Difficulty>.Values)
{
if (!HasPlayableDifficulty(songParts, profile.CurrentInstrument, difficulty))
if (!HasPlayableDifficulty(song, profile.CurrentInstrument, difficulty))
{
continue;
}
@@ -524,12 +524,12 @@ private void CreateItem(string body, bool selected, UnityAction a)
CreateItem(null, body, selected, a);
}

private bool HasPlayableInstrument(in AvailableParts parts, in Instrument instrument)
private bool HasPlayableInstrument(SongEntry entry, in Instrument instrument)
{
// For vocals, all players *must* select the same gamemode (solo/harmony)
if (instrument is Instrument.Vocals or Instrument.Harmony)
{
if (!parts.HasInstrument(instrument))
if (!entry.HasInstrument(instrument))
{
return false;
}
@@ -547,18 +547,18 @@ private bool HasPlayableInstrument(in AvailableParts parts, in Instrument instru
}
}

return parts.HasInstrument(instrument) || instrument switch
return entry.HasInstrument(instrument) || instrument switch
{
// Allow 5 -> 4-lane conversions to be played on 4-lane
Instrument.FourLaneDrums or
Instrument.ProDrums => parts.HasInstrument(Instrument.FiveLaneDrums),
Instrument.ProDrums => entry.HasInstrument(Instrument.FiveLaneDrums),
// Allow 4 -> 5-lane conversions to be played on 5-lane
Instrument.FiveLaneDrums => parts.HasInstrument(Instrument.ProDrums),
Instrument.FiveLaneDrums => entry.HasInstrument(Instrument.ProDrums),
_ => false
};
}

private bool HasPlayableDifficulty(in AvailableParts parts, in Instrument instrument, in Difficulty difficulty)
private bool HasPlayableDifficulty(SongEntry entry, in Instrument instrument, in Difficulty difficulty)
{
// For vocals, insert special difficulties
if (instrument is Instrument.Vocals or Instrument.Harmony)
@@ -567,13 +567,13 @@ private bool HasPlayableDifficulty(in AvailableParts parts, in Instrument instru
}

// Otherwise, we can do this
return parts[instrument][difficulty] || instrument switch
return entry[instrument][difficulty] || instrument switch
{
// Allow 5 -> 4-lane conversions to be played on 4-lane
Instrument.FourLaneDrums or
Instrument.ProDrums => parts[Instrument.FiveLaneDrums][difficulty],
Instrument.ProDrums => entry[Instrument.FiveLaneDrums][difficulty],
// Allow 4 -> 5-lane conversions to be played on 5-lane
Instrument.FiveLaneDrums => parts[Instrument.ProDrums][difficulty],
Instrument.FiveLaneDrums => entry[Instrument.ProDrums][difficulty],
_ => false
};
}
44 changes: 22 additions & 22 deletions Assets/Script/Menu/MusicLibrary/Sidebar.cs
Original file line number Diff line number Diff line change
@@ -152,14 +152,14 @@ private void ShowSongInfo(SongViewType songViewType)
_length.text = time.ToString(@"m\:ss");
}

UpdateDifficulties(songEntry.Parts);
UpdateDifficulties(songEntry);

_cancellationToken = new();
// Finally, update album cover
LoadAlbumCover();
}

private void UpdateDifficulties(in AvailableParts parts)
private void UpdateDifficulties(SongEntry entry)
{
// Show all difficulty rings
foreach (var difficultyRing in _difficultyRings)
@@ -175,68 +175,68 @@ private void UpdateDifficulties(in AvailableParts parts)
*/


_difficultyRings[0].SetInfo("guitar", "FiveFretGuitar", parts[Instrument.FiveFretGuitar]);
_difficultyRings[1].SetInfo("bass", "FiveFretBass", parts[Instrument.FiveFretBass]);
_difficultyRings[0].SetInfo("guitar", "FiveFretGuitar", entry[Instrument.FiveFretGuitar]);
_difficultyRings[1].SetInfo("bass", "FiveFretBass", entry[Instrument.FiveFretBass]);

// 5-lane or 4-lane
if (parts.GetDrumType() == DrumsType.FiveLane)
if (entry.HasInstrument(Instrument.FiveLaneDrums))
{
_difficultyRings[2].SetInfo("ghDrums", "FiveLaneDrums", parts[Instrument.FiveLaneDrums]);
_difficultyRings[2].SetInfo("ghDrums", "FiveLaneDrums", entry[Instrument.FiveLaneDrums]);
}
else
{
_difficultyRings[2].SetInfo("drums", "FourLaneDrums", parts[Instrument.FourLaneDrums]);
_difficultyRings[2].SetInfo("drums", "FourLaneDrums", entry[Instrument.FourLaneDrums]);
}

_difficultyRings[3].SetInfo("keys", "Keys", parts[Instrument.Keys]);
_difficultyRings[3].SetInfo("keys", "Keys", entry[Instrument.Keys]);

if (parts.HasInstrument(Instrument.Harmony))
if (entry.HasInstrument(Instrument.Harmony))
{
_difficultyRings[4].SetInfo(
parts.VocalsCount switch
entry.VocalsCount switch
{
2 => "twoVocals",
>= 3 => "harmVocals",
_ => "vocals"
},
"Harmony",
parts[Instrument.Harmony]
entry[Instrument.Harmony]
);
}
else
{
_difficultyRings[4].SetInfo("vocals", "Vocals", parts[Instrument.Vocals]);
_difficultyRings[4].SetInfo("vocals", "Vocals", entry[Instrument.Vocals]);
}

// Protar or Co-op
if (parts.HasInstrument(Instrument.ProGuitar_17Fret) || parts.HasInstrument(Instrument.ProGuitar_22Fret))
if (entry.HasInstrument(Instrument.ProGuitar_17Fret) || entry.HasInstrument(Instrument.ProGuitar_22Fret))
{
var values = parts[Instrument.ProGuitar_17Fret];
var values = entry[Instrument.ProGuitar_17Fret];
if (values.Intensity == -1)
values = parts[Instrument.ProGuitar_22Fret];
values = entry[Instrument.ProGuitar_22Fret];
_difficultyRings[5].SetInfo("realGuitar", "ProGuitar", values);
}
else
{
_difficultyRings[5].SetInfo("guitarCoop", "FiveFretCoopGuitar", parts[Instrument.FiveFretCoopGuitar]);
_difficultyRings[5].SetInfo("guitarCoop", "FiveFretCoopGuitar", entry[Instrument.FiveFretCoopGuitar]);
}

// ProBass or Rhythm
if (parts.HasInstrument(Instrument.ProBass_17Fret) || parts.HasInstrument(Instrument.ProBass_22Fret))
if (entry.HasInstrument(Instrument.ProBass_17Fret) || entry.HasInstrument(Instrument.ProBass_22Fret))
{
var values = parts[Instrument.ProBass_17Fret];
var values = entry[Instrument.ProBass_17Fret];
if (values.Intensity == -1)
values = parts[Instrument.ProBass_22Fret];
values = entry[Instrument.ProBass_22Fret];
_difficultyRings[6].SetInfo("realBass", "ProBass", values);
}
else
{
_difficultyRings[6].SetInfo("rhythm", "FiveFretRhythm", parts[Instrument.FiveFretRhythm]);
_difficultyRings[6].SetInfo("rhythm", "FiveFretRhythm", entry[Instrument.FiveFretRhythm]);
}

_difficultyRings[7].SetInfo("trueDrums", "TrueDrums", PartValues.Default);
_difficultyRings[8].SetInfo("realKeys", "ProKeys", parts[Instrument.ProKeys]);
_difficultyRings[9].SetInfo("band", "Band", parts[Instrument.Band]);
_difficultyRings[8].SetInfo("realKeys", "ProKeys", entry[Instrument.ProKeys]);
_difficultyRings[9].SetInfo("band", "Band", entry[Instrument.Band]);
}

public async void LoadAlbumCover()

0 comments on commit 9a5db10

Please sign in to comment.