Skip to content

Commit

Permalink
1.34.4 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rcelyte committed Jan 26, 2024
1 parent 80702a0 commit 20fa182
Show file tree
Hide file tree
Showing 37 changed files with 382 additions and 307 deletions.
2 changes: 1 addition & 1 deletion BeatUpClient/BeatUpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<LocalRefsDir Condition="Exists('..\Refs')">..\Refs</LocalRefsDir>
<BeatSaberDir>$(LocalRefsDir)</BeatSaberDir>
<DebugType>full</DebugType>
<ModVersion>0.7.0</ModVersion>
<ModVersion>0.8.0</ModVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil">
Expand Down
31 changes: 21 additions & 10 deletions BeatUpClient/MakeThingsPublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

string managed = Path.Combine("Beat Saber_Data", "Managed");
var refs = new (string path, string name, string[]? overrides)[] {
(managed, "BGNet.dll", new[] {
(managed, "BGNetCore.dll", new[] {
"ClientCertificateValidator::ValidateCertificateChainInternal",
"ConnectedPlayerManager/ConnectedPlayer",
"ConnectedPlayerManager/PlayerConnectedPacket",
Expand All @@ -21,6 +21,7 @@
"LiteNetLibConnectionManager::GetConnectionMessage",
"MasterServerConnectionManager::HandleConnectToServerSuccess",
"MenuRpcManager::_multiplayerSessionManager",
"MenuRpcManager::InvokeSetSelectedBeatmap",
"MultiplayerSessionManager::_packetSerializer",
"NetworkPacketSerializer`2::_messsageHandlers",
"NetworkPacketSerializer`2::_typeRegistry",
Expand Down Expand Up @@ -77,7 +78,6 @@
"BeatmapCharacteristicSegmentedControlController::didSelectBeatmapCharacteristicEvent",
"BeatmapDifficultySegmentedControlController::_difficultySegmentedControl",
"BeatmapDifficultySegmentedControlController::didSelectDifficultyEvent",
"BeatmapLevelsModel::_loadedPreviewBeatmapLevels",
"ColorsOverrideSettingsPanelController::_editColorSchemeButton",
"CustomLevelLoader::_defaultAllDirectionsEnvironmentInfo",
"CustomLevelLoader::_defaultEnvironmentInfo",
Expand All @@ -92,9 +92,6 @@
"GameSongController::_beatmapCallbacksController",
"JoiningLobbyViewController::_loadingControl",
"LevelScenesTransitionSetupDataSO::get_gameplayCoreSceneSetupData",
"LobbyPlayersDataModel::_multiplayerSessionManager",
"LobbyPlayersDataModel::HandleMenuRpcManagerGetRecommendedBeatmap",
"LobbyPlayersDataModel::HandleMultiplayerSessionManagerPlayerConnected",
"MainFlowCoordinator::_simpleDialogPromptViewController",
"MainFlowCoordinator::HandleMainMenuViewControllerDidFinish",
"MainFlowCoordinator::HandleMultiplayerModeSelectionFlowCoordinatorDidFinish",
Expand All @@ -120,9 +117,7 @@
"MultiplayerModeSelectionFlowCoordinator::PresentMasterServerUnavailableErrorDialog",
"MultiplayerModeSelectionViewController::_customServerEndPointText",
"MultiplayerModeSelectionViewController::_maintenanceMessageText",
"MultiplayerStatusModel::_request",
"PCAppInit::TransitionToNextScene",
"QuickPlaySetupModel::_request",
"StandardLevelDetailView::_beatmapCharacteristicSegmentedControlController",
"StandardLevelDetailView::_beatmapDifficultySegmentedControlController",
}),
Expand All @@ -142,9 +137,10 @@
"MultiplayerCore.Patches.DataModelBinderPatch::_playersDataModelMethod",
"MultiplayerCore.Plugin",
}),
(managed, "Polyglot.dll", new[] {
"Polyglot.LocalizationImporter::Import",
"Polyglot.LocalizedTextComponent`1::localizedComponent",
(managed, "BGLib.Polyglot.dll", new[] {
"BGLib.Polyglot.LocalizationImporter::Import",
"BGLib.Polyglot.LocalizationImporter::Initialize",
"BGLib.Polyglot.LocalizedTextComponent`1::localizedComponent",
}),
("Plugins", "SiraUtil.dll", new[] {
"SiraUtil.Affinity.Harmony.HarmonyAffinityPatcher",
Expand Down Expand Up @@ -202,12 +198,27 @@
(managed, "UnityEngine.AudioModule.dll", null),
(managed, "UnityEngine.CoreModule.dll", null),
(managed, "UnityEngine.ImageConversionModule.dll", null),
(managed, "UnityEngine.JSONSerializeModule.dll", null),
(managed, "UnityEngine.UI.dll", null),
(managed, "UnityEngine.UIModule.dll", null),
(managed, "UnityEngine.UnityWebRequestAudioModule.dll", null),
(managed, "UnityEngine.UnityWebRequestModule.dll", null),
(managed, "VRUI.dll", null),
(managed, "Zenject-usage.dll", null),
(managed, "MediaLoader.dll", null),
(managed, "DataModels.dll", new[] {
"BeatmapKey::beatmapCharacteristic",
"BeatmapLevelsModel::_loadedBeatmapLevels",
"FileDifficultyBeatmap::beatmapPath",
"FileDifficultyBeatmap::lightshowPath",
"FileSystemBeatmapLevelData::_audioDataPath",
"FileSystemBeatmapLevelData::_difficultyBeatmaps",
"LobbyPlayersDataModel::_multiplayerSessionManager",
"LobbyPlayersDataModel::HandleMenuRpcManagerGetRecommendedBeatmap",
"LobbyPlayersDataModel::HandleMultiplayerSessionManagerPlayerConnected",
"MultiplayerStatusModel::_request",
"QuickPlaySetupModel::_request",
}),

(managed, "netstandard.dll", null), // TODO: Required by `Hive.Versioning.VersionRange`; remove once beta version check is gone
};
Expand Down
2 changes: 2 additions & 0 deletions BeatUpClient/cs/Detour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ static partial class BeatUpClient {
public static object Base<T1, T2, T3, T4, T5, T6, T7>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) => null!;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public static object Base<T1, T2, T3, T4, T5, T6, T7, T8>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) => null!;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public unsafe static System.IntPtr PassRef<T>(ref T value) => new(System.Runtime.CompilerServices.Unsafe.AsPointer(ref value));
[System.AttributeUsage(System.AttributeTargets.Method)]
public class DetourAttribute : System.Attribute, IPatch { // TODO: make sure all of this works as expected
System.Type type;
Expand Down
36 changes: 12 additions & 24 deletions BeatUpClient/cs/DifficultyPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

static partial class BeatUpClient {
class DifficultyPanel {
class PlaceholderDifficulty : EmptyDifficultyBeatmap, IDifficultyBeatmap {
public new BeatmapDifficulty difficulty {get;}
public PlaceholderDifficulty(BeatmapDifficulty difficulty) =>
this.difficulty = difficulty; // TODO: assign to EmptyDifficultyBeatmap.<difficulty>k__BackingField directly
}
static UnityEngine.GameObject characteristicTemplate = null!;
static UnityEngine.GameObject difficultyTemplate = null!;
BeatmapCharacteristicSegmentedControlController characteristicSelector;
Expand Down Expand Up @@ -50,38 +45,31 @@ class PlaceholderDifficulty : EmptyDifficultyBeatmap, IDifficultyBeatmap {
this.hideHints = hideHints;
}
public void Clear() =>
Update(null, null!);
public void Update(PreviewDifficultyBeatmap? beatmapLevel, System.Action<PreviewDifficultyBeatmap> onChange) {
Update(null, null!, default, null!);
public void Update(BeatmapLevel? beatmapLevel, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, System.Action<BeatmapCharacteristicSO, BeatmapDifficulty> onChange) {
characteristicSelector.transform.parent.gameObject.SetActive(false);
difficultySelector.transform.parent.gameObject.SetActive(false);

characteristicSelector.didSelectBeatmapCharacteristicEvent = delegate {};
difficultySelector.didSelectDifficultyEvent = delegate {};
if(beatmapLevel == null)
return;
System.Collections.Generic.IReadOnlyList<PreviewDifficultyBeatmapSet>? previewSets = beatmapLevel.beatmapLevel.previewDifficultyBeatmapSets;
if(previewSets == null)
return;
PlaceholderDifficulty[]? diffs = previewSets
.FirstOrDefault(set => set.beatmapCharacteristic == beatmapLevel.beatmapCharacteristic && set.beatmapDifficulties?.Length >= 1)
?.beatmapDifficulties.Select(diff => new PlaceholderDifficulty(diff)).ToArray();
difficultySelector.SetData(diffs ?? new[] {new PlaceholderDifficulty(beatmapLevel.beatmapDifficulty)}, beatmapLevel.beatmapDifficulty);
characteristicSelector.SetData(previewSets.Select(set => new DifficultyBeatmapSet(set.beatmapCharacteristic, null!)).ToList(), beatmapLevel.beatmapCharacteristic);
difficultySelector.SetData(beatmapLevel.GetDifficulties(characteristic).DefaultIfEmpty(difficulty), difficulty, BeatmapDifficultyMask.All);
characteristicSelector.SetData(beatmapLevel.GetCharacteristics(), characteristic, new());
if(hideHints)
foreach(HMUI.HoverHint hint in characteristicSelector.GetComponentsInChildren<HMUI.HoverHint>())
hint.enabled = false;
characteristicSelector.didSelectBeatmapCharacteristicEvent += (controller, beatmapCharacteristic) => {
PreviewDifficultyBeatmapSet set = previewSets.First(set => set.beatmapCharacteristic == beatmapCharacteristic);
BeatmapDifficulty closestDifficulty = set.beatmapDifficulties[0];
foreach(BeatmapDifficulty difficulty in set.beatmapDifficulties) {
if(difficulty > beatmapLevel.beatmapDifficulty)
characteristicSelector.didSelectBeatmapCharacteristicEvent += (BeatmapCharacteristicSegmentedControlController controller, BeatmapCharacteristicSO newCharacteristic) => {
BeatmapDifficulty closestDifficulty = beatmapLevel.GetDifficulties(newCharacteristic).First();
foreach(BeatmapDifficulty diff in beatmapLevel.GetDifficulties(newCharacteristic)) {
if(diff > difficulty)
break;
closestDifficulty = difficulty;
closestDifficulty = diff;
}
onChange(new PreviewDifficultyBeatmap(beatmapLevel.beatmapLevel, beatmapCharacteristic, closestDifficulty));
onChange(newCharacteristic, closestDifficulty);
};
difficultySelector.didSelectDifficultyEvent += (controller, difficulty) =>
onChange(new PreviewDifficultyBeatmap(beatmapLevel.beatmapLevel, beatmapLevel.beatmapCharacteristic, difficulty));
difficultySelector.didSelectDifficultyEvent += (BeatmapDifficultySegmentedControlController controller, BeatmapDifficulty newDifficulty) =>
onChange(characteristic, newDifficulty);
characteristicSelector.transform.parent.gameObject.SetActive(true);
difficultySelector.transform.parent.gameObject.SetActive(true);
}
Expand Down
2 changes: 1 addition & 1 deletion BeatUpClient/cs/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static class BeatUpClient_Error {
BeatUpClient.Base(self, viewController, subMenuType);
return;
}
self._simpleDialogPromptViewController.Init(header, message, Polyglot.Localization.Get("BUTTON_OK"), buttonNumber => {
self._simpleDialogPromptViewController.Init(header, message, BGLib.Polyglot.Localization.Get("BUTTON_OK"), buttonNumber => {
skip = true;
self.DismissViewController(self._simpleDialogPromptViewController, HMUI.ViewController.AnimationDirection.Vertical, () =>
self.HandleMainMenuViewControllerDidFinish(viewController, MainMenuViewController.MenuButton.Multiplayer));
Expand Down
2 changes: 1 addition & 1 deletion BeatUpClient/cs/LobbyUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InstantHoverHint : HMUI.HoverHint, UnityEngine.EventSystems.IPointerEnterH
} else {
infoText = UnityEngine.Object.Instantiate(SinglePlayerOnlyTitle.gameObject, MultiplayerSettingsPanel);
infoText.name = "BeatUpClient_Info";
Polyglot.LocalizedTextMeshProUGUI text = infoText.GetComponentInChildren<Polyglot.LocalizedTextMeshProUGUI>();
BGLib.Polyglot.LocalizedTextMeshProUGUI text = infoText.GetComponentInChildren<BGLib.Polyglot.LocalizedTextMeshProUGUI>();
text.localizedComponent.richText = true;
text.Key = "BEATUP_INFO";
}
Expand Down
24 changes: 24 additions & 0 deletions BeatUpClient/cs/Localization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
static partial class BeatUpClient {
[Detour(typeof(BGLib.Polyglot.LocalizationImporter), nameof(BGLib.Polyglot.LocalizationImporter.Initialize))]
static void LocalizationImporter_Initialize(BGLib.Polyglot.LocalizationModel settings) {
Base(settings);

string localization = "Polyglot\t100\n" +
"BEATUP_COUNTDOWN_DURATION\t\tCountdown Duration\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_SKIP_RESULTS_PYRAMID\t\tSkip Results Pyramid\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_PER_PLAYER_DIFFICULTY\t\tPer-Player Difficulty\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_PER_PLAYER_MODIFIERS\t\tPer-Player Modifiers\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_ADD_SERVER\t\tAdd Server\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_EDIT_SERVER\t\tEdit Server\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_ENTER_HOSTNAME\t\tEnter Hostname\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_DIRECT_DOWNLOADS\t\t<color=red>[Experimental]</color> Direct Downloads\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_ENABLE_DIRECT_DOWNLOADS\t\tEnable downloading unmodded custom levels directly from other BeatUpClient users.<br>WARNING: songs may fail to load, and may break BeatTogether lobbies.\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_HIDE_OTHER_LEVELS\t\tHide notes from other players\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_MAY_IMPROVE_PERFORMANCE\t\tMay improve performance\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
$"BEATUP_INFO\t\tBeatUpClient {modVersion} <color=red>| BETA</color> is active.<br>If any issues arise, please contact <color=lightblue>@rcelyte</color> on Discord.\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_SELECTED_MODIFIERS\t\tSelected Modifiers\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_SWITCH\t\tSwitch\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n" +
"BEATUP_LARGE_LOBBY_AUTOKICK\t\tMultiplayerCore is required to play in lobbies with more than 5 players\t"+/*French*/"\t"+/*Spanish*/"\t"+/*German*/"\t\t\t\t\t\t\t\t\t\t\t\t\t"+/*Japanese*/"\t"+/*Simplified Chinese*/"\t\t"+/*Korean*/"\t\t\t\t\t\t\t\t\n";
BGLib.Polyglot.LocalizationImporter.Import(localization, BGLib.Polyglot.GoogleDriveDownloadFormat.TSV);
}
}
2 changes: 1 addition & 1 deletion BeatUpClient/cs/Migration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static class BeatUpClient_Migration {
return;
}
bool dismissed = false;
self._simpleDialogPromptViewController.Init("BeatTogether Migration", "Migrating legacy hostnames...", Polyglot.Localization.Get("BUTTON_CANCEL"), buttonNumber => {
self._simpleDialogPromptViewController.Init("BeatTogether Migration", "Migrating legacy hostnames...", BGLib.Polyglot.Localization.Get("BUTTON_CANCEL"), buttonNumber => {
dismissed = true;
self.DismissViewController(self._simpleDialogPromptViewController, HMUI.ViewController.AnimationDirection.Vertical);
});
Expand Down
2 changes: 1 addition & 1 deletion BeatUpClient/cs/Net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum MessageType : byte {
}
}

internal static void ProcessMpPreview(IPreviewBeatmapLevel preview, IConnectedPlayer player, string[]? requirements = null) {
internal static void ProcessMpPreview(PreviewBeatmapLevel preview, IConnectedPlayer player, string[]? requirements = null) {
Log.Debug($"ProcessMpPreview(player=\"{player}\")");
RecommendPreview current = playerData.previews[PlayerIndex(player)];
if(preview.levelID != current.levelID || current.previewDifficultyBeatmapSets == null) // Ignore if we already have a BeatUpClient preview for this level
Expand Down
23 changes: 9 additions & 14 deletions BeatUpClient/cs/Packets/1_RecommendPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,18 @@ internal class RecommendPreview : PreviewBeatmapLevel { // TODO: unify requireme
public RecommendPreview(LiteNetLib.Utils.NetDataReader reader) : base(reader, false) {
labels = CreateArray((uint)(previewDifficultyBeatmapSets?.Count() ?? 0), i =>
CreateArray(UpperBound(reader.GetByte(), 5), i => reader.GetString()));
requirements = CreateArray(UpperBound(reader.GetByte(), 16), i => reader.GetString());
suggestions = CreateArray(UpperBound(reader.GetByte(), 16), i => reader.GetString());
this.requirements = CreateArray(UpperBound(reader.GetByte(), 16), i => reader.GetString());
this.suggestions = CreateArray(UpperBound(reader.GetByte(), 16), i => reader.GetString());
}
public RecommendPreview(IPreviewBeatmapLevel? preview, string[]? requirements) : base(preview, false) {
public RecommendPreview(PreviewBeatmapLevel? preview, string[]? requirements) : base(preview, false) {
labels = CreateArray((uint)(previewDifficultyBeatmapSets?.Count() ?? 0), i =>
CreateArray((uint)previewDifficultyBeatmapSets![(int)i].beatmapDifficulties.Count(), i => string.Empty));
this.requirements = requirements ?? new string[0];
suggestions = new string[0];
CreateArray((uint)previewDifficultyBeatmapSets![(int)i].difficulties.Count(), i => string.Empty));
(this.requirements, this.suggestions) = (requirements ?? new string[0], new string[0]);
}
public RecommendPreview(CustomPreviewBeatmapLevel preview) : this((IPreviewBeatmapLevel)preview, null) { // TODO: labels
string path = System.IO.Path.Combine(preview.customLevelPath, "Info.dat");
if(!System.IO.File.Exists(path))
return;
Newtonsoft.Json.Linq.JObject info = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(path));
Newtonsoft.Json.Linq.IJEnumerable<Newtonsoft.Json.Linq.JToken> customData = Newtonsoft.Json.Linq.Extensions.Children(info["_difficultyBeatmapSets"]?.Children()["_difficultyBeatmaps"] ?? new Newtonsoft.Json.Linq.JArray())["_customData"];
requirements = Newtonsoft.Json.Linq.Extensions.Values<string>(customData["_requirements"]).ToHashSet().ToArray()!;
suggestions = Newtonsoft.Json.Linq.Extensions.Values<string>(customData["_suggestions"]).ToHashSet().ToArray()!;
public RecommendPreview(BeatmapLevel from) : base(from, false) { // TODO: labels
labels = CreateArray((uint)(previewDifficultyBeatmapSets?.Count() ?? 0), i =>
CreateArray((uint)previewDifficultyBeatmapSets![(int)i].difficulties.Count(), i => string.Empty));
(this.requirements, this.suggestions) = (new string[0], new string[0]);
}
}
}
7 changes: 3 additions & 4 deletions BeatUpClient/cs/Packets/MpBeatmapPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ internal class MpBeatmapPacket : PreviewBeatmapLevel {
}
}
// TODO: switching between `MpBeatmapPacket`s and `RecommendPreview`s is a lossy conversion
public MpBeatmapPacket(RecommendPreview preview, PreviewDifficultyBeatmap beatmap) : base(beatmap.beatmapLevel, true) {
(characteristic, difficulty) = (beatmap.beatmapCharacteristic.serializedName, beatmap.beatmapDifficulty);
PreviewDifficultyBeatmapSet? set = beatmap.beatmapLevel.previewDifficultyBeatmapSets?.FirstOrDefault(set => set.beatmapCharacteristic == beatmap.beatmapCharacteristic);
requirements = (set?.beatmapDifficulties ?? new BeatmapDifficulty[0])
public MpBeatmapPacket(RecommendPreview preview, BeatmapLevel info, BeatmapKey key) : base(info, true) {
(characteristic, difficulty) = (key.beatmapCharacteristic.SerializedName(), key.difficulty);
requirements = info.GetDifficulties(key.beatmapCharacteristic)
.SelectMany(diff => preview.requirements.Select(req => (diff, req)))
.ToLookup(pair => pair.diff, pair => pair.req);
}
Expand Down
Loading

0 comments on commit 20fa182

Please sign in to comment.