From 564a4598b9941e4074cda1bc380b028c144cfdaa Mon Sep 17 00:00:00 2001 From: Matthew Bowra-Dean Date: Mon, 29 Nov 2010 23:23:53 +1300 Subject: [PATCH] Added renderer selection to Windows launcher. --- OpenRA.Launcher/JSBridge.cs | 1 + OpenRA.Launcher/Launcher.Designer.cs | 31 ++++++++++++++++++++++++++++ OpenRA.Launcher/Launcher.cs | 20 +++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/OpenRA.Launcher/JSBridge.cs b/OpenRA.Launcher/JSBridge.cs index 1d03890a5d..268918e43a 100644 --- a/OpenRA.Launcher/JSBridge.cs +++ b/OpenRA.Launcher/JSBridge.cs @@ -58,6 +58,7 @@ namespace OpenRA.Launcher Process p = new Process(); p.StartInfo.FileName = "OpenRA.Game.exe"; p.StartInfo.Arguments = "Game.Mods=" + string.Join(",", modList.ToArray()); + p.StartInfo.Arguments += " Graphics.Renderer=" + Launcher.Renderer; p.Start(); return true; } diff --git a/OpenRA.Launcher/Launcher.Designer.cs b/OpenRA.Launcher/Launcher.Designer.cs index 89d88ea070..9f16d315a5 100644 --- a/OpenRA.Launcher/Launcher.Designer.cs +++ b/OpenRA.Launcher/Launcher.Designer.cs @@ -35,6 +35,8 @@ this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.webBrowser = new System.Windows.Forms.WebBrowser(); this.panel1 = new System.Windows.Forms.Panel(); + this.cgButton = new System.Windows.Forms.RadioButton(); + this.glButton = new System.Windows.Forms.RadioButton(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -103,6 +105,8 @@ // // panel1 // + this.panel1.Controls.Add(this.cgButton); + this.panel1.Controls.Add(this.glButton); this.panel1.Controls.Add(this.installButton); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Location = new System.Drawing.Point(0, 465); @@ -110,6 +114,30 @@ this.panel1.Size = new System.Drawing.Size(671, 47); this.panel1.TabIndex = 5; // + // cgButton + // + this.cgButton.AutoSize = true; + this.cgButton.Location = new System.Drawing.Point(481, 18); + this.cgButton.Name = "cgButton"; + this.cgButton.Size = new System.Drawing.Size(87, 17); + this.cgButton.TabIndex = 4; + this.cgButton.TabStop = true; + this.cgButton.Text = "CG Renderer"; + this.cgButton.UseVisualStyleBackColor = true; + this.cgButton.CheckedChanged += new System.EventHandler(this.rendererChanged); + // + // glButton + // + this.glButton.AutoSize = true; + this.glButton.Location = new System.Drawing.Point(574, 18); + this.glButton.Name = "glButton"; + this.glButton.Size = new System.Drawing.Size(86, 17); + this.glButton.TabIndex = 3; + this.glButton.TabStop = true; + this.glButton.Text = "GL Renderer"; + this.glButton.UseVisualStyleBackColor = true; + this.glButton.CheckedChanged += new System.EventHandler(this.rendererChanged); + // // Launcher // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -127,6 +155,7 @@ this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.ResumeLayout(false); this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.ResumeLayout(false); } @@ -139,5 +168,7 @@ private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.WebBrowser webBrowser; + private System.Windows.Forms.RadioButton cgButton; + private System.Windows.Forms.RadioButton glButton; } } \ No newline at end of file diff --git a/OpenRA.Launcher/Launcher.cs b/OpenRA.Launcher/Launcher.cs index b1dbed671a..785125ccaa 100644 --- a/OpenRA.Launcher/Launcher.cs +++ b/OpenRA.Launcher/Launcher.cs @@ -21,6 +21,9 @@ namespace OpenRA.Launcher public partial class Launcher : Form { Dictionary allMods; + public static string Renderer = "Gl"; + static string SupportDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "OpenRA"; + public Launcher() { InitializeComponent(); @@ -34,6 +37,11 @@ namespace OpenRA.Launcher (b.ObjectForScripting as JSBridge).Document = b.Document; }; RefreshMods(); + string response = UtilityProgram.CallSimpleResponse("--settings-value", SupportDir, "Graphics.Renderer"); + if (Util.IsError(ref response) || response.Equals("gl", StringComparison.InvariantCultureIgnoreCase)) + glButton.Checked = true; + else + cgButton.Checked = true; } Mod GetMetadata(string mod) @@ -167,8 +175,7 @@ namespace OpenRA.Launcher treeView.Nodes["ModsNode"].ExpandAll(); treeView.Invalidate(); - string responseString = UtilityProgram.CallSimpleResponse("--settings-value", - Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + "OpenRA", "Game.Mods"); + string responseString = UtilityProgram.CallSimpleResponse("--settings-value", SupportDir, "Game.Mods"); if (Util.IsError(ref responseString)) treeView.SelectedNode = treeView.Nodes["ModsNode"].Nodes["ra"]; @@ -183,7 +190,14 @@ namespace OpenRA.Launcher string modHtmlPath = string.Format("mods{0}{1}{0}mod.html", Path.DirectorySeparatorChar, e.Node.Name); if (!File.Exists(modHtmlPath)) return; webBrowser.Navigate(Path.GetFullPath(modHtmlPath)); - + } + + private void rendererChanged(object sender, EventArgs e) + { + if (sender == glButton) + Renderer = "Gl"; + else + Renderer = "Cg"; } } }