Пример #1
0
        public static SimpleAvatarList ParseJSON(string json)
        {
            SimpleAvatarList o = null;

            VRCModLogger.Log("[AvatarFavLocal] Received " + json);
            var root = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);

            if (root.ContainsKey("list"))
            {
                VRCModLogger.Log("[AvatarFavLocal] Detected version 0 schema, upgrading to 1");
                // Version 0
                var avs    = new List <string>();
                var avlist = JsonConvert.DeserializeObject <SerializableApiAvatarList>(json);
                o           = new SimpleAvatarList();
                o.version   = 1;
                o.avatarIDs = (from av in avlist.list select av.id).ToArray();
            }

            if (root.ContainsKey("version"))
            {
                //System.Diagnostics.Debug.WriteLine(root["version"].GetType().FullName);
                var version = (int)(Int64)root["version"];
                if (version == CURRENT_VERSION)
                {
                    VRCModLogger.Log($"[AvatarFavLocal] Detected version {CURRENT_VERSION} schema. Yay!");
                    o = JsonConvert.DeserializeObject <SimpleAvatarList>(json);
                }
            }

            return(o);
        }
Пример #2
0
 public static Command CreateInstance(String className, Client client, bool log = true)
 {
     if (log)
     {
         VRCModLogger.Log("Creating command instance " + className + ". Client: " + client);
     }
     if (commands.TryGetValue(className, out Type commandClass))
     {
         try
         {
             Command command = (Command)Activator.CreateInstance(commandClass);
             long    outId;
             lock (counter)
             {
                 outId = (long)(counter.NextDouble() * long.MaxValue);
             }
             command.SetLog(log);
             command.SetClient(client);
             command.SetOutId(className + " " + outId);
             if (!runningCommands.TryGetValue(className, out Dictionary <string, Command> commandContainer))
             {
                 commandContainer = new Dictionary <String, Command>();
                 runningCommands.Add(className, commandContainer);
             }
             commandContainer.Add("" + outId, command);
             return(command);
         }
         catch (Exception e)
         {
             VRCModLogger.LogError(e.ToString());
         }
     }
     return(null);
 }
Пример #3
0
        private void OnApplicationStart()
        {
            string lp    = "";
            bool   first = true;

            foreach (var lp2 in Environment.GetCommandLineArgs())
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    lp += " " + lp2;
                }
            }
            VRCModLogger.Log("[VRCTools] Launch parameters:" + lp);

            ModPrefs.RegisterCategory("vrctools", "VRCTools");
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownloadasked", false, null, true);
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownload", false, "Enable AvatarFav Updater");

            ModPrefs.RegisterPrefBool("vrctools", "enablediscordrichpresence", true, "Enable Discord RichPresence");
            ModPrefs.RegisterPrefBool("vrctools", "enabledebugconsole", false, "Enable Debug Console");

            ModPrefs.RegisterPrefBool("vrctools", "allowdiscordjoinrequests", true, "Allow Discord join requests");
            ModPrefs.RegisterPrefBool("vrctools", "hidenameondiscord", true, "Hide your name on Discord");
        }
        private static IEnumerator AddAvatarToList(string avatarId, string avatarName)
        {
            bool found = false;

            foreach (string avatarfavId in AvatarFavMod.favoriteAvatarList)
            {
                if (avatarfavId == avatarId)
                {
                    found = true;
                    VRCModLogger.LogError("[VRCheatAvatarfileImporter] Avatar " + avatarName + " already exist in list");
                    break;
                }
            }
            if (!found)
            {
                using (WWW avtrRequest = new WWW(API.GetApiUrl() + "avatars/" + avatarId + "?apiKey=" + AvatarFavMod.GetApiKey()))
                {
                    yield return(avtrRequest);

                    int rc = WebRequestsUtils.GetResponseCode(avtrRequest);
                    if (rc == 200)
                    {
                        string uuid = APIUser.CurrentUser?.id ?? "";
                        SerializableApiAvatar aa = null;
                        try
                        {
                            aa = JsonConvert.DeserializeObject <SerializableApiAvatar>(avtrRequest.text);
                        }
                        catch (Exception e)
                        {
                            VRCModLogger.LogError("[VRCheatAvatarfileImporter] Unable to add the avatar " + avatarName + ": Unable to parse the API response. " + e);
                        }

                        if (aa != null)
                        {
                            if (aa.authorId != uuid)
                            {
                                if (aa.releaseStatus == "public")
                                {
                                    VRCModLogger.Log("[VRCheatAvatarfileImporter] Adding avatar " + avatarName + " to the database");
                                    yield return(AddAvatar(avatarId, avatarName));
                                }
                                else
                                {
                                    VRCModLogger.Log("[VRCheatAvatarfileImporter] Unable to add the avatar " + avatarName + ": This avatar is not public anymore (private)");
                                }
                            }
                            else
                            {
                                VRCModLogger.Log("[VRCheatAvatarfileImporter] Unable to add the avatar " + avatarName + ": This avatar is own avatar");
                            }
                        }
                    }
                    else
                    {
                        VRCModLogger.Log("[VRCheatAvatarfileImporter] Unable to add the avatar " + avatarName + ": This avatar is not public anymore (deleted)");
                    }
                }
            }
        }
Пример #5
0
 static void OnApplicationStart()
 {
     if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WindowsPlayer)
     {
         VRCModLogger.Log("[VeryPoorQuest] This module is intended for use on the Quest! PC users can already set their performance rating minimum...");
     }
 }
Пример #6
0
        internal static IEnumerator CheckDownloadFiles()
        {
            string vrccedllPath = Values.VRCToolsDependenciesPath + "VRCCore-Editor.dll";

            int buildNumber = -1;

            VRCModLogger.Log("[DependenciesDownloader] Getting game version");
            PropertyInfo vrcApplicationSetupInstanceProperty = typeof(VRCApplicationSetup).GetProperties(BindingFlags.Public | BindingFlags.Static).First((pi) => pi.PropertyType == typeof(VRCApplicationSetup));

            if (vrcApplicationSetupInstanceProperty != null)
            {
                buildNumber = ((VRCApplicationSetup)vrcApplicationSetupInstanceProperty.GetValue(null, null)).buildNumber;
            }
            VRCModLogger.Log("[DependenciesDownloader] Game build " + buildNumber);


            yield return(DownloadDependency(ModValues.discordrpcdependencyDownloadLink, "discord-rpc.dll"));

            yield return(DownloadDependency(ModValues.oharmonydependencyDownloadLink, "0Harmony.dll"));

            try
            {
                VRCModLogger.LogError("[DependenciesDownloader] Loading 0Harmony.dll");
                Assembly.LoadFile(Values.VRCToolsDependenciesPath + "0Harmony.dll");
            }
            catch (Exception e)
            {
                VRCModLogger.LogError("[DependenciesDownloader] Unable to load 0Harmony.dll: " + e);
            }
        }
Пример #7
0
        internal static void Patch() // TODO: Optimise this crap
        {
            //APMDPMJMOCD.DBBLBDCLNHJ = FJALLEGMKMA.Full;

            VRCModLogger.Log("[RamExploitPatcher] Creating Harmony instance");
            HarmonyInstance harmonyInstance = HarmonyInstance.Create("vrctools.ramexploitpatcher");

            VRCModLogger.Log("[RamExploitPatcher] Looking for NetworkingPeer.OnEvent method");
            Type[]     typesInAssembly = typeof(QuickMenu).Assembly.GetTypes();
            MethodInfo method          = null;

            foreach (Type type in typesInAssembly)
            {
                if (type.Name != "PunTurnManager")
                {
                    method = type.GetMethod("OnEvent", BindingFlags.Public | BindingFlags.Instance);
                    if (method != null)
                    {
                        break;
                    }
                }
            }

            if (method != null)
            {
                VRCModLogger.Log("[RamExploitPatcher] Patching NetworkingPeer.OnEvent");
                harmonyInstance.Patch(method, null, null, new HarmonyMethod(typeof(RamExploitPatcher).GetMethod("OnEventPatcher", BindingFlags.NonPublic | BindingFlags.Static)));
                VRCModLogger.Log("[RamExploitPatcher] Patch applied !");
            }
            else
            {
                VRCModLogger.LogError("[RamExploitPatcher] Unable to found method NetworkingPeer.OnEvent !");
            }
        }
Пример #8
0
 public void Connected()
 {
     client.autoReconnect = true;
     VRCModLogger.Log("[VRCModNetworkManager] Client autoReconnect set to true");
     State = ConnectionState.CONNECTED;
     OnConnected?.Invoke();
 }
Пример #9
0
 internal static void ConnectAsync()
 {
     if (State != ConnectionState.DISCONNECTED)
     {
         VRCModLogger.Log("[VRCModNetworkManager] Trying to connect to server, but client is not disconnected");
     }
     else if (client != null && client.autoReconnect)
     {
         VRCModLogger.Log("[VRCModNetworkManager] Trying to connect to server, but client already exist and is tagged as auto-reconnecting");
     }
     else
     {
         if (client == null)
         {
             client = new Client(SERVER_ADDRESS, SERVER_PORT, VRCMODNW_VERSION);
             if (instance == null)
             {
                 instance = new VRCModNetworkManager();
             }
             client.SetConnectionListener(instance);
             if (modsCheckerThread == null)
             {
                 modsCheckerThread = new Thread(ModCheckThread)
                 {
                     Name         = "Mod Check Thread",
                     IsBackground = true
                 };
                 modsCheckerThread.Start();
             }
         }
         State = ConnectionState.CONNECTING;
         client.StartConnection();
     }
 }
Пример #10
0
        private static void TryAuthenticate(string authData)
        {
            VRCModLogger.Log("[VRCModNetwork] Getting current instanceId");
            if (RoomManagerBase.currentRoom != null && RoomManagerBase.currentRoom.id != null && RoomManagerBase.currentRoom.currentInstanceIdWithTags != null)
            {
                userInstanceId = RoomManagerBase.currentRoom.id + ":" + RoomManagerBase.currentRoom.currentInstanceIdWithTags;
            }
            VRCModLogger.Log("[VRCModNetwork] Getting current modList");
            modlist = ModDesc.GetAllMods();
            VRCModLogger.Log("[VRCModNetwork] Getting current environment");
            ApiServerEnvironment env = VRCApplicationSetup._instance.ServerEnvironment;
            string stringEnv         = "";

            if (env == ApiServerEnvironment.Dev)
            {
                stringEnv = "dev";
            }
            if (env == ApiServerEnvironment.Beta)
            {
                stringEnv = "beta";
            }
            if (env == ApiServerEnvironment.Release)
            {
                stringEnv = "release";
            }
            VRCModLogger.Log("[VRCModNetwork] Env: " + env);
            VRCModLogger.Log("[VRCModNetwork] Authenticating");
            AuthCommand authCommand = CommandManager.CreateInstance("AUTH", client, false) as AuthCommand;

            authCommand.Auth(userUuid, authData, stringEnv, userInstanceId, roomSecret, modlist);
            VRCModLogger.Log("[VRCModNetwork] Done");
        }
Пример #11
0
        void Update()
        {
            if (toggle.isOn != lastToggle)
            {
                lastToggle = !lastToggle;
                VRCModLogger.Log("Toggle switched to " + lastToggle);
                try { OnChange(lastToggle); } catch (Exception e) { Debug.LogError(e); }
                if (Time.time - startTime >= switchDuration)
                {
                    startTime = Time.time;
                }
                else
                {
                    startTime = Time.time - ((startTime - Time.time) * switchDuration);
                }
            }
            fillValue = Mathf.Clamp((Time.time - startTime) * (1 / switchDuration), 0, 1);
            if (!lastToggle)
            {
                fillValue = 1 - fillValue;
            }

            if (fillValue != 0 && fillValue != 1)
            {
                VRCModLogger.Log("fillValue: " + fillValue);
            }

            cursor.GetComponent <RectTransform>().anchoredPosition = new Vector2(GetSwitchValue(-37, 37), 0);
            backgroundFilling.fillAmount = GetSwitchValue(0.1f, 0.9f);
        }
Пример #12
0
 public void OnUpdate()
 {
     if (initialized)
     {
         if ((RoomManager.currentRoom != null) && !string.IsNullOrEmpty(RoomManager.currentRoom.id) && !string.IsNullOrEmpty(RoomManager.currentRoom.currentInstanceIdOnly))
         {
             if (currentRoom == null)
             {
                 currentRoom = RoomManager.currentRoom;
                 VRC_AvatarPedestal[] pedestalsInWorld = Resources.FindObjectsOfTypeAll <VRC_AvatarPedestal>();
                 VRCModLogger.Log("[AvatarPedestalFix] Found " + pedestalsInWorld.Length + " VRC_AvatarPedestal in current world");
                 foreach (VRC_AvatarPedestal p in pedestalsInWorld)
                 {
                     if (!string.IsNullOrEmpty(p.blueprintId))
                     {
                         foreach (VRC_Trigger trigger in p.GetComponents <VRC_Trigger>())
                         {
                             trigger.ExecuteTrigger = new Action <VRC_Trigger.TriggerEvent>((VRC_Trigger.TriggerEvent evt) => Networking.RPC(VRC_EventHandler.VrcTargetType.Local, (GameObject)instance.GetValue(p), "SetAvatarUse", new object[0]));
                         }
                     }
                 }
             }
         }
         else
         {
             currentRoom = null;
         }
     }
 }
Пример #13
0
        public static void DeviceChanged()
        {
            var isInVR = VRCTrackingManager.IsInVRMode();
            var model  = UnityEngine.XR.XRDevice.model;

            if (isInVR)
            {
                if (model.ToLower().Contains("oculus") || model.ToLower().Contains("rift"))
                {
                    presence.smallImageKey  = "headset_rift";
                    presence.smallImageText = "Oculus Rift";
                }
                else if (model.ToLower().Contains("htc") || model.ToLower().Contains("vive"))
                {
                    presence.smallImageKey  = "headset_vive";
                    presence.smallImageText = "HTC Vive";
                }
                else
                {
                    presence.smallImageKey  = "headset_generic";
                    presence.smallImageText = "VR Headset";
                }
            }
            else
            {
                presence.smallImageKey  = "desktop";
                presence.smallImageText = "Desktop";
            }
            VRCModLogger.Log("[DiscordManager.DeviceChanged] isInVR: " + isInVR + " Model: " + model);
        }
Пример #14
0
        private static IEnumerator CheckAvatarOriginalReleaseStatus(string blueprintId, string id, string authorId)
        {
            VRCModLogger.Log("[AvatarStealerChecker] Checking avatar " + blueprintId);
            using (WWW avtrRequest = new WWW(API.GetApiUrl() + "avatars/" + blueprintId + "?apiKey=" + API.ApiKey))
            {
                yield return(avtrRequest);

                int rc = WebRequestsUtils.GetResponseCode(avtrRequest);
                if (rc == 200)
                {
                    try
                    {
                        VRCModLogger.Log("[AvatarStealerChecker] " + avtrRequest.text);
                        SerializableApiAvatar aa = JsonConvert.DeserializeObject <SerializableApiAvatar>(avtrRequest.text);
                        if (!aa.releaseStatus.Equals("public") && !aa.authorId.Equals(authorId))
                        {
                            VRCModLogger.Log("[AvatarStealerChecker] Avatar " + id + " is a private stealed avatar ! (" + blueprintId + ")");
                            checkedAvatars[id] = true;
                        }
                    }
                    catch (Exception e)
                    {
                        VRCModLogger.LogError("[AvatarStealerChecker] " + e.ToString());
                    }
                }
            }
        }
Пример #15
0
        public static IEnumerator CheckVRCModLoaderHash()
        {
            string vrcmodloaderPath = Values.VRCModLoaderAssemblyPath;

            if (File.Exists(vrcmodloaderPath))
            {
                string fileHash = "";
                using (var md5 = MD5.Create())
                {
                    using (var stream = File.OpenRead(vrcmodloaderPath))
                    {
                        var hash = md5.ComputeHash(stream);
                        fileHash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                    }
                }
                VRCModLogger.Log("[VRCModLoaderUpdater] Local VRCModLoader file hash: " + fileHash);

                WWW hashCheckWWW = new WWW("https://download2.survival-machines.fr/vrcmodloader/VRCModLoaderHashCheck.php?localhash=" + fileHash);
                yield return(hashCheckWWW);

                while (!hashCheckWWW.isDone)
                {
                    yield return(null);
                }
                int responseCode = WebRequestsUtils.GetResponseCode(hashCheckWWW);
                VRCModLogger.Log("[VRCModLoaderUpdater] hash check webpage returned [" + responseCode + "] \"" + hashCheckWWW.text + "\"");
                if (responseCode == 200 && hashCheckWWW.text.Equals("OUTOFDATE"))
                {
                    yield return(ShowVRCModLoaderUpdatePopup());
                }
            }
        }
Пример #16
0
        private IEnumerator VRCToolsSetup()
        {
            VRCModLogger.Log("[VRCTools] Waiting for UI Manager...");
            yield return(VRCUiManagerUtils.WaitForUiManagerInit());

            VRCModLogger.Log("[VRCTools] UIManager initialised ! Resuming setup");

            VRCModLogger.Log("[VRCTools] CheckDownloadFiles");
            yield return(DependenciesDownloader.CheckDownloadFiles());

            VRCModLogger.Log("[VRCTools] CheckVRCModLoaderHash");
            yield return(VRCModLoaderUpdater.CheckVRCModLoaderHash());

            if (ModPrefs.GetBool("vrctools", "enablediscordrichpresence"))
            {
                VRCModLogger.Log("[VRCTools] DiscordManager Init");
                DiscordManager.Init();
            }
            VRCModLogger.Log("[VRCTools] CheckForPermissions");
            yield return(CheckForPermissions());

            VRCModLogger.Log("[VRCTools] VRCModNetworkStatus Setup");
            VRCModNetworkStatus.Setup();
            VRCModLogger.Log("[VRCTools] ModConfigPage Setup");
            ModConfigPage.Setup();
            VRCModLogger.Log("[VRCTools] ModdedUsersManager Init");
            ModdedUsersManager.Init();

            VRCModLogger.Log("[VRCTools] Init done !");

            VRCFlowManagerUtils.EnableVRCFlowManager();

            initialising = false;
            Initialised  = true;
        }
Пример #17
0
 private static MethodInfo GetCallbackHandleMessageMethod()
 {
     VRCModLogger.Log("[VRCTools] [OculusUtils] Fetching Callback.HandleMessage Method");
     if (t_Oculus_Platform_Callback == null)
     {
         Type[] staticTypes = typeof(QuickMenu).Assembly.GetTypes();
         foreach (Type t in staticTypes)
         {
             if (t.HasMethodContainingString("Cannot provide a null notification callback."))
             {
                 t_Oculus_Platform_Callback = t;
                 break;
             }
         }
     }
     if (t_Oculus_Platform_Callback == null)
     {
         return(null);                                    // Don't have oculus classes or not found
     }
     if (m_HandleMessage == null)
     {
         foreach (MethodInfo m in t_Oculus_Platform_Callback.GetMethods(BindingFlags.NonPublic | BindingFlags.Static))
         {
             if (m.GetParameters().Length == 1)
             {
                 m_HandleMessage = m;
                 break;
             }
         }
     }
     return(m_HandleMessage);
 }
Пример #18
0
        private static void GetAssembliesPostfix(ref Assembly[] __result)
        {
            System.Diagnostics.StackFrame[] stackFrames = new System.Diagnostics.StackTrace().GetFrames();
            Type callingType = stackFrames[stackFrames.Length - 2].GetMethod().DeclaringType.DeclaringType;

            if (callingType != typeof(Analytics))
            {
                return;
            }

            VRCModLogger.Log("[VRCTools | Analytics patch] Processing assemblies");

            List <Assembly> assemblies = new List <Assembly>();

            foreach (Assembly assembly in __result)
            {
                if (assembly.GetName().Name == "HarmonySharedState" || assembly.GetName().Name == "VRCModLoader" || assembly.GetName().Name == "VRChat_Enhancer" || assembly.GetName().Name == "RubyLoader" || assembly.GetName().Name == "RubyCore" || !File.Exists(assembly.Location))
                {
                    Console.WriteLine("[VRCTools | Analytics patch] Discarding assembly " + assembly.GetName().Name);
                    continue;
                }

                assemblies.Add(assembly);
            }
            __result = assemblies.ToArray();
        }
Пример #19
0
 private static long GetCombinedId(object eventLogEntry)
 {
     if (eventLogEntry.GetType().IsArray)
     {
         VRCModLogger.Log("[RamExploitPatcher] Packet contains array of VRC_EventLog.EventLogEntry");
         return(0);
     }
     if (eventLogEntryGetter == null)
     {
         VRCModLogger.Log("[RamExploitPatcher] Looking for VRC_EventLog.EventLogEntry.get_CombineId");
         FieldInfo[] eventLogEntryGetterList = eventLogEntry.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
         VRCModLogger.Log("[RamExploitPatcher] Public instance types in " + eventLogEntry.GetType() + " :");
         foreach (FieldInfo fi in eventLogEntryGetterList)
         {
             VRCModLogger.Log("[RamExploitPatcher]  - [" + fi.FieldType + "] " + fi.Name);
             if (fi.FieldType == typeof(long))
             {
                 VRCModLogger.Log("[RamExploitPatcher] TYPE MATCH !");
                 eventLogEntryGetter = fi;
                 break;
             }
         }
     }
     return((long)eventLogEntryGetter.GetValue(eventLogEntry));
 }
Пример #20
0
        void OnApplicationStart()
        {
            // Check if the game started with "--hidemods", and if so, block mods to start with
            if (Environment.CommandLine.Contains("--hidemods"))
            {
                hidingMods = true;
            }
            if (hidingMods)
            {
                VRCModLogger.Log("[hideModule] The client was started with mods hidden. Press CTRL+R at any time to show supported mod menus.");
            }

            // Mod detection to add compatibility, while also avoiding breaking things if these mods are not present
            if (ModManager.Mods.Find(x => x.Name == "AvatarFav") != null)
            {
                avatarFav = true;
            }
            // Using reflection to access emmVRC
            emmVRCAPI = null;
            emmVRC    = AppDomain.CurrentDomain.GetAssemblies().Any(a =>
            {
                emmVRCAPI = a.GetType("emmVRC.emmVRC");
                return(emmVRCAPI != null);
            });
        }
Пример #21
0
        private void OnApplicationStart()
        {
            String lp    = "";
            bool   first = true;

            foreach (var lp2 in Environment.GetCommandLineArgs())
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    lp += " " + lp2;
                }
            }
            VRCModLogger.Log("Launch parameters:" + lp);

            ModPrefs.RegisterCategory("vrctools", "VRCTools");
            ModPrefs.RegisterPrefBool("vrctools", "remoteauthcheckasked", false, null, true);
            ModPrefs.RegisterPrefBool("vrctools", "remoteauthcheck", false, "Allow VRCModNetwork Auth");
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownloadasked", false, null, true);
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownload", false, "Enable AvatarFav Updater");

            ModPrefs.RegisterPrefBool("vrctools", "enablediscordrichpresence", true, "Enable Discord RichPresence");
            ModPrefs.RegisterPrefBool("vrctools", "enablestealerdetector", true, "Enable Stealer Detector");
            ModPrefs.RegisterPrefBool("vrctools", "enableramexploitpatch", true, "Enable RAMExploit Patch");
            ModPrefs.RegisterPrefBool("vrctools", "enabledebugconsole", false, "Enable Debug Console");
        }
Пример #22
0
        private void LoadAvatars()
        {
            VRCModLogger.Log("[AvatarFav] Loading from cache...");

            handleFreshJSON(File.ReadAllText("AvatarFav.json"), nosave: true, overwrite: false);
            avatarsJSONLoaded = true;
        }
Пример #23
0
        private void CreateButton(string text, int xoffset, Action onClick)
        {
            Transform baseButtonTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/CloseButton") ?? QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/SettingsButton");

            if (baseButtonTransform != null)
            {
                Transform modconf = UnityUiUtils.DuplicateButton(baseButtonTransform, text, new Vector2(0, 0));
                modconf.name = "ModConfigsButton (" + text + ")";
                modconf.GetComponentInChildren <RectTransform>().sizeDelta = new Vector2(300, 100);
                modconf.GetComponentInChildren <Text>().color = Color.white;
                //modconf.GetComponent<Button>().interactable = false;
                modconf.GetComponent <Button>().onClick.RemoveAllListeners();
                modconf.GetComponent <Button>().onClick.AddListener(() => onClick());
                modconf.GetComponent <RectTransform>().SetParent(transform, true);
                modconf.GetComponent <RectTransform>().localPosition    = new Vector3(0, 0, 0);
                modconf.GetComponent <RectTransform>().anchoredPosition = new Vector2(xoffset, -440);
                modconf.GetComponent <RectTransform>().localRotation    = Quaternion.identity;
                modconf.GetComponent <RectTransform>().localScale       = Vector3.one;
                modconf.GetComponentInChildren <Text>().fontSize        = 30;
            }
            else
            {
                VRCModLogger.Log("[ModConfigPage] QuickMenu/ShortcutMenu/SettingsButton and QuickMenu/ShortcutMenu/SettingsButton are null");
            }
        }
Пример #24
0
        public Client(string address, int port, string clientVersion)
        {
            this.address       = address;
            this.port          = port;
            this.clientVersion = clientVersion;

            keepaliveThread = new Thread(() =>
            {
                while (true)
                {
                    if (listen)
                    {
                        try
                        {
                            WriteLine("KEEPALIVE");
                        }
                        catch (Exception e)
                        {
                            VRCModLogger.Log("Error while trying to send keepalive: " + e);
                        }
                    }
                    Thread.Sleep(3000);
                }
            });
            keepaliveThread.Name         = "VRCMod Networking Thread (Keepalive)";
            keepaliveThread.IsBackground = true;
        }
Пример #25
0
 internal static void ConnectAsync()
 {
     if (!VRCTools.ModPrefs.GetBool("vrctools", "remoteauthcheck"))
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client doesn't allow auth");
     }
     else if (State != ConnectionState.DISCONNECTED)
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client is not disconnected");
     }
     else if (client != null && client.autoReconnect)
     {
         VRCModLogger.Log("[VRCMOD NWManager] Trying to connect to server, but client already exist and is tagged as auto-reconnecting");
     }
     else
     {
         if (client == null)
         {
             client = new Client(SERVER_ADDRESS, SERVER_PORT, VRCMODNW_VERSION);
             if (instance == null)
             {
                 instance = new VRCModNetworkManager();
             }
             client.SetConnectionListener(instance);
             Thread modsCheckerThread = new Thread(() => ModCheckThread());
             modsCheckerThread.Name         = "Mod Check Thread";
             modsCheckerThread.IsBackground = true;
             modsCheckerThread.Start();
         }
         State = ConnectionState.CONNECTING;
         client.StartConnection();
     }
 }
Пример #26
0
 public static IEnumerator WaitForUiManagerInit()
 {
     VRCModLogger.Log("WaitForUIManager");
     if (uiManagerInstance == null)
     {
         FieldInfo[] nonpublicStaticFields = typeof(VRCUiManager).GetFields(BindingFlags.NonPublic | BindingFlags.Static);
         if (nonpublicStaticFields.Length == 0)
         {
             VRCModLogger.Log("[VRCUiManagerUtils] nonpublicStaticFields.Length == 0");
             yield break;
         }
         FieldInfo uiManagerInstanceField = nonpublicStaticFields.First(field => field.FieldType == typeof(VRCUiManager));
         if (uiManagerInstanceField == null)
         {
             VRCModLogger.Log("[VRCUiManagerUtils] uiManagerInstanceField == null");
             yield break;
         }
         uiManagerInstance = uiManagerInstanceField.GetValue(null) as VRCUiManager;
         VRCModLogger.Log("[VRCUiManagerUtils] Waiting for UI Manager...");
         while (uiManagerInstance == null)
         {
             uiManagerInstance = uiManagerInstanceField.GetValue(null) as VRCUiManager;
             yield return(null);
         }
         VRCModLogger.Log("[VRCUiManagerUtils] UI Manager loaded");
     }
 }
Пример #27
0
        public static void ClearSpecificList(this UiAvatarList list)
        {
            if (fieldCachedSpecificList == null)
            {
                FieldInfo[] npInstFields = typeof(UiAvatarList).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (FieldInfo fi in npInstFields)
                {
                    if (fi.FieldType == typeof(Dictionary <string, ApiAvatar>))
                    {
                        fieldCachedSpecificList = fi;
                        VRCModLogger.Log("fieldCachedSpecificList: " + fieldCachedSpecificList);
                        break;
                    }
                }
                if (fieldCachedSpecificList == null)
                {
                    VRCModLogger.LogError("[AvatarFav] No CachedSpecificList field found in UiAvatarList !");
                    return;
                }
            }
            ((Dictionary <string, ApiAvatar>)fieldCachedSpecificList.GetValue(list)).Clear();
            list.ClearAll();

            VRCModLogger.Log("Number of elements in list after clear: " + ((Dictionary <string, ApiAvatar>)fieldCachedSpecificList.GetValue(list)).Count);
        }
Пример #28
0
 public void Connected()
 {
     client.autoReconnect = true;
     VRCModLogger.Log("Client autoReconnect set to true");
     State = ConnectionState.CONNECTED;
     VRCModNetworkStatus.UpdateNetworkStatus();
     OnConnected?.Invoke();
 }
Пример #29
0
 public void WriteLine(string lout)
 {
     if (!"KEEPALIVE".Equals(lout))
     {
         VRCModLogger.Log("[VRCMODNW] >>> " + lout);
     }
     sslStream.Write(Encoding.UTF8.GetBytes(lout + "\r\n"));
 }
Пример #30
0
 void OnLevelWasLoaded(int level)
 {
     if (level == 1 && (int)Storage.Read("VRC_AVATAR_PERFORMANCE_RATING_MINIMUM_TO_DISPLAY", typeof(int), 5) != 5)
     {
         Storage.Write("VRC_AVATAR_PERFORMANCE_RATING_MINIMUM_TO_DISPLAY", 5);
         Storage.SaveNow();
         VRCModLogger.Log("[VeryPoorQuest] The deed is done. Have a nice day!");
     }
 }