Skip to content

Commit

Permalink
Started Ouvert support
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Mar 17, 2023
1 parent 4513c90 commit 50c0fb1
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 120 deletions.
340 changes: 324 additions & 16 deletions Assets/Scenes/MenuScene.unity

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/Script/Data/SongInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public Dictionary<string, int> JsonDiffs {
[JsonProperty]
public string source;
[JsonProperty]
public float? songLength;
public float songLength;
[JsonProperty]
public float delay;

Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void Update() {
}

// End song
if (realSongTime > song.songLength.Value + 0.5f) {
if (realSongTime > song.songLength + 0.5f) {
MainMenu.isPostSong = true;
Exit();
}
Expand Down
47 changes: 47 additions & 0 deletions Assets/Script/Serialization/OuvertExport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;

namespace YARG.Serialization {
public static class OuvertExport {
private class SongData {
[JsonProperty("Name")]
public string songName;
[JsonProperty("Artist")]
public string artistName;
[JsonProperty("Album")]
public string album;
[JsonProperty("Genre")]
public string genre;
[JsonProperty("Charter")]
public string charter;
[JsonProperty("Year")]
public string year;

// public bool lyrics;
[JsonProperty("songlength")]
public int songLength;
}

public static void ExportOuvertSongsTo(string path) {
var songs = new List<SongData>();

// Convert SongInfo to SongData
foreach (var song in SongLibrary.Songs) {
songs.Add(new SongData {
songName = song.SongName,
artistName = song.ArtistName,
album = null,
genre = null,
charter = null,
year = null,
songLength = (int) (song.songLength * 1000f)
});
}

// Create file
var json = JsonConvert.SerializeObject(songs);
File.WriteAllText(path, json.ToString());
}
}
}
11 changes: 11 additions & 0 deletions Assets/Script/Serialization/OuvertExport.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Script/UI/GameUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void Start() {
}

private void Update() {
songProgress.fillAmount = Play.Instance.SongTime / Play.song.songLength.Value;
songProgress.fillAmount = Play.Instance.SongTime / Play.song.songLength;
}

public void AddTrackImage(RenderTexture rt) {
Expand Down
17 changes: 4 additions & 13 deletions Assets/Script/UI/SelectedSongView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ public void UpdateSongView(SongInfo songInfo) {
}

// Song length
if (songInfo.songLength == null) {
lengthText.text = "N/A";
} else {
int time = (int) songInfo.songLength.Value;
int minutes = time / 60;
int seconds = time % 60;

lengthText.text = $"{minutes}:{seconds:00}";
}
int time = (int) songInfo.songLength;
int minutes = time / 60;
int seconds = time % 60;
lengthText.text = $"{minutes}:{seconds:00}";

// Source
supportText.text = Utils.SourceToGameName(songInfo.source);
Expand Down Expand Up @@ -176,10 +171,6 @@ private IEnumerator LoadAlbumCoverCoroutine(string filePath) {
}

public void PlaySong() {
if (songInfo.songLength == null) {
return;
}

MainMenu.Instance.chosenSong = songInfo;
MainMenu.Instance.ShowPreSong();
}
Expand Down
7 changes: 7 additions & 0 deletions Assets/Script/UI/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YARG.Serialization;

namespace YARG.UI {
public class SettingsMenu : MonoBehaviour {
Expand Down Expand Up @@ -53,6 +54,12 @@ public void SongFolderUpdate() {
}
}

public void OuvertExportButton() {
StandaloneFileBrowser.SaveFilePanelAsync("Save Song List", null, "songs", "json", path => {
OuvertExport.ExportOuvertSongsTo(path);
});
}

public void CalibrationUpdate() {
// Guaranteed to as the input field is decimal
PlayerManager.globalCalibration = float.Parse(calibrationInput.text, CultureInfo.InvariantCulture);
Expand Down
1 change: 1 addition & 0 deletions Assets/Script/Util/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static string SourceToGameName(string source) {
"rbacdc" => "Rock Band AC/DC",
"gdrb" => "Green Day Rock Band",
"lrb" => "Lego Rock Band",
"rbn" => "Rock Band Network",

_ => "Unknown/Custom"
};
Expand Down
79 changes: 0 additions & 79 deletions Assets/Settings/AddressableAssetsData/link.xml

This file was deleted.

7 changes: 0 additions & 7 deletions Assets/Settings/AddressableAssetsData/link.xml.meta

This file was deleted.

3 changes: 1 addition & 2 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ PlayerSettings:
16:9: 1
Others: 1
bundleVersion: 0.1.0
preloadedAssets:
- {fileID: 11400000, guid: 8efbce013f4e1c34895851b7038c76e9, type: 2}
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
Expand Down

0 comments on commit 50c0fb1

Please sign in to comment.