mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Notification delay
World ragdoll restriction
This commit is contained in:
parent
9c339f3662
commit
0239ab3057
14 changed files with 501 additions and 414 deletions
|
@ -1,4 +1,4 @@
|
|||
[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.6", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.7", "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)]
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
# Players Instance Notifier
|
||||
This mod implements sound notifications for players joining and leaving.
|
||||
This can be considered as attempt of [JoinNotifier](https://github.com/knah/VRCMods/tree/master/JoinNotifier) revival.
|
||||
|
||||
# Installation
|
||||
* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader)
|
||||
* Get [latest release DLL](../../../releases/latest):
|
||||
* Put `ml_pin.dll` in `Mods` folder of game
|
||||
|
||||
# Usage
|
||||
Available mod's settings in `Settings - Audio - Players Instance Notifier`:
|
||||
* **Notify of:** players notification filter type, available filters: `None`, `Friends`, `All`; `All` by default.
|
||||
* **Mixed volume:** volume of notifications; `100` by default.
|
||||
* Note: Respects game's interface volume setting and mixes with it accordingly.
|
||||
* **Notify in public instances:** notifies in `Public` instances; `true` by default.
|
||||
* **Notify in friends instances:** notifies in `Friends of friends` and `Friends` instances; `true` by default.
|
||||
* **Notify in private instances:** notifies in `Everyone can invite` and `Owner must invite` instances; `true` by default.
|
||||
* **Always notify of friends:** notifies friends join/leave no matter what; `false` by default.
|
||||
|
||||
# Custom notification sounds
|
||||
You can setup your own notification sounds.
|
||||
Go to `<game_folder>/UserData/PlayersInstanceNotifier` and replace to your preferable sounds.
|
||||
|
||||
Available sounds for replacement:
|
||||
* **player_join.wav**
|
||||
* **player_leave.wav**
|
||||
* **friend_join.wav**
|
||||
* **friend_leave.wav**
|
||||
# Players Instance Notifier
|
||||
This mod implements sound notifications for players joining and leaving.
|
||||
This can be considered as attempt of [JoinNotifier](https://github.com/knah/VRCMods/tree/master/JoinNotifier) revival.
|
||||
|
||||
# Installation
|
||||
* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader)
|
||||
* Get [latest release DLL](../../../releases/latest):
|
||||
* Put `ml_pin.dll` in `Mods` folder of game
|
||||
|
||||
# Usage
|
||||
Available mod's settings in `Settings - Audio - Players Instance Notifier`:
|
||||
* **Notify of:** players notification filter type, available filters: `None`, `Friends`, `All`; `All` by default.
|
||||
* **Mixed volume:** volume of notifications; `100` by default.
|
||||
* Note: Respects game's interface volume setting and mixes with it accordingly.
|
||||
* **Delay between notifications:** prevents notification until previous one is finished; `true` by default.
|
||||
* **Notify in public instances:** notifies in `Public` instances; `true` by default.
|
||||
* **Notify in friends instances:** notifies in `Friends of friends` and `Friends` instances; `true` by default.
|
||||
* **Notify in private instances:** notifies in `Everyone can invite` and `Owner must invite` instances; `true` by default.
|
||||
* **Always notify of friends:** notifies friends join/leave no matter what; `false` by default.
|
||||
|
||||
# Custom notification sounds
|
||||
You can setup your own notification sounds.
|
||||
Go to `<game_folder>/UserData/PlayersInstanceNotifier` and replace to your preferable sounds.
|
||||
|
||||
Available sounds for replacement:
|
||||
* **player_join.wav**
|
||||
* **player_leave.wav**
|
||||
* **friend_join.wav**
|
||||
* **friend_leave.wav**
|
||||
|
|
|
@ -1,195 +1,207 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ml_pin
|
||||
{
|
||||
static class Settings
|
||||
{
|
||||
internal class SettingEvent<T>
|
||||
{
|
||||
event Action<T> m_action;
|
||||
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
|
||||
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
|
||||
public void Invoke(T p_value) => m_action?.Invoke(p_value);
|
||||
}
|
||||
|
||||
public enum NotificationType
|
||||
{
|
||||
None = 0,
|
||||
Friends,
|
||||
All
|
||||
};
|
||||
|
||||
enum ModSetting
|
||||
{
|
||||
NotifyType,
|
||||
Volume,
|
||||
NotifyInPublic,
|
||||
NotifyInFriends,
|
||||
NotifyInPrivate,
|
||||
FriendsAlways
|
||||
};
|
||||
|
||||
public static NotificationType NotifyType { get; private set; } = NotificationType.All;
|
||||
public static float Volume { get; private set; } = 1.0f;
|
||||
public static bool NotifyInPublic { get; private set; } = true;
|
||||
public static bool NotifyInFriends { get; private set; } = true;
|
||||
public static bool NotifyInPrivate { get; private set; } = true;
|
||||
public static bool FriendsAlways { get; private set; } = false;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
public static readonly SettingEvent<NotificationType> OnNotifyTypeChanged = new SettingEvent<NotificationType>();
|
||||
public static readonly SettingEvent<float> OnVolumeChanged = new SettingEvent<float>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInPublicChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInFriendsChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInPrivateChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnFriendsAlwaysChanged = new SettingEvent<bool>();
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PIN", null, true);
|
||||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.NotifyType.ToString(), (int)NotifyType),
|
||||
ms_category.CreateEntry(ModSetting.Volume.ToString(), (int)(Volume * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInPublic.ToString(), NotifyInPublic),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInFriends.ToString(), NotifyInFriends),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInPrivate.ToString(), NotifyInPrivate),
|
||||
ms_category.CreateEntry(ModSetting.FriendsAlways.ToString(), FriendsAlways),
|
||||
};
|
||||
|
||||
NotifyType = (NotificationType)(int)ms_entries[(int)ModSetting.NotifyType].BoxedValue;
|
||||
Volume = (int)ms_entries[(int)ModSetting.Volume].BoxedValue * 0.01f;
|
||||
NotifyInPublic = (bool)ms_entries[(int)ModSetting.NotifyInPublic].BoxedValue;
|
||||
NotifyInFriends = (bool)ms_entries[(int)ModSetting.NotifyInFriends].BoxedValue;
|
||||
NotifyInPrivate = (bool)ms_entries[(int)ModSetting.NotifyInPrivate].BoxedValue;
|
||||
FriendsAlways = (bool)ms_entries[(int)ModSetting.FriendsAlways].BoxedValue;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
||||
static System.Collections.IEnumerator WaitMainMenuUi()
|
||||
{
|
||||
while(ViewManager.Instance == null)
|
||||
yield return null;
|
||||
while(ViewManager.Instance.gameMenuView == null)
|
||||
yield return null;
|
||||
while(ViewManager.Instance.gameMenuView.Listener == null)
|
||||
yield return null;
|
||||
|
||||
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action<string, string>(OnToggleUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnSliderUpdate_" + ms_category.Identifier, new Action<string, string>(OnSliderUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnDropdownUpdate_" + ms_category.Identifier, new Action<string, string>(OnDropdownUpdate));
|
||||
};
|
||||
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(ResourcesHandler.GetEmbeddedResource("mods_extension.js"));
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(ResourcesHandler.GetEmbeddedResource("mod_menu.js"));
|
||||
foreach(var l_entry in ms_entries)
|
||||
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSetting", ms_category.Identifier, l_entry.DisplayName, l_entry.GetValueAsString());
|
||||
};
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && bool.TryParse(p_value, out bool l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.NotifyInPublic:
|
||||
{
|
||||
NotifyInPublic = l_value;
|
||||
OnNotifyInPublicChanged.Invoke(NotifyInPublic);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.NotifyInFriends:
|
||||
{
|
||||
NotifyInFriends = l_value;
|
||||
OnNotifyInFriendsChanged.Invoke(NotifyInFriends);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.NotifyInPrivate:
|
||||
{
|
||||
NotifyInPrivate = l_value;
|
||||
OnNotifyInPrivateChanged.Invoke(NotifyInPrivate);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FriendsAlways:
|
||||
{
|
||||
FriendsAlways = l_value;
|
||||
OnFriendsAlwaysChanged.Invoke(FriendsAlways);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && int.TryParse(p_value, out int l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.Volume:
|
||||
{
|
||||
Volume = l_value * 0.01f;
|
||||
OnVolumeChanged.Invoke(Volume);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnDropdownUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && int.TryParse(p_value, out int l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.NotifyType:
|
||||
{
|
||||
NotifyType = (NotificationType)l_value;
|
||||
OnNotifyTypeChanged.Invoke(NotifyType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ml_pin
|
||||
{
|
||||
static class Settings
|
||||
{
|
||||
internal class SettingEvent<T>
|
||||
{
|
||||
event Action<T> m_action;
|
||||
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
|
||||
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
|
||||
public void Invoke(T p_value) => m_action?.Invoke(p_value);
|
||||
}
|
||||
|
||||
public enum NotificationType
|
||||
{
|
||||
None = 0,
|
||||
Friends,
|
||||
All
|
||||
};
|
||||
|
||||
enum ModSetting
|
||||
{
|
||||
NotifyType,
|
||||
Volume,
|
||||
Delay,
|
||||
NotifyInPublic,
|
||||
NotifyInFriends,
|
||||
NotifyInPrivate,
|
||||
FriendsAlways
|
||||
};
|
||||
|
||||
public static NotificationType NotifyType { get; private set; } = NotificationType.All;
|
||||
public static float Volume { get; private set; } = 1.0f;
|
||||
public static bool Delay { get; private set; } = true;
|
||||
public static bool NotifyInPublic { get; private set; } = true;
|
||||
public static bool NotifyInFriends { get; private set; } = true;
|
||||
public static bool NotifyInPrivate { get; private set; } = true;
|
||||
public static bool FriendsAlways { get; private set; } = false;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
public static readonly SettingEvent<NotificationType> OnNotifyTypeChanged = new SettingEvent<NotificationType>();
|
||||
public static readonly SettingEvent<float> OnVolumeChanged = new SettingEvent<float>();
|
||||
public static readonly SettingEvent<bool> OnDelayChange = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInPublicChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInFriendsChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnNotifyInPrivateChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnFriendsAlwaysChanged = new SettingEvent<bool>();
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("PIN", null, true);
|
||||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.NotifyType.ToString(), (int)NotifyType),
|
||||
ms_category.CreateEntry(ModSetting.Volume.ToString(), (int)(Volume * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.Delay.ToString(), Delay),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInPublic.ToString(), NotifyInPublic),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInFriends.ToString(), NotifyInFriends),
|
||||
ms_category.CreateEntry(ModSetting.NotifyInPrivate.ToString(), NotifyInPrivate),
|
||||
ms_category.CreateEntry(ModSetting.FriendsAlways.ToString(), FriendsAlways),
|
||||
};
|
||||
|
||||
NotifyType = (NotificationType)(int)ms_entries[(int)ModSetting.NotifyType].BoxedValue;
|
||||
Volume = (int)ms_entries[(int)ModSetting.Volume].BoxedValue * 0.01f;
|
||||
Delay = (bool)ms_entries[(int)ModSetting.Delay].BoxedValue;
|
||||
NotifyInPublic = (bool)ms_entries[(int)ModSetting.NotifyInPublic].BoxedValue;
|
||||
NotifyInFriends = (bool)ms_entries[(int)ModSetting.NotifyInFriends].BoxedValue;
|
||||
NotifyInPrivate = (bool)ms_entries[(int)ModSetting.NotifyInPrivate].BoxedValue;
|
||||
FriendsAlways = (bool)ms_entries[(int)ModSetting.FriendsAlways].BoxedValue;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
||||
static System.Collections.IEnumerator WaitMainMenuUi()
|
||||
{
|
||||
while(ViewManager.Instance == null)
|
||||
yield return null;
|
||||
while(ViewManager.Instance.gameMenuView == null)
|
||||
yield return null;
|
||||
while(ViewManager.Instance.gameMenuView.Listener == null)
|
||||
yield return null;
|
||||
|
||||
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action<string, string>(OnToggleUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnSliderUpdate_" + ms_category.Identifier, new Action<string, string>(OnSliderUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnDropdownUpdate_" + ms_category.Identifier, new Action<string, string>(OnDropdownUpdate));
|
||||
};
|
||||
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(ResourcesHandler.GetEmbeddedResource("mods_extension.js"));
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(ResourcesHandler.GetEmbeddedResource("mod_menu.js"));
|
||||
foreach(var l_entry in ms_entries)
|
||||
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSetting", ms_category.Identifier, l_entry.DisplayName, l_entry.GetValueAsString());
|
||||
};
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && bool.TryParse(p_value, out bool l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.Delay:
|
||||
{
|
||||
Delay = l_value;
|
||||
OnDelayChange.Invoke(Delay);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.NotifyInPublic:
|
||||
{
|
||||
NotifyInPublic = l_value;
|
||||
OnNotifyInPublicChanged.Invoke(NotifyInPublic);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.NotifyInFriends:
|
||||
{
|
||||
NotifyInFriends = l_value;
|
||||
OnNotifyInFriendsChanged.Invoke(NotifyInFriends);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.NotifyInPrivate:
|
||||
{
|
||||
NotifyInPrivate = l_value;
|
||||
OnNotifyInPrivateChanged.Invoke(NotifyInPrivate);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FriendsAlways:
|
||||
{
|
||||
FriendsAlways = l_value;
|
||||
OnFriendsAlwaysChanged.Invoke(FriendsAlways);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && int.TryParse(p_value, out int l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.Volume:
|
||||
{
|
||||
Volume = l_value * 0.01f;
|
||||
OnVolumeChanged.Invoke(Volume);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnDropdownUpdate(string p_name, string p_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting) && int.TryParse(p_value, out int l_value))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.NotifyType:
|
||||
{
|
||||
NotifyType = (NotificationType)l_value;
|
||||
OnNotifyTypeChanged.Invoke(NotifyType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = l_value;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,70 +1,99 @@
|
|||
using ABI_RC.Core.AudioEffects;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace ml_pin
|
||||
{
|
||||
class SoundManager
|
||||
{
|
||||
public enum SoundType
|
||||
{
|
||||
PlayerJoin = 0,
|
||||
PlayerLeave,
|
||||
FriendJoin,
|
||||
FriendLeave
|
||||
}
|
||||
|
||||
const string c_modName = "PlayersInstanceNotifier";
|
||||
|
||||
bool m_loaded = false;
|
||||
readonly AudioClip[] m_clips = null;
|
||||
|
||||
internal SoundManager()
|
||||
{
|
||||
m_clips = new AudioClip[4];
|
||||
for(int i = 0; i < 4; i++)
|
||||
m_clips[i] = null;
|
||||
}
|
||||
public void LoadSounds()
|
||||
{
|
||||
if(!m_loaded)
|
||||
{
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.PlayerJoin, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "player_join.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.PlayerLeave, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "player_leave.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.FriendJoin, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "friend_join.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.FriendLeave, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "friend_leave.wav")));
|
||||
|
||||
m_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator LoadAudioClip(SoundType p_type, string p_path)
|
||||
{
|
||||
using UnityWebRequest l_uwr = UnityWebRequestMultimedia.GetAudioClip("file://" + p_path, AudioType.WAV);
|
||||
((DownloadHandlerAudioClip)l_uwr.downloadHandler).streamAudio = true;
|
||||
yield return l_uwr.SendWebRequest();
|
||||
|
||||
if(l_uwr.isNetworkError || l_uwr.isHttpError)
|
||||
{
|
||||
MelonLoader.MelonLogger.Warning(l_uwr.error);
|
||||
yield break;
|
||||
}
|
||||
|
||||
AudioClip l_content;
|
||||
AudioClip l_clip = (l_content = DownloadHandlerAudioClip.GetContent(l_uwr));
|
||||
yield return l_content;
|
||||
if(!l_uwr.isDone || (l_clip == null))
|
||||
yield break;
|
||||
|
||||
m_clips[(int)p_type] = l_clip;
|
||||
}
|
||||
|
||||
public void PlaySound(SoundType p_type)
|
||||
{
|
||||
if(m_loaded && (m_clips[(int)p_type] != null))
|
||||
InterfaceAudio.Instance.UserInterfaceAudio.PlayOneShot(m_clips[(int)p_type], Settings.Volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
using ABI_RC.Core.AudioEffects;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace ml_pin
|
||||
{
|
||||
class SoundManager
|
||||
{
|
||||
public enum SoundType
|
||||
{
|
||||
PlayerJoin = 0,
|
||||
PlayerLeave,
|
||||
FriendJoin,
|
||||
FriendLeave
|
||||
}
|
||||
|
||||
const string c_modName = "PlayersInstanceNotifier";
|
||||
|
||||
bool m_loaded = false;
|
||||
readonly AudioClip[] m_clips = null;
|
||||
int[] m_clipDelays = null;
|
||||
int[] m_playTicks = null;
|
||||
|
||||
internal SoundManager()
|
||||
{
|
||||
m_clips = new AudioClip[4];
|
||||
for(int i = 0; i < 4; i++)
|
||||
m_clips[i] = null;
|
||||
|
||||
m_clipDelays = new int[4];
|
||||
m_clipDelays[(int)SoundType.PlayerJoin] = 708;
|
||||
m_clipDelays[(int)SoundType.PlayerLeave] = 380;
|
||||
m_clipDelays[(int)SoundType.FriendJoin] = 708;
|
||||
m_clipDelays[(int)SoundType.FriendLeave] = 380;
|
||||
|
||||
m_playTicks = new int[4];
|
||||
for(int i = 0; i < 4; i++)
|
||||
m_playTicks[i] = 0;
|
||||
}
|
||||
public void LoadSounds()
|
||||
{
|
||||
if(!m_loaded)
|
||||
{
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.PlayerJoin, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "player_join.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.PlayerLeave, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "player_leave.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.FriendJoin, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "friend_join.wav")));
|
||||
MelonLoader.MelonCoroutines.Start(LoadAudioClip(SoundType.FriendLeave, Path.Combine(MelonLoader.Utils.MelonEnvironment.UserDataDirectory, c_modName, "friend_leave.wav")));
|
||||
|
||||
m_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator LoadAudioClip(SoundType p_type, string p_path)
|
||||
{
|
||||
using UnityWebRequest l_uwr = UnityWebRequestMultimedia.GetAudioClip("file://" + p_path, AudioType.WAV);
|
||||
((DownloadHandlerAudioClip)l_uwr.downloadHandler).streamAudio = true;
|
||||
yield return l_uwr.SendWebRequest();
|
||||
|
||||
if(l_uwr.isNetworkError || l_uwr.isHttpError)
|
||||
{
|
||||
MelonLoader.MelonLogger.Warning(l_uwr.error);
|
||||
yield break;
|
||||
}
|
||||
|
||||
AudioClip l_content;
|
||||
AudioClip l_clip = (l_content = DownloadHandlerAudioClip.GetContent(l_uwr));
|
||||
yield return l_content;
|
||||
if(!l_uwr.isDone || (l_clip == null))
|
||||
yield break;
|
||||
|
||||
m_clips[(int)p_type] = l_clip;
|
||||
m_clipDelays[(int)p_type] = (int)(l_clip.length * 1000f);
|
||||
}
|
||||
|
||||
public void PlaySound(SoundType p_type)
|
||||
{
|
||||
if(m_loaded && (m_clips[(int)p_type] != null))
|
||||
{
|
||||
if(Settings.Delay)
|
||||
{
|
||||
int l_tick = Environment.TickCount;
|
||||
if(l_tick - m_playTicks[(int)p_type] > m_clipDelays[(int)p_type])
|
||||
{
|
||||
m_playTicks[(int)p_type] = l_tick;
|
||||
InterfaceAudio.Instance.UserInterfaceAudio.PlayOneShot(m_clips[(int)p_type], Settings.Volume);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_playTicks[(int)p_type] = Environment.TickCount;
|
||||
InterfaceAudio.Instance.UserInterfaceAudio.PlayOneShot(m_clips[(int)p_type], Settings.Volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Authors>SDraw</Authors>
|
||||
<Company>None</Company>
|
||||
<Product>PlayersInstanceNotifier</Product>
|
||||
<Version>1.0.6</Version>
|
||||
<Version>1.0.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
|
|
@ -1,64 +1,71 @@
|
|||
{
|
||||
let l_block = document.createElement('div');
|
||||
l_block.innerHTML = `
|
||||
<div class ="settings-subcategory">
|
||||
<div class ="subcategory-name">Players Instance Notifier</div>
|
||||
<div class ="subcategory-description"></div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify of: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyType" class ="inp_dropdown no-scroll" data-options="0:None,1:Friends,2:All" data-current="2"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Mixed volume: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Volume" class ="inp_slider no-scroll" data-min="0" data-max="100" data-current="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in public instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInPublic" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in friends instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInFriends" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in private instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInPrivate" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Always notify of friends: </div>
|
||||
<div class ="option-input">
|
||||
<div id="FriendsAlways" class ="inp_toggle no-scroll" data-current="false"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('settings-audio').appendChild(l_block);
|
||||
|
||||
// Toggles
|
||||
for (let l_toggle of l_block.querySelectorAll('.inp_toggle'))
|
||||
modsExtension.addSetting('PIN', l_toggle.id, modsExtension.createToggle(l_toggle, 'OnToggleUpdate_PIN'));
|
||||
|
||||
// Sliders
|
||||
for (let l_slider of l_block.querySelectorAll('.inp_slider'))
|
||||
modsExtension.addSetting('PIN', l_slider.id, modsExtension.createSlider(l_slider, 'OnSliderUpdate_PIN'));
|
||||
|
||||
// Dropdowns
|
||||
for (let l_dropdown of l_block.querySelectorAll('.inp_dropdown'))
|
||||
modsExtension.addSetting('PIN', l_dropdown.id, modsExtension.createDropdown(l_dropdown, 'OnDropdownUpdate_PIN'));
|
||||
}
|
||||
{
|
||||
let l_block = document.createElement('div');
|
||||
l_block.innerHTML = `
|
||||
<div class ="settings-subcategory">
|
||||
<div class ="subcategory-name">Players Instance Notifier</div>
|
||||
<div class ="subcategory-description"></div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify of: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyType" class ="inp_dropdown no-scroll" data-options="0:None,1:Friends,2:All" data-current="2"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Mixed volume: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Volume" class ="inp_slider no-scroll" data-min="0" data-max="100" data-current="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Delay between notifications: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Delay" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in public instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInPublic" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in friends instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInFriends" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Notify in private instances: </div>
|
||||
<div class ="option-input">
|
||||
<div id="NotifyInPrivate" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Always notify of friends: </div>
|
||||
<div class ="option-input">
|
||||
<div id="FriendsAlways" class ="inp_toggle no-scroll" data-current="false"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('settings-audio').appendChild(l_block);
|
||||
|
||||
// Toggles
|
||||
for (let l_toggle of l_block.querySelectorAll('.inp_toggle'))
|
||||
modsExtension.addSetting('PIN', l_toggle.id, modsExtension.createToggle(l_toggle, 'OnToggleUpdate_PIN'));
|
||||
|
||||
// Sliders
|
||||
for (let l_slider of l_block.querySelectorAll('.inp_slider'))
|
||||
modsExtension.addSetting('PIN', l_slider.id, modsExtension.createSlider(l_slider, 'OnSliderUpdate_PIN'));
|
||||
|
||||
// Dropdowns
|
||||
for (let l_dropdown of l_block.querySelectorAll('.inp_dropdown'))
|
||||
modsExtension.addSetting('PIN', l_dropdown.id, modsExtension.createDropdown(l_dropdown, 'OnDropdownUpdate_PIN'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue