diff --git a/PSLauncher/ClientINI.cs b/PSLauncher/ClientINI.cs new file mode 100644 index 0000000..b5c096d --- /dev/null +++ b/PSLauncher/ClientINI.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; + +namespace PSLauncher +{ + class ClientINI + { + string inipath; + + public ClientINI(String inipath) + { + this.inipath = inipath; + } + + public void writeEntries(List entries, int primaryIndex=0) + { + FileStream writer = File.Open(this.inipath, FileMode.Create); + + // reorder based on primary index + if(primaryIndex != 0) + { + entries.Insert(0, entries[primaryIndex]); + entries.RemoveAt(primaryIndex + 1); + } + + System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); + FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); + string version = fvi.FileVersion; + + string contents = "# FILE AUTOGENERATED BY PSForever Launcher " + version + "\n"; + contents += "[network]\n"; + + for(int i = 0; i < entries.Count; i++) + { + ServerEntry entry = entries[i]; + + contents += "# Name: " + entry.name + "\n"; + // we only want login0 to be used, but have the rest written there for manual editing as well + contents += String.Format("{3}login{0}={1}:{2}\n", i, entry.hostname, entry.port, + i == 0 ? "" : "#"); + } + + byte[] outBytes = Encoding.ASCII.GetBytes(contents); + + writer.Write(outBytes, 0, outBytes.Length); + writer.Close(); + } + } +} diff --git a/PSLauncher/LauncherForm.Designer.cs b/PSLauncher/LauncherForm.Designer.cs index 234f82c..c385cf1 100644 --- a/PSLauncher/LauncherForm.Designer.cs +++ b/PSLauncher/LauncherForm.Designer.cs @@ -31,6 +31,8 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LauncherForm)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.label1 = new System.Windows.Forms.Label(); + this.serverSelection = new System.Windows.Forms.ComboBox(); this.hideShowOutput = new System.Windows.Forms.Button(); this.skipLauncher = new System.Windows.Forms.CheckBox(); this.passwordLabel = new System.Windows.Forms.Label(); @@ -76,6 +78,8 @@ // splitContainer1.Panel1 // this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.splitContainer1.Panel1.Controls.Add(this.label1); + this.splitContainer1.Panel1.Controls.Add(this.serverSelection); this.splitContainer1.Panel1.Controls.Add(this.hideShowOutput); this.splitContainer1.Panel1.Controls.Add(this.skipLauncher); this.splitContainer1.Panel1.Controls.Add(this.passwordLabel); @@ -90,18 +94,37 @@ // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.ps_consoleOutput); - this.splitContainer1.Size = new System.Drawing.Size(404, 287); + this.splitContainer1.Size = new System.Drawing.Size(444, 287); this.splitContainer1.SplitterDistance = this.splitContainer1.Panel1MinSize; this.splitContainer1.TabIndex = 0; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(202, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 26; + this.label1.Text = "Server"; + // + // serverSelection + // + this.serverSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.serverSelection.FormattingEnabled = true; + this.serverSelection.Location = new System.Drawing.Point(246, 10); + this.serverSelection.Name = "serverSelection"; + this.serverSelection.Size = new System.Drawing.Size(195, 21); + this.serverSelection.TabIndex = 3; + this.serverSelection.SelectedIndexChanged += new System.EventHandler(this.serverSelection_SelectedIndexChanged); + // // hideShowOutput // this.hideShowOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.hideShowOutput.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.hideShowOutput.Location = new System.Drawing.Point(317, 69); + this.hideShowOutput.Location = new System.Drawing.Point(357, 69); this.hideShowOutput.Name = "hideShowOutput"; this.hideShowOutput.Size = new System.Drawing.Size(84, 21); - this.hideShowOutput.TabIndex = 23; + this.hideShowOutput.TabIndex = 5; this.hideShowOutput.Text = "vv Show vv"; this.hideShowOutput.UseVisualStyleBackColor = true; this.hideShowOutput.Click += new System.EventHandler(this.hideShowOutput_Click_1); @@ -109,10 +132,10 @@ // skipLauncher // this.skipLauncher.AutoSize = true; - this.skipLauncher.Location = new System.Drawing.Point(205, 13); + this.skipLauncher.Location = new System.Drawing.Point(205, 71); this.skipLauncher.Name = "skipLauncher"; this.skipLauncher.Size = new System.Drawing.Size(95, 17); - this.skipLauncher.TabIndex = 3; + this.skipLauncher.TabIndex = 4; this.skipLauncher.Text = "Skip Launcher"; this.skipLauncher.UseVisualStyleBackColor = true; this.skipLauncher.CheckedChanged += new System.EventHandler(this.loginFormChanged); @@ -198,8 +221,8 @@ this.ps_consoleOutput.Name = "ps_consoleOutput"; this.ps_consoleOutput.ReadOnly = true; this.ps_consoleOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.ps_consoleOutput.Size = new System.Drawing.Size(404, 188); - this.ps_consoleOutput.TabIndex = 1; + this.ps_consoleOutput.Size = new System.Drawing.Size(444, 188); + this.ps_consoleOutput.TabIndex = 0; this.ps_consoleOutput.WordWrap = false; // // outputRightClick @@ -256,8 +279,8 @@ this.aboutToolStripMenuItem1}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(404, 24); - this.menuStrip1.TabIndex = 2; + this.menuStrip1.Size = new System.Drawing.Size(444, 24); + this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // // settingsToolStripMenuItem @@ -280,13 +303,13 @@ // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.splitContainer1); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(404, 287); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(444, 287); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.LeftToolStripPanelVisible = false; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; this.toolStripContainer1.RightToolStripPanelVisible = false; - this.toolStripContainer1.Size = new System.Drawing.Size(404, 311); + this.toolStripContainer1.Size = new System.Drawing.Size(444, 311); this.toolStripContainer1.TabIndex = 3; this.toolStripContainer1.Text = "toolStripContainer1"; // @@ -299,7 +322,7 @@ this.AcceptButton = this.launchGame; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(404, 311); + this.ClientSize = new System.Drawing.Size(444, 311); this.Controls.Add(this.toolStripContainer1); this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(420, 350); @@ -350,6 +373,8 @@ private System.Windows.Forms.ToolStripMenuItem selectAll; private System.Windows.Forms.ToolStripMenuItem copy; private System.Windows.Forms.ToolStripMenuItem saveToFile; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox serverSelection; } } diff --git a/PSLauncher/LauncherForm.cs b/PSLauncher/LauncherForm.cs index dffd79a..76364d7 100644 --- a/PSLauncher/LauncherForm.cs +++ b/PSLauncher/LauncherForm.cs @@ -60,6 +60,13 @@ namespace PSLauncher Console.SetOut(new Util.ControlWriter(this.ps_consoleOutput)); #endif + // Load server + loadServerSelection(); + + // Make sure selection is valid + if(Settings.Default.ServerSelection >= -1 && Settings.Default.ServerSelection < serverSelection.Items.Count) + serverSelection.SelectedIndex = Settings.Default.ServerSelection; + string psDefault = Util.getDefaultPlanetSideDirectory(); // first run with no settings or invalid starting path @@ -173,10 +180,40 @@ namespace PSLauncher return; } + // Build arguments + List arguments = new List(); + + if (skipLauncher.Checked) + arguments.Add("/K:StagingTest"); + + if (Settings.Default.CoreCombat) + arguments.Add("/CC"); + + if (Settings.Default.ExtraArgs != "") + arguments.Add(Settings.Default.ExtraArgs); + + // Rewrite client.ini if selected + if(Settings.Default.GenerateClientINI) + { + string inipath = Path.Combine(Path.GetDirectoryName(psExe), "client.ini"); + ClientINI ini = new ClientINI(inipath); + + try + { + ini.writeEntries(Util.LoadServerList(), serverSelection.SelectedIndex); + } + catch(IOException exp) + { + setErrorMessage("Failed to write INI file"); + addLine(String.Format("ClientINI: error - '{0}' ({1})", exp.Message, inipath)); + return; + } + } + if (skipLauncher.Checked) { // magic string to login to planetside from the actual game - if(!startPlanetSide(psExe, Path.GetDirectoryName(psExe), "/K:StagingTest " + Settings.Default.ExtraArgs)) + if(!startPlanetSide(psExe, Path.GetDirectoryName(psExe), String.Join(" ", arguments))) { gameStopped(); } @@ -615,11 +652,12 @@ namespace PSLauncher a.ShowDialog(this); } - private void loginFormChanged(object sender, EventArgs e) + private void loginFormChangedUpdate() { if (gameState == GameState.Stopped) { - if (username.Text.Length > 0 && password.Text.Length > 0 || skipLauncher.Checked) + if ((username.Text.Length > 0 && password.Text.Length > 0 || skipLauncher.Checked) && + serverSelection.SelectedIndex != -1) launchGame.Enabled = true; else launchGame.Enabled = false; @@ -639,6 +677,11 @@ namespace PSLauncher } } + private void loginFormChanged(object sender, EventArgs e) + { + loginFormChangedUpdate(); + } + private void setConsoleWindowState(bool open) { if (!open) @@ -646,9 +689,9 @@ namespace PSLauncher oldSize = this.Size; this.hideShowOutput.Text = "vv Show vv"; - this.MinimumSize = this.MaximumSize = new System.Drawing.Size(420, 160); + this.MinimumSize = this.MaximumSize = new System.Drawing.Size(460, 160); - this.Size = new System.Drawing.Size(420, 160); + this.Size = new System.Drawing.Size(460, 160); this.WindowState = FormWindowState.Normal; this.MaximizeBox = false; @@ -657,7 +700,7 @@ namespace PSLauncher else { this.hideShowOutput.Text = "^^ Hide ^^"; - this.MinimumSize = new System.Drawing.Size(420, 350); + this.MinimumSize = new System.Drawing.Size(460, 350); this.MaximumSize = new System.Drawing.Size(0, 0); if (oldSize.IsEmpty) @@ -699,11 +742,43 @@ namespace PSLauncher } } + private void loadServerSelection() + { + int index = serverSelection.SelectedIndex; + + List entries = Util.LoadServerList(); + serverSelection.Items.Clear(); + + foreach (ServerEntry entry in entries) + { + serverSelection.Items.Add(entry.name); + } + + if (entries.Count > 0 && index != -1) + { + if (index + 1 >= entries.Count) + { + serverSelection.SelectedIndex = entries.Count - 1; + } + else + { + serverSelection.SelectedIndex = index; + } + } + + loginFormChangedUpdate(); + + // Dont let us select a server without any servers! + serverSelection.Enabled = entries.Count != 0; + } + private void settingsToolStripMenuItem_Click(object sender, EventArgs e) { SettingsForm a = new SettingsForm(); a.StartPosition = FormStartPosition.CenterParent; a.ShowDialog(this); + + loadServerSelection(); } private void selectAll_Click(object sender, EventArgs e) @@ -741,5 +816,13 @@ namespace PSLauncher f.Close(); } } + + private void serverSelection_SelectedIndexChanged(object sender, EventArgs e) + { + Settings.Default.ServerSelection = serverSelection.SelectedIndex; + + // Update the login form as well + loginFormChangedUpdate(); + } } } diff --git a/PSLauncher/PSLauncher.csproj b/PSLauncher/PSLauncher.csproj index 51fa766..958fbce 100644 --- a/PSLauncher/PSLauncher.csproj +++ b/PSLauncher/PSLauncher.csproj @@ -168,6 +168,7 @@ AboutBox1.cs + Form diff --git a/PSLauncher/Properties/AssemblyInfo.cs b/PSLauncher/Properties/AssemblyInfo.cs index b5d2729..1e601e6 100644 --- a/PSLauncher/Properties/AssemblyInfo.cs +++ b/PSLauncher/Properties/AssemblyInfo.cs @@ -32,8 +32,8 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] // Stamp // [assembly: AssemblyInformationalVersion("%version% [ %branch% @ %shorthash%%haschanges% ]")] diff --git a/PSLauncher/Properties/Settings.Designer.cs b/PSLauncher/Properties/Settings.Designer.cs index 1d2b79b..885ea84 100644 --- a/PSLauncher/Properties/Settings.Designer.cs +++ b/PSLauncher/Properties/Settings.Designer.cs @@ -108,5 +108,29 @@ namespace PSLauncher.Properties { this["ServerList"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool GenerateClientINI { + get { + return ((bool)(this["GenerateClientINI"])); + } + set { + this["GenerateClientINI"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int ServerSelection { + get { + return ((int)(this["ServerSelection"])); + } + set { + this["ServerSelection"] = value; + } + } } } diff --git a/PSLauncher/Properties/Settings.settings b/PSLauncher/Properties/Settings.settings index f0ada66..ecf5550 100644 --- a/PSLauncher/Properties/Settings.settings +++ b/PSLauncher/Properties/Settings.settings @@ -26,5 +26,11 @@ <string>PSForever,play.psforever.net,51000</string> </ArrayOfString> + + True + + + 0 + \ No newline at end of file diff --git a/PSLauncher/ServerList.Designer.cs b/PSLauncher/ServerList.Designer.cs index bcbb92a..00a5a15 100644 --- a/PSLauncher/ServerList.Designer.cs +++ b/PSLauncher/ServerList.Designer.cs @@ -87,7 +87,7 @@ this.hostnameInput.Location = new System.Drawing.Point(11, 207); this.hostnameInput.Name = "hostnameInput"; this.hostnameInput.Size = new System.Drawing.Size(144, 20); - this.hostnameInput.TabIndex = 3; + this.hostnameInput.TabIndex = 7; this.hostnameInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textInput_KeyPress); // // portInput @@ -95,7 +95,7 @@ this.portInput.Location = new System.Drawing.Point(168, 207); this.portInput.Name = "portInput"; this.portInput.Size = new System.Drawing.Size(50, 20); - this.portInput.TabIndex = 4; + this.portInput.TabIndex = 10; this.portInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.portInput_KeyPress); // // deleteItem @@ -108,7 +108,7 @@ this.deleteItem.Location = new System.Drawing.Point(291, 95); this.deleteItem.Name = "deleteItem"; this.deleteItem.Size = new System.Drawing.Size(24, 26); - this.deleteItem.TabIndex = 5; + this.deleteItem.TabIndex = 3; this.deleteItem.UseVisualStyleBackColor = false; this.deleteItem.Click += new System.EventHandler(this.deleteItem_Click); // @@ -127,7 +127,7 @@ this.label2.Location = new System.Drawing.Point(165, 185); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(26, 13); - this.label2.TabIndex = 7; + this.label2.TabIndex = 8; this.label2.Text = "Port"; // // addButton @@ -135,7 +135,7 @@ this.addButton.Location = new System.Drawing.Point(230, 205); this.addButton.Name = "addButton"; this.addButton.Size = new System.Drawing.Size(42, 23); - this.addButton.TabIndex = 8; + this.addButton.TabIndex = 11; this.addButton.Text = "Add"; this.addButton.UseVisualStyleBackColor = true; this.addButton.Click += new System.EventHandler(this.addButton_Click); @@ -155,7 +155,7 @@ this.okButton.Location = new System.Drawing.Point(93, 239); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(62, 23); - this.okButton.TabIndex = 28; + this.okButton.TabIndex = 12; this.okButton.Text = "OK"; this.okButton.UseVisualStyleBackColor = true; this.okButton.Click += new System.EventHandler(this.okButton_Click); @@ -166,7 +166,7 @@ this.label4.Location = new System.Drawing.Point(9, 131); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(69, 13); - this.label4.TabIndex = 30; + this.label4.TabIndex = 4; this.label4.Text = "Server Name"; // // serverNameInput @@ -174,7 +174,7 @@ this.serverNameInput.Location = new System.Drawing.Point(12, 153); this.serverNameInput.Name = "serverNameInput"; this.serverNameInput.Size = new System.Drawing.Size(206, 20); - this.serverNameInput.TabIndex = 29; + this.serverNameInput.TabIndex = 5; this.serverNameInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textInput_KeyPress); // // cancelButton @@ -183,7 +183,7 @@ this.cancelButton.Location = new System.Drawing.Point(173, 239); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(62, 23); - this.cancelButton.TabIndex = 31; + this.cancelButton.TabIndex = 13; this.cancelButton.Text = "Cancel"; this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); diff --git a/PSLauncher/ServerList.cs b/PSLauncher/ServerList.cs index 30628f9..5d16e95 100644 --- a/PSLauncher/ServerList.cs +++ b/PSLauncher/ServerList.cs @@ -13,15 +13,15 @@ using System.Diagnostics; namespace PSLauncher { + public struct ServerEntry + { + public string name; + public string hostname; + public int port; + } + public partial class ServerList : Form { - struct ServerEntry - { - public string name; - public string hostname; - public int port; - } - List entries = new List(); public ServerList() @@ -30,24 +30,9 @@ namespace PSLauncher this.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath); - StringCollection serverList = Settings.Default.ServerList; - - foreach(String entry in serverList) + foreach(ServerEntry entry in Util.LoadServerList()) { - String [] tokens = entry.Split(','); - - if(tokens.Length != 3) - { - Debug.WriteLine("Failed to load server entry " + entry); - continue; - } - - ServerEntry newEntry = new ServerEntry(); - newEntry.name = tokens[0]; - newEntry.hostname = tokens[1]; - newEntry.port = int.Parse(tokens[2]); - - addEntry(newEntry); + addEntry(entry); } } @@ -68,8 +53,6 @@ namespace PSLauncher private void portInput_KeyPress(object sender, KeyPressEventArgs e) { - Debug.WriteLine("Char: " + e.KeyChar.ToString()); - if(e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == '\b') { if(portInput.Text.Length >= 5 && e.KeyChar != '\b') @@ -136,8 +119,6 @@ namespace PSLauncher { int selected = serverDisplay.SelectedIndex; - Debug.WriteLine("Move " + selected + " ^"); - if (selected == -1 || selected == 0) return; @@ -154,8 +135,6 @@ namespace PSLauncher { int selected = serverDisplay.SelectedIndex; - Debug.WriteLine("Move " + selected + " v"); - if (selected == -1 || (selected+1) == entries.Count) return; diff --git a/PSLauncher/SettingsForm.Designer.cs b/PSLauncher/SettingsForm.Designer.cs index 65918dc..fc24a36 100644 --- a/PSLauncher/SettingsForm.Designer.cs +++ b/PSLauncher/SettingsForm.Designer.cs @@ -39,6 +39,7 @@ this.button1 = new System.Windows.Forms.Button(); this.coreCombat = new System.Windows.Forms.CheckBox(); this.editServerList = new System.Windows.Forms.Button(); + this.generateClientIni = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label2 @@ -47,7 +48,7 @@ this.label2.Location = new System.Drawing.Point(9, 17); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(90, 13); - this.label2.TabIndex = 10; + this.label2.TabIndex = 0; this.label2.Text = "PlanetSide Folder"; // // selectDirectory @@ -55,7 +56,7 @@ this.selectDirectory.Location = new System.Drawing.Point(12, 59); this.selectDirectory.Name = "selectDirectory"; this.selectDirectory.Size = new System.Drawing.Size(75, 23); - this.selectDirectory.TabIndex = 9; + this.selectDirectory.TabIndex = 2; this.selectDirectory.Text = "Choose"; this.selectDirectory.UseVisualStyleBackColor = true; this.selectDirectory.Click += new System.EventHandler(this.button1_Click); @@ -66,24 +67,24 @@ this.planetsidePathTextField.Name = "planetsidePathTextField"; this.planetsidePathTextField.ReadOnly = true; this.planetsidePathTextField.Size = new System.Drawing.Size(222, 20); - this.planetsidePathTextField.TabIndex = 8; + this.planetsidePathTextField.TabIndex = 1; this.planetsidePathTextField.Text = "Path to PlanetSide folder"; // // launchArgs // - this.launchArgs.Location = new System.Drawing.Point(10, 182); + this.launchArgs.Location = new System.Drawing.Point(12, 195); this.launchArgs.Name = "launchArgs"; this.launchArgs.Size = new System.Drawing.Size(222, 20); - this.launchArgs.TabIndex = 15; + this.launchArgs.TabIndex = 9; this.launchArgs.TextChanged += new System.EventHandler(this.launchArgs_TextChanged); // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(7, 163); + this.label10.Location = new System.Drawing.Point(9, 176); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(158, 13); - this.label10.TabIndex = 16; + this.label10.TabIndex = 8; this.label10.Text = "Additional command line options"; // // planetsideVersion @@ -91,7 +92,7 @@ this.planetsideVersion.Location = new System.Drawing.Point(102, 59); this.planetsideVersion.Name = "planetsideVersion"; this.planetsideVersion.Size = new System.Drawing.Size(132, 21); - this.planetsideVersion.TabIndex = 25; + this.planetsideVersion.TabIndex = 3; this.planetsideVersion.Text = "Version"; this.planetsideVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -101,7 +102,7 @@ this.clearOnLaunch.Location = new System.Drawing.Point(12, 123); this.clearOnLaunch.Name = "clearOnLaunch"; this.clearOnLaunch.Size = new System.Drawing.Size(133, 17); - this.clearOnLaunch.TabIndex = 26; + this.clearOnLaunch.TabIndex = 5; this.clearOnLaunch.Text = "Clear output on launch"; this.clearOnLaunch.UseVisualStyleBackColor = true; this.clearOnLaunch.CheckedChanged += new System.EventHandler(this.clearOnLaunch_CheckedChanged); @@ -112,7 +113,7 @@ this.button1.Location = new System.Drawing.Point(91, 226); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(62, 23); - this.button1.TabIndex = 27; + this.button1.TabIndex = 10; this.button1.Text = "OK"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click_1); @@ -123,7 +124,7 @@ this.coreCombat.Location = new System.Drawing.Point(12, 98); this.coreCombat.Name = "coreCombat"; this.coreCombat.Size = new System.Drawing.Size(87, 17); - this.coreCombat.TabIndex = 28; + this.coreCombat.TabIndex = 4; this.coreCombat.Text = "Core Combat"; this.coreCombat.UseVisualStyleBackColor = true; this.coreCombat.CheckedChanged += new System.EventHandler(this.coreCombat_CheckedChanged); @@ -133,16 +134,28 @@ this.editServerList.Location = new System.Drawing.Point(134, 94); this.editServerList.Name = "editServerList"; this.editServerList.Size = new System.Drawing.Size(100, 23); - this.editServerList.TabIndex = 29; + this.editServerList.TabIndex = 7; this.editServerList.Text = "Edit Server List..."; this.editServerList.UseVisualStyleBackColor = true; this.editServerList.Click += new System.EventHandler(this.editServerList_Click); // + // generateClientIni + // + this.generateClientIni.AutoSize = true; + this.generateClientIni.Location = new System.Drawing.Point(12, 146); + this.generateClientIni.Name = "generateClientIni"; + this.generateClientIni.Size = new System.Drawing.Size(111, 17); + this.generateClientIni.TabIndex = 6; + this.generateClientIni.Text = "Generate client.ini"; + this.generateClientIni.UseVisualStyleBackColor = true; + this.generateClientIni.CheckedChanged += new System.EventHandler(this.generateClientIni_CheckedChanged); + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(244, 251); + this.Controls.Add(this.generateClientIni); this.Controls.Add(this.editServerList); this.Controls.Add(this.coreCombat); this.Controls.Add(this.planetsideVersion); @@ -178,5 +191,6 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox coreCombat; private System.Windows.Forms.Button editServerList; + private System.Windows.Forms.CheckBox generateClientIni; } } \ No newline at end of file diff --git a/PSLauncher/SettingsForm.cs b/PSLauncher/SettingsForm.cs index 553ea63..144abeb 100644 --- a/PSLauncher/SettingsForm.cs +++ b/PSLauncher/SettingsForm.cs @@ -26,6 +26,7 @@ namespace PSLauncher launchArgs.Text = Settings.Default.ExtraArgs; clearOnLaunch.Checked = Settings.Default.ClearOutputOnLaunch; coreCombat.Checked = Settings.Default.CoreCombat; + generateClientIni.Checked = Settings.Default.GenerateClientINI; checkPath(Path.Combine(planetsidePathTextField.Text, PS_EXE_NAME), false); } @@ -118,5 +119,10 @@ namespace PSLauncher a.StartPosition = FormStartPosition.CenterParent; a.ShowDialog(this); } + + private void generateClientIni_CheckedChanged(object sender, EventArgs e) + { + Settings.Default.GenerateClientINI = generateClientIni.Checked; + } } } diff --git a/PSLauncher/Util.cs b/PSLauncher/Util.cs index 9100faa..3a0e9c1 100644 --- a/PSLauncher/Util.cs +++ b/PSLauncher/Util.cs @@ -1,4 +1,5 @@ -using System; +using PSLauncher.Properties; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; @@ -56,6 +57,32 @@ namespace PSLauncher public static class Util { + public static List LoadServerList() + { + List entries = new List(); + StringCollection serverList = Settings.Default.ServerList; + + foreach (String entry in serverList) + { + String[] tokens = entry.Split(','); + + if (tokens.Length != 3) + { + Console.WriteLine("LoadServerList: Failed to load server entry " + entry); + continue; + } + + ServerEntry newEntry = new ServerEntry(); + newEntry.name = tokens[0]; + newEntry.hostname = tokens[1]; + newEntry.port = int.Parse(tokens[2]); + + entries.Add(newEntry); + } + + return entries; + } + public static string getDefaultPlanetSideDirectory() { // paths are in order of newest (most likely to have the right planetside) to oldest @@ -72,7 +99,7 @@ namespace PSLauncher String defaultDirectory; defaultDirectory = key.GetValue("").ToString(); - Console.WriteLine("LaunchPad.exe key found {0}", defaultDirectory); + Console.WriteLine("PSDiscover: LaunchPad.exe key found {0}", defaultDirectory); defaultDirectory = Path.GetDirectoryName(defaultDirectory); @@ -87,7 +114,7 @@ namespace PSLauncher } else { - Console.WriteLine("No LaunchPad.exe key found"); + Console.WriteLine("PSDiscover: No LaunchPad.exe key found"); } // HACK: Should work on Win7 and above @@ -105,18 +132,18 @@ namespace PSLauncher int i = 1; foreach(var path in pathsToCheck) { - Console.WriteLine("M{0} - {1}", i, path); + Console.WriteLine("PSDiscover: M{0} - {1}", i, path); if (Directory.Exists(path) && checkDirForPlanetSide(path)) { - Console.WriteLine("Path found using M{0}", i); + Console.WriteLine("PSDiscover: Path found using M{0}", i); return path; } i += 1; } - Console.WriteLine("No default planetside.exe path found"); + Console.WriteLine("PSDiscover: No default planetside.exe path found!"); // give up :'( return ""; diff --git a/PSLauncher/app.config b/PSLauncher/app.config index 4217a5c..75d594a 100644 --- a/PSLauncher/app.config +++ b/PSLauncher/app.config @@ -33,6 +33,12 @@ + + True + + + 0 + \ No newline at end of file