Ejemplo n.º 1
0
        private void gameList_Changed(object sender, EventArgs e)
        {
            var selected = (GameInfo)((ComboBox)sender).SelectedItem;

            if (selected != null)
            {
                Log.Print($"Game changed to '{selected.Name}'.");
                param.LastSelectedGame = selected.Name;
                selectedGameParams     = param.GetGameParam(selected);
                if (!string.IsNullOrEmpty(selectedGameParams.Path))
                {
                    Log.Print($"Game path '{selectedGameParams.Path}'.");
                }
            }

            RefreshForm();
        }
Ejemplo n.º 2
0
        private void Init()
        {
            FormBorderStyle = FormBorderStyle.FixedDialog;
            instance        = this;

            Log.Init();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            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(Application.StartupPath, "ATTTModManager.exe") });
                                    setValue.Invoke(null, new object[] { REG_PATH, "Path", Application.StartupPath });
                                }
                            }
                        }
                        break;
                    }
                }
            }

            for (var i = (InstallType)0; i < InstallType.Count; i++)
            {
                var btn = new RadioButton();
                btn.Name     = i.ToString();
                btn.Text     = i.ToString();
                btn.Dock     = DockStyle.Left;
                btn.AutoSize = true;
                btn.Click   += installType_Click;
                installTypeGroup.Controls.Add(btn);
            }

            version             = typeof(ATTTModManager).Assembly.GetName().Version;
            currentVersion.Text = version.ToString();

            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();
                gameList.Items.AddRange(config.GameInfo);

                GameInfo selected = null;
                if (!string.IsNullOrEmpty(param.LastSelectedGame))
                {
                    selected = config.GameInfo.FirstOrDefault(x => x.Name == param.LastSelectedGame);
                }
                selected = selected ?? config.GameInfo.First();
                gameList.SelectedItem = selected;
                selectedGameParams    = param.GetGameParam(selected);
            }
            else
            {
                InactiveForm();
                Log.Print($"Error parsing file '{Config.filename}'.");
                return;
            }

            CheckLastVersion();
        }