private static void DispatchWindowEvents()
        {
            if (!User32.PeekMessage(out Msg msg, IntPtr.Zero, 0, 0, 1))
            {
                if (currentStatus != tmpCurrentStatus || progressTotal != tmpProgressTotal || progressDownload != tmpProgressDownload)
                {
                    tmpCurrentStatus    = currentStatus;
                    tmpProgressTotal    = progressTotal;
                    tmpProgressDownload = progressDownload;

                    UpdaterWindow.RedrawWindow();
                }
                Thread.Sleep(16); // ~60/s
            }
        public static void Start()
        {
            var prefCategory    = MelonPreferences.CreateCategory("VRCModUpdater");
            var diplayTimeEntry = prefCategory.CreateEntry("displaytime", postUpdateDisplayDuration, "Display time (seconds)");

            toFromBroken                = prefCategory.CreateEntry("toFromBroken", true, "Attempt to move mods to and from Broken mods folder based on status in Remote API");
            resolveDependencies         = prefCategory.CreateEntry("resolveDependencies", true, "Attempt to download missing required dependencies");
            resolveOptionalDependencies = prefCategory.CreateEntry("resolveOptionalDependencies", false, "Also attempt to download missing OPTIONAL dependencies");
            popUpMsg = prefCategory.CreateEntry("popUpMsg", true, "Display pop up messsage box if mods are updated or moved to/from broken");

            if (float.TryParse(diplayTimeEntry.GetValueAsString(), out float diplayTime))
            {
                postUpdateDisplayDuration = diplayTime;
            }

            UpdaterWindow.CreateWindow();

            new Thread(() =>
            {
                try
                {
                    UpdateMods();
                }
                catch (Exception e)
                {
                    MelonLogger.Error("Failed to update mods:\n" + e);
                }

                isUpdatingMods = false;
            })
            {
                Name         = "VRCModUpdater",
                IsBackground = true
            }.Start();

            while (isUpdatingMods || UpdaterWindow.IsOpen) // We need to do that event w/o the window, because the console need it
            {
                if (!isUpdatingMods && !UpdaterWindow.IsWindowClosing)
                {
                    UpdaterWindow.DestroyWindow();
                }

                DispatchWindowEvents();
            }
        }
Example #3
0
        public static void Start()
        {
            var prefCategory    = MelonPreferences.CreateCategory("VRCModUpdater");
            var diplayTimeEntry = prefCategory.CreateEntry("displaytime", postUpdateDisplayDuration, "Display time (seconds)");

            if (float.TryParse(diplayTimeEntry.GetValueAsString(), out float diplayTime))
            {
                postUpdateDisplayDuration = diplayTime;
            }

            UpdaterWindow.CreateWindow();

            new Thread(() =>
            {
                try
                {
                    UpdateMods();
                }
                catch (Exception e)
                {
                    MelonLogger.Error("Failed to update mods:\n" + e);
                }

                isUpdatingMods = false;
            })
            {
                Name         = "VRCModUpdater",
                IsBackground = true
            }.Start();

            while (isUpdatingMods || UpdaterWindow.IsOpen) // We need to do that event w/o the window, because the console need it
            {
                if (!isUpdatingMods && !UpdaterWindow.IsWindowClosing)
                {
                    UpdaterWindow.DestroyWindow();
                }

                DispatchWindowEvents();
            }
        }