public void AddDependency(FOGameDependency depend, string Path) { FOGameDependency newDepend = depend; newDepend.Path = Path; if (this.dependencies == null) this.dependencies = new List<FOGameDependency>(); this.dependencies.Add(newDepend); }
public void SetDependencyPath(FOGameDependency dependency, string path) { TextBox txt = this.FindByDependency(this.Form, dependency); txt.Text = path; }
private TextBox FindByDependency(Control root, FOGameDependency dependency) { if (root == null) return null; if (root.Tag is FOGameDependency && (FOGameDependency)root.Tag == dependency) return (TextBox)root; return (from Control control in root.Controls select FindByDependency(control, dependency)).FirstOrDefault(x => x != null); }
public bool VerifyDependency(string fileName, FOGameDependency dependency) { if (!File.Exists(fileName)) { this.view.ShowError(string.Format("{0} doesn't exist", fileName)); return false; } if (string.IsNullOrEmpty(dependency.Script.Path)) { if (!string.IsNullOrEmpty(dependency.Script.Url)) { using (var webClient = new System.Net.WebClient()) { try { string fullPath = Path.Combine(this.scriptPath, Utils.GetFilenameFromUrl(dependency.Script.Url)); if (!File.Exists(fullPath)) { webClient.Proxy = null; webClient.DownloadFile(dependency.Script.Url, fullPath); } dependency.Script.Path = fullPath; } catch (WebException ex) { this.view.ShowError("Failed to download " + dependency.Script.Url + ":" + ex.Message); return false; } } } else this.view.ShowError("No script available for verifying dependency " + dependency.Name); } ResolveHost resolveHost = new ResolveHost(); bool chooseNew = false; do { if (chooseNew) { fileName = this.view.SelectFileName(dependency.Name); } chooseNew = false; if (!resolveHost.RunResolveScript(dependency.Script.Path, dependency.Name, fileName)) { chooseNew = !this.view.AskYesNoQuestion(fileName + " doesn't seem to be a valid file for " + dependency.Name + ", do you want to use it anyway?", "Play FOnline"); } } while (chooseNew); this.view.SetDependencyPath(dependency, fileName); this.selectedDependencies[dependency] = fileName; return true; }