private void FilePreferencesMenuItem_Click(object sender, EventArgs e) { PreferencesForm form = new PreferencesForm(); form.ShowDialog(); }
private bool LoadClient(Plugin plugin, uint otbVersion) { SupportedClient client = plugin.Instance.SupportedClients.Find( delegate(SupportedClient sc) { return sc.OtbVersion == otbVersion; }); if (client == null) { MessageBox.Show("The selected plugin does not support this version."); return false; } uint datSignature = (uint)Properties.Settings.Default["DatSignature"]; uint sprSignature = (uint)Properties.Settings.Default["SprSignature"]; if (client.DatSignature != datSignature || client.SprSignature != sprSignature) { string message; if (datSignature == 0 || sprSignature == 0) { message = "No client is selected. Please navigate to the client folder."; } else { message = string.Format("The selected client is not compatible with this otb. Please navigate to the folder of a compatible client {0}.", client.Version); } MessageBox.Show(message); PreferencesForm form = new PreferencesForm(); if (form.ShowDialog() == DialogResult.OK && form.Plugin != null) { return this.LoadClient(form.Plugin, otbVersion); } else { return false; } } string clientFolder = (string)Properties.Settings.Default["ClientDirectory"]; if (string.IsNullOrEmpty(clientFolder)) { return false; } string datPath = Utils.FindClientFile(clientFolder, ".dat"); string sprPath = Utils.FindClientFile(clientFolder, ".spr"); bool extended = (bool)Properties.Settings.Default["Extended"]; bool transparency = (bool)Properties.Settings.Default["Transparency"]; extended = extended || client.Version >= 960; if (!File.Exists(datPath) || !File.Exists(sprPath)) { MessageBox.Show("Client files not found."); return false; } Trace.WriteLine(string.Format("OTB version {0}.", otbVersion)); bool result; try { result = plugin.Instance.LoadClient(client, extended, transparency, datPath, sprPath); } catch (UnauthorizedAccessException error) { MessageBox.Show(error.Message + " Please run this program as administrator."); return false; } Trace.WriteLine("Loading client files."); if (!result) { MessageBox.Show(string.Format("The plugin could not load dat or spr.")); } this.serverItems.ClientVersion = client.Version; Trace.WriteLine(string.Format("Client version {0}.", client.Version)); return result; }
private bool LoadClient(Plugin plugin, UInt32 otbVersion) { SupportedClient client = plugin.Instance.SupportedClients.Find( delegate(SupportedClient sc) { return sc.OtbVersion == otbVersion; }); if (client == null) { MessageBox.Show("The selected plugin does not support this version."); return false; } UInt32 datSignature = Program.preferences.DatSignature; UInt32 sprSignature = Program.preferences.SprSignature; if (client.DatSignature != datSignature || client.SprSignature != sprSignature) { string message; if (datSignature == 0 || sprSignature == 0) message = "No client is selected. Please navigate to the client folder."; else message = String.Format("The selected client is not compatible with this otb. Please navigate to the folder of a compatible client {0}.", client.Version); MessageBox.Show(message); PreferencesForm form = new PreferencesForm(); form.ShowDialog(); return false; } string clientFolder = Program.preferences.ClientDirectory; if (String.IsNullOrEmpty(clientFolder)) { return false; } string datPath = Utils.FindClientFile(clientFolder, ".dat"); string sprPath = Utils.FindClientFile(clientFolder, ".spr"); bool extended = Program.preferences.Extended; bool transparency = Program.preferences.Transparency; extended = (extended || client.Version >= 960); if (!File.Exists(datPath) || !File.Exists(sprPath)) { MessageBox.Show("Client files not found."); return false; } Trace.WriteLine(String.Format("OTB version {0}.", otbVersion)); bool result; try { result = plugin.Instance.LoadClient(client, extended, transparency, datPath, sprPath); } catch (UnauthorizedAccessException error) { MessageBox.Show(error.Message + " Please run this program as administrator."); return false; } Trace.WriteLine("Loading client files."); if (!result) { MessageBox.Show(String.Format("The plugin could not load dat or spr.")); } items.clientVersion = client.Version; Trace.WriteLine(String.Format("Client version {0}.", client.Version)); return result; }