-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from Kylemc1413/feature/zenject
Zenjectify
Showing
27 changed files
with
682 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
source/SongCore/HarmonyPatches/AllowNegativeNjsValuesPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using SiraUtil.Affinity; | ||
|
||
namespace SongCore.HarmonyPatches | ||
{ | ||
internal class AllowNegativeNjsValuesPatch : IAffinity | ||
{ | ||
private readonly BeatmapBasicData _beatmapBasicData; | ||
|
||
private AllowNegativeNjsValuesPatch(BeatmapBasicData beatmapBasicData) | ||
{ | ||
_beatmapBasicData = beatmapBasicData; | ||
} | ||
|
||
[AffinityPatch(typeof(BeatmapObjectSpawnMovementData), nameof(BeatmapObjectSpawnMovementData.Init))] | ||
[AffinityPrefix] | ||
private void ForceNegativeStartNoteJumpMovementSpeed(ref float startNoteJumpMovementSpeed) | ||
{ | ||
var noteJumpMovementSpeed = _beatmapBasicData.noteJumpMovementSpeed; | ||
if (noteJumpMovementSpeed < 0) | ||
{ | ||
startNoteJumpMovementSpeed = noteJumpMovementSpeed; | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
source/SongCore/HarmonyPatches/BeatmapLevelDifficultyDataPatches.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using SiraUtil.Affinity; | ||
using SongCore.Utilities; | ||
|
||
namespace SongCore.HarmonyPatches | ||
{ | ||
internal class BeatmapLevelDifficultyDataPatches : IAffinity | ||
{ | ||
private readonly bool? _showRotationNoteSpawnLines; | ||
private readonly bool? _oneSaber; | ||
|
||
private BeatmapLevelDifficultyDataPatches(BeatmapLevel beatmapLevel, BeatmapKey beatmapKey) | ||
{ | ||
var difficultyData = Collections.RetrieveDifficultyData(beatmapLevel, beatmapKey); | ||
if (difficultyData != null) | ||
{ | ||
_showRotationNoteSpawnLines = difficultyData._showRotationNoteSpawnLines; | ||
_oneSaber = difficultyData._oneSaber; | ||
} | ||
} | ||
|
||
[AffinityPatch(typeof(BeatLineManager), nameof(BeatLineManager.HandleNoteWasSpawned))] | ||
[AffinityPrefix] | ||
private bool ShowOrHideRotationNoteSpawnLines() | ||
{ | ||
return _showRotationNoteSpawnLines ?? true; | ||
} | ||
|
||
[AffinityPatch(typeof(SaberManager.InitData), "ctor", AffinityMethodType.Constructor, null, typeof(bool), typeof(SaberType))] | ||
private void ForceOneSaber(SaberManager.InitData __instance) | ||
{ | ||
if (_oneSaber.HasValue) | ||
{ | ||
Accessors.OneSaberModeAccessor(ref __instance) = _oneSaber.Value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using HarmonyLib; | ||
|
||
namespace SongCore.HarmonyPatches | ||
{ | ||
[HarmonyPatch(typeof(GameplayCoreInstaller), nameof(GameplayCoreInstaller.InstallBindings))] | ||
internal class BindBeatmapLevelPatch | ||
{ | ||
private static void Postfix(GameplayCoreInstaller __instance) | ||
{ | ||
__instance.Container.Bind<BeatmapLevel>().FromInstance(__instance._sceneSetupData.beatmapLevel).AsSingle(); | ||
} | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
source/SongCore/HarmonyPatches/CosmeticCharacteristicsPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using BGLib.Polyglot; | ||
using HMUI; | ||
using SiraUtil.Affinity; | ||
using SongCore.Utilities; | ||
using UnityEngine; | ||
|
||
namespace SongCore.HarmonyPatches | ||
{ | ||
internal class CosmeticCharacteristicsPatch : IAffinity | ||
{ | ||
private readonly StandardLevelDetailViewController _standardLevelDetailViewController; | ||
|
||
private CosmeticCharacteristicsPatch(StandardLevelDetailViewController standardLevelDetailViewController) | ||
{ | ||
_standardLevelDetailViewController = standardLevelDetailViewController; | ||
} | ||
|
||
[AffinityPatch(typeof(BeatmapCharacteristicSegmentedControlController), nameof(BeatmapCharacteristicSegmentedControlController.SetData))] | ||
private void SetCosmeticCharacteristic(BeatmapCharacteristicSegmentedControlController __instance, BeatmapCharacteristicSO selectedBeatmapCharacteristic) | ||
{ | ||
if (!Plugin.Configuration.DisplayCustomCharacteristics) | ||
{ | ||
return; | ||
} | ||
|
||
var beatmapLevel = _standardLevelDetailViewController._beatmapLevel; | ||
if (beatmapLevel.hasPrecalculatedData) | ||
{ | ||
return; | ||
} | ||
|
||
var extraSongData = Collections.RetrieveExtraSongData(Hashing.GetCustomLevelHash(beatmapLevel)!); | ||
if (extraSongData?._characteristicDetails == null || extraSongData._characteristicDetails.Length == 0) | ||
{ | ||
return; | ||
} | ||
|
||
var segmentedControl = __instance._segmentedControl; | ||
var dataItems = segmentedControl._dataItems; | ||
var newDataItems = new List<IconSegmentedControl.DataItem>(); | ||
var i = 0; | ||
var cellIndex = 0; | ||
foreach (var dataItem in dataItems) | ||
{ | ||
var beatmapCharacteristic = __instance._beatmapCharacteristics[i]; | ||
var serializedName = beatmapCharacteristic.serializedName; | ||
var characteristicDetails = extraSongData._characteristicDetails.FirstOrDefault(c => c._beatmapCharacteristicName == serializedName); | ||
|
||
if (characteristicDetails != null) | ||
{ | ||
Sprite? icon = null; | ||
|
||
var customLevelPath = Collections.GetCustomLevelPath(beatmapLevel.levelID); | ||
if (characteristicDetails._characteristicIconFilePath != null && !string.IsNullOrEmpty(customLevelPath)) | ||
{ | ||
icon = Utils.LoadSpriteFromFile(Path.Combine(customLevelPath, characteristicDetails._characteristicIconFilePath)); | ||
} | ||
|
||
if (icon == null) | ||
{ | ||
icon = beatmapCharacteristic.icon; | ||
} | ||
|
||
var label = characteristicDetails._characteristicLabel ?? Localization.Get(beatmapCharacteristic.descriptionLocalizationKey); | ||
newDataItems.Add(new IconSegmentedControl.DataItem(icon, label)); | ||
} | ||
else | ||
{ | ||
newDataItems.Add(dataItem); | ||
} | ||
|
||
if (beatmapCharacteristic == selectedBeatmapCharacteristic) | ||
{ | ||
cellIndex = i; | ||
} | ||
|
||
i++; | ||
} | ||
|
||
segmentedControl.SetData(newDataItems.ToArray()); | ||
segmentedControl.SelectCellWithNumber(cellIndex); | ||
} | ||
} | ||
} |
Oops, something went wrong.