예제 #1
0
        private static bool CheckForRageVersion(float MinimumVersion)
        {
            string RPHFile = "RAGEPluginHook.exe";

            string[] files = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.exe", SearchOption.TopDirectoryOnly);
            foreach (string file in files)
            {
                if (Path.GetFileName(file).ToLower() == "ragepluginhook.exe")
                {
                    RPHFile = file;
                    break;
                }
            }

            var   versionInfo = FileVersionInfo.GetVersionInfo(RPHFile);
            float Rageversion;

            try
            {
                Rageversion = float.Parse(versionInfo.ProductVersion.Substring(0, 4), CultureInfo.InvariantCulture);
                Game.LogTrivial("Albo1125.Common detected RAGEPluginHook version: " + Rageversion.ToString());

                //If user's RPH version is older than the minimum
                if (Rageversion < MinimumVersion)
                {
                    CorrectRPHVersion = false;
                }
                //If user's RPH version is (above) the specified minimum
                else
                {
                    CorrectRPHVersion = true;
                }
            }
            catch (Exception e)
            {
                //If for whatever reason the version couldn't be found.
                Game.LogTrivial(e.ToString());
                Game.LogTrivial("Unable to detect your Rage installation.");
                if (File.Exists("RAGEPluginHook.exe"))
                {
                    Game.LogTrivial("RAGEPluginHook.exe exists");
                }
                else
                {
                    Game.LogTrivial("RAGEPluginHook doesn't exist.");
                }
                Game.LogTrivial("Rage Version: " + versionInfo.ProductVersion.ToString());
                Game.DisplayNotification("Albo1125.Common was unable to detect RPH installation. Please send me your logfile.");
                CorrectRPHVersion = false;
            }

            return(CorrectRPHVersion);
        }
예제 #2
0
            /// <summary>
            /// Checks whether the person has the specified minimum version or higher.
            /// </summary>
            /// <param name="minimumVersion">Provide in the format of a float i.e.: 0.22</param>
            /// <returns></returns>
            public static bool checkForRageVersion(float minimumVersion)
            {
                var   versionInfo = FileVersionInfo.GetVersionInfo("RAGEPluginHook.exe");
                float Rageversion;

                try
                {
                    //If you decide to use this in your plugin, I would appreciate some credit :)
                    Rageversion = float.Parse(versionInfo.ProductVersion.Substring(0, 4), CultureInfo.InvariantCulture);
                    Function.LogDebug("ComputerPlus detected RAGEPluginHook version: " + Rageversion.ToString());

                    //If user's RPH version is older than the minimum
                    if (Rageversion < minimumVersion)
                    {
                        correctVersion = false;
                        GameFiber.StartNew(delegate
                        {
                            while (Game.IsLoading)
                            {
                                GameFiber.Yield();
                            }
                            //If you decide to use this in your plugin, I would appreciate some credit :)
                            Game.DisplayNotification("RPH ~r~v" + Rageversion.ToString() + " ~s~detected. ~b~ComputerPlus ~s~requires ~b~v" + minimumVersion.ToString() + " ~s~or higher.");
                            GameFiber.Sleep(5000);
                            Function.Log("RAGEPluginHook version " + Rageversion.ToString() + " detected. ComputerPlus requires v" + minimumVersion.ToString() + " or higher.");
                            Function.Log("Preparing redirect...");
                            Game.DisplayNotification("You are being redirected to the RagePluginHook website so you can download the latest version.");
                            Game.DisplayNotification("Press Backspace to cancel the redirect.");

                            int count = 0;
                            while (true)
                            {
                                GameFiber.Sleep(10);
                                count++;
                                if (Game.IsKeyDownRightNow(System.Windows.Forms.Keys.Back))
                                {
                                    break;
                                }
                                if (count >= 300)
                                {
                                    //URL to the RPH download page.
                                    //I use bit.ly to track the number of times this is called: at the moment, it has been called 327 times over the past 2 days! What a timesaver for me.
                                    System.Diagnostics.Process.Start("http://bit.ly/RPHDownload");
                                    break;
                                }
                            }
                        });
                    }
                    //If user's RPH version is (above) the specified minimum
                    else
                    {
                        correctVersion = true;
                    }
                }
                catch (Exception e)
                {
                    //If for whatever reason the version couldn't be found.
                    Function.Log(e.ToString());
                    Function.Log("Unable to detect your Rage installation.");
                    if (File.Exists("RAGEPluginHook.exe"))
                    {
                        Function.Log("RAGEPluginHook.exe exists");
                    }
                    else
                    {
                        Function.Log("RAGEPluginHook doesn't exist.");
                    }
                    Function.Log("Rage Version: " + versionInfo.ProductVersion.ToString());
                    Function.Log("ComputerPlus unable to detect RPH installation. Please send me your logfile.");
                    correctVersion = false;
                }

                return(correctVersion);
            }
예제 #3
0
        /// <summary>
        /// Checks whether the person has the specified minimum version or higher.
        /// </summary>
        /// <param name="minimumVersion">Provide in the format of a float i.e.: 0.22</param>
        /// <returns></returns>
        public static bool checkForRageVersion(float minimumVersion)
        {
            var   versionInfo = FileVersionInfo.GetVersionInfo("RAGEPluginHook.exe");
            float Rageversion;

            try
            {
                Rageversion = float.Parse(versionInfo.ProductVersion.Substring(0, 4), CultureInfo.InvariantCulture);
                Logger.Log("Detected RAGEPluginHook version: " + Rageversion.ToString());

                //If user's RPH version is older than the minimum
                if (Rageversion < minimumVersion)
                {
                    correctVersion = false;
                    GameFiber.StartNew(delegate
                    {
                        while (Game.IsLoading)
                        {
                            GameFiber.Yield();
                        }

                        Notifier.DisplayNotification("RPH Version", "RPH ~r~v" + Rageversion.ToString() +
                                                     "~s~ detected. ~b~Touch The Rear~s~ requires ~b~v" + minimumVersion.ToString() +
                                                     "~s~ or higher.");
                        GameFiber.Sleep(5000);
                        Logger.Log("RAGEPluginHook version " + Rageversion.ToString() +
                                   " detected. Touch The Rear requires v" + minimumVersion.ToString() + " or higher.");
                        Logger.Log("Preparing redirect...");
                        Notifier.DisplayNotification("RPH Version", "You are being redirected to the RagePluginHook website so you can download the latest version.");
                        Notifier.DisplayNotification("RPH Version", "Press Backspace to cancel the redirect.");

                        int count = 0;
                        while (true)
                        {
                            GameFiber.Sleep(10);
                            count++;
                            if (Game.IsKeyDownRightNow(System.Windows.Forms.Keys.Back))
                            {
                                break;
                            }

                            if (count >= 300)
                            {
                                //URL to the RPH download page.
                                System.Diagnostics.Process.Start("http://bit.ly/RPHDownloadPage");
                                break;
                            }
                        }
                    });
                }
                //If user's RPH version is (above) the specified minimum
                else
                {
                    correctVersion = true;
                }
            }
            catch (Exception e)
            {
                //If for whatever reason the version couldn't be found.
                Logger.Log(e.ToString());
                Logger.Log("Unable to detect your Rage installation.");
                if (File.Exists("RAGEPluginHook.exe"))
                {
                    Logger.Log("RAGEPluginHook.exe exists");
                }
                else
                {
                    Logger.Log("RAGEPluginHook doesn't exist.");
                }

                Logger.Log("Rage Version: " + versionInfo.ProductVersion.ToString());
                Notifier.DisplayNotification("ERROR", "Unable to detect RPH installation. Please send your logfile in the support channel on HazyTube's discord server.");
                correctVersion = false;
            }

            return(correctVersion);
        }