Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
Fixed(?) a crash when entering multiplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Exomanz committed Apr 23, 2023
1 parent 8f40faf commit 43e6acb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
11 changes: 6 additions & 5 deletions MenuSaberColors/MenuSaberColorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace MenuSaberColors
{
public class MenuSaberColorManager : MonoBehaviour
{
[Inject] private readonly SiraLog Logger;
private SiraLog logger = null!;

public MethodInfo setColorsMethod = typeof(SetSaberGlowColor).GetMethod("SetColors");
public List<SetSaberGlowColor> leftSideSabers = new List<SetSaberGlowColor>();
Expand All @@ -22,8 +22,9 @@ public class MenuSaberColorManager : MonoBehaviour
private ColorSchemesSettings playerColorSchemesSettings;

[Inject]
internal void Construct(PlayerDataModel dataModel)
internal void Construct(PlayerDataModel dataModel, SiraLog logger)
{
this.logger = logger;
playerColorSchemesSettings = dataModel.playerData.colorSchemesSettings;
Patches.ShouldSaberColorsBeUpdated += this.RefreshData;
}
Expand All @@ -49,7 +50,7 @@ public void RefreshData(MenuEnvironmentManager.MenuEnvironmentType menuEnvironme
}
catch (Exception ex)
{
Logger.Error("Error occured while trying to update saber colors.\n" + ex);
logger.Error("Error occured while refreshing saber data.\n" + ex);
return;
}

Expand Down Expand Up @@ -155,9 +156,9 @@ public static Color ToColor(HSBColor hsbColor)
return new Color(Mathf.Clamp01(r), Mathf.Clamp01(g), Mathf.Clamp01(b), hsbColor.a);
}
}

#pragma warning disable CS0649
[Inject] private readonly MenuSaberColorManager colorManager;

#pragma warning restore CS0649
private readonly FieldAccessor<ColorScheme, Color>.Accessor saberAColorAccessor = FieldAccessor<ColorScheme, Color>.GetAccessor("_saberAColor");
private readonly FieldAccessor<ColorScheme, Color>.Accessor saberBColorAccessor = FieldAccessor<ColorScheme, Color>.GetAccessor("_saberBColor");
private ColorScheme aprilFools = new ColorScheme("memory-only_menuSaberColors_aprilFoolsColorScheme", "LOL", useNonLocalizedName: false, "OWNED", isEditable: false, new Color(0f, 0f, 0f), new Color(0f, 0f, 0f), new Color(0f, 0f, 0f), new Color(0f, 0f, 0f), supportsEnvironmentColorBoost: false, new Color(0f, 0f, 0f), new Color(0f, 0f, 0f), new Color(0f, 0f, 0f));
Expand Down
3 changes: 3 additions & 0 deletions MenuSaberColors/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ internal void ToggleValueChangedPostfix()
[AffinityPatch(typeof(MenuEnvironmentManager), nameof(MenuEnvironmentManager.ShowEnvironmentType), AffinityMethodType.Normal)]
internal void ShowEnvironmentTypePostfix(ref MenuEnvironmentManager.MenuEnvironmentType menuEnvironmentType)
{
if (menuEnvironmentType == MenuEnvironmentManager.MenuEnvironmentType.Lobby)
return;

ShouldSaberColorsBeUpdated(menuEnvironmentType);
}
}
Expand Down
2 changes: 1 addition & 1 deletion MenuSaberColors/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Plugin(IPALogger logger, Zenjector zenjector)
zenjector.Install<ColorManagerInstaller>(Container =>
{
GameObject saberColorManagerGO;
bool doesObjectExist = GameObject.Find("MenuSaberColorManager") != null;
bool doesObjectExist = GameObject.Find("MenuSaberColorManager") != null!;

if (doesObjectExist) return;
else saberColorManagerGO = new GameObject("MenuSaberColorManager");
Expand Down
4 changes: 2 additions & 2 deletions MenuSaberColors/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.7")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyVersion("1.0.8")]
[assembly: AssemblyFileVersion("1.0.8")]
4 changes: 2 additions & 2 deletions MenuSaberColors/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"id": "MenuSaberColors",
"name": "MenuSaberColors",
"author": "Exomanz",
"version": "1.0.7",
"version": "1.0.8",
"description": "A PC Port of henri's QonsistentSaberColors, which allows for your menu pointers to be the same color as your selected color scheme!",
"gameVersion": "1.27.0",
"gameVersion": "1.29.1",
"dependsOn": {
"BSIPA": "^4.2.2",
"SiraUtil": "^3.1.2"
Expand Down

0 comments on commit 43e6acb

Please sign in to comment.