Skip to content

Commit

Permalink
Finished Ouvert support
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Mar 17, 2023
1 parent 50c0fb1 commit fcef602
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 14 deletions.
13 changes: 12 additions & 1 deletion Assets/Script/Data/SongInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class SongInfo {
};

public bool fetched;
public bool errored;

[JsonProperty]
[JsonConverter(typeof(DirectoryInfoConverter))]
Expand Down Expand Up @@ -151,6 +150,18 @@ public Dictionary<string, int> JsonDiffs {
[JsonProperty]
public float delay;

[JsonProperty]
public string album;
[JsonProperty]
public string genre;
[JsonProperty]
public string charter;
[JsonProperty]
public string year;

[JsonProperty]
public string loadingPhrase;

public Dictionary<string, int> partDifficulties;

public SongInfo(DirectoryInfo folder) {
Expand Down
8 changes: 4 additions & 4 deletions Assets/Script/Serialization/OuvertExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public static void ExportOuvertSongsTo(string path) {
songs.Add(new SongData {
songName = song.SongName,
artistName = song.ArtistName,
album = null,
genre = null,
charter = null,
year = null,
album = song.album,
genre = song.genre,
charter = song.charter,
year = song.year,
songLength = (int) (song.songLength * 1000f)
});
}
Expand Down
15 changes: 13 additions & 2 deletions Assets/Script/Serialization/SongIni.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static SongInfo CompleteSongInfo(SongInfo song) {
} else if (data.Sections.ContainsSection("Song")) {
section = data["Song"];
} else {
song.errored = true;
Debug.LogError($"No `song` section found in `{song.folder}`.");
return song;
}
Expand All @@ -45,6 +44,19 @@ public static SongInfo CompleteSongInfo(SongInfo song) {
song.SongName = section["name"];
song.ArtistName = section["artist"];

// Get other metadata
song.album = section.GetKeyData("album")?.Value;
song.genre = section.GetKeyData("genre")?.Value;
song.year = section.GetKeyData("year")?.Value;
song.loadingPhrase = section.GetKeyData("loading_phrase")?.Value;

// Get charter
if (section.ContainsKey("charter")) {
song.charter = section["charter"];
} else if (section.ContainsKey("frets")) {
song.charter = section["frets"];
}

// Get song source
if (section.ContainsKey("icon") && section["icon"] != "0") {
song.source ??= section["icon"];
Expand Down Expand Up @@ -102,7 +114,6 @@ public static SongInfo CompleteSongInfo(SongInfo song) {
}
}
} catch (Exception e) {
song.errored = true;
Debug.LogError($"Failed to parse song.ini for `{song.folder}`.");
Debug.LogException(e);
}
Expand Down
25 changes: 24 additions & 1 deletion Assets/Script/SongLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using Newtonsoft.Json;
using UnityEngine;
using YARG.Data;
using YARG.Serialization;

namespace YARG {
public static class SongLibrary {
public static DirectoryInfo songFolder = new(@"B:\YARG_Songs");
public static DirectoryInfo songFolder = new(GetSongFolder());

public static float loadPercent = 0f;

Expand All @@ -25,6 +27,27 @@ public static List<SongInfo> Songs {
private set;
} = null;

private static string GetSongFolder() {
if (!string.IsNullOrEmpty(PlayerPrefs.GetString("songFolder"))) {
// Load song folder from player prefs (if available)
return PlayerPrefs.GetString("songFolder");
} else {
// Otherwise look for Clone Hero...
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var cloneHeroPath = Path.Combine(documentsPath, $"Clone Hero{Path.DirectorySeparatorChar}Songs");
var yargPath = Path.Combine(documentsPath, $"YARG{Path.DirectorySeparatorChar}Songs");

if (Directory.Exists(cloneHeroPath)) {
return cloneHeroPath;
} else if (!Directory.Exists(yargPath)) {
Directory.CreateDirectory(yargPath);
}

// And if not, create our own
return yargPath;
}
}

/// <summary>
/// Should be called before you access <see cref="Songs"/>.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions Assets/Script/UI/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public static MainMenu Instance {
private void Start() {
Instance = this;

// Load song folder from player prefs
if (!string.IsNullOrEmpty(PlayerPrefs.GetString("songFolder"))) {
SongLibrary.songFolder = new(PlayerPrefs.GetString("songFolder"));
}

if (!isPostSong) {
ShowMainMenu();
} else {
Expand Down
79 changes: 79 additions & 0 deletions Assets/Settings/AddressableAssetsData/link.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<linker>
<assembly fullname="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="YARG.PlayMode.DrumsTrack" preserve="all" />
<type fullname="YARG.PlayMode.FiveFretTrack" preserve="all" />
<type fullname="YARG.PlayMode.Fret" preserve="all" />
<type fullname="YARG.PlayMode.RealGuitarTrack" preserve="all" />
<type fullname="YARG.Pools.BeatLine" preserve="all" />
<type fullname="YARG.Pools.NoteComponent" preserve="all" />
<type fullname="YARG.Pools.NotePool" preserve="all" />
<type fullname="YARG.Pools.Pool" preserve="all" />
<type fullname="YARG.Util.FadeLight" preserve="all" />
<type fullname="YARG.Util.ParticleGroup" preserve="all" />
<type fullname="YARG.Util.WaveyLight" preserve="all" />
<type fullname="YARG.Pools.Pool/KVP" preserve="nothing" serialized="true" />
</assembly>
<assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
</assembly>
<assembly fullname="Unity.RenderPipelines.Universal.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.Rendering.Universal.UniversalAdditionalCameraData" preserve="all" />
<type fullname="UnityEngine.Rendering.Universal.UniversalAdditionalLightData" preserve="all" />
</assembly>
<assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.SceneProvider" preserve="all" />
</assembly>
<assembly fullname="Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="TMPro.TextMeshPro" preserve="all" />
<type fullname="TMPro.TMP_FontAsset" preserve="all" />
<type fullname="TMPro.FaceInfo_Legacy" preserve="nothing" serialized="true" />
<type fullname="TMPro.FontAssetCreationSettings" preserve="nothing" serialized="true" />
<type fullname="TMPro.KerningTable" preserve="nothing" serialized="true" />
<type fullname="TMPro.TMP_Character" preserve="nothing" serialized="true" />
<type fullname="TMPro.TMP_FontFeatureTable" preserve="nothing" serialized="true" />
<type fullname="TMPro.TMP_FontWeightPair" preserve="nothing" serialized="true" />
<type fullname="TMPro.VertexGradient" preserve="nothing" serialized="true" />
</assembly>
<assembly fullname="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.Camera" preserve="all" />
<type fullname="UnityEngine.GameObject" preserve="all" />
<type fullname="UnityEngine.Light" preserve="all" />
<type fullname="UnityEngine.LineRenderer" preserve="all" />
<type fullname="UnityEngine.Material" preserve="all" />
<type fullname="UnityEngine.Mesh" preserve="all" />
<type fullname="UnityEngine.MeshFilter" preserve="all" />
<type fullname="UnityEngine.MeshRenderer" preserve="all" />
<type fullname="UnityEngine.Object" preserve="all" />
<type fullname="UnityEngine.RectTransform" preserve="all" />
<type fullname="UnityEngine.RenderTexture" preserve="all" />
<type fullname="UnityEngine.Shader" preserve="all" />
<type fullname="UnityEngine.Sprite" preserve="all" />
<type fullname="UnityEngine.Texture2D" preserve="all" />
<type fullname="UnityEngine.Transform" preserve="all" />
<type fullname="UnityEngine.Events.PersistentCallGroup" preserve="nothing" serialized="true" />
</assembly>
<assembly fullname="UnityEngine.ParticleSystemModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.ParticleSystem" preserve="all" />
<type fullname="UnityEngine.ParticleSystemRenderer" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.BoxCollider" preserve="all" />
<type fullname="UnityEngine.MeshCollider" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.Font" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.TextCoreFontEngineModule">
<type fullname="UnityEngine.TextCore.FaceInfo" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.TextCore.Glyph" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.TextCore.GlyphMetrics" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.TextCore.GlyphRect" preserve="nothing" serialized="true" />
</assembly>
<assembly fullname="UnityEngine.UI">
<type fullname="UnityEngine.UI.MaskableGraphic/CullStateChangedEvent" preserve="nothing" serialized="true" />
</assembly>
</linker>
7 changes: 7 additions & 0 deletions Assets/Settings/AddressableAssetsData/link.xml.meta

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

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

0 comments on commit fcef602

Please sign in to comment.