Пример #1
0
        private static void Init()
        {
            Log.Init <Log>();
#if NET35
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
#else
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#endif
            if (!Utils.IsUnixPlatform())
            {
                foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var registry = asm.GetType("Microsoft.Win32.Registry");
                    if (registry != null)
                    {
                        var getValue = registry.GetMethod("GetValue", new Type[] { typeof(string), typeof(string), typeof(object) });
                        if (getValue != null)
                        {
                            var exePath = getValue.Invoke(null, new object[] { REG_PATH, "ExePath", string.Empty }) as string;
                            if (string.IsNullOrEmpty(exePath) || !File.Exists(exePath))
                            {
                                var setValue = registry.GetMethod("SetValue", new Type[] { typeof(string), typeof(string), typeof(object) });
                                if (setValue != null)
                                {
                                    setValue.Invoke(null, new object[] { REG_PATH, "ExePath", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UnityModManager.exe") });
                                    setValue.Invoke(null, new object[] { REG_PATH, "Path", AppDomain.CurrentDomain.BaseDirectory });
                                }
                            }
                        }
                        break;
                    }
                }
            }

            version = typeof(UnityModManager).Assembly.GetName().Version;

            config = Config.Load();
            param  = Param.Load();

            if (config != null && config.GameInfo != null && config.GameInfo.Length > 0)
            {
                config.GameInfo = config.GameInfo.OrderBy(x => x.Name).ToArray();

                if (!string.IsNullOrEmpty(param.LastSelectedGame))
                {
                    selectedGame       = config.GameInfo.FirstOrDefault(x => x.Name == param.LastSelectedGame);
                    selectedGameParams = param.GetGameParam(selectedGame);
                }
                if (selectedGame != null)
                {
                    Log.Print($"Selected '{selectedGame}' game. Do you want to change selection? Yes:<y> Continue:<any>");
                    var k = Console.ReadKey();
                    if (k.Key == ConsoleKey.Y)
                    {
                        SelectGame();
                    }
                }
                else
                {
                    SelectGame();
                }
            }
            else
            {
                Log.Print($"Error parsing file '{Config.filename}'.");
                Close();
                return;
            }

            ReadGameAssets();

            //CheckLastVersion();
        }