1
0
mirror of synced 2025-02-21 12:49:31 +01:00

migration to tja2fumen

-> Use tja2Fumen instead of tja2bin
-> Added logic to grab the latest in a folder
-> Removed usage of fumen offset as tja2bin & tja2fumen inject that into the generated file
This commit is contained in:
Fluto 2023-07-16 13:40:26 +10:00
parent c269bcab60
commit f728d694b3
7 changed files with 140 additions and 113 deletions

View File

@ -56,6 +56,11 @@ To begin place custom songs in `SongDirectory` specified in your configuration f
Each song must have it's own directory with a unique name. Each song must have it's own directory with a unique name.
These songs can be nested within folders. These songs can be nested within folders.
### Updating tja2fumen
tja2fumen is developed by [vivaria](https://github.com/vivaria) and may be updated over time. If there is a new update feel free to grab their latest version for their tja conversion program at https://github.com/vivaria/tja2fumen/releases/latest.
After downloading the .exe file, place it in your `.\BepInEx\plugins\com.fluto.takotako` folder :)
### Structure
The folder must have this structure: The folder must have this structure:
``` ```
Offical Songs Offical Songs
@ -178,7 +183,8 @@ LANG=ja_JP` followed by `7z x path/to/zip`. This will correct the mojibake (garb
## Credits ## Credits
- [SonicAudioTools](https://github.com/blueskythlikesclouds/SonicAudioTools) - [SonicAudioTools](https://github.com/blueskythlikesclouds/SonicAudioTools)
- [VGAudio](https://github.com/Thealexbarney/VGAudio) - [VGAudio](https://github.com/Thealexbarney/VGAudio)
- Pulsar#5356 for the TJA2BIN.exe - [tja2fumen](https://github.com/vivaria/tja2fumen) Thank you vivaria for making an open source tja interpreter!
- Pulsar#5356 for their previous work on TJA2BIN.exe
## Licensing ## Licensing
Uses the following licensed libraries. Uses the following licensed libraries.

View File

@ -225,7 +225,7 @@ namespace TJAConvert
branchMania = false, branchMania = false,
branchUra = false, branchUra = false,
previewPos = (int) (metadata.PreviewTime * 1000) + addedTime, previewPos = (int) (metadata.PreviewTime * 1000) + addedTime,
fumenOffsetPos = (int) (metadata.Offset * 10) + (addedTime), fumenOffsetPos = /*(int) (metadata.Offset * 1000) +*/ (addedTime), // tja2bin and tja2fumen use this value, so it can be ignored here :)
tjaFileHash = tjaHash, tjaFileHash = tjaHash,
songName = new TextEntry() songName = new TextEntry()
{ {

View File

@ -66,7 +66,7 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuildCopy" AfterTargets="PostBuildEvent"> <Target Name="PostBuildCopy" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(ProjectDir)..\TakoTako\Executables\tja2bin.exe" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="true" /> <Copy SourceFiles="$(ProjectDir)..\TakoTako\Executables\tja2fumen.exe" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(TargetDir)TJAConvert.exe" DestinationFolder="$(ProjectDir)..\TakoTako\Executables" SkipUnchangedFiles="true" /> <Copy SourceFiles="$(TargetDir)TJAConvert.exe" DestinationFolder="$(ProjectDir)..\TakoTako\Executables" SkipUnchangedFiles="true" />
</Target> </Target>
</Project> </Project>

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
@ -75,7 +76,7 @@ public class CustomMusicLoaderPatch
else else
{ {
using var fileStream = File.OpenRead(savePath); using var fileStream = File.OpenRead(savePath);
data = (CustomMusicSaveDataBody) JsonConvert.DeserializeObject<CustomMusicSaveDataBodySerializable>(File.ReadAllText(savePath)); data = (CustomMusicSaveDataBody)JsonConvert.DeserializeObject<CustomMusicSaveDataBodySerializable>(File.ReadAllText(savePath));
data.CustomTrackToEnsoRecordInfo ??= new System.Collections.Generic.Dictionary<int, EnsoRecordInfo[]>(); data.CustomTrackToEnsoRecordInfo ??= new System.Collections.Generic.Dictionary<int, EnsoRecordInfo[]>();
data.CustomTrackToMusicInfoEx ??= new System.Collections.Generic.Dictionary<int, MusicInfoEx>(); data.CustomTrackToMusicInfoEx ??= new System.Collections.Generic.Dictionary<int, MusicInfoEx>();
} }
@ -119,7 +120,7 @@ public class CustomMusicLoaderPatch
{ {
var data = GetCustomSaveData(); var data = GetCustomSaveData();
var savePath = SaveFilePath; var savePath = SaveFilePath;
var json = JsonConvert.SerializeObject((CustomMusicSaveDataBodySerializable) data); var json = JsonConvert.SerializeObject((CustomMusicSaveDataBodySerializable)data);
using Stream fs = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None, 4096, FileOptions.WriteThrough); using Stream fs = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None, 4096, FileOptions.WriteThrough);
using var streamWriter = new StreamWriter(fs); using var streamWriter = new StreamWriter(fs);
@ -174,10 +175,12 @@ public class CustomMusicLoaderPatch
Log.LogError(e); Log.LogError(e);
} }
}); });
var tjaPaths = Directory.GetFiles(MusicTrackDirectory, "*.tja", SearchOption.AllDirectories).Select(Path.GetDirectoryName).Distinct().ToList(); var tjaPaths = Directory.GetFiles(MusicTrackDirectory, "*.tja", SearchOption.AllDirectories).Select(Path.GetDirectoryName).Distinct().ToList();
// convert / add TJA songs // convert / add TJA songs
Parallel.ForEach(tjaPaths, new ParallelOptions() {MaxDegreeOfParallelism = 4}, musicDirectory => Parallel.ForEach(tjaPaths, new ParallelOptions()
{
MaxDegreeOfParallelism = 4
}, musicDirectory =>
{ {
try try
{ {
@ -200,11 +203,14 @@ public class CustomMusicLoaderPatch
{ {
var pathName = Path.GetFileName(musicDirectory); var pathName = Path.GetFileName(musicDirectory);
var pluginDirectory = @$"{Environment.CurrentDirectory}\BepInEx\plugins\{PluginInfo.PLUGIN_GUID}"; var pluginDirectory = @$"{Environment.CurrentDirectory}\BepInEx\plugins\{PluginInfo.PLUGIN_GUID}";
var tjaConvertPath = @$"{pluginDirectory}\TJAConvert.exe"; var tjaConvertPath = @$"{pluginDirectory}\TJAConvert.exe";
var tja2BinConvertPath = @$"{pluginDirectory}\tja2bin.exe"; var tja2FumenConvertPath = GetTja2FumenPath();
if (!File.Exists(tjaConvertPath) || !File.Exists(tja2BinConvertPath))
if (!File.Exists(tjaConvertPath) || string.IsNullOrWhiteSpace(tja2FumenConvertPath) || !File.Exists(tja2FumenConvertPath))
throw new Exception("Cannot find .exes in plugin folder"); throw new Exception("Cannot find .exes in plugin folder");
Log.LogInfo($"Using {tja2FumenConvertPath} for generating TJAs");
Log.LogInfo($"Converting {pathName}"); Log.LogInfo($"Converting {pathName}");
var info = new ProcessStartInfo() var info = new ProcessStartInfo()
{ {
@ -222,7 +228,7 @@ public class CustomMusicLoaderPatch
process.StartInfo = info; process.StartInfo = info;
process.Start(); process.Start();
var result = process.StandardOutput.ReadToEnd(); var result = process.StandardOutput.ReadToEnd();
var resultLines = result.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries); var resultLines = result.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in resultLines) foreach (var line in resultLines)
{ {
@ -325,6 +331,52 @@ public class CustomMusicLoaderPatch
return customSongsList; return customSongsList;
string GetTja2FumenPath()
{
// determine conversion program
var pluginDirectory = @$"{Environment.CurrentDirectory}\BepInEx\plugins\{PluginInfo.PLUGIN_GUID}";
// var tjaConvertPath = @$"{pluginDirectory}\TJAConvert.exe";
var files = Directory
.EnumerateFiles(pluginDirectory)
.Where(x =>
x.Contains("tja2fumen", StringComparison.InvariantCultureIgnoreCase)
&& x.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)).ToList();
// if something is just called tja2fumen.exe use that
var foundFile = files.FirstOrDefault(x => x.Contains("tja2fumen.exe", StringComparison.InvariantCultureIgnoreCase));
if (!string.IsNullOrWhiteSpace(foundFile))
return foundFile;
var regex = new Regex(@"tja2fumen\-(?<VERSION>\d?.?\d+.\d+.\d+)\.exe");
var versionPaths = files
.Select(x =>
{
var match = regex.Match(x);
Version version = null;
if (match.Success)
Version.TryParse(match.Groups["VERSION"].Value, out version);
return (x, version);
})
.Where(x => x.version != null)
.OrderByDescending(x => x.version)
.FirstOrDefault();
// try and pick the last version
if (versionPaths.version != null)
return versionPaths.x;
// just pick the first one
if (files.Count > 0)
return files[0];
var originalPath = @$"{pluginDirectory}\tja2bin.exe";
if (File.Exists(originalPath))
return originalPath;
return null;
}
void SubmitDirectory(string directory, bool isTjaSong) void SubmitDirectory(string directory, bool isTjaSong)
{ {
var dataPath = Path.Combine(directory, "data.json"); var dataPath = Path.Combine(directory, "data.json");
@ -382,7 +434,7 @@ public class CustomMusicLoaderPatch
else else
{ {
// For official songs, we can just use the hash of the song internal name. // For official songs, we can just use the hash of the song internal name.
song.UniqueId = (int) (MurmurHash2.Hash(song.id) & 0xFFFF_FFF); song.UniqueId = (int)(MurmurHash2.Hash(song.id) & 0xFFFF_FFF);
} }
if (song.UniqueId <= SaveDataMax) if (song.UniqueId <= SaveDataMax)
@ -490,62 +542,23 @@ public class CustomMusicLoaderPatch
false, false,
0, 0,
true, // can we capture footage true, // can we capture footage
2, // Always mark custom songs as "both players need to have this song to play it" 2, // Always mark custom songs as "both players need to have this song to play it"
new[] new[] { song.branchEasy, song.branchNormal, song.branchHard, song.branchMania, song.branchUra },
{ new[] { song.starEasy, song.starNormal, song.starHard, song.starMania, song.starUra },
song.branchEasy, new[] { song.shinutiEasy, song.shinutiNormal, song.shinutiHard, song.shinutiMania, song.shinutiUra },
song.branchNormal, new[] { song.shinutiEasyDuet, song.shinutiNormalDuet, song.shinutiHardDuet, song.shinutiManiaDuet, song.shinutiUraDuet },
song.branchHard, new[] { song.scoreEasy, song.scoreNormal, song.scoreHard, song.scoreMania, song.scoreUra }
song.branchMania,
song.branchUra
}, new[]
{
song.starEasy,
song.starNormal,
song.starHard,
song.starMania,
song.starUra
}, new[]
{
song.shinutiEasy,
song.shinutiNormal,
song.shinutiHard,
song.shinutiMania,
song.shinutiUra
}, new[]
{
song.shinutiEasyDuet,
song.shinutiNormalDuet,
song.shinutiHardDuet,
song.shinutiManiaDuet,
song.shinutiUraDuet
}, new[]
{
song.scoreEasy,
song.scoreNormal,
song.scoreHard,
song.scoreMania,
song.scoreUra
}
#if TAIKO_IL2CPP #if TAIKO_IL2CPP
, 0, // no idea what this is, going to mark them as default for now :) , 0, // no idea what this is, going to mark them as default for now :)
string.Empty, // no idea what this is, going to mark them as default for now :) string.Empty, // no idea what this is, going to mark them as default for now :)
string.Empty, // no idea what this is, going to mark them as default for now :) string.Empty, // no idea what this is, going to mark them as default for now :)
false, // no idea what this is, going to mark them as default for now :), false, // no idea what this is, going to mark them as default for now :),
new[] // no idea what this is, setting it to shinuti score new[] // no idea what this is, setting it to shinuti score
{ {
song.shinutiEasy, song.shinutiEasy, song.shinutiNormal, song.shinutiHard, song.shinutiMania, song.shinutiUra
song.shinutiNormal,
song.shinutiHard,
song.shinutiMania,
song.shinutiUra
}, new[] // no idea what this is, setting it to shinuti duet score }, new[] // no idea what this is, setting it to shinuti duet score
{ {
song.shinutiEasyDuet, song.shinutiEasyDuet, song.shinutiNormalDuet, song.shinutiHardDuet, song.shinutiManiaDuet, song.shinutiUraDuet
song.shinutiNormalDuet,
song.shinutiHardDuet,
song.shinutiManiaDuet,
song.shinutiUraDuet
} }
#endif #endif
); );
@ -966,7 +979,7 @@ public class CustomMusicLoaderPatch
for (int k = 0; k < 5; k++) for (int k = 0; k < 5; k++)
{ {
GetPlayerRecordInfo(playDataMgr, 0, musicInfoAccess[j].UniqueId, (EnsoData.EnsoLevelType) k, out var dst4); GetPlayerRecordInfo(playDataMgr, 0, musicInfoAccess[j].UniqueId, (EnsoData.EnsoLevelType)k, out var dst4);
song2.NotPlayed[k] = dst4.playCount <= 0; song2.NotPlayed[k] = dst4.playCount <= 0;
song2.NotCleared[k] = dst4.crown < DataConst.CrownType.Silver; song2.NotCleared[k] = dst4.crown < DataConst.CrownType.Silver;
song2.NotFullCombo[k] = dst4.crown < DataConst.CrownType.Gold; song2.NotFullCombo[k] = dst4.crown < DataConst.CrownType.Gold;
@ -981,7 +994,7 @@ public class CustomMusicLoaderPatch
song2.HighScores[k].crown = dst4.crown; song2.HighScores[k].crown = dst4.crown;
#endif #endif
GetPlayerRecordInfo(playDataMgr, 1, musicInfoAccess[j].UniqueId, (EnsoData.EnsoLevelType) k, out var dst5); GetPlayerRecordInfo(playDataMgr, 1, musicInfoAccess[j].UniqueId, (EnsoData.EnsoLevelType)k, out var dst5);
song2.NotPlayed2P[k] = dst5.playCount <= 0; song2.NotPlayed2P[k] = dst5.playCount <= 0;
song2.NotCleared2P[k] = dst4.crown < DataConst.CrownType.Silver; song2.NotCleared2P[k] = dst4.crown < DataConst.CrownType.Silver;
song2.NotFullCombo2P[k] = dst5.crown < DataConst.CrownType.Gold; song2.NotFullCombo2P[k] = dst5.crown < DataConst.CrownType.Gold;
@ -1090,11 +1103,11 @@ public class CustomMusicLoaderPatch
settings.rankMatchType = EnsoData.RankMatchType.None; settings.rankMatchType = EnsoData.RankMatchType.None;
settings.musicuid = selectedSongInfo.Id; settings.musicuid = selectedSongInfo.Id;
settings.musicUniqueId = songUniqueId; settings.musicUniqueId = songUniqueId;
settings.genre = (EnsoData.SongGenre) selectedSongInfo.SongGenre; settings.genre = (EnsoData.SongGenre)selectedSongInfo.SongGenre;
settings.playerNum = 1; settings.playerNum = 1;
var player1Entry = settings.ensoPlayerSettings[0]; var player1Entry = settings.ensoPlayerSettings[0];
player1Entry.neiroId = ensoMode.neiro; player1Entry.neiroId = ensoMode.neiro;
player1Entry.courseType = (EnsoData.EnsoLevelType) selectedCourse; player1Entry.courseType = (EnsoData.EnsoLevelType)selectedCourse;
player1Entry.speed = ensoMode.speed; player1Entry.speed = ensoMode.speed;
player1Entry.dron = ensoMode.dron; player1Entry.dron = ensoMode.dron;
player1Entry.reverse = ensoMode.reverse; player1Entry.reverse = ensoMode.reverse;
@ -1110,13 +1123,13 @@ public class CustomMusicLoaderPatch
{ {
var player2Entry = settings.ensoPlayerSettings[1]; var player2Entry = settings.ensoPlayerSettings[1];
player2Entry.neiroId = ensoMode2P.neiro; player2Entry.neiroId = ensoMode2P.neiro;
player2Entry.courseType = (EnsoData.EnsoLevelType) selectedCourse2P; player2Entry.courseType = (EnsoData.EnsoLevelType)selectedCourse2P;
player2Entry.speed = ensoMode2P.speed; player2Entry.speed = ensoMode2P.speed;
player2Entry.dron = ensoMode2P.dron; player2Entry.dron = ensoMode2P.dron;
player2Entry.reverse = ensoMode2P.reverse; player2Entry.reverse = ensoMode2P.reverse;
player2Entry.randomlv = ensoMode2P.randomlv; player2Entry.randomlv = ensoMode2P.randomlv;
player2Entry.special = ensoMode2P.special; player2Entry.special = ensoMode2P.special;
GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, 1, songUniqueId, (EnsoData.EnsoLevelType) selectedCourse2P, out var dst); GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, 1, songUniqueId, (EnsoData.EnsoLevelType)selectedCourse2P, out var dst);
player2Entry.hiScore = dst.normalHiScore.score; player2Entry.hiScore = dst.normalHiScore.score;
settings.playerNum = 2; settings.playerNum = 2;
settings.ensoPlayerSettings[1] = player2Entry; settings.ensoPlayerSettings[1] = player2Entry;
@ -1127,13 +1140,13 @@ public class CustomMusicLoaderPatch
settings.isRandomSelect = selectedSongInfo.IsRandomSelect; settings.isRandomSelect = selectedSongInfo.IsRandomSelect;
settings.isDailyBonus = selectedSongInfo.IsDailyBonus; settings.isDailyBonus = selectedSongInfo.IsDailyBonus;
ensoMode.songUniqueId = settings.musicUniqueId; ensoMode.songUniqueId = settings.musicUniqueId;
ensoMode.level = (EnsoData.EnsoLevelType) selectedCourse; ensoMode.level = (EnsoData.EnsoLevelType)selectedCourse;
__instance.settings = settings; __instance.settings = settings;
__instance.ensoMode = ensoMode; __instance.ensoMode = ensoMode;
__instance.SetSaveDataEnsoMode(CourseSelect.PlayerType.Player1); __instance.SetSaveDataEnsoMode(CourseSelect.PlayerType.Player1);
ensoMode2P.songUniqueId = settings.musicUniqueId; ensoMode2P.songUniqueId = settings.musicUniqueId;
ensoMode2P.level = (EnsoData.EnsoLevelType) selectedCourse2P; ensoMode2P.level = (EnsoData.EnsoLevelType)selectedCourse2P;
__instance.ensoMode2P = ensoMode2P; __instance.ensoMode2P = ensoMode2P;
__instance.SetSaveDataEnsoMode(CourseSelect.PlayerType.Player2); __instance.SetSaveDataEnsoMode(CourseSelect.PlayerType.Player2);
@ -1151,7 +1164,7 @@ public class CustomMusicLoaderPatch
settings.voiceVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.Voice); settings.voiceVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.Voice);
settings.bgmVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.Bgm); settings.bgmVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.Bgm);
settings.neiroVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.InGameNeiro); settings.neiroVolume = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySoundManager.GetVolume(SoundManager.SoundType.InGameNeiro);
settings.effectLevel = (EnsoData.EffectLevel) dst2.qualityLevel; settings.effectLevel = (EnsoData.EffectLevel)dst2.qualityLevel;
__instance.settings = settings; __instance.settings = settings;
#if TAIKO_IL2CPP #if TAIKO_IL2CPP
ensoDataManager.SetSettingsRemake(ref settings); ensoDataManager.SetSettingsRemake(ref settings);
@ -1204,20 +1217,20 @@ public class CustomMusicLoaderPatch
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.EnsoData.CopySettings(out var dst); TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.EnsoData.CopySettings(out var dst);
#endif #endif
__instance.music_id = dst.musicuid; __instance.music_id = dst.musicuid;
__instance.genre = (int) dst.genre; __instance.genre = (int)dst.genre;
__instance.course_type = (int) dst.ensoPlayerSettings[0].courseType; __instance.course_type = (int)dst.ensoPlayerSettings[0].courseType;
__instance.neiro_id = dst.ensoPlayerSettings[0].neiroId; __instance.neiro_id = dst.ensoPlayerSettings[0].neiroId;
__instance.speed = (int) dst.ensoPlayerSettings[0].speed; __instance.speed = (int)dst.ensoPlayerSettings[0].speed;
__instance.dron = (int) dst.ensoPlayerSettings[0].dron; __instance.dron = (int)dst.ensoPlayerSettings[0].dron;
__instance.reverse = (int) dst.ensoPlayerSettings[0].reverse; __instance.reverse = (int)dst.ensoPlayerSettings[0].reverse;
__instance.randomlv = (int) dst.ensoPlayerSettings[0].randomlv; __instance.randomlv = (int)dst.ensoPlayerSettings[0].randomlv;
__instance.special = (int) dst.ensoPlayerSettings[0].special; __instance.special = (int)dst.ensoPlayerSettings[0].special;
PlayDataManager playData = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData; PlayDataManager playData = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData;
playData.GetEnsoMode(out var dst2); playData.GetEnsoMode(out var dst2);
__instance.sort_course = (int) dst2.songSortCourse; __instance.sort_course = (int)dst2.songSortCourse;
__instance.sort_type = (int) dst2.songSortType; __instance.sort_type = (int)dst2.songSortType;
__instance.sort_filter = (int) dst2.songFilterType; __instance.sort_filter = (int)dst2.songFilterType;
__instance.sort_favorite = (int) dst2.songFilterTypeFavorite; __instance.sort_favorite = (int)dst2.songFilterTypeFavorite;
MusicDataInterface.MusicInfoAccesser[] array = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.MusicData.musicInfoAccessers.ToArray(); MusicDataInterface.MusicInfoAccesser[] array = TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.MusicData.musicInfoAccessers.ToArray();
#if TAIKO_IL2CPP #if TAIKO_IL2CPP
playData.GetMusicInfoExAllIl2cpp(0, out var dst3); playData.GetMusicInfoExAllIl2cpp(0, out var dst3);
@ -1296,7 +1309,7 @@ public class CustomMusicLoaderPatch
return; return;
} }
int num = (int) levelType; int num = (int)levelType;
if (num is < 0 or >= 5) if (num is < 0 or >= 5)
num = 0; num = 0;
@ -1304,7 +1317,7 @@ public class CustomMusicLoaderPatch
var saveData = GetCustomSaveData().CustomTrackToEnsoRecordInfo; var saveData = GetCustomSaveData().CustomTrackToEnsoRecordInfo;
if (!saveData.TryGetValue(uniqueId, out var ensoData)) if (!saveData.TryGetValue(uniqueId, out var ensoData))
{ {
ensoData = new EnsoRecordInfo[(int) EnsoData.EnsoLevelType.Num]; ensoData = new EnsoRecordInfo[(int)EnsoData.EnsoLevelType.Num];
saveData[uniqueId] = ensoData; saveData[uniqueId] = ensoData;
} }
@ -1323,7 +1336,7 @@ public class CustomMusicLoaderPatch
for (int levelType = 0; levelType < __instance.selectedSongInfo.HighScores.Length; ++levelType) for (int levelType = 0; levelType < __instance.selectedSongInfo.HighScores.Length; ++levelType)
{ {
EnsoRecordInfo dst; EnsoRecordInfo dst;
GetPlayerRecordInfo(__instance.playDataManager, 0, song.UniqueId, (EnsoData.EnsoLevelType) levelType, out dst); GetPlayerRecordInfo(__instance.playDataManager, 0, song.UniqueId, (EnsoData.EnsoLevelType)levelType, out dst);
var highScore = __instance.selectedSongInfo.HighScores[levelType]; var highScore = __instance.selectedSongInfo.HighScores[levelType];
highScore.hiScoreRecordInfos = dst.normalHiScore; highScore.hiScoreRecordInfos = dst.normalHiScore;
highScore.crown = dst.crown; highScore.crown = dst.crown;
@ -1342,7 +1355,8 @@ public class CustomMusicLoaderPatch
Animator iconCrown2 = __instance.diffCourseAnims[levelType].IconCrowns[1]; Animator iconCrown2 = __instance.diffCourseAnims[levelType].IconCrowns[1];
if (__instance.status.Is2PActive) if (__instance.status.Is2PActive)
{ {
GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, 1, __instance.selectedSongInfo.UniqueId, (EnsoData.EnsoLevelType) levelType, out var dst); GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, 1, __instance.selectedSongInfo.UniqueId,
(EnsoData.EnsoLevelType)levelType, out var dst);
switch (dst.crown) switch (dst.crown)
{ {
case DataConst.CrownType.Silver: case DataConst.CrownType.Silver:
@ -1376,7 +1390,8 @@ public class CustomMusicLoaderPatch
[HarmonyWrapSafe] [HarmonyWrapSafe]
public static void UpdateDisplay_Postfix(CourseSelectScoreDisplay __instance, int musicUniqueId, EnsoData.EnsoLevelType levelType) public static void UpdateDisplay_Postfix(CourseSelectScoreDisplay __instance, int musicUniqueId, EnsoData.EnsoLevelType levelType)
{ {
GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, __instance.playerType == DataConst.PlayerType.Player_1 ? 0 : 1, musicUniqueId, levelType, out var dst); GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, __instance.playerType == DataConst.PlayerType.Player_1 ? 0 : 1,
musicUniqueId, levelType, out var dst);
var normalHiScore = dst.normalHiScore; var normalHiScore = dst.normalHiScore;
for (int index = 0; index < 6; ++index) for (int index = 0; index < 6; ++index)
{ {
@ -1387,19 +1402,19 @@ public class CustomMusicLoaderPatch
num = normalHiScore.score; num = normalHiScore.score;
break; break;
case 1: case 1:
num = (int) normalHiScore.excellent; num = (int)normalHiScore.excellent;
break; break;
case 2: case 2:
num = (int) normalHiScore.good; num = (int)normalHiScore.good;
break; break;
case 3: case 3:
num = (int) normalHiScore.bad; num = (int)normalHiScore.bad;
break; break;
case 4: case 4:
num = (int) normalHiScore.combo; num = (int)normalHiScore.combo;
break; break;
case 5: case 5:
num = (int) normalHiScore.renda; num = (int)normalHiScore.renda;
break; break;
} }
@ -1420,7 +1435,7 @@ public class CustomMusicLoaderPatch
int num = musicInfoAccesser.Stars[4] > 0 ? 5 : 4; int num = musicInfoAccesser.Stars[4] > 0 ? 5 : 4;
for (int levelType = 0; levelType < num; ++levelType) for (int levelType = 0; levelType < num; ++levelType)
{ {
GetPlayerRecordInfo(playData, playerId, musicInfoAccesser.UniqueId, (EnsoData.EnsoLevelType) levelType, out var dst); GetPlayerRecordInfo(playData, playerId, musicInfoAccesser.UniqueId, (EnsoData.EnsoLevelType)levelType, out var dst);
switch (dst.crown) switch (dst.crown)
{ {
case DataConst.CrownType.Silver: case DataConst.CrownType.Silver:
@ -1453,7 +1468,8 @@ public class CustomMusicLoaderPatch
for (int levelType = 0; levelType < num; ++levelType) for (int levelType = 0; levelType < num; ++levelType)
{ {
GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, playerId, musicUniqueId, (EnsoData.EnsoLevelType) levelType, out var dst); GetPlayerRecordInfo(TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData, playerId, musicUniqueId, (EnsoData.EnsoLevelType)levelType,
out var dst);
__instance.bestScores[levelType].RootObject.SetValue(dst.normalHiScore.score); __instance.bestScores[levelType].RootObject.SetValue(dst.normalHiScore.score);
} }
} }
@ -1464,26 +1480,31 @@ public class CustomMusicLoaderPatch
/// Save scores to custom save data /// Save scores to custom save data
/// </summary> /// </summary>
[HarmonyPatch(typeof(PlayDataManager), "UpdatePlayerScoreRecordInfo", [HarmonyPatch(typeof(PlayDataManager), "UpdatePlayerScoreRecordInfo",
new Type[] {typeof(int), typeof(int), typeof(int), typeof(EnsoData.EnsoLevelType), typeof(bool), typeof(DataConst.SpecialTypes), typeof(HiScoreRecordInfo), typeof(DataConst.ResultType), typeof(bool), typeof(DataConst.CrownType)})] new Type[]
{
typeof(int), typeof(int), typeof(int), typeof(EnsoData.EnsoLevelType), typeof(bool), typeof(DataConst.SpecialTypes), typeof(HiScoreRecordInfo),
typeof(DataConst.ResultType), typeof(bool), typeof(DataConst.CrownType)
})]
[HarmonyPrefix] [HarmonyPrefix]
public static bool UpdatePlayerScoreRecordInfo(PlayDataManager __instance, int playerId, int charaIndex, int uniqueId, EnsoData.EnsoLevelType levelType, bool isSinuchi, DataConst.SpecialTypes spTypes, HiScoreRecordInfo record, public static bool UpdatePlayerScoreRecordInfo(PlayDataManager __instance, int playerId, int charaIndex, int uniqueId, EnsoData.EnsoLevelType levelType, bool isSinuchi,
DataConst.SpecialTypes spTypes, HiScoreRecordInfo record,
DataConst.ResultType resultType, bool savemode, DataConst.CrownType crownType) DataConst.ResultType resultType, bool savemode, DataConst.CrownType crownType)
{ {
if (!uniqueIdToSong.ContainsKey(uniqueId)) if (!uniqueIdToSong.ContainsKey(uniqueId))
return true; return true;
int num = (int) levelType; int num = (int)levelType;
if (num is < 0 or >= 5) if (num is < 0 or >= 5)
num = 0; num = 0;
var saveData = GetCustomSaveData().CustomTrackToEnsoRecordInfo; var saveData = GetCustomSaveData().CustomTrackToEnsoRecordInfo;
if (!saveData.TryGetValue(uniqueId, out var ensoData)) if (!saveData.TryGetValue(uniqueId, out var ensoData))
{ {
ensoData = new EnsoRecordInfo[(int) EnsoData.EnsoLevelType.Num]; ensoData = new EnsoRecordInfo[(int)EnsoData.EnsoLevelType.Num];
saveData[uniqueId] = ensoData; saveData[uniqueId] = ensoData;
} }
EnsoRecordInfo ensoRecordInfo = ensoData[(int) levelType]; EnsoRecordInfo ensoRecordInfo = ensoData[(int)levelType];
#pragma warning disable Harmony003 #pragma warning disable Harmony003
if (ensoRecordInfo.normalHiScore.score <= record.score) if (ensoRecordInfo.normalHiScore.score <= record.score)
{ {
@ -1498,14 +1519,14 @@ public class CustomMusicLoaderPatch
if (crownType != DataConst.CrownType.Off) if (crownType != DataConst.CrownType.Off)
{ {
if (IsValueInRange((int) crownType, 0, 5) && ensoRecordInfo.crown <= crownType) if (IsValueInRange((int)crownType, 0, 5) && ensoRecordInfo.crown <= crownType)
{ {
ensoRecordInfo.crown = crownType; ensoRecordInfo.crown = crownType;
ensoRecordInfo.cleared = crownType >= DataConst.CrownType.Silver; ensoRecordInfo.cleared = crownType >= DataConst.CrownType.Silver;
} }
} }
ensoData[(int) levelType] = ensoRecordInfo; ensoData[(int)levelType] = ensoRecordInfo;
if (savemode && playerId == 0) if (savemode && playerId == 0)
SaveCustomData(); SaveCustomData();
@ -1546,7 +1567,7 @@ public class CustomMusicLoaderPatch
for (int i = 0; i < __instance.SongList.Count; i++) for (int i = 0; i < __instance.SongList.Count; i++)
{ {
#if TAIKO_IL2CPP #if TAIKO_IL2CPP
var song = (SongSelectManager.Song) __instance.SongList[(Index) i]; var song = (SongSelectManager.Song)__instance.SongList[(Index)i];
#elif TAIKO_MONO #elif TAIKO_MONO
var song = __instance.SongList[i]; var song = __instance.SongList[i];
#endif #endif
@ -1758,20 +1779,20 @@ public class CustomMusicLoaderPatch
return testPath; return testPath;
// add every difficulty below this one // add every difficulty below this one
Difficulty difficultyEnum = (Difficulty) Enum.Parse(typeof(Difficulty), difficulty); Difficulty difficultyEnum = (Difficulty)Enum.Parse(typeof(Difficulty), difficulty);
int difficultyInt = (int) difficultyEnum; int difficultyInt = (int)difficultyEnum;
var checkDifficulties = new System.Collections.Generic.List<Difficulty>(); var checkDifficulties = new System.Collections.Generic.List<Difficulty>();
for (int i = 1; i < (int) Difficulty.Count; i++) for (int i = 1; i < (int)Difficulty.Count; i++)
{ {
AddIfInRange(difficultyInt - i); AddIfInRange(difficultyInt - i);
AddIfInRange(difficultyInt + i); AddIfInRange(difficultyInt + i);
void AddIfInRange(int checkDifficulty) void AddIfInRange(int checkDifficulty)
{ {
if (checkDifficulty is >= 0 and < (int) Difficulty.Count) if (checkDifficulty is >= 0 and < (int)Difficulty.Count)
checkDifficulties.Add((Difficulty) checkDifficulty); checkDifficulties.Add((Difficulty)checkDifficulty);
} }
} }
@ -1804,7 +1825,7 @@ public class CustomMusicLoaderPatch
Count, Count,
} }
private static Difficulty[] AllDifficulties = (Difficulty[]) Enum.GetValues(typeof(Difficulty)); private static Difficulty[] AllDifficulties = (Difficulty[])Enum.GetValues(typeof(Difficulty));
#endregion #endregion
@ -1813,7 +1834,7 @@ public class CustomMusicLoaderPatch
private static readonly Regex sheetNameRegex = new Regex("^song_(?<songName>.*?_custom_\\d*?)$"); private static readonly Regex sheetNameRegex = new Regex("^song_(?<songName>.*?_custom_\\d*?)$");
private static readonly Regex songFilePathRegex = new Regex("sound\\/(?<sheetName>.*?)\\.bin$"); private static readonly Regex songFilePathRegex = new Regex("sound\\/(?<sheetName>.*?)\\.bin$");
[HarmonyPatch(typeof(Cryptgraphy), nameof(Cryptgraphy.ReadAllAesBytesAsyncInternal))] [HarmonyPatch(typeof(Cryptgraphy), nameof(Cryptgraphy.ReadAllAesBytesAsyncInternal))]
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyWrapSafe] [HarmonyWrapSafe]
@ -1834,9 +1855,9 @@ public class CustomMusicLoaderPatch
Log.LogError($"Cannot find song : {songName}"); Log.LogError($"Cannot find song : {songName}");
return true; return true;
} }
var newPath = Path.Combine(songInstance.FolderPath, $"{sheetName.Replace(songName, songInstance.SongName)}.bin"); var newPath = Path.Combine(songInstance.FolderPath, $"{sheetName.Replace(songName, songInstance.SongName)}.bin");
var bytes = File.ReadAllBytes(newPath); var bytes = File.ReadAllBytes(newPath);
if (songInstance.areFilesGZipped) if (songInstance.areFilesGZipped)
{ {
@ -2191,7 +2212,7 @@ public class CustomMusicLoaderPatch
public class ConversionItem public class ConversionItem
{ {
[JsonIgnore] public const int CurrentVersion = 2; [JsonIgnore] public const int CurrentVersion = 3;
[JsonIgnore] public const int MaxAttempts = 3; [JsonIgnore] public const int MaxAttempts = 3;
[JsonProperty("f")] public string FolderName; [JsonProperty("f")] public string FolderName;

View File

@ -77,7 +77,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Executables\tja2bin.exe" /> <None Remove="Executables\tja2fumen.exe" />
<None Remove="Executables\**" /> <None Remove="Executables\**" />
<None Remove="Exes\**" /> <None Remove="Exes\**" />
</ItemGroup> </ItemGroup>
@ -98,7 +98,7 @@
<Target Name="PostBuildCopy" AfterTargets="PostBuildEvent"> <Target Name="PostBuildCopy" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetDir)$(AssemblyName).dll" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" /> <Copy SourceFiles="$(TargetDir)$(AssemblyName).dll" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" />
<Copy SourceFiles="$(ProjectDir)\Executables\tja2bin.exe" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" /> <Copy SourceFiles="$(ProjectDir)\Executables\tja2fumen.exe" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" />
<Copy SourceFiles="$(ProjectDir)\Executables\TJAConvert.exe" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" /> <Copy SourceFiles="$(ProjectDir)\Executables\TJAConvert.exe" DestinationFolder="$(GameDir)\BepInEx\plugins\$(AssemblyName)" />
</Target> </Target>
</Project> </Project>