public static void OpenUserWorldInWorldMenu()
        {
            UserInfoExtensionsMod.HideAllPopups();

            string location;

            if (!Utilities.ActiveUser.IsSelf)
            {
                location = Utilities.ActiveUser.location;
            }
            else
            {
                location = APIUser.CurrentUser.location;
            }
            if (Utilities.userInfo.field_Private_ApiWorld_1 != null && !(string.IsNullOrEmpty(location) || location == "private"))
            {
                string processedLocation = Utilities.ActiveUser.location.Split(new char[] { ':' }, 2)[1];
                int    count;
                try
                {
                    count = Utilities.userInfo.field_Private_ApiWorld_1.instances[processedLocation];
                }
                catch
                {
                    count = 0;
                }
                ApiWorldInstance instance = new ApiWorldInstance(Utilities.userInfo.field_Private_ApiWorld_1, processedLocation, count);
                Utilities.worldInfo.Method_Public_Void_ApiWorld_ApiWorldInstance_Boolean_Boolean_0(Utilities.userInfo.field_Private_ApiWorld_1, instance);
                VRCUiManager.prop_VRCUiManager_0.ShowScreenButton("UserInterface/MenuContent/Screens/WorldInfo");
            }
            else
            {
                Utilities.OpenPopupV2("Notice", "Cannot grab this user's world", "Close", new Action(() => Utilities.ClosePopup()));
            }
        }
        public static void OpenUserInBrowser()
        {
            UserInfoExtensionsMod.HideAllPopups();

            System.Diagnostics.Process.Start("https://vrchat.com/home/user/" + Utilities.ActiveUser.id);
            Utilities.OpenPopupV2("Notice:", "User has been opened in the default browser", "Close", new Action(() => Utilities.ClosePopup()));
        }
        public static void ShowBioLinksPopup()
        {
            UserInfoExtensionsMod.HideAllPopups();

            if (Utilities.ActiveUser.bioLinks == null)
            {
                Utilities.OpenPopupV2("Notice:", "Cannot get users links", "Close", new Action(() => Utilities.ClosePopup()));
            }
            else
            {
                CheckLinks(Utilities.ActiveUser.bioLinks);
                if (Utilities.ActiveUser.bioLinks.Count == 0)
                {
                    Utilities.OpenPopupV2("Notice:", "This user has no bio links", "Close", new Action(() => Utilities.ClosePopup()));
                }
                else if (bioLinks.Count == 0)
                {
                    Utilities.OpenPopupV2("Notice:", "This user has invalid links", "Close", new Action(() => Utilities.ClosePopup()));
                }
                else
                {
                    VRCUiManager.prop_VRCUiManager_0.ShowScreenButton("UserInterface/MenuContent/Popups/BioLinksPopup");
                }
            }
        }
        public static void ShowBioLanguagesPopup()
        {
            UserInfoExtensionsMod.HideAllPopups();

            if (userLanguages == null || userLanguages.Count == 0)
            {
                Utilities.OpenPopupV2("Notice:", "This user has no bio languages", "Close", new Action(() => Utilities.ClosePopup()));
            }
            else
            {
                VRCUiManager.prop_VRCUiManager_0.ShowScreenButton("UserInterface/MenuContent/Popups/BioLanguagesPopup");
            }
        }
        public static void GetBio()
        {
            UserInfoExtensionsMod.HideAllPopups();

            if (Utilities.ActiveUser.bio != null && Utilities.ActiveUser.bio.Length >= 100)
            {
                Utilities.OpenPopupV1("Bio:", Utilities.ActiveUser.bio, "Close", new Action(() => Utilities.ClosePopup()));
            }
            else
            {
                Utilities.OpenPopupV2("Bio:", Utilities.ActiveUser.bio, "Close", new Action(() => Utilities.ClosePopup()));
            }
        }
        public static void FromAvatar()
        {
            UserInfoExtensionsMod.HideAllPopups();

            if (!canGet)
            {
                Utilities.OpenPopupV2("Slow down!", "Please wait a little in between button presses", "Close", new Action(() => Utilities.ClosePopup()));
                return;
            }

            MelonCoroutines.Start(StartTimer());

            isFromSocialPage = false;
            OpenUserInSocialMenu(avatarPage.field_Public_SimpleAvatarPedestal_0.field_Internal_ApiAvatar_0.authorId);
        }
Exemplo n.º 7
0
        public override void OnApplicationStart()
        {
            Instance = this;
            CacheManager.Init();

            foreach (MethodInfo method in typeof(MenuController).GetMethods().Where(mi => mi.Name.StartsWith("Method_Public_Void_APIUser_") && !mi.Name.Contains("_PDM_")))
            {
                HarmonyInstance.Patch(method, postfix: new HarmonyMethod(typeof(UserInfoExtensionsMod).GetMethod("OnUserInfoOpen", BindingFlags.Static | BindingFlags.Public)));
            }
            HarmonyInstance.Patch(AccessTools.Method(typeof(PageUserInfo), "Back"), postfix: new HarmonyMethod(typeof(UserInfoExtensionsMod).GetMethod("OnUserInfoClose", BindingFlags.Static | BindingFlags.Public)));
            LayoutDescription popupLayout = new LayoutDescription
            {
                RowHeight  = 80,
                NumColumns = 3,
                NumRows    = 5
            };

            menu            = ExpansionKitApi.CreateCustomFullMenuPopup(popupLayout);
            userDetailsMenu = ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UserDetailsMenu);

            menu.AddLabel("General Things");
            menu.AddSpacer();
            menu.AddSimpleButton("Back", () => menu.Hide());
            userDetailsMenu.AddSimpleButton("UserInfoExtensions", () =>
            {
                HideAllPopups();
                menu.Show();
                foreach (ModuleBase module in modules)
                {
                    module.OnUIXMenuOpen();
                }
            });

            AddModule(new QuickMenuFromSocial());
            AddModule(new GetAvatarAuthor());
            AddModule(new BioButtons());
            AddModule(new UserInformation());
            AddModule(new AvatarInformation());

            VRCUtils.OnUiManagerInit += OnUiManagerInit;

            MelonLogger.Msg("Initialized!");
        }
        public static void ToQuickMenu()
        {
            UserInfoExtensionsMod.HideAllPopups();

            foreach (Player player in PlayerManager.field_Private_Static_PlayerManager_0.field_Private_List_1_Player_0)
            {
                if (player.field_Private_APIUser_0 == null)
                {
                    continue;
                }
                if (player.field_Private_APIUser_0.id == Utilities.ActiveUser.id)
                {
                    closeMenu.Invoke(VRCUiManager.prop_VRCUiManager_0, new object[] { true, false });                                                    //Closes Big Menu
                    openQuickMenu.Invoke(QuickMenu.prop_QuickMenu_0, new object[] { true });                                                             //Opens Quick Menu
                    QuickMenu.prop_QuickMenu_0.Method_Public_Void_Player_0(PlayerManager.Method_Public_Static_Player_String_0(Utilities.ActiveUser.id)); //Does the rest lmao
                    return;
                }
            }
            Utilities.OpenPopupV2("Notice:", "You cannot show this user on the Quick Menu because they are not in the same instance", "Close", new Action(() => Utilities.ClosePopup()));
        }
        public static async void FromSocial()
        {
            UserInfoExtensionsMod.HideAllPopups();

            if (!canGet)
            {
                Utilities.OpenPopupV2("Slow down!", "Please wait a little in between button presses", "Close", new Action(() => Utilities.ClosePopup()));
                return;
            }

            MelonCoroutines.Start(StartTimer());

            WebRequest request = WebRequest.Create(avatarLink.OriginalString);

            try
            {
                WebResponse response = await request.GetResponseAsync().NoAwait();

                isFromSocialPage = true;

                StreamReader streamReader  = new StreamReader(response.GetResponseStream());
                JObject      jsonData      = JObject.Parse(streamReader.ReadToEnd());
                JsonData     requestedData = jsonData.ToObject <JsonData>();

                await Utilities.YieldToMainThread();

                OpenUserInSocialMenu(requestedData.ownerId);

                response.Close();
                streamReader.Close();
            }
            catch
            {
                Utilities.OpenPopupV2("Error!", "Something went wrong and the author could not be retreived. Please try again", "Close", new Action(() => Utilities.ClosePopup()));
                return;
            }
        }