Skip to content

Commit

Permalink
improved dta parsing (#267)
Browse files Browse the repository at this point in the history
* add hopo_threshold support to please jnack

* fix DXT3 image byte parsing

* DXT3 loop cleanup

* hopo threshold fix

* actually reference hopo_threshold this time

* small RB fixes

* expand ExtractedCONSongEntry class

* Fixed icons

* "Reset Camera Settings" button

* Did someone say UPDATE?

* improve dta parsing

---------

Co-authored-by: EliteAsian <lavasnakegaming@gmail.com>
  • Loading branch information
rjkiv and EliteAsian123 authored May 7, 2023
1 parent e5a51ad commit 8fb34a6
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 232 deletions.
390 changes: 185 additions & 205 deletions Assets/Art/Fonts/FontSprites.asset

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/Art/Fonts/FontSprites.asset.meta

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

4 changes: 2 additions & 2 deletions Assets/Art/UI/FontSprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 43 additions & 4 deletions Assets/Scenes/MenuScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,46 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -13
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_Pivot.x
value: 0.0000000060535967
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_Pivot.y
value: 0.5000001
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_LocalScale.x
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_LocalScale.y
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7958013129826989183, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.000005722046
objectReference: {fileID: 0}
- target: {fileID: 7958013129959512565, guid: 3fc0ccbfee2d4c34e91b324e319e71de,
type: 3}
propertyPath: m_AnchorMax.y
Expand Down Expand Up @@ -7292,7 +7332,9 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: v12.34.56
m_text: 'v12.34.56

'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae170e91fd29a90479e906ddffb1d8ee, type: 2}
m_sharedMaterial: {fileID: -5480317595949376055, guid: ae170e91fd29a90479e906ddffb1d8ee,
Expand Down Expand Up @@ -10848,9 +10890,6 @@ MonoBehaviour:
editPlayers: {fileID: 1471919259}
addPlayer: {fileID: 410452336}
credits: {fileID: 365708825}
loadingScreen: {fileID: 784751310}
loadingStatus: {fileID: 1090956613}
progressBar: {fileID: 1649890904}
versionText: {fileID: 528723089}
updateObject: {fileID: 1540998545}
menuButtons:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace YARG {
public static class Constants {
public static readonly YargVersion VERSION_TAG = YargVersion.Parse("v0.10.0b");
public static readonly YargVersion VERSION_TAG = YargVersion.Parse("v0.10.0");

// General
public const float HIT_MARGIN = 0.095f;
Expand Down
28 changes: 19 additions & 9 deletions Assets/Script/Serialization/Xbox/XboxRawfileBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public static List<ExtractedConSongEntry> BrowseFolder(string folder){
currentSong.MoggAudioLength = fs.Length - currentSong.MoggAddressAudioOffset;
MoggBASSInfoGenerator(currentSong, currentArray.Array("song"));

// Debug.Log($"{currentSong.ShortName}:\nMidi path: {currentSong.NotesFile}\nMogg path: {currentSong.MoggPath}\nImage path: {currentSong.ImagePath}");

// will validate the song outside of this class, in SongScanThread.cs
// so okay to add to song list for now
songList.Add(currentSong);
Expand Down Expand Up @@ -171,14 +173,11 @@ public static ExtractedConSongEntry DTAParser(DataArray dta){
cur.HopoThreshold = (dtaArray.Array("hopo_threshold") != null) ? ((DataAtom) dtaArray.Array("hopo_threshold")[1]).Int : 0;
cur.VocalParts = (dtaArray.Array("vocal_parts") != null) ? ((DataAtom) dtaArray.Array("vocal_parts")[1]).Int : 1;
// get the path of the song files
if(dtaArray.Array("midi_file") != null){
string loc = "";
if(dtaArray.Array("midi_file")[1] is DataSymbol symPath)
loc = symPath.Name.Split("/")[1];

else if(dtaArray.Array("midi_file")[1] is DataAtom atmPath)
loc = atmPath.Name.Split("/")[1];
cur.Location = loc;
if(dtaArray.Array("name") != null){
if(dtaArray.Array("name")[1] is DataSymbol symPath)
cur.Location = symPath.Name.Split("/")[1];
else if(dtaArray.Array("name")[1] is DataAtom atmPath)
cur.Location = atmPath.Name.Split("/")[1];
}
else cur.Location = cur.ShortName;
break;
Expand Down Expand Up @@ -213,6 +212,9 @@ public static ExtractedConSongEntry DTAParser(DataArray dta){
cur.PartDifficulties[inst] = DtaDifficulty.ToNumberedDiff(inst, ((DataAtom) inner[1]).Int);
}
}
// Set pro drums
if(cur.PartDifficulties.ContainsKey(Instrument.DRUMS))
cur.PartDifficulties[Instrument.REAL_DRUMS] = cur.PartDifficulties[Instrument.DRUMS];
break;
case "game_origin":
cur.Source = ((DataSymbol) dtaArray[1]).Name;
Expand Down Expand Up @@ -266,6 +268,10 @@ public static ExtractedConSongEntry DTAParser(DataArray dta){

// must be done after the above parallel loop due to race issues with ranks and vocalParts
if(!cur.PartDifficulties.ContainsKey(Instrument.VOCALS) || cur.PartDifficulties[Instrument.VOCALS] == 0) cur.VocalParts = 0;
// Set harmony difficulty (if exists)
else if(cur.PartDifficulties.ContainsKey(Instrument.VOCALS) && cur.VocalParts > 1) {
cur.PartDifficulties[Instrument.HARMONY] = cur.PartDifficulties[Instrument.VOCALS];
}

return cur;
}
Expand Down Expand Up @@ -307,7 +313,11 @@ public static void MoggBASSInfoGenerator(ExtractedConSongEntry song, DataArray d
case "vols":
var volArray = dtaArray[1] as DataArray;
VolumeData = new float[volArray.Count];
for (int v = 0; v < volArray.Count; v++) VolumeData[v] = ((DataAtom) volArray[v]).Float;
for (int v = 0; v < volArray.Count; v++){
var volAtom = (DataAtom) volArray[v];
if(volAtom.Type == DataType.FLOAT) VolumeData[v] = ((DataAtom) volArray[v]).Float;
else VolumeData[v] = ((DataAtom) volArray[v]).Int;
}
break;
case "crowd_channels":
CrowdChannels = new int[dtaArray.Count - 1];
Expand Down
10 changes: 10 additions & 0 deletions Assets/Script/Settings/SettingsManager.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public void CopyCurrentSongTextFilePath() {
GUIUtility.systemCopyBuffer = TwitchController.Instance.TextFilePath;
}

public void ResetCameraSettings() {
TrackCamFOV.Data = 55f;
TrackCamYPos.Data = 2.66f;
TrackCamZPos.Data = 1.14f;
TrackCamRot.Data = 24.12f;

// Force update sliders
GameManager.Instance.SettingsMenu.UpdateSettingsForTab();
}

private static void VSyncCallback(bool value) {
QualitySettings.vSyncCount = value ? 1 : 0;
}
Expand Down
1 change: 1 addition & 0 deletions Assets/Script/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class Tab {
"LowQuality",
"DisableBloom",
new HeaderMetadata("Camera"),
new ButtonRowMetadata("ResetCameraSettings"),
"TrackCamFOV",
"TrackCamYPos",
"TrackCamZPos",
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Settings/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private async UniTask OnDisable() {
}
}

private void UpdateSettingsForTab() {
public void UpdateSettingsForTab() {
if (CurrentTab == "_SongFolderManager") {
UpdateSongFolderManager();

Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Song/Types/RawConSongEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ExtractedConSongEntry : SongEntry {
public float[,] MatrixRatios { get; set; }

// image info
public string ImagePath { get; set; }
public string ImagePath { get; set; } = string.Empty;

}
}
6 changes: 5 additions & 1 deletion Assets/Script/UI/MusicLibrary/DifficultyRing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public void SetInfo(SongEntry songEntry, Instrument instrument) {
}

public void SetInfo(bool hasInstrument, Instrument instrument, int difficulty) {
SetInfo(hasInstrument, instrument.ToStringName(), difficulty);
}

public void SetInfo(bool hasInstrument, string instrumentName, int difficulty) {
// Set instrument icon
var icon = Addressables.LoadAssetAsync<Sprite>($"FontSprites[{instrument.ToStringName()}]").WaitForCompletion();
var icon = Addressables.LoadAssetAsync<Sprite>($"FontSprites[{instrumentName}]").WaitForCompletion();
instrumentIcon.sprite = icon;

// Acceptable difficulty range is -1 to 6
Expand Down
4 changes: 2 additions & 2 deletions Assets/Script/UI/MusicLibrary/Sidebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void UpdateSidebar() {
difficultyRings[6].SetInfo(songEntry, Instrument.REAL_BASS);
}

difficultyRings[7].SetInfo(songEntry.HasInstrument(Instrument.REAL_DRUMS), Instrument.REAL_DRUMS, -1);
difficultyRings[7].SetInfo(false, "trueDrums", -1);
difficultyRings[8].SetInfo(songEntry, Instrument.REAL_KEYS);
difficultyRings[9].SetInfo(songEntry.HasInstrument(Instrument.REAL_DRUMS), Instrument.REAL_DRUMS, -1);
difficultyRings[9].SetInfo(false, "band", -1);
}
}
}
4 changes: 4 additions & 0 deletions Assets/Settings/Localization/Settings Shared Data.asset
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ MonoBehaviour:
m_Key: Header.Cache
m_Metadata:
m_Items: []
- m_Id: 15356265326043136
m_Key: ResetCameraSettings
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
4 changes: 4 additions & 0 deletions Assets/Settings/Localization/Settings_en-US.asset
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ MonoBehaviour:
m_Localized: Cache
m_Metadata:
m_Items: []
- m_Id: 15356265326043136
m_Localized: Reset Camera Settings
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/TextMesh Pro/Resources/TMP Settings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MonoBehaviour:
m_IsTextObjectScaleStatic: 0
m_fallbackFontAssets: []
m_matchMaterialPreset: 1
m_defaultSpriteAsset: {fileID: 11400000, guid: 561a9ddd6c9b8f54a9b206759d0e836e,
m_defaultSpriteAsset: {fileID: 11400000, guid: e5fa1977e0ef0404f8f275b843378e25,
type: 2}
m_defaultSpriteAssetPath: Sprite Assets/
m_enableEmojiSupport: 1
Expand Down

0 comments on commit 8fb34a6

Please sign in to comment.