示例#1
0
        private static int LoadAndRun(LemonFunc <int> functionToWaitForAsync)
        {
            FolderPath = Path.Combine(MelonUtils.UserDataDirectory, "MelonStartScreen");
            if (!Directory.Exists(FolderPath))
            {
                Directory.CreateDirectory(FolderPath);
            }

            ThemesFolderPath = Path.Combine(FolderPath, "Themes");
            if (!Directory.Exists(ThemesFolderPath))
            {
                Directory.CreateDirectory(ThemesFolderPath);
            }

            UIConfig.Load();
            if (!UIConfig.General.Enabled)
            {
                return(functionToWaitForAsync());
            }

            // We try to resolve all the signatures, which are available for Unity 2018.1.0+
            // If we can't find them (signatures changed or <2018.1.0), then we run the function and return.
            try
            {
                if (!NativeSignatureResolver.Apply())
                {
                    return(functionToWaitForAsync());
                }

                if (!ApplyUser32SetTimerPatch())
                {
                    return(functionToWaitForAsync());
                }

                MelonDebug.Msg("Initializing Screen Renderer");
                ScreenRenderer.Init();
                MelonDebug.Msg("Screen Renderer initialized");

                RegisterMessageCallbacks();

                // Initial render
                ScreenRenderer.Render();
            }
            catch (Exception e)
            {
                MelonLogger.Error(e);
                ScreenRenderer.disabled = true;
                return(functionToWaitForAsync());
            }

            initialized = true;

            StartFunction(functionToWaitForAsync);
            MainLoop();

            return(functionRunResult);
        }
示例#2
0
 private static void StartFunction(LemonFunc <int> func)
 {
     new Thread(() =>
     {
         functionRunResult = func();
         functionRunDone   = true;
     })
     {
         IsBackground = true,
         Name         = "MelonStartScreen Function Thread"
     }.Start();
 }
示例#3
0
        internal static int LoadAndRun(LemonFunc <int> functionToWaitForAsync)
        {
            // We don't support Unity versions under 2017.2.0 (yet?)
            if (!MelonLaunchOptions.Core.StartScreen || !MelonUtils.GetUnityVersion().StartsWith("20") || MelonUtils.GetUnityVersion().StartsWith("2017.1"))
            {
                return(functionToWaitForAsync());
            }

            if (!Load())
            {
                return(functionToWaitForAsync());
            }

            if (LoadAndRunMethod != null)
            {
                return((int)LoadAndRunMethod.Invoke(null, new object[] { functionToWaitForAsync }));
            }

            return(-1);
        }
示例#4
0
        private static int LoadAndRun(LemonFunc <int> functionToWaitForAsync)
        {
            // We try to resolve all the signatures, which are available for Unity 2018.1.0+
            // If we can't find them (signatures changed or <2018.1.0), then we run the function and return.
            try
            {
                if (!NativeSignatureResolver.Apply())
                {
                    return(functionToWaitForAsync());
                }

                if (!ApplyUser32SetTimerPatch())
                {
                    return(functionToWaitForAsync());
                }

                MelonDebug.Msg("Initializing Screen Renderer");
                ScreenRenderer.Init();
                MelonDebug.Msg("Screen Renderer initialized");

                RegisterMessageCallbacks();

                // Initial render
                ScreenRenderer.Render();
            }
            catch (Exception e)
            {
                MelonLogger.Error(e);
                return(functionToWaitForAsync());
            }

            initialized = true;

            StartFunction(functionToWaitForAsync);
            MainLoop();

            return(functionRunResult);
        }
        internal static int LoadAndRun(LemonFunc <int> functionToWaitForAsync)
        {
            if (!MelonLaunchOptions.Core.StartScreen)
            {
                return(functionToWaitForAsync());
            }

            // Doesn't support Unity versions lower than 2017.2.0 (yet?)
            // Doesn't support Unity versions lower than 2018 (Crashing Issue)
            UnityVersion unityVersion   = UnityInformationHandler.EngineVersion;
            UnityVersion minimumVersion = new UnityVersion(2018);

            if (unityVersion < minimumVersion)
            {
                return(functionToWaitForAsync());
            }

            // Doesn't support Unity versions higher than to 2020.3.21 (Crashing Issue)
            UnityVersion maximumVersion = new UnityVersion(2020, 3, 21);

            if (unityVersion > maximumVersion)
            {
                return(functionToWaitForAsync());
            }

            if (!Load())
            {
                return(functionToWaitForAsync());
            }

            if (LoadAndRunMethod != null)
            {
                return((int)LoadAndRunMethod.Invoke(null, new object[] { functionToWaitForAsync }));
            }

            return(-1);
        }
示例#6
0
 internal HostInfo(string url, LemonFunc <string, InfoStruct> func)
 {
     URL  = url;
     Func = func;
 }