示例#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();
        }
示例#2
0
        private void gameList_Changed(object sender, EventArgs e)
        {
            additionallyGroupBox.Visible = false;
            var selected = (GameInfo)((ComboBox)sender).SelectedItem;

            if (selected != null)
            {
                Log.Print($"切换游戏为“{selected.Name}”。");
                param.LastSelectedGame = selected.Name;
                selectedGameParams     = param.GetGameParam(selected);
                if (!string.IsNullOrEmpty(selectedGameParams.Path))
                {
                    Log.Print($"游戏目录“{selectedGameParams.Path}”。");
                }
            }

            if (!string.IsNullOrEmpty(selected.Comment))
            {
                notesTextBox.Text            = selected.Comment;
                additionallyGroupBox.Visible = true;
            }

            RefreshForm();
        }
示例#3
0
        private void Init()
        {
            FormBorderStyle = FormBorderStyle.FixedDialog;
            instance        = this;

            Log.Init();

            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, "UnityModManager.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(UnityModManager).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();
        }
示例#4
0
        private void Init()
        {
            var skins = new Dictionary <string, string> {
                ["默认皮肤"] = ""
            };

            skins = Utils.GetMatchedFiles(SKINS_PATH, "*.ssk", skins);
            var skinSet = new BindingSource {
                DataSource = skins
            };

            skinSetBox.DataSource    = skinSet;
            skinSetBox.DisplayMember = "Key";
            skinSetBox.ValueMember   = "Value";
            _autoSizeFormControlUtil = new AutoSizeFormControlUtil(this);
            _autoSizeFormControlUtil.RefreshControlsInfo(Controls[0]);
            FormBorderStyle = FormBorderStyle.FixedDialog;
            instance        = this;
            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)
                    {
                        continue;
                    }
                    var getValue = registry.GetMethod("GetValue", new[] { 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[] { typeof(string), typeof(string), typeof(object) });
                            if (setValue != null)
                            {
                                setValue.Invoke(null, new object[] { REG_PATH, "ExePath", Path.Combine(Application.StartupPath, "DearUnityModManager.exe") });
                                setValue.Invoke(null, new object[] { REG_PATH, "Path", Application.StartupPath });
                            }
                        }
                    }
                    break;
                }
            }
            var rbWidth = 0;

            for (var i = (InstallType)0; i < InstallType.Count; i++)
            {
                var rb = new RadioButton
                {
                    Name     = i.ToString(),
                    Text     = i == InstallType.DoorstopProxy ? $"{i.ToString()}(推荐)" : i.ToString(),
                    AutoSize = true,
                    Location = new Point(rbWidth + 8, 50),
                    Margin   = new Padding(0)
                };
                rb.Click += installType_Click;
                installTypeGroup.Controls.Add(rb);
                rbWidth += rb.Width + 200;
            }
            version             = typeof(UnityModManager).Assembly.GetName().Version;
            currentVersion.Text = version.ToString();
            config = Config.Load();
            param  = Param.Load();
            skinSetBox.SelectedIndex = param.LastSelectedSkin;
            if (config?.GameInfo != null && config.GameInfo.Length > 0)
            {
                config.GameInfo = config.GameInfo.OrderBy(x => x.GameName).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($"解析配置文件“{Config.filename}”失败!");
                return;
            }
            CheckLastVersion();
        }
示例#5
0
        private void Init()
        {
            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, "UnityModManager.exe") });
                                    setValue.Invoke(null, new object[] { REG_PATH, "Path", Application.StartupPath });
                                }
                            }
                        }
                        break;
                    }
                }
            }

            version             = typeof(UnityModManager).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();
                selectedGame    = config.GameInfo.First();

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

            CheckLastVersion();
        }