Skip to content

Commit

Permalink
Fixed multiple issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed May 10, 2023
1 parent c8075ed commit b1dc6cd
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 34 deletions.
16 changes: 8 additions & 8 deletions Assets/Prefabs/UI/MusicLibrary/MusicLibrary.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -3495,7 +3495,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 4030813026385655377}
m_TargetAssemblyTypeName: YARG.UI.MusicLibrary.Sidebar, Assembly-CSharp
m_MethodName: PlaySong
m_MethodName: PrimaryButtonClick
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
Expand Down Expand Up @@ -4638,7 +4638,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_Mode: 0
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
Expand Down Expand Up @@ -5314,9 +5314,9 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: YARG.UI.SelectedSongView, Assembly-CSharp
m_MethodName: PlaySong
- m_Target: {fileID: 4030813026385655377}
m_TargetAssemblyTypeName: YARG.UI.MusicLibrary.Sidebar, Assembly-CSharp
m_MethodName: PrimaryButtonClick
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
Expand Down Expand Up @@ -5394,9 +5394,9 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: YARG.UI.SelectedSongView, Assembly-CSharp
m_MethodName: PlaySong
- m_Target: {fileID: 4030813026385655377}
m_TargetAssemblyTypeName: YARG.UI.MusicLibrary.Sidebar, Assembly-CSharp
m_MethodName: PrimaryButtonClick
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Prefabs/UI/MusicLibrary/SongView.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
Expand Down
10 changes: 5 additions & 5 deletions Assets/Script/Audio/Interfaces/IAudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace YARG {
public interface IAudioManager {
public bool UseStarpowerFx { get; set; }
public bool UseStarpowerFx { get; set; }
public bool IsChipmunkSpeedup { get; set; }

public IList<string> SupportedFormats { get; }

public bool IsAudioLoaded { get; }
public bool IsPlaying { get; }

public double MasterVolume { get; }
public double SfxVolume { get; }

Expand All @@ -31,10 +31,10 @@ public interface IAudioManager {
public void UnloadSong();

public void LoadPreviewAudio(SongEntry song);

public void Play();
public void Pause();

public void FadeIn();
public void FadeOut();

Expand All @@ -43,7 +43,7 @@ public interface IAudioManager {
public void SetStemVolume(SongStem stem, double volume);

public void UpdateVolumeSetting(SongStem stem, double volume);

public double GetVolumeSetting(SongStem stem);

public void ApplyReverb(SongStem stem, bool reverb);
Expand Down
8 changes: 3 additions & 5 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using UnityEngine.InputSystem;
using YARG.Chart;
using YARG.Data;
using YARG.Serialization;
using YARG.Serialization.Parser;
using YARG.Settings;
using YARG.Song;
Expand Down Expand Up @@ -117,8 +116,7 @@ private void StartSong() {
// Load MOGG if CON, otherwise load stems
if (song is ExtractedConSongEntry rawConSongEntry) {
GameManager.AudioManager.LoadMogg(rawConSongEntry, isSpeedUp);
}
else {
} else {
var stems = AudioHelpers.GetSupportedStems(song.Location);

GameManager.AudioManager.LoadSong(stems, isSpeedUp);
Expand Down Expand Up @@ -165,7 +163,7 @@ private void StartSong() {

// Hide loading screen
GameUI.Instance.loadingContainer.SetActive(false);

realSongTime = SONG_START_OFFSET;
StartCoroutine(StartAudio());

Expand Down Expand Up @@ -225,7 +223,7 @@ private IEnumerator StartAudio() {
realSongTime += Time.deltaTime;
yield return null;
}

GameManager.AudioManager.Play();
audioStarted = true;
}
Expand Down
16 changes: 14 additions & 2 deletions Assets/Script/Serialization/Xbox/XboxCONInnerFileRetriever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;

namespace YARG.Serialization {
Expand All @@ -27,8 +28,19 @@ await UniTask.RunOnThreadPool(() => {
return f;
}

public static byte[] RetrieveFile(string location, uint filesize, uint[] fileOffsets) {
return RetrieveFile(location, filesize, fileOffsets, null).AsTask().Result;
public static byte[] RetrieveFile(string CONname, uint filesize, uint[] fileOffsets) {
// TEMP: Merge with above. Doesn't work in sync for some reason

byte[] f = new byte[filesize];
uint lastSize = filesize % 0x1000;
Parallel.For(0, fileOffsets.Length, i => {
uint ReadLen = (i == fileOffsets.Length - 1) ? lastSize : 0x1000;
using var fs = new FileStream(CONname, FileMode.Open, FileAccess.Read);
using var br = new BinaryReader(fs, new ASCIIEncoding());
fs.Seek(fileOffsets[i], SeekOrigin.Begin);
Array.Copy(br.ReadBytes((int) ReadLen), 0, f, i * 0x1000, (int) ReadLen);
});
return f;
}
}
}
9 changes: 2 additions & 7 deletions Assets/Script/UI/MusicLibrary/Sidebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,9 @@ private async UniTask LoadExtractedRbConCover(ExtractedConSongEntry conSongEntry
}
}

public void PlaySong() {
public void PrimaryButtonClick() {
var viewType = SongSelection.Instance.Songs[SongSelection.Instance.SelectedIndex];
if (viewType is not SongViewType songViewType) {
return;
}

MainMenu.Instance.chosenSong = songViewType.SongEntry;
MainMenu.Instance.ShowPreSong();
viewType.PrimaryButtonClick();
}

public void SearchFilter(string type) {
Expand Down
13 changes: 7 additions & 6 deletions Assets/Script/UI/MusicLibrary/SongSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,17 @@ private void OnGenericNavigation(NavigationType navigationType, bool pressed) {
return;
}

SongViewType view = _songs[SelectedIndex] as SongViewType;
switch (navigationType) {
case NavigationType.UP: SelectedIndex--; break;
case NavigationType.DOWN: SelectedIndex++; break;
// case NavigationType.PRIMARY: selectedSongView.PlaySong(); break;
case NavigationType.PRIMARY: view?.PrimaryButtonClick(); break;
case NavigationType.SECONDARY: Back(); break;
// case NavigationType.TERTIARY:
// if (songs.Count > 0) {
// searchField.text = $"artist:{songs[selectedSongIndex].song.Artist}";
// }
// break;
case NavigationType.TERTIARY:
if (view != null) {
searchField.text = $"artist:{view.SongEntry.Artist}";
}
break;
}
}

Expand Down
7 changes: 7 additions & 0 deletions Assets/Script/UI/MusicLibrary/ViewTypes/SongViewType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@ public override void SecondaryTextClick() {

SongSelection.Instance.searchField.text = $"artist:{SongEntry.Artist}";
}

public override void PrimaryButtonClick() {
base.PrimaryButtonClick();

MainMenu.Instance.chosenSong = SongEntry;
MainMenu.Instance.ShowPreSong();
}
}
}
4 changes: 4 additions & 0 deletions Assets/Script/UI/MusicLibrary/ViewTypes/ViewType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ public enum BackgroundType {
public virtual void SecondaryTextClick() {

}

public virtual void PrimaryButtonClick() {

}
}
}

0 comments on commit b1dc6cd

Please sign in to comment.