Skip to content

Commit

Permalink
Bump version, final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Meivyn committed Mar 18, 2024
1 parent fac677b commit 1f21a3f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace SongCore.HarmonyPatches
{
// TODO: Remove missing characteristic. Might end up in wiped save data.
[HarmonyPatch(typeof(BeatmapCharacteristicCollection))]
[HarmonyPatch(nameof(BeatmapCharacteristicCollection.GetBeatmapCharacteristicBySerializedName), MethodType.Normal)]
internal class CustomCharacteristicsPatch
Expand Down
24 changes: 11 additions & 13 deletions source/SongCore/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ private void MenuLoaded(ScenesTransitionSetupDataSO scenesTransitionSetupData, D

public void Dispose()
{
Logging.Logger.Notice(nameof(Dispose));

SceneManager.activeSceneChanged -= HandleActiveSceneChanged;

_gameScenesManager.transitionDidStartEvent -= CancelSongLoading;
Expand Down Expand Up @@ -166,12 +164,15 @@ private void HandleActiveSceneChanged(Scene previousScene, Scene nextScene)
{
if (_loadingTaskCancellationTokenSource.IsCancellationRequested && nextScene.name == "MainMenu")
{
Logging.Logger.Notice("Song loading was cancelled. Resuming...");
RefreshSongs();
}
}

private static void HandleDidSelectLevel(LevelCollectionViewController levelCollectionViewController, BeatmapLevel beatmapLevel)
{
Logging.Logger.Debug($"Selected level: {beatmapLevel.levelID} | {beatmapLevel.songName}");

if (!beatmapLevel.hasPrecalculatedData && Collections.RetrieveExtraSongData(Hashing.GetCustomLevelHash(beatmapLevel)) is { } songData)
{
if (Plugin.Configuration.CustomSongPlatforms && !string.IsNullOrWhiteSpace(songData._customEnvironmentName))
Expand Down Expand Up @@ -322,21 +323,18 @@ void AddOfficialBeatmapLevelsRepository(BeatmapLevelsRepository levelsRepository

#region AddCustomBeatmaps

var customLevelsPath = _customLevelsPath;

try
{
#region DirectorySetup

if (!Directory.Exists(customLevelsPath))
if (!Directory.Exists(_customLevelsPath))
{
Directory.CreateDirectory(customLevelsPath);
Directory.CreateDirectory(_customLevelsPath);
}

var customWipLevelsPath = _customWIPPath;
if (!Directory.Exists(customWipLevelsPath))
if (!Directory.Exists(_customWIPPath))
{
Directory.CreateDirectory(customWipLevelsPath);
Directory.CreateDirectory(_customWIPPath);
}

#endregion
Expand All @@ -348,10 +346,10 @@ void AddOfficialBeatmapLevelsRepository(BeatmapLevelsRepository levelsRepository
{
try
{
var cachePath = Path.Combine(customWipLevelsPath, "Cache");
CacheZIPs(cachePath, customWipLevelsPath);
var cachePath = Path.Combine(_customWIPPath, "Cache");
CacheZIPs(cachePath, _customWIPPath);

var cacheFolders = Directory.GetDirectories(cachePath).ToArray();
var cacheFolders = Directory.GetDirectories(cachePath);
LoadCachedZIPs(cacheFolders, fullRefresh, CachedWIPLevels);
}
catch (Exception ex)
Expand Down Expand Up @@ -392,7 +390,7 @@ void AddOfficialBeatmapLevelsRepository(BeatmapLevelsRepository levelsRepository
#region LoadCustomLevels

// Get Levels from CustomLevels and CustomWIPLevels folders
var songFolders = Directory.GetDirectories(customLevelsPath).Concat(Directory.GetDirectories(customWipLevelsPath)).ToArray();
var songFolders = Directory.GetDirectories(_customLevelsPath).Concat(Directory.GetDirectories(_customWIPPath)).ToArray();
var loadedData = new ConcurrentBag<string>();

var processedSongsCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/SongCore/SongCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@

<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="2.0.0-beta7" PrivateAssets="all" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.2" PrivateAssets="all" />
</ItemGroup>
</Project>
7 changes: 1 addition & 6 deletions source/SongCore/UI/ProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ public static ProgressBar Create()

public void ShowMessage(string message, float time)
{
StopAllCoroutines();
_showingMessage = true;
_headerText.text = message;
_loadingBar.enabled = false;
_loadingBackg.enabled = false;
_canvas.enabled = true;
ShowMessage(message);
StartCoroutine(DisableCanvasRoutine(time));
}

Expand Down
48 changes: 23 additions & 25 deletions source/SongCore/UI/RequirementsUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ private RequirementsUI(StandardLevelDetailViewController standardLevelDetailView
internal Sprite? StandardIcon;

//Currently selected song data
public BeatmapLevel beatmapLevel;
public BeatmapKey beatmapKey;
public Data.ExtraSongData songData;
public BeatmapLevel? beatmapLevel;
public BeatmapKey? beatmapKey;
public Data.ExtraSongData? songData;
public Data.ExtraSongData.DifficultyData? diffData;
public bool wipFolder;

Expand Down Expand Up @@ -277,8 +277,8 @@ internal void ShowRequirements()

if (customListTableData.data.Count > 0)
{
if (environmentName == null && beatmapLevel != null) // TODO: Can this actually be null?
environmentName = beatmapLevel.GetEnvironmentName(beatmapKey.beatmapCharacteristic, beatmapKey.difficulty);
if (environmentName == null && beatmapLevel != null && beatmapKey.HasValue)
environmentName = beatmapLevel.GetEnvironmentName(beatmapKey.Value.beatmapCharacteristic, beatmapKey.Value.difficulty);
customListTableData.data.Add(new CustomCellInfo("<size=75%>Environment Info", $"This Map uses the Environment: {environmentName}", EnvironmentIcon));

}
Expand Down Expand Up @@ -339,47 +339,45 @@ private void EnableOrDisableSongButtons()
return;
}

var songData = Collections.RetrieveExtraSongData(Hashing.GetCustomLevelHash(_standardLevelDetailViewController._beatmapLevel));

if (songData == null)
var extraSongData = Collections.RetrieveExtraSongData(Hashing.GetCustomLevelHash(_standardLevelDetailViewController._beatmapLevel));
if (extraSongData == null)
{
ButtonGlowColor = false;
ButtonInteractable = false;
return;
}

var wipFolderSong = false;
var diffData = Collections.RetrieveDifficultyData(_standardLevelDetailViewController._beatmapLevel, _standardLevelDetailViewController.beatmapKey);
var actionButton = _standardLevelDetailViewController._standardLevelDetailView.actionButton;
var practiceButton = _standardLevelDetailViewController._standardLevelDetailView.practiceButton;

if (diffData != null)
var difficultyData = Collections.RetrieveDifficultyData(_standardLevelDetailViewController._beatmapLevel, _standardLevelDetailViewController.beatmapKey);
if (difficultyData != null)
{
//If no additional information is present
if (!diffData.additionalDifficultyData._requirements.Any() &&
!diffData.additionalDifficultyData._suggestions.Any() &&
!diffData.additionalDifficultyData._warnings.Any() &&
!diffData.additionalDifficultyData._information.Any() &&
!songData.contributors.Any() && !Utils.DiffHasColors(diffData))
if (!difficultyData.additionalDifficultyData._requirements.Any() &&
!difficultyData.additionalDifficultyData._suggestions.Any() &&
!difficultyData.additionalDifficultyData._warnings.Any() &&
!difficultyData.additionalDifficultyData._information.Any() &&
!extraSongData.contributors.Any() && !Utils.DiffHasColors(difficultyData))
{
ButtonGlowColor = false;
ButtonInteractable = false;
}
else if (!diffData.additionalDifficultyData._warnings.Any())
else if (!difficultyData.additionalDifficultyData._warnings.Any())
{
ButtonGlowColor = true;
ButtonInteractable = true;
SetRainbowColors(Utils.DiffHasColors(diffData));
SetRainbowColors(Utils.DiffHasColors(difficultyData));
}
else if (diffData.additionalDifficultyData._warnings.Any())
else if (difficultyData.additionalDifficultyData._warnings.Any())
{
ButtonGlowColor = true;
ButtonInteractable = true;
if (diffData.additionalDifficultyData._warnings.Contains("WIP"))
if (difficultyData.additionalDifficultyData._warnings.Contains("WIP"))
{
actionButton.interactable = false;
}
SetRainbowColors(Utils.DiffHasColors(diffData));
SetRainbowColors(Utils.DiffHasColors(difficultyData));
}
}

Expand All @@ -391,9 +389,9 @@ private void EnableOrDisableSongButtons()
wipFolderSong = true;
}

if (diffData != null)
if (difficultyData != null)
{
foreach (var requirement in diffData.additionalDifficultyData._requirements)
foreach (var requirement in difficultyData.additionalDifficultyData._requirements)
{
if (!Collections.capabilities.Contains(requirement))
{
Expand All @@ -415,8 +413,8 @@ private void EnableOrDisableSongButtons()

beatmapLevel = _standardLevelDetailViewController._beatmapLevel;
beatmapKey = _standardLevelDetailViewController.beatmapKey;
this.songData = songData;
this.diffData = diffData;
songData = extraSongData;
diffData = difficultyData;
wipFolder = wipFolderSong;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/SongCore/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static byte[] GetResource(Assembly asm, string resourceName)
public static void PrintHierarchy(Transform transform, string spacing = "|-> ")
{
spacing = spacing.Insert(1, " ");
var tempList = transform.Cast<Transform>().ToList();
var tempList = transform.Cast<Transform>();
foreach (var child in tempList)
{
Console.WriteLine($"{spacing}{child.name}");
Expand Down
2 changes: 1 addition & 1 deletion source/SongCore/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"gameVersion": "1.35.0",
"id": "SongCore",
"name": "SongCore",
"version": "3.12.1",
"version": "3.13.0",
"dependsOn": {
"BSIPA": "^4.3.0",
"BeatSaberMarkupLanguage": "^1.7.6",
Expand Down

0 comments on commit 1f21a3f

Please sign in to comment.