Beispiel #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);
        }
Beispiel #2
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);
        }