Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.37.5 #153

Merged
merged 9 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [master, 1.37.1]
branches: [master]
tags: v*
pull_request:
branches: [master]
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
BUILDTEXT: Filename=${{ steps.Build.outputs.filename }}
ASSEMBLYNAME: AssemblyName=${{ steps.Build.outputs.assemblyname }}
- name: Upload Artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: ${{ steps.Build.outputs.filename }}
path: ${{ steps.Build.outputs.artifactpath }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ obj
Source\9_Resources\AssetBundles\asset_bundle.manifest
Source\9_Resources\AssetBundles\AssetBundles
Source\9_Resources\AssetBundles\AssetBundles.manifest
BeatLeader.csproj.user
BeatLeader.csproj.user
BeatLeader.sln.DotSettings.user
28 changes: 0 additions & 28 deletions BeatLeader.sln.DotSettings.user

This file was deleted.

6 changes: 5 additions & 1 deletion Source/2_Core/Installers/OnMenuInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using BeatLeader.DataManager;
using BeatLeader.DataManager;
using BeatLeader.Interop;
using BeatLeader.ViewControllers;
using BeatLeader.Replayer;
using JetBrains.Annotations;
using Zenject;
using BeatLeader.Components;

namespace BeatLeader.Installers {
[UsedImplicitly]
Expand Down Expand Up @@ -36,6 +37,9 @@ private void BindLeaderboard() {
Container.Bind<BeatLeaderMenuButtonManager>().FromNewComponentOnNewGameObject().AsSingle().NonLazy();
Container.Bind<BeatLeaderFlowCoordinator>().FromNewComponentOnNewGameObject().AsSingle().NonLazy();
Container.Bind<ReplayLaunchViewController>().FromNewComponentAsViewController().AsSingle();

_ = BeatmapDifficultyPanel.BeatmapDifficultySegmentedControl;
_ = BeatmapCharacteristicPanel.BeatmapCharacteristicSegmentedControl;
}
}
}
4 changes: 2 additions & 2 deletions Source/2_Core/Managers/ReplayRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ private void TryGetSaberOffsets(Saber saber, out Vector3 localPosition, out Quat
controllerRot = xrRigTransform.LocalToWorldRotation(controllerRot);
var controllerTransform = new ReeTransform(controllerPos, controllerRot);

localPosition = controllerTransform.WorldToLocalPosition(saber.handlePos);
localRotation = controllerTransform.WorldToLocalRotation(saber.handleRot);
localPosition = controllerTransform.WorldToLocalPosition(saber._handleTransform.position);
localRotation = controllerTransform.WorldToLocalRotation(saber._handleTransform.rotation);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ static void ConvertAndAddSliderData(SliderData sliderData, ICollection<NoteData>
var lineIndex = i < sliceCount - 1 ? sliderData.headLineIndex : sliderData.tailLineIndex;
var noteLineLayer = i < sliceCount - 1 ? sliderData.headLineLayer : sliderData.tailLineLayer;
var time = Mathf.LerpUnclamped(sliderData.time, sliderData.tailTime, (float)i / (sliceCount - 1));
var beat = sliderData.beat;
var sliderNoteData = NoteData.CreateBurstSliderNoteData(
time,
beat,
lineIndex,
noteLineLayer,
sliderData.headBeforeJumpLineLayer,
Expand Down
2 changes: 1 addition & 1 deletion Source/2_Core/Replayer/ReplayFinishController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void HandleReplayFinished() {
}

private void HandleLevelFailed() {
if (!_gameplayManagerInitData.failOn0Energy) return;
if (_gameplayManagerInitData.continueGameplayWith0Energy) return;
HandleLevelFinished();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/2_Core/Replayer/ReplayTimeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class ReplayTimeController : BeatmapTimeController, IReplayTimeControll
public float ReplayEndTime {
get {
_replayEndTime = _replayEndTime is -1 ? _launchData.MainReplay.PlayerMovementFrames.LastOrDefault().time : _replayEndTime;
var failTime = !_gameplayManagerInitData.failOn0Energy ? 0 : _replayEndTime;
var failTime = _gameplayManagerInitData.continueGameplayWith0Energy ? 0 : _replayEndTime;
return _launchData.IsBattleRoyale || failTime == 0 ? SongEndTime : failTime;
}
}
Expand Down
17 changes: 9 additions & 8 deletions Source/7_Utils/BSMLUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,38 @@
using UnityEngine;
using BeatSaberMarkupLanguage.Attributes;
using System.Reflection;
using System.Threading.Tasks;

namespace BeatLeader.Utils {
public static class BSMLUtility {
public static void AddSpriteToBSMLCache(string name, Sprite sprite) {
Utilities.spriteCache.Add(name, sprite);
Utilities.SpriteCache.Add(name, sprite);
}
public static Sprite LoadSprite(string location) {
Sprite sprite = null;
if (location.Length > 1 && location.StartsWith("#")) {
string text = location.Substring(1);
sprite = FindSpriteCached(text);
} else Utilities.GetData(location, (byte[] data) => {
sprite = Utilities.LoadSpriteRaw(data);
} else {
sprite = Utilities.LoadSpriteFromAssemblyAsync(location).GetAwaiter().GetResult();
sprite.texture.wrapMode = TextureWrapMode.Clamp;
});
}

if (sprite == null) {
throw new Exception($"Can not find sprite located at [{location}]!");
}
return sprite;
}
public static Sprite FindSpriteCached(string name) {
if (Utilities.spriteCache.TryGetValue(name, out var value) && value != null) {
if (Utilities.SpriteCache.TryGetValue(name, out var value) && value != null) {
return value;
}

Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
foreach (Sprite sprite in array) {
if (sprite.name.Length != 0) {
if (!Utilities.spriteCache.TryGetValue(sprite.name, out var value2) || value2 == null) {
Utilities.spriteCache[sprite.name] = sprite;
if (!Utilities.SpriteCache.TryGetValue(sprite.name, out var value2) || value2 == null) {
Utilities.SpriteCache[sprite.name] = sprite;
}

if (sprite.name == name) {
Expand All @@ -44,11 +45,11 @@

return value;
}
public static bool ParseInObjectHierarchy<T>(this T obj, string content = null, object host = null) where T : Behaviour {

Check warning on line 48 in Source/7_Utils/BSMLUtility.cs

View workflow job for this annotation

GitHub Actions / Build

Cannot convert null literal to non-nullable reference type.

Check warning on line 48 in Source/7_Utils/BSMLUtility.cs

View workflow job for this annotation

GitHub Actions / Build

Cannot convert null literal to non-nullable reference type.
content ??= ReadViewDefinition(host?.GetType() ?? typeof(T));
if (string.IsNullOrEmpty(content)) return false;
try {
BSMLParser.instance.Parse(content, obj.gameObject, host ?? obj);
BSMLParser.Instance.Parse(content, obj.gameObject, host ?? obj);
} catch (Exception ex) {
Debug.LogException(ex);
return false;
Expand Down
8 changes: 4 additions & 4 deletions Source/8_UI/BSML Addons/BSMLAddonsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ internal static class BSMLAddonsLoader {
new GenericSettingExtensionHandler(),
new GraphicExtensionHandler(),
new ImageViewExtensionHandler(),
new LayoutElementExtensionHandler(),
new ModalViewExtensionHandler()
};

private static bool _ready;

public static void LoadAddons() {
if (_ready) return;
if (!_ready) {
foreach (var sprite in spritesToCache)
BSMLUtility
.AddSpriteToBSMLCache("bl-" + sprite.Key, sprite.Value);
foreach (var tag in addonTags) BSMLParser.instance.RegisterTag(tag);
foreach (var handler in addonHandlers) BSMLParser.instance.RegisterTypeHandler(handler);
}
foreach (var tag in addonTags) BSMLParser.Instance.RegisterTag(tag);
foreach (var handler in addonHandlers) BSMLParser.Instance.RegisterTypeHandler(handler);
_ready = true;
}
}
Expand Down
18 changes: 9 additions & 9 deletions Source/8_UI/BSML Addons/TypeHandlers/BetterButtonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public override void HandleType(BSMLParser.ComponentTypeWithData componentType,
try
{
BetterButton button;
if (button = componentType.component as BetterButton)
if (button = componentType.Component as BetterButton)
{
if (componentType.data.TryGetValue("transition", out string transition) && transition != "Animation")
if (componentType.Data.TryGetValue("transition", out string transition) && transition != "Animation")
{
button.Button.transition = (Selectable.Transition)Enum.Parse(typeof(Selectable.Transition), transition);
}

#region Button colors
if (componentType.data.TryGetValue("normalColor", out string normalColor))
if (componentType.Data.TryGetValue("normalColor", out string normalColor))
{
ColorBlock colors = button.Button.colors;
if (ColorUtility.TryParseHtmlString(normalColor, out Color color))
Expand All @@ -62,7 +62,7 @@ public override void HandleType(BSMLParser.ComponentTypeWithData componentType,
button.Button.colors = colors;
}
}
if (componentType.data.TryGetValue("highlightedColor", out string highlightedColor))
if (componentType.Data.TryGetValue("highlightedColor", out string highlightedColor))
{
ColorBlock colors = button.Button.colors;
if (ColorUtility.TryParseHtmlString(highlightedColor, out Color color))
Expand All @@ -71,7 +71,7 @@ public override void HandleType(BSMLParser.ComponentTypeWithData componentType,
button.Button.colors = colors;
}
}
if (componentType.data.TryGetValue("pressedColor", out string pressedColor))
if (componentType.Data.TryGetValue("pressedColor", out string pressedColor))
{
ColorBlock colors = button.Button.colors;
if (ColorUtility.TryParseHtmlString(pressedColor, out Color color))
Expand All @@ -80,7 +80,7 @@ public override void HandleType(BSMLParser.ComponentTypeWithData componentType,
button.Button.colors = colors;
}
}
if (componentType.data.TryGetValue("colorMultiplier", out string colorMultiplier))
if (componentType.Data.TryGetValue("colorMultiplier", out string colorMultiplier))
{
ColorBlock colors = button.Button.colors;
if (float.TryParse(colorMultiplier, out float result))
Expand All @@ -91,20 +91,20 @@ public override void HandleType(BSMLParser.ComponentTypeWithData componentType,
}
#endregion

if (componentType.data.TryGetValue("highlightedSprite", out string highlightedImage))
if (componentType.Data.TryGetValue("highlightedSprite", out string highlightedImage))
{
SpriteState spriteState = button.Button.spriteState;
spriteState.highlightedSprite = BSMLUtility.LoadSprite(highlightedImage);
button.Button.spriteState = spriteState;
}
if (componentType.data.TryGetValue("pressedSprite", out string pressedImage))
if (componentType.Data.TryGetValue("pressedSprite", out string pressedImage))
{
SpriteState spriteState = button.Button.spriteState;
spriteState.pressedSprite = BSMLUtility.LoadSprite(pressedImage);
button.Button.spriteState = spriteState;
}

BetterImageHandler.HandleImage(componentType.data, button.TargetGraphic);
BetterImageHandler.HandleImage(componentType.Data, button.TargetGraphic);
}
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions Source/8_UI/BSML Addons/TypeHandlers/BetterImageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public static void HandleImage(Dictionary<string, string> data, Image image, str
public override void HandleType(BSMLParser.ComponentTypeWithData componentType, BSMLParserParams parserParams)
{
BetterImage image;
if ((image = componentType.component as BetterImage) != null)
if ((image = componentType.Component as BetterImage) != null)
{
HandleImage(componentType.data, image.Image);
HandleImage(componentType.Data, image.Image);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ internal class GenericSettingExtensionHandler : TypeHandler {
};

public override void HandleType(BSMLParser.ComponentTypeWithData componentType, BSMLParserParams parserParams) {
if (!componentType.data.TryGetValue("hideText", out var showText) ||
if (!componentType.Data.TryGetValue("hideText", out var showText) ||
!bool.TryParse(showText, out var showTextBool) || !showTextBool) return;

var text = default(GameObject?);
var transform = default(Transform?);
var parent = default(Transform?);
switch (componentType.component) {
switch (componentType.Component) {
case SliderSetting sliderSetting:
var sliderTransform = sliderSetting.slider.transform;
var sliderTransform = sliderSetting.Slider.transform;
parent = sliderTransform.parent;
transform = sliderTransform;
text = sliderSetting.GetComponentInChildren<TextMeshProUGUI>().gameObject;
break;
case IncDecSetting incDecSetting:
text = incDecSetting.GetComponentInChildren<TextMeshProUGUI>().gameObject;
transform = incDecSetting.text.transform.parent;
transform = incDecSetting.TextMesh.transform.parent;
parent = incDecSetting.transform;
break;
case ToggleSetting toggleSetting:
text = toggleSetting.text.gameObject;
transform = toggleSetting.toggle.transform;
text = toggleSetting.TextMesh.gameObject;
transform = toggleSetting.Toggle.transform;
parent = toggleSetting.transform;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ internal class GraphicExtensionHandler : TypeHandler {

public override void HandleType(BSMLParser.ComponentTypeWithData componentType, BSMLParserParams parserParams) {
Graphic graphic;
if ((graphic = componentType.component as Graphic) != null
&& componentType.data.TryGetValue("useMask", out string asMaskStr)
if ((graphic = componentType.Component as Graphic) != null
&& componentType.Data.TryGetValue("useMask", out string asMaskStr)
&& bool.TryParse(asMaskStr, out bool asMask) && asMask) {
graphic.gameObject.AddComponent<Mask>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ internal class ImageViewExtensionHandler : TypeHandler {
};

public override void HandleType(BSMLParser.ComponentTypeWithData componentType, BSMLParserParams parserParams) {
if (!componentType.data.TryGetValue("skew", out string skew) ||
if (!componentType.Data.TryGetValue("skew", out string skew) ||
!float.TryParse(skew.Replace('.', ','), out float skewFloat)) return;

var component = componentType.component;
var component = componentType.Component;
foreach (var view in component.GetComponentsInChildren<ImageView>()) {
view.SetField("_skew", skewFloat);
view.SetAllDirty();
Expand Down
Loading
Loading