diff --git a/README.md b/README.md index 356baf8..546217e 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,11 @@ Merged set of MelonLoader mods for ChilloutVR. **State table for game build 2022r170:** | Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes | |-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------| -| Avatar Change Info | ml_aci | 1.0.3 | Yes | Working | +| Avatar Change Info | ml_aci | 1.0.3 | Yes | Working | Will be superseded by `Extended Game Notifications` | Avatar Motion Tweaker | ml_amt | 1.2.1 | Yes | Working | | Desktop Head Tracking | ml_dht | 1.1.1 | Yes | Working | | Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working | +| Extended Game Notifications | ml_egn | 1.0.0 | On review | Working | Four Point Tracking | ml_fpt | 1.0.9 | Retired | Deprecated | In-game feature since 2022r170 update | Leap Motion Extension | ml_lme | 1.2.9 | Yes | Working | -| Server Connection Info | ml_sci | 1.0.2 | Yes | Working | +| Server Connection Info | ml_sci | 1.0.2 | Yes | Working | Will be superseded by `Extended Game Notifications` diff --git a/ml_egn/Main.cs b/ml_egn/Main.cs new file mode 100644 index 0000000..f250abd --- /dev/null +++ b/ml_egn/Main.cs @@ -0,0 +1,86 @@ +using ABI_RC.Core.EventSystem; +using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Networking; +using ABI_RC.Core.Util; +using DarkRift.Client; +using System.Reflection; + +namespace ml_egn +{ + public class ExtendedGameNotifications : MelonLoader.MelonMod + { + public override void OnInitializeMelon() + { + HarmonyInstance.Patch( + typeof(AssetManagement).GetMethod(nameof(AssetManagement.LoadLocalAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnLocalAvatarLoad), BindingFlags.NonPublic | BindingFlags.Static)) + ); + + HarmonyInstance.Patch( + typeof(CVRSyncHelper).GetMethod(nameof(CVRSyncHelper.SpawnProp)), + null, + new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnPropSpawned), BindingFlags.NonPublic | BindingFlags.Static)) + ); + + HarmonyInstance.Patch( + typeof(NetworkManager).GetMethod("OnGameNetworkConnectionClosed", BindingFlags.NonPublic | BindingFlags.Instance), + null, + new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnGameNetworkConnectionClosed), BindingFlags.NonPublic | BindingFlags.Static)) + ); + } + + static void OnLocalAvatarLoad() + { + try + { + if(Utils.IsMenuOpened()) + Utils.ShowMenuNotification("Avatar changed", 1f); + else + Utils.ShowHUDNotification("(Synced) Client", "Avatar changed"); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnPropSpawned() + { + try + { + if(Utils.IsConnected()) + { + if(Utils.IsMenuOpened()) + Utils.ShowMenuNotification("Prop spawned", 1f); + else + Utils.ShowHUDNotification("(Synced) Client", "Prop spawned"); + } + else + { + if(Utils.IsMenuOpened()) + ViewManager.Instance.TriggerAlert("Prop Error", "Not connected to live instance", -1, true); + else + Utils.ShowHUDNotification("(Local) Client", "Unable to spawn prop", "Not connected to live instance"); + } + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1) + { + try + { + if((__1 != null) && (!__1.LocalDisconnect)) + Utils.ShowHUDNotification("(Local) Client", "Connection lost", (__1.Error != System.Net.Sockets.SocketError.Success) ? ("Reason: " + __1.Error.ToString()) : "", true); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + } +} diff --git a/ml_egn/Properties/AssemblyInfo.cs b/ml_egn/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..de777d8 --- /dev/null +++ b/ml_egn/Properties/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Reflection; + +[assembly: AssemblyTitle("ExtendedGameNotifications")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyFileVersion("1.0.0")] + +[assembly: MelonLoader.MelonInfo(typeof(ml_egn.ExtendedGameNotifications), "ExtendedGameNotifications", "1.0.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] +[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] \ No newline at end of file diff --git a/ml_egn/README.md b/ml_egn/README.md new file mode 100644 index 0000000..7103d28 --- /dev/null +++ b/ml_egn/README.md @@ -0,0 +1,8 @@ +# Extended Game Notifications +This mod shows main menu notifications and HUD popups upon avatar changing, prop spawning and server connection loss. +Basically, merged previous `Avatar Change Info` and `Server Connection Info` mods in one. + +# Installation +* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader) +* Get [latest release DLL](../../../releases/latest): + * Put `ml_egn.dll` in `Mods` folder of game diff --git a/ml_egn/Utils.cs b/ml_egn/Utils.cs new file mode 100644 index 0000000..f4935b9 --- /dev/null +++ b/ml_egn/Utils.cs @@ -0,0 +1,46 @@ +using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Networking; +using ABI_RC.Core.UI; +using DarkRift; + +namespace ml_egn +{ + static class Utils + { + public static bool IsMenuOpened() + { + return ((ViewManager.Instance != null) ? ViewManager.Instance.isGameMenuOpen() : false); + } + + public static void ShowMenuNotification(string p_message, float p_time = 1f) + { + if(ViewManager.Instance != null) + ViewManager.Instance.TriggerPushNotification(p_message, p_time); + } + + public static void ShowMenuAlert(string p_title, string p_message) + { + if(ViewManager.Instance != null) + ViewManager.Instance.TriggerAlert(p_title, p_message, -1, true); + } + + public static void ShowHUDNotification(string p_title, string p_message, string p_small = "", bool p_immediate = false) + { + if(CohtmlHud.Instance != null) + { + if(p_immediate) + CohtmlHud.Instance.ViewDropTextImmediate(p_title, p_message, p_small); + else + CohtmlHud.Instance.ViewDropText(p_title, p_message, p_small); + } + } + + public static bool IsConnected() + { + bool l_result = false; + if((NetworkManager.Instance != null) && (NetworkManager.Instance.GameNetwork != null)) + l_result = (NetworkManager.Instance.GameNetwork.ConnectionState == ConnectionState.Connected); + return l_result; + } + } +} diff --git a/ml_egn/ml_egn.csproj b/ml_egn/ml_egn.csproj new file mode 100644 index 0000000..d3728e6 --- /dev/null +++ b/ml_egn/ml_egn.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {1B5ACA07-6266-4C9A-BA30-D4BBE6634846} + Library + Properties + ml_egn + ml_egn + v4.7.2 + 512 + true + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + False + F:\games\Steam\common\ChilloutVR\MelonLoader\0Harmony.dll + False + + + False + F:\games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + False + + + False + + + False + False + + + False + F:\games\Steam\common\ChilloutVR\MelonLoader\MelonLoader.dll + False + + + + + + + + + + False + False + + + + + + + + + + + + + + copy /y "$(TargetPath)" "D:\Games\Steam\steamapps\common\ChilloutVR\Mods\" + + \ No newline at end of file diff --git a/ml_egn/ml_egn.csproj.user b/ml_egn/ml_egn.csproj.user new file mode 100644 index 0000000..04df561 --- /dev/null +++ b/ml_egn/ml_egn.csproj.user @@ -0,0 +1,6 @@ + + + + D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\;D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\ + + \ No newline at end of file diff --git a/ml_mods_cvr.sln b/ml_mods_cvr.sln index e7ec63f..2a6635d 100644 --- a/ml_mods_cvr.sln +++ b/ml_mods_cvr.sln @@ -3,38 +3,26 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.1738 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_fpt", "ml_fpt\ml_fpt.csproj", "{EC0A8C41-A429-42CD-B8FA-401A802D4BA6}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_lme", "ml_lme\ml_lme.csproj", "{83CC74B7-F444-40E1-BD06-67CEC995A919}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_aci", "ml_aci\ml_aci.csproj", "{1B5ACA07-6266-4C9A-BA30-D4BBE6634846}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_drs", "ml_drs\ml_drs.csproj", "{06CD5155-4459-48C3-8A53-E0B91136351B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_amt", "ml_amt\ml_amt.csproj", "{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_sci", "ml_sci\ml_sci.csproj", "{E5481D41-196C-4241-AF26-6595EF1863C1}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_dht", "ml_dht\ml_dht.csproj", "{6DD89FC3-A974-4C39-A3EE-F60C24B17B5B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_egn", "ml_egn\ml_egn.csproj", "{1B5ACA07-6266-4C9A-BA30-D4BBE6634846}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EC0A8C41-A429-42CD-B8FA-401A802D4BA6}.Debug|x64.ActiveCfg = Debug|x64 - {EC0A8C41-A429-42CD-B8FA-401A802D4BA6}.Debug|x64.Build.0 = Debug|x64 - {EC0A8C41-A429-42CD-B8FA-401A802D4BA6}.Release|x64.ActiveCfg = Release|x64 - {EC0A8C41-A429-42CD-B8FA-401A802D4BA6}.Release|x64.Build.0 = Release|x64 {83CC74B7-F444-40E1-BD06-67CEC995A919}.Debug|x64.ActiveCfg = Debug|x64 {83CC74B7-F444-40E1-BD06-67CEC995A919}.Debug|x64.Build.0 = Debug|x64 {83CC74B7-F444-40E1-BD06-67CEC995A919}.Release|x64.ActiveCfg = Release|x64 {83CC74B7-F444-40E1-BD06-67CEC995A919}.Release|x64.Build.0 = Release|x64 - {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Debug|x64.ActiveCfg = Debug|x64 - {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Debug|x64.Build.0 = Debug|x64 - {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Release|x64.ActiveCfg = Release|x64 - {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Release|x64.Build.0 = Release|x64 {06CD5155-4459-48C3-8A53-E0B91136351B}.Debug|x64.ActiveCfg = Debug|x64 {06CD5155-4459-48C3-8A53-E0B91136351B}.Debug|x64.Build.0 = Debug|x64 {06CD5155-4459-48C3-8A53-E0B91136351B}.Release|x64.ActiveCfg = Release|x64 @@ -43,14 +31,14 @@ Global {74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Debug|x64.Build.0 = Debug|x64 {74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Release|x64.ActiveCfg = Release|x64 {74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Release|x64.Build.0 = Release|x64 - {E5481D41-196C-4241-AF26-6595EF1863C1}.Debug|x64.ActiveCfg = Debug|x64 - {E5481D41-196C-4241-AF26-6595EF1863C1}.Debug|x64.Build.0 = Debug|x64 - {E5481D41-196C-4241-AF26-6595EF1863C1}.Release|x64.ActiveCfg = Release|x64 - {E5481D41-196C-4241-AF26-6595EF1863C1}.Release|x64.Build.0 = Release|x64 {6DD89FC3-A974-4C39-A3EE-F60C24B17B5B}.Debug|x64.ActiveCfg = Debug|x64 {6DD89FC3-A974-4C39-A3EE-F60C24B17B5B}.Debug|x64.Build.0 = Debug|x64 {6DD89FC3-A974-4C39-A3EE-F60C24B17B5B}.Release|x64.ActiveCfg = Release|x64 {6DD89FC3-A974-4C39-A3EE-F60C24B17B5B}.Release|x64.Build.0 = Release|x64 + {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Debug|x64.ActiveCfg = Debug|x64 + {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Debug|x64.Build.0 = Debug|x64 + {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Release|x64.ActiveCfg = Release|x64 + {1B5ACA07-6266-4C9A-BA30-D4BBE6634846}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE