private void Button1_Click(object sender, EventArgs e) { if (storageFolderBrowserDialog.ShowDialog() != DialogResult.OK) { DialogResult = DialogResult.Cancel; return; } string path = storageFolderBrowserDialog.SelectedPath; if (!File.Exists(Path.Combine(path, ".build.info"))) { MessageBox.Show("Invalid storage folder selected!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _gameType = CASCGame.DetectLocalGame(path); if (_gameType == CASCGameType.Unknown) { return; } textBox1.Text = path; if (_gameType == CASCGameType.WoW) { wowProductComboBox.Enabled = true; } }
public static CASCConfig LoadLocalStorageConfig(string basePath) { var config = new CASCConfig { OnlineMode = false, BasePath = basePath }; config.GameType = CASCGame.DetectLocalGame(basePath); if (config.GameType == CASCGameType.Agent || config.GameType == CASCGameType.Hearthstone) { throw new Exception("Local mode not supported for this game!"); } string buildInfoPath = Path.Combine(basePath, ".build.info"); using (Stream buildInfoStream = new FileStream(buildInfoPath, FileMode.Open)) { config._BuildInfo = VerBarConfig.ReadVerBarConfig(buildInfoStream); } Dictionary <string, string> bi = null; for (int i = 0; i < config._BuildInfo.Count; ++i) { if (config._BuildInfo[i]["Active"] == "1") { bi = config._BuildInfo[i]; break; } } if (bi == null) { throw new Exception("Can't find active BuildInfoEntry"); } string dataFolder = CASCGame.GetDataFolder(config.GameType); config.ActiveBuild = 0; config._Builds = new List <KeyValueConfig>(); string buildKey = bi["BuildKey"]; string buildCfgPath = Path.Combine(basePath, dataFolder, "config", buildKey.Substring(0, 2), buildKey.Substring(2, 2), buildKey); using (Stream stream = new FileStream(buildCfgPath, FileMode.Open)) { config._Builds.Add(KeyValueConfig.ReadKeyValueConfig(stream)); } string cdnKey = bi["CDNKey"]; string cdnCfgPath = Path.Combine(basePath, dataFolder, "config", cdnKey.Substring(0, 2), cdnKey.Substring(2, 2), cdnKey); using (Stream stream = new FileStream(cdnCfgPath, FileMode.Open)) { config._CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream); } return(config); }
private void Button1_Click(object sender, EventArgs e) { if (storageFolderBrowserDialog.ShowDialog() != DialogResult.OK) { DialogResult = DialogResult.Cancel; return; } string path = storageFolderBrowserDialog.SelectedPath; if (!File.Exists(Path.Combine(path, ".build.info"))) { MessageBox.Show("Invalid storage folder selected!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _gameType = CASCGame.DetectLocalGame(path); if (_gameType == CASCGameType.Unknown) { return; } textBox1.Text = path; productComboBox.Items.Clear(); productComboBox.Enabled = sharedInstallProducts.TryGetValue(_gameType, out var products); if (productComboBox.Enabled) { productComboBox.Items.AddRange(products); } }