Example #1
0
 private async void btn_settings_Click(object sender, RoutedEventArgs e)
 {
     Settings settings = new Settings(profile);
     settings.ShowDialog();
     UpdateProfile();
     await Task.Delay(1000);
     label.Content = "准备就绪了呢";
     probar.IsIndeterminate = false;
 }
Example #2
0
        //private async Task<bool> DownloadFile()
        //{

        //}

        private void CreateNewProfile()
        {
            profile = new Proflie();
            profile.Name = "Futa Master";
            profile.ID = Guid.NewGuid().ToString().Substring(0, 8).ToUpper();
            profile.FOV = 75;
            profile.Clantag = "^1CN";
            profile.Title = "^5SuperTeknoMW3";
            profile.ShowConsole = false;
            profile.Maxfps = 300;
            profile.SkipUpdate = false;

            var settings = new Settings(profile);
            settings.ShowDialog();
        }
Example #3
0
        private async void LoadProfile()
        {
            try
            {
                if (File.Exists("teknogods.ini"))
                {
                    bool AutoChanged = false;
                    bool NeedChange = false;
                    IniParser ini = new IniParser("teknogods.ini");
                    profile = new Proflie();

                    string _name = ini.GetSetting("Settings", "Name");
                    if (string.IsNullOrWhiteSpace(_name) || _name.Length > 15 || _name.Length < 3)
                    {
                        profile.Name = "Futa Master";
                        NeedChange = true;
                    }
                    else
                    {
                        profile.Name = _name;
                    }

                    string _id = ini.GetSetting("Settings", "ID");
                    if (string.IsNullOrWhiteSpace(_id) || _id.Length != 8)
                    {
                        if (Directory.Exists("dw"))
                        {
                            string[] files = Directory.GetFiles("dw");
                            foreach (var item in files)
                            {
                                string item2 = item.Replace("dw\\", "");
                                if (item2.StartsWith("iw5_") && item2.EndsWith(".stat"))
                                {
                                    var result = MessageBox.Show("你的配置文件里没有ID,但是游戏内似乎包含了有效ID。\n阁下是否想重新创建一个新的ID呢?\n\n 注意创建新ID会丢失以前的存档。", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
                                    if (result == MessageBoxResult.Yes)
                                    {
                                        var id = Guid.NewGuid();
                                        _id = id.ToString().Substring(0, 8).ToUpper();
                                    }
                                    else
                                    {
                                        _id = item2.Substring(item2.Length - 13, 8).ToUpper();
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            var id = Guid.NewGuid();
                            _id = id.ToString().Substring(0, 8).ToUpper();
                        }
                        profile.ID = _id;
                    }
                    else
                    {
                        profile.ID = _id;
                    }

                    string _fov = ini.GetSetting("Settings", "FOV");
                    if (string.IsNullOrWhiteSpace(_fov))
                    {
                        profile.FOV = 75;
                        AutoChanged = true;
                    }
                    else
                    {
                        try
                        {
                            if (Convert.ToInt32(_fov) >= 65 || Convert.ToInt32(_fov) <= 90)
                            {
                                profile.FOV = Convert.ToInt32(_fov);
                            }
                        }
                        catch (Exception)
                        {
                            profile.FOV = 75;
                            AutoChanged = true;
                        }

                    }

                    string _clantag = ini.GetSetting("Settings", "Clantag");
                    if (string.IsNullOrWhiteSpace(_clantag) || _clantag.Length > 4)
                    {
                        profile.Clantag = "^1CN";
                        AutoChanged = true;
                    }
                    else
                    {
                        profile.Clantag = _clantag;
                    }

                    string _title = ini.GetSetting("Settings", "Title");
                    if (string.IsNullOrWhiteSpace(_clantag) || _title.Length > 25)
                    {
                        profile.Title = "^5SuperTeknoMW3";
                        AutoChanged = true;
                    }
                    else
                    {
                        profile.Title = _title;
                    }

                    string _showconsole = ini.GetSetting("Settings", "ShowConsole");
                    if (string.IsNullOrWhiteSpace(_showconsole))
                    {
                        profile.ShowConsole = false;
                        AutoChanged = true;
                    }
                    else
                    {
                        try
                        {
                            profile.SkipUpdate = Convert.ToBoolean(_showconsole);
                        }
                        catch (Exception)
                        {
                            profile.ShowConsole = false;
                            AutoChanged = true;
                        }
                    }

                    string _maxfps = ini.GetSetting("Settings", "Maxfps");
                    if (string.IsNullOrWhiteSpace(_maxfps))
                    {
                        profile.Maxfps = 300;
                        AutoChanged = true;
                    }
                    else
                    {
                        try
                        {
                            if (Convert.ToInt32(_maxfps) >= 30 || Convert.ToInt32(_maxfps) <= 300)
                            {
                                profile.Maxfps = Convert.ToInt32(_maxfps);
                            }
                        }
                        catch (Exception)
                        {
                            profile.Maxfps = 300;
                            AutoChanged = true;
                        }

                    }

                    string _skipupdate = ini.GetSetting("Settings", "SkipUpdate");
                    if (string.IsNullOrWhiteSpace(_skipupdate))
                    {
                        profile.SkipUpdate = false;
                        AutoChanged = true;
                    }
                    else
                    {
                        try
                        {
                            profile.SkipUpdate = Convert.ToBoolean(_skipupdate);
                        }
                        catch (Exception)
                        {
                            profile.SkipUpdate = false;
                            AutoChanged = true;
                        }
                    }

                    if (NeedChange)
                    {
                        MessageBox.Show("你的玩家名不符合规范哦,请阁下先修改一下。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        Settings st = new Settings(profile);
                        st.ShowDialog();
                        UpdateProfile();
                    }
                    else if (AutoChanged)
                    {
                        SaveProfile();
                    }
                    else
                    {
                        textBlock.Text = "欢迎阁下!" + profile.Name;
                        await Task.Delay(1000);
                        label.Content = "准备就绪了呢";
                        probar.IsIndeterminate = false;
                        EnableAll();
                    }
                }
                else
                {
                    MessageBox.Show("配置文件不存在呢,请阁下先设置一下你的玩家信息吧。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CreateNewProfile();
                    newuser = true;
                    UpdateProfile();
                }
            }
            catch (Exception)
            {
                File.Delete("teknogods.ini");
                MessageBox.Show("启动器读取配置文件的时候出问题了%>_<%,还请阁下重新设置一下吧。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                CreateNewProfile();
                UpdateProfile();
            }
        }