Ejemplo n.º 1
0
 /// <summary>
 /// 设置升级信息
 /// </summary>
 /// <param name="config"></param>
 public void SetUpgradeInfo(UpgradeConfig config)
 {
     try
     {
         var path = $"{AppDomain.CurrentDomain.BaseDirectory}\\upgrade.config.json";
         var str  = JsonHelper.ObjectToJSON(config);
         FileUtil.Write(path, str);
         Clients.Caller.setupgradecallback(new
         {
             success = true,
             site    = new Site
             {
                 Name         = tranferSite,
                 PhysicalPath = "UpgradeSite",
                 Port         = 3000,
                 DefaultPage  = "http://127.0.0.1:3000"
             }
         });
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         Clients.Caller.setupgradecallback(new { success = false, msg = ex.Message });
     }
 }
Ejemplo n.º 2
0
    public UpgradeConfig GetDefaultUpgradeConfig()
    {
        if (upgradeConfig == null)
        {
            lock (synObj)
            {
                if (upgradeConfig == null)
                {
                    var config = new UpgradeConfig();
                    config.speedStage.Add(new Tuple <int, int>(3, 0));
                    config.speedStage.Add(new Tuple <int, int>(4, 1000));
                    config.speedStage.Add(new Tuple <int, int>(5, 2000));
                    config.speedStage.Add(new Tuple <int, int>(6, 5000));
                    config.speedStage.Add(new Tuple <int, int>(7, 10000));
                    config.speedStage.Add(new Tuple <int, int>(8, 20000));
                    config.hpStage.Add(new Tuple <int, int>(100, 0));
                    config.hpStage.Add(new Tuple <int, int>(150, 1000));
                    config.hpStage.Add(new Tuple <int, int>(200, 2000));
                    config.hpStage.Add(new Tuple <int, int>(300, 5000));
                    config.hpStage.Add(new Tuple <int, int>(500, 10000));
                    config.hpStage.Add(new Tuple <int, int>(1000, 20000));
                    upgradeConfig = config;
                }
            }
        }

        return(upgradeConfig);
    }
Ejemplo n.º 3
0
        private static void UpdateThumbnail(UpgradeButton upgradeButton, UpgradeConfig upgradeConfig)
        {
            var thumbnail = upgradeConfig.IsAdded.Value
                ? upgradeConfig.ActiveThumbnail
                : upgradeConfig.InactiveThumbnail;

            upgradeButton.SetThumbnail(thumbnail);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新升级配置文件
        /// </summary>
        /// <param name="upgradeConfig"></param>
        /// <remarks>2017-1-10 杨浩 创建</remarks>
        private static void UpdateUpgradeConfig(decimal?version)
        {
            var _config = new UpgradeConfig()
            {
                Version    = version,
                SqlContent = ""
            };

            BLL.Config.Config.Instance.UpdateConfig(_config, "Upgrade.config");
        }
Ejemplo n.º 5
0
    void LoadUpgradeConf(XmlReader reader, WeaponConfig weaponConf, string uType)
    {
        UpgradeConfig uConf = new UpgradeConfig();

        if (reader.HasAttributes)
        {
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "base")
                {
                    uConf.baseData = float.Parse(reader.Value);
                }
                else if (reader.Name == "upFactor")
                {
                    uConf.upFactor = float.Parse(reader.Value);
                }
                else if (reader.Name == "basePrice")
                {
                    uConf.basePrice = float.Parse(reader.Value);
                }
                else if (reader.Name == "upPriceFactor")
                {
                    uConf.upPriceFactor = float.Parse(reader.Value);
                }
                else if (reader.Name == "maxLevel")
                {
                    uConf.maxLevel = int.Parse(reader.Value);
                }
            }
        }

        switch (uType)
        {
        case "Damage":
            weaponConf.damageConf = uConf;
            break;

        case "Frequency":
            weaponConf.attackRateConf = uConf;
            break;

        case "Accuracy":
            weaponConf.accuracyConf = uConf;
            break;
        }
    }
Ejemplo n.º 6
0
 private void OnUpgradeClicked(UpgradeConfig upgradeConfig)
 {
     _selectedUpgrade.Value = _selectedUpgrade.Value == upgradeConfig ? null : upgradeConfig;
 }
Ejemplo n.º 7
0
 private void OnIsAddedChanged(UpgradeButton upgradeButton, UpgradeConfig upgradeConfig)
 {
     UpdateThumbnail(upgradeButton, upgradeConfig);
     OnSelectedUpgradeChanged();
 }
Ejemplo n.º 8
0
 private void OnSelectedUpgradeChanged(UpgradeButton upgradeButton, UpgradeConfig upgradeConfig)
 {
     upgradeButton.Border.GetComponent <Image>().enabled = _selectedUpgrade.Value == upgradeConfig;
 }
Ejemplo n.º 9
0
 public HandSpeedUpgrade(UpgradeConfig config, Button button) : base(config, button)
 {
     Instance = this;
 }
 public ScorePerSecondUpgrade(UpgradeConfig config, Button button) : base(config, button)
 {
     Instance = this;
 }
Ejemplo n.º 11
0
        private async void MainForm_Shown(object sender, EventArgs e)
        {
            vscodeButton.Enabled    = false;
            vscodeCheck.Enabled     = false;
            vscodeText.Visible      = false;
            vsCodeFileLabel.Visible = false;
            this.Enabled            = false;
            if (zipStore == null)
            {
                if (debugMode)
                {
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.Title = "Select the installer zip";
                    var res = ofd.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
                        zipStore = new ZipFile(fs);
                        zipStore.IsStreamOwner = true;
                        closeZip = true;
                    }
                    else
                    {
                        MessageBox.Show("File Error. Please select a zip file.");
                        Application.Exit();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("File Error. Try redownloading the file, and if this error continues contact WPILib support.");
                    Application.Exit();
                    return;
                }
            }



            // Look for upgrade config. Should always be there.
            var upgradeEntry = zipStore.FindEntry("installUtils/upgradeConfig.json", true);

            if (upgradeEntry == -1)
            {
                // Error
                MessageBox.Show("File Error?");
                Application.Exit();
                return;
            }

            string upgradeConfigStr = "";
            string fullConfigStr    = "";
            string vsConfigStr      = "";

            using (StreamReader reader = new StreamReader(zipStore.GetInputStream(upgradeEntry)))
            {
                upgradeConfigStr = await reader.ReadToEndAsync();

                upgradeConfig = JsonConvert.DeserializeObject <UpgradeConfig>(upgradeConfigStr, new JsonSerializerSettings
                {
                    MissingMemberHandling = MissingMemberHandling.Error
                });
                extractionControllers.Add(new ExtractionIgnores(toolsCheck, upgradeConfig.Tools.Folder, false));
                extractionControllers.Add(new ExtractionIgnores(wpilibCheck, upgradeConfig.Maven.Folder, false));

                var osType = OSLoader.GetOsType();
                switch (osType)
                {
                case OsType.Linux64:
                    if (upgradeConfig.InstallerType != UpgradeConfig.LinuxInstallerType)
                    {
                        MessageBox.Show("You need the Linux installer for this system");
                        Application.Exit();
                        return;
                    }
                    isWindows = false;
                    break;

                case OsType.MacOs64:
                    if (upgradeConfig.InstallerType != UpgradeConfig.MacInstallerType)
                    {
                        MessageBox.Show("You need the Mac installer for this system");
                        Application.Exit();
                        return;
                    }
                    isWindows = false;
                    break;

                case OsType.Windows64:
                    if (upgradeConfig.InstallerType != UpgradeConfig.Windows64InstallerType)
                    {
                        MessageBox.Show("You need the Windows64 installer for this system");
                        Application.Exit();
                        return;
                    }
                    isWindows = true;
                    break;

                case OsType.Windows32:
                    if (upgradeConfig.InstallerType != UpgradeConfig.Windows32InstallerType)
                    {
                        MessageBox.Show("You need the Windows32 installer for this system");
                        Application.Exit();
                        return;
                    }
                    isWindows = true;
                    break;

                default:
                    MessageBox.Show("Unknown OS type?");
                    Application.Exit();
                    return;
                }
            }

            // Look for VS Code config. Should always be there.
            var vsCodeEntry = zipStore.FindEntry("installUtils/vscodeConfig.json", true);

            if (vsCodeEntry == -1)
            {
                // Error
                MessageBox.Show("File Error?");
                Application.Exit();
                return;
            }

            using (StreamReader reader = new StreamReader(zipStore.GetInputStream(vsCodeEntry)))
            {
                vsConfigStr = await reader.ReadToEndAsync();

                vsCodeConfig = JsonConvert.DeserializeObject <VsCodeConfig>(vsConfigStr, new JsonSerializerSettings
                {
                    MissingMemberHandling = MissingMemberHandling.Error
                });
            }

            vscodeButton.Enabled = true;

            // Look for full config. Will not be there on upgrade
            var fullEntry = zipStore.FindEntry("installUtils/fullConfig.json", true);

            if (fullEntry == -1)
            {
                // Disable any full entry things
                javaCheck.Enabled = false;
                javaCheck.Checked = false;
                cppCheck.Enabled  = false;
                cppCheck.Checked  = false;
            }
            else
            {
                using (StreamReader reader = new StreamReader(zipStore.GetInputStream(fullEntry)))
                {
                    fullConfigStr = await reader.ReadToEndAsync();

                    fullConfig = JsonConvert.DeserializeObject <FullConfig>(fullConfigStr, new JsonSerializerSettings
                    {
                        MissingMemberHandling = MissingMemberHandling.Error,
                    });

                    extractionControllers.Add(new ExtractionIgnores(cppCheck, fullConfig.CppToolchain.Directory, false));

                    extractionControllers.Add(new ExtractionIgnores(gradleCheck, "installUtils/" + fullConfig.Gradle.ZipName, true));
                }

                var jdkEntry = zipStore.FindEntry("installUtils/jdkConfig.json", true);
                if (jdkEntry == -1)
                {
                    // Error
                    MessageBox.Show("File Error?");
                    Application.Exit();
                    return;
                }
                else
                {
                    using (StreamReader reader = new StreamReader(zipStore.GetInputStream(jdkEntry)))
                    {
                        var jdkConfigStr = await reader.ReadToEndAsync();

                        var jdkConfig = JsonConvert.DeserializeObject <JdkConfig>(jdkConfigStr, new JsonSerializerSettings
                        {
                            MissingMemberHandling = MissingMemberHandling.Error,
                        });


                        extractionControllers.Add(new ExtractionIgnores(javaCheck, jdkConfig.Folder, false));
                    }
                }
            }

            if (isWindows)
            {
                var publicFolder = Environment.GetEnvironmentVariable("PUBLIC");
                frcHome = Path.Combine(publicFolder, $"frc{upgradeConfig.FrcYear}");
            }
            else
            {
                var userFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                frcHome = Path.Combine(userFolder, $"frc{upgradeConfig.FrcYear}");
            }

            VSCodeInstall vsi = new VSCodeInstall(Path.Combine(frcHome, "vscode"));

            if (!vsi.IsInstalled())
            {
                vsCodeWpiExtCheck.Checked = false;
                vsCodeWpiExtCheck.Enabled = false;
            }
            else
            {
                vsCodeWpiExtCheck.Checked = true;
                vsCodeWpiExtCheck.Enabled = true;
            }

            this.vsCodeFileLabel.Text = VsCodeFiles.GetFileName(vsCodeConfig.VsCodeVersion);



            this.performInstallButton.Enabled = true;
            this.performInstallButton.Visible = true;
            this.Enabled = true;
        }