Winforms launcher beginnings.
This commit is contained in:
committed by
Paul Chote
parent
d93c42e89c
commit
439c366ba2
99
OpenRA.Launcher/ConfigureModsDialog.Designer.cs
generated
Normal file
99
OpenRA.Launcher/ConfigureModsDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,99 @@
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
partial class ConfigureModsDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.installButton = new System.Windows.Forms.Button();
|
||||
this.installModDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(275, 227);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 0;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(194, 227);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// installButton
|
||||
//
|
||||
this.installButton.Location = new System.Drawing.Point(12, 227);
|
||||
this.installButton.Name = "installButton";
|
||||
this.installButton.Size = new System.Drawing.Size(116, 23);
|
||||
this.installButton.TabIndex = 2;
|
||||
this.installButton.Text = "Install Mod...";
|
||||
this.installButton.UseVisualStyleBackColor = true;
|
||||
this.installButton.Click += new System.EventHandler(this.InstallMod);
|
||||
//
|
||||
// installModDialog
|
||||
//
|
||||
this.installModDialog.Filter = "Zip files|*.zip";
|
||||
this.installModDialog.RestoreDirectory = true;
|
||||
//
|
||||
// ConfigureModsDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(362, 262);
|
||||
this.Controls.Add(this.installButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ConfigureModsDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Configure Mods";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button installButton;
|
||||
private System.Windows.Forms.OpenFileDialog installModDialog;
|
||||
}
|
||||
}
|
||||
37
OpenRA.Launcher/ConfigureModsDialog.cs
Normal file
37
OpenRA.Launcher/ConfigureModsDialog.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
public partial class ConfigureModsDialog : Form
|
||||
{
|
||||
string[] currentMods;
|
||||
string[] allMods;
|
||||
public ConfigureModsDialog(string[] currentMods)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Util.UacShield(installButton);
|
||||
|
||||
this.currentMods = currentMods;
|
||||
|
||||
var response = UtilityProgram.Call("--list-mods");
|
||||
if (!response.IsError)
|
||||
allMods = response.ResponseLines;
|
||||
else
|
||||
throw new Exception(string.Format("Could not list mods: {0}", response.Response));
|
||||
}
|
||||
|
||||
private void InstallMod(object sender, EventArgs e)
|
||||
{
|
||||
if (installModDialog.ShowDialog() != DialogResult.OK) return;
|
||||
UtilityProgram.CallWithAdmin("--install-mods", "foo.zip");
|
||||
}
|
||||
}
|
||||
}
|
||||
123
OpenRA.Launcher/ConfigureModsDialog.resx
Normal file
123
OpenRA.Launcher/ConfigureModsDialog.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="installModDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
158
OpenRA.Launcher/MainForm.Designer.cs
generated
Normal file
158
OpenRA.Launcher/MainForm.Designer.cs
generated
Normal file
@@ -0,0 +1,158 @@
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.launchButton = new System.Windows.Forms.Button();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.quitButton = new System.Windows.Forms.Button();
|
||||
this.configModsButton = new System.Windows.Forms.Button();
|
||||
this.configGameButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(51, 3);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(192, 64);
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// launchButton
|
||||
//
|
||||
this.launchButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.launchButton.Location = new System.Drawing.Point(51, 97);
|
||||
this.launchButton.Name = "launchButton";
|
||||
this.launchButton.Size = new System.Drawing.Size(192, 50);
|
||||
this.launchButton.TabIndex = 1;
|
||||
this.launchButton.Text = "Launch OpenRA";
|
||||
this.launchButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.launchButton, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.quitButton, 0, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.configModsButton, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.configGameButton, 0, 4);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 6;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(294, 372);
|
||||
this.tableLayoutPanel1.TabIndex = 2;
|
||||
//
|
||||
// quitButton
|
||||
//
|
||||
this.quitButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.quitButton.Location = new System.Drawing.Point(51, 311);
|
||||
this.quitButton.Name = "quitButton";
|
||||
this.quitButton.Size = new System.Drawing.Size(192, 50);
|
||||
this.quitButton.TabIndex = 2;
|
||||
this.quitButton.Text = "Quit";
|
||||
this.quitButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// configModsButton
|
||||
//
|
||||
this.configModsButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.configModsButton.Location = new System.Drawing.Point(51, 168);
|
||||
this.configModsButton.Name = "configModsButton";
|
||||
this.configModsButton.Size = new System.Drawing.Size(192, 50);
|
||||
this.configModsButton.TabIndex = 3;
|
||||
this.configModsButton.Text = "Configure Mods...";
|
||||
this.configModsButton.UseVisualStyleBackColor = true;
|
||||
this.configModsButton.Click += new System.EventHandler(this.ConfigureMods);
|
||||
//
|
||||
// configGameButton
|
||||
//
|
||||
this.configGameButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.configGameButton.Location = new System.Drawing.Point(51, 239);
|
||||
this.configGameButton.Name = "configGameButton";
|
||||
this.configGameButton.Size = new System.Drawing.Size(192, 50);
|
||||
this.configGameButton.TabIndex = 4;
|
||||
this.configGameButton.Text = "Configure Game...";
|
||||
this.configGameButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.Location = new System.Drawing.Point(3, 70);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(288, 17);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(294, 372);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "OpenRA Launcher";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button launchButton;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Button quitButton;
|
||||
private System.Windows.Forms.Button configModsButton;
|
||||
private System.Windows.Forms.Button configGameButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
37
OpenRA.Launcher/MainForm.cs
Normal file
37
OpenRA.Launcher/MainForm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
string configPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + "OpenRA";
|
||||
string[] currentMods;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
quitButton.Click += (o, e) => { Application.Exit(); };
|
||||
var response = UtilityProgram.Call("--settings-value", configPath, "Game.Mods");
|
||||
|
||||
if (response.IsError)
|
||||
currentMods = new string[] { };
|
||||
else
|
||||
currentMods = response.Response.Split(',');
|
||||
|
||||
label1.Text = string.Format("Current Mods: {0}", currentMods.Length > 0 ? string.Join(",", currentMods) : "ra");
|
||||
}
|
||||
|
||||
private void ConfigureMods(object sender, EventArgs e)
|
||||
{
|
||||
var d = new ConfigureModsDialog(currentMods);
|
||||
d.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
4788
OpenRA.Launcher/MainForm.resx
Normal file
4788
OpenRA.Launcher/MainForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
82
OpenRA.Launcher/OpenRA.Launcher.csproj
Normal file
82
OpenRA.Launcher/OpenRA.Launcher.csproj
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2EA6C9C7-28A8-46C6-A42C-9275692EB285}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRA.Launcher</RootNamespace>
|
||||
<AssemblyName>OpenRA.Launcher</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigureModsDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ConfigureModsDialog.Designer.cs">
|
||||
<DependentUpon>ConfigureModsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="UtilityProgram.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ConfigureModsDialog.resx">
|
||||
<DependentUpon>ConfigureModsDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
16
OpenRA.Launcher/Program.cs
Normal file
16
OpenRA.Launcher/Program.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
26
OpenRA.Launcher/Util.cs
Normal file
26
OpenRA.Launcher/Util.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
static class Util
|
||||
{
|
||||
[DllImport("user32")]
|
||||
public static extern UInt32 SendMessage
|
||||
(IntPtr hWnd, UInt32 msg, UInt32 wParam, UInt32 lParam);
|
||||
|
||||
internal const int BCM_FIRST = 0x1600; //Normal button
|
||||
|
||||
internal const int BCM_SETSHIELD = (BCM_FIRST + 0x000C); //Elevated button
|
||||
|
||||
static public void UacShield(Button b)
|
||||
{
|
||||
b.FlatStyle = FlatStyle.System;
|
||||
SendMessage(b.Handle, BCM_SETSHIELD, 0, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
96
OpenRA.Launcher/UtilityProgram.cs
Normal file
96
OpenRA.Launcher/UtilityProgram.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Launcher
|
||||
{
|
||||
class UtilityProgramResponse
|
||||
{
|
||||
public bool IsError
|
||||
{
|
||||
get { return response.StartsWith("Error:"); }
|
||||
}
|
||||
|
||||
string response;
|
||||
|
||||
public string Response
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsError)
|
||||
return response.Remove(0, 7);
|
||||
else
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ResponseLines
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = response;
|
||||
if (IsError)
|
||||
s = response.Remove(0, 7);
|
||||
return s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
|
||||
public UtilityProgramResponse(string response)
|
||||
{
|
||||
this.response = response.Trim('\r', '\n');
|
||||
}
|
||||
}
|
||||
|
||||
static class UtilityProgram
|
||||
{
|
||||
static string BuildArgs(string command, string[] args)
|
||||
{
|
||||
StringBuilder arguments = new StringBuilder();
|
||||
arguments.Append("\"");
|
||||
arguments.Append(command + "=");
|
||||
arguments.Append(string.Join(",", args));
|
||||
arguments.Append("\"");
|
||||
return arguments.ToString();
|
||||
}
|
||||
|
||||
public static UtilityProgramResponse Call(string command, params string[] args)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "OpenRA.Utility.exe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args);
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
|
||||
p.Start();
|
||||
|
||||
return new UtilityProgramResponse(p.StandardOutput.ReadToEnd());
|
||||
}
|
||||
|
||||
public static UtilityProgramResponse CallWithAdmin(string command, params string[] args)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "OpenRA.Utility.exe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args);
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.Verb = "runas";
|
||||
|
||||
try
|
||||
{
|
||||
p.Start();
|
||||
}
|
||||
catch (Win32Exception e)
|
||||
{
|
||||
if (e.NativeErrorCode == 1223) //ERROR_CANCELLED
|
||||
return new UtilityProgramResponse("Error: User cancelled elevation prompt.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
p.WaitForExit();
|
||||
|
||||
return new UtilityProgramResponse(File.ReadAllText("output.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user