Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Fix issue with exception being thrown when selecting avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
gompoc committed Oct 4, 2021
1 parent 1da300e commit 20c145d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/Output
obj/
.idea
ModJsons/
ModJsons/
packages/
2 changes: 1 addition & 1 deletion ActionMenuUtils/ActionMenuUtils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<VrcReferences>true</VrcReferences>
<Version>2.0.0.0</Version>
<Version>2.0.1.0</Version>
<LangVersion>9</LangVersion>
<CopyToMods>true</CopyToMods>
<GenerateJson>true</GenerateJson>
Expand Down
6 changes: 3 additions & 3 deletions ActionMenuUtils/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Main = ActionMenuUtils.Main;

[assembly: MelonGame("VRChat", "VRChat")]
[assembly: MelonInfo(typeof(Main), "ActionMenuUtils", "2.0.0", "gompo", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: MelonInfo(typeof(Main), "ActionMenuUtils", "2.0.1", "gompo", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: VerifyLoaderVersion(0, 4, 3, true)]
[assembly: ModJsonInfo(
140,
Expand Down Expand Up @@ -71,14 +71,14 @@ public override void OnApplicationStart()
SetupAMAPIButtons();
SetupUIXButtons();
}

private static void SetupUIXButtons()
{
ExpansionKitApi.GetExpandedMenu(ExpandedMenu.AvatarMenu).AddSimpleButton("Set as reset avatar for ActionMenuUtils",
() =>
{
var avatarId = GameObject.Find("UserInterface/MenuContent/Screens/Avatar/AvatarPreviewBase/MainRoot/MainModel").GetComponent<SimpleAvatarPedestal>().field_Internal_ApiAvatar_0.id;
var fallbackAvatarId =GameObject.Find("UserInterface/MenuContent/Screens/Avatar/AvatarPreviewBase/FallbackRoot/FallbackModel").GetComponent<SimpleAvatarPedestal>().field_Internal_ApiAvatar_0.id;
var fallbackAvatarId = GameObject.Find("UserInterface/MenuContent/Screens/Avatar/AvatarPreviewBase/FallbackRoot/FallbackModel").GetComponent<SimpleAvatarPedestal>().field_Internal_ApiAvatar_0?.id;
ModSettings.customAvatarId = avatarId;
ModSettings.fallbackAvatarId = fallbackAvatarId;
ModSettings.Save();
Expand Down
2 changes: 1 addition & 1 deletion ActionMenuUtils/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void Apply()
customAvatarId = CustomAvatarId.Value;
fallbackAvatarId = FallbackAvatarId.Value;

if(Main.UIXAvatarMenuButton is {})
if(Main.UIXAvatarMenuButton is not null)
Main.UIXAvatarMenuButton.active = enableCustomAvatarReset;
}

Expand Down
21 changes: 15 additions & 6 deletions ActionMenuUtils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,25 @@ public static void ResetAvatar()
//TODO: Pick your own avatar for reset
if (ModSettings.enableCustomAvatarReset)
{
if (!IsValidAvatarId(ModSettings.customAvatarId) || !IsValidAvatarId(ModSettings.fallbackAvatarId))
ApiAvatar avatar = null;
ApiAvatar fallbackAvatar = null;

if (IsValidAvatarId(ModSettings.customAvatarId))
{
avatar = API.Fetch<ApiAvatar>(ModSettings.customAvatarId);
}
else
{
SwitchToRobot(true);
return;
}

var avatar = API.Fetch<ApiAvatar>(ModSettings.customAvatarId);
var fallbackAvatar = API.Fetch<ApiAvatar>(ModSettings.fallbackAvatarId);
if (IsValidAvatarId(ModSettings.fallbackAvatarId))
{
fallbackAvatar = API.Fetch<ApiAvatar>(ModSettings.fallbackAvatarId);
}

if (avatar is null || fallbackAvatar is null)
if (avatar is null)
{
SwitchToRobot();
return;
Expand All @@ -90,11 +99,11 @@ public static void ResetAvatar()
}
}

private static void SwitchToRobot(bool valuesWereNull = false)
private static void SwitchToRobot(bool invalidId = false)
{
if (ModSettings.enableCustomAvatarReset)
{
MelonLogger.Warning(valuesWereNull
MelonLogger.Warning(invalidId
? "Couldn't switch to selected custom avatar. Make sure to select one first using the uix button on the left of the avatar page."
: "Couldn't switch to selected custom avatar. This likely means that the avatar you had selected before is no longer available.");
}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### ActionMenuUtils v2.0.1
- Fixed exception being thrown when selecting an avatar

### ActionMenuUtils v2.0.0
- Mod now depends on ActionMenuApi & UIExpansionKit, this just makes maintaining it easier for me when/if something breaks
- New setting added that you can enable so you can now select which avatar you want to reset into. You can select avatar by going to the AvatarMenu and clicking the UIExpansionKit button on the left
Expand Down
10 changes: 2 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
### ActionMenuUtils v2.0.0
- Mod now depends on ActionMenuApi & UIExpansionKit, this just makes maintaining it easier for me when/if something breaks
- New setting added that you can enable so you can now select which avatar you want to reset into. You can select avatar by going to the AvatarMenu and clicking the UIExpansionKit button on the left

### StandaloneThirdPerson v1.3.0
- Fixed issue with mod not showing when not launching through steam (--no-vr)
- Added secondary keybinds for third person toggle and freeform toggle, you can leave these as `None` or set them to `LeftControl` for example
- Added a setting to enable/disable freeform
### ActionMenuUtils v2.0.1
- Fixed exception being thrown when selecting an avatar
2 changes: 1 addition & 1 deletion StandaloneThirdPerson/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Main = StandaloneThirdPerson.Main;

[assembly: MelonGame("VRChat", "VRChat")]
[assembly: MelonInfo(typeof(Main), "StandaloneThirdPerson", "1.3.0", "gompo & ljoonal", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: MelonInfo(typeof(Main), "StandaloneThirdPerson", "1.3.1", "gompo & ljoonal", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: ModJsonInfo(
242,
"A simple standalone third person mod\n" +
Expand Down
2 changes: 1 addition & 1 deletion StandaloneThirdPerson/StandaloneThirdPerson.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<VrcReferences>true</VrcReferences>
<Version>1.3.0.0</Version>
<Version>1.3.1.0</Version>
<LangVersion>9</LangVersion>
<CopyToMods>true</CopyToMods>
<GenerateJson>true</GenerateJson>
Expand Down
3 changes: 2 additions & 1 deletion StandaloneThirdPerson/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace StandaloneThirdPerson
{
public static class Utils
[PatchShield]
internal static class Utils
{
public static bool IsBigMenuOpen()
{
Expand Down

0 comments on commit 20c145d

Please sign in to comment.