private bool OpenMod(string path, bool bSilent = false) { DirectoryInfo di = new DirectoryInfo(path); if (di.Exists && di.Name.ToLower() == "mapsrc" && di.Parent != null && di.Parent.Name.ToLower() == "source") { di = di.Parent; } if (di.Exists && di.Name.ToLower() == "source" && di.Parent != null) { FileInfo[] files = di.Parent.GetFiles("*.settings"); if (files.Length > 0 && files[0].Name == "mod.settings") { di = di.Parent; } } if (di.Exists && File.Exists(di.FullName.TrimEnd('\\', '/') + "/mod.settings")) { bool loadedMod = false; string modDir = di.FullName; foreach (NS2Mod mod in Program.cfg.mods) { if (mod.modDir == modDir) { loadedMod = true; currentMod = mod; break; } } if (!loadedMod) { loadedMod = true; currentMod = new NS2Mod(); currentMod.modDir = modDir; Program.cfg.mods.Add(currentMod); } Program.cfg.lastOpenMod = currentMod.modDir; currentMod.lastOpened = DateTime.Now; Program.cfg.Save(Globals.ConfigFilePath); LoadExistingOverviewImageIntoGUI(); return(true); } else if (!bSilent) { MessageBox.Show(di.FullName + Environment.NewLine + Environment.NewLine + " is not an NS2 Mod directory!"); } return(false); }
public Configuration(NS2Mod currentMod) { this.currentMod = currentMod; InitializeComponent(); cbUseBuilder.Checked = Program.cfg.useBuilder; cbReverseOrder.Checked = currentMod.overlayReverseOrder; txtNs2Dir.Text = Program.cfg.ns2Path; if (!string.IsNullOrWhiteSpace(currentMod.overviewOverlayPath)) { txtOverlayPath.Text = currentMod.overviewOverlayPath; FileInfo fi = new FileInfo(currentMod.overviewOverlayPath); if (fi.Exists && fi.Length > 0) { try { Bitmap bmp = (Bitmap)Bitmap.FromFile(fi.FullName); pictureBox1.Image = bmp; } catch (Exception) { } } } }
public Main(string[] args) { overviewManager = new BackgroundWorker(); overviewManager.DoWork += new DoWorkEventHandler(overviewManager_DoWork); overviewManager.RunWorkerCompleted += new RunWorkerCompletedEventHandler(overviewManager_RunWorkerCompleted); overviewManager.WorkerReportsProgress = false; overviewManager.WorkerSupportsCancellation = true; InitializeComponent(); PopulateRecentMenu(); if (args.Length > 0) { arg0 = args[0]; if (args.Length == 1) { startupOperation = StartupOperation.RestartWithGUI; } if (args.Length == 2) { string opt = args[1].ToLower(); if (opt == "overview") { startupOperation = StartupOperation.Overview; } else if (opt == "overviewlaunch") { startupOperation = StartupOperation.OverviewLaunch; } else if (opt == "launch") { startupOperation = StartupOperation.Launch; } else if (opt != "loadgui") { startupOperation = StartupOperation.RestartWithGUI; } } OpenMod(arg0); } if (currentMod == null) { foreach (NS2Mod mod in Program.cfg.mods) { if (mod.modDir == Program.cfg.lastOpenMod) { currentMod = mod; currentMod.lastOpened = DateTime.Now; break; } } if (currentMod == null) { currentMod = new NS2Mod(); Program.cfg.mods.Add(currentMod); currentMod.lastOpened = DateTime.Now; Program.cfg.lastOpenMod = currentMod.modDir; } Program.cfg.Save(Globals.ConfigFilePath); LoadExistingOverviewImageIntoGUI(); } btnCopyToOutput.Visible = btnCopyToOutput.Enabled = !Program.cfg.useBuilder; txtModDir.Text = currentMod.modDir; }