Esempio n. 1
0
        public void OnPlayerLeft(Player player)
        {
            var apiUser = player.field_Private_APIUser_0;

            if (!JoinNotifierSettings.ShouldNotifyInCurrentInstance())
            {
                return;
            }
            if (Environment.TickCount - myLastLevelLoad < 5_000)
            {
                return;
            }
            var isFriendsWith = APIUser.IsFriendsWith(apiUser.id);

            if (JoinNotifierSettings.ShowFriendsOnly() && !isFriendsWith)
            {
                return;
            }
            var playerName = player.field_Private_APIUser_0.displayName ?? "!null!";

            if (JoinNotifierSettings.ShouldBlinkIcon(false))
            {
                MelonCoroutines.Start(BlinkIconCoroutine(myLeaveImage));
            }
            if (JoinNotifierSettings.ShouldPlaySound(false))
            {
                myLeaveSource.Play();
            }
            if (JoinNotifierSettings.ShouldShowNames(false))
            {
                MelonCoroutines.Start(ShowName(myLeaveText, myLeaveNames, playerName, false, isFriendsWith));
            }
        }
Esempio n. 2
0
        private void CreateGameObjects()
        {
            if (myJoinImage != null)
            {
                return;
            }

            var hudRoot = GameObject.Find("UserInterface/UnscaledUI/HudContent/Hud");

            if (hudRoot == null)
            {
                MelonLogger.Log("Not creating gameobjects - no hud root");
                return;
            }

            MelonLogger.Log("Creating gameobjects");
//            var pathToThing = "UserInterface/UnscaledUI/HudContent/Hud/NotificationDotParent/NotificationDot";
            myJoinImage  = CreateNotifierImage("join", 0f, JoinNotifierSettings.GetJoinIconColor());
            myJoinSource = CreateAudioSource(myJoinClip, myJoinImage.gameObject);
            myJoinText   = CreateTextNear(myJoinImage, 110f, TextAnchor.LowerRight);

            myLeaveImage  = CreateNotifierImage("leave", 100f, JoinNotifierSettings.GetLeaveIconColor());
            myLeaveSource = CreateAudioSource(myLeaveClip, myLeaveImage.gameObject);
            myLeaveText   = CreateTextNear(myLeaveImage, 110f, TextAnchor.LowerLeft);
        }
Esempio n. 3
0
        public void OnPlayerJoined(Player player)
        {
            var apiUser = player.field_Private_APIUser_0;

            if (APIUser.CurrentUser.id == apiUser.id)
            {
                myObservedLocalPlayerJoin = true;
                myLastLevelLoad           = Environment.TickCount;
            }

            if (!myObservedLocalPlayerJoin || Environment.TickCount - myLastLevelLoad < 5_000)
            {
                return;
            }
            if (!JoinNotifierSettings.ShouldNotifyInCurrentInstance())
            {
                return;
            }
            var playerName = apiUser.displayName ?? "!null!";

            if (JoinNotifierSettings.ShouldBlinkIcon(true))
            {
                MelonCoroutines.Start(BlinkIconCoroutine(myJoinImage));
            }
            if (JoinNotifierSettings.ShouldPlaySound(true))
            {
                myJoinSource.Play();
            }
            if (JoinNotifierSettings.ShouldShowNames(true))
            {
                MelonCoroutines.Start(ShowName(myJoinText, playerName));
            }
        }
Esempio n. 4
0
        public override void OnApplicationStart()
        {
            MelonLogger.Log("ApplicationStart");
            JoinNotifierSettings.RegisterSettings();
            // MelonLogger.Log("ApplicationStart done");

            MelonCoroutines.Start(InitThings());
        }
Esempio n. 5
0
        private AudioSource CreateAudioSource(AudioClip clip, GameObject parent)
        {
            var source = parent.AddComponent <AudioSource>();

            source.clip        = clip;
            source.spatialize  = false;
            source.volume      = JoinNotifierSettings.GetSoundVolume();
            source.loop        = false;
            source.playOnAwake = false;
            if (JoinNotifierSettings.GetUseUiMixer())
            {
                source.outputAudioMixerGroup = VRCAudioManager.field_Private_Static_VRCAudioManager_0.uiGroup;
            }
            return(source);
        }
Esempio n. 6
0
        public IEnumerator ShowName(Text text, List <string> namesList, string name, bool isJoin, bool isFriend)
        {
            var color = JoinNotifierSettings.ShowFriendsInDifferentColor() && isFriend
                ? (isJoin
                    ? JoinNotifierSettings.GetFriendJoinIconColor()
                    : JoinNotifierSettings.GetFriendLeaveIconColor())
                : (isJoin ? JoinNotifierSettings.GetJoinIconColor() : JoinNotifierSettings.GetLeaveIconColor());
            var playerLine = $"<color={RenderHex(color)}>{name}</color>";

            namesList.Add(playerLine);

            text.text = string.Join("\n", namesList);
            yield return(new WaitForSeconds(3));

            namesList.Remove(playerLine);
            text.text = string.Join("\n", namesList);
        }
Esempio n. 7
0
        private Text CreateTextNear(Image image, float offset, TextAnchor alignment)
        {
            var gameObject = new GameObject(image.gameObject.name + "-text");

            gameObject.AddComponent <Text>();
            gameObject.transform.SetParent(image.transform, false);
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.localPosition = Vector3.up * offset;
            var text = gameObject.GetComponent <Text>();

            text.color              = image.color;
            text.fontStyle          = FontStyle.Bold;
            text.horizontalOverflow = HorizontalWrapMode.Overflow;
            text.verticalOverflow   = VerticalWrapMode.Overflow;
            text.alignment          = alignment;
            text.fontSize           = JoinNotifierSettings.GetTextSize();
            text.font = Resources.GetBuiltinResource <Font>("Arial.ttf");

            gameObject.SetActive(true);
            return(text);
        }
Esempio n. 8
0
        public override void OnModSettingsApplied()
        {
            MelonLogger.Log("Settings apply start");
            if (myJoinSource != null)
            {
                myJoinSource.volume = JoinNotifierSettings.GetSoundVolume();
                myJoinSource.outputAudioMixerGroup = JoinNotifierSettings.GetUseUiMixer() ? VRCAudioManager.field_Private_Static_VRCAudioManager_0.uiGroup : null;
            }

            if (myLeaveSource != null)
            {
                myLeaveSource.volume = JoinNotifierSettings.GetSoundVolume();
                myLeaveSource.outputAudioMixerGroup = JoinNotifierSettings.GetUseUiMixer() ? VRCAudioManager.field_Private_Static_VRCAudioManager_0.uiGroup : null;
            }

            if (myJoinImage != null)
            {
                myJoinImage.color = JoinNotifierSettings.GetJoinIconColor();
            }

            if (myLeaveImage != null)
            {
                myLeaveImage.color = JoinNotifierSettings.GetLeaveIconColor();
            }

            if (myJoinText != null)
            {
                myJoinText.fontSize = JoinNotifierSettings.GetTextSize();
                myJoinText.color    = JoinNotifierSettings.GetJoinIconColor();
            }

            if (myLeaveText != null)
            {
                myLeaveText.fontSize = JoinNotifierSettings.GetTextSize();
                myLeaveText.color    = JoinNotifierSettings.GetLeaveIconColor();
            }
            MelonLogger.Log("Settings apply done");
        }
Esempio n. 9
0
        public override void OnApplicationStart()
        {
            JoinNotifierSettings.RegisterSettings();

            MelonCoroutines.Start(InitThings());
        }