Refactoring of OpenRA.Utility. Whole lot of work on OpenRA.Launcher

Mod configuration dialog now fully functional, launch button also works.
This commit is contained in:
Matthew Bowra-Dean
2010-11-05 03:00:02 +13:00
committed by Paul Chote
parent f98f3d0b39
commit da384af339
13 changed files with 909 additions and 272 deletions

View File

@@ -33,13 +33,22 @@
this.installButton = new System.Windows.Forms.Button();
this.installModDialog = new System.Windows.Forms.OpenFileDialog();
this.treeView1 = new System.Windows.Forms.TreeView();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.addButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.label1 = new System.Windows.Forms.Label();
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.label2 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
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.Location = new System.Drawing.Point(446, 477);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 0;
@@ -50,7 +59,7 @@
//
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.Location = new System.Drawing.Point(365, 477);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 1;
@@ -59,7 +68,8 @@
//
// installButton
//
this.installButton.Location = new System.Drawing.Point(12, 227);
this.installButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.installButton.Location = new System.Drawing.Point(12, 477);
this.installButton.Name = "installButton";
this.installButton.Size = new System.Drawing.Size(116, 23);
this.installButton.TabIndex = 2;
@@ -74,17 +84,121 @@
//
// treeView1
//
this.treeView1.Location = new System.Drawing.Point(12, 12);
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.Location = new System.Drawing.Point(3, 23);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(175, 209);
this.tableLayoutPanel1.SetRowSpan(this.treeView1, 2);
this.treeView1.Size = new System.Drawing.Size(233, 212);
this.treeView1.TabIndex = 3;
this.treeView1.Enter += new System.EventHandler(this.treeView1_Enter);
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeViewSelect);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.treeView1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.addButton, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.removeButton, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.listView1, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.propertyGrid1, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.label2, 2, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
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, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(509, 459);
this.tableLayoutPanel1.TabIndex = 4;
//
// addButton
//
this.addButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.addButton.Location = new System.Drawing.Point(242, 103);
this.addButton.Name = "addButton";
this.addButton.Size = new System.Drawing.Size(24, 23);
this.addButton.TabIndex = 5;
this.addButton.Text = "+";
this.addButton.UseVisualStyleBackColor = true;
this.addButton.Click += new System.EventHandler(this.ActivateMod);
//
// removeButton
//
this.removeButton.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.removeButton.Location = new System.Drawing.Point(242, 132);
this.removeButton.Name = "removeButton";
this.removeButton.Size = new System.Drawing.Size(24, 23);
this.removeButton.TabIndex = 6;
this.removeButton.Text = "-";
this.removeButton.UseVisualStyleBackColor = true;
this.removeButton.Click += new System.EventHandler(this.DeactivateMod);
//
// listView1
//
this.listView1.Activation = System.Windows.Forms.ItemActivation.OneClick;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listView1.Location = new System.Drawing.Point(272, 23);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.tableLayoutPanel1.SetRowSpan(this.listView1, 2);
this.listView1.Size = new System.Drawing.Size(234, 212);
this.listView1.TabIndex = 8;
this.listView1.TileSize = new System.Drawing.Size(10, 10);
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListViewSelect);
this.listView1.Enter += new System.EventHandler(this.ListViewSelect);
//
// label1
//
this.label1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(96, 3);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 10;
this.label1.Text = "All Mods";
//
// propertyGrid1
//
this.tableLayoutPanel1.SetColumnSpan(this.propertyGrid1, 3);
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.Location = new System.Drawing.Point(3, 241);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.PropertySort = System.Windows.Forms.PropertySort.NoSort;
this.propertyGrid1.Size = new System.Drawing.Size(503, 215);
this.propertyGrid1.TabIndex = 9;
this.propertyGrid1.ToolbarVisible = false;
//
// label2
//
this.label2.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(356, 3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 13);
this.label2.TabIndex = 11;
this.label2.Text = "Active Mods";
//
// 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.treeView1);
this.ClientSize = new System.Drawing.Size(533, 512);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.installButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
@@ -94,6 +208,8 @@
this.Name = "ConfigureModsDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Configure Mods";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
@@ -105,5 +221,13 @@
private System.Windows.Forms.Button installButton;
private System.Windows.Forms.OpenFileDialog installModDialog;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button addButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.PropertyGrid propertyGrid1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}
}

View File

@@ -1,27 +1,30 @@
using System;
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
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
{
struct Mod
{
public string Title;
public string Version;
public string Author;
public string Description;
public string Requires;
public bool Standalone;
}
public partial class ConfigureModsDialog : Form
{
string[] activeMods;
List<string> activeMods;
public List<string> ActiveMods
{
get { return activeMods; }
}
Dictionary<string, Mod> allMods;
public ConfigureModsDialog(string[] activeMods)
{
@@ -29,19 +32,21 @@ namespace OpenRA.Launcher
Util.UacShield(installButton);
this.activeMods = activeMods;
this.activeMods = new List<string>(activeMods);
listView1.Items.AddRange(activeMods.Select(x => new ListViewItem(x)).ToArray());
RefreshMods();
}
Mod GetMetadata(string mod)
{
var response = UtilityProgram.Call("-i", mod);
Mod m = new Mod();
if (response.IsError) return m;
if (response.IsError) return null;
string[] lines = response.ResponseLines;
string title = "", version = "", author = "", description = "", requires = "";
bool standalone = false;
foreach (string line in lines)
{
string s = line.Trim(' ', '\r', '\n');
@@ -51,29 +56,29 @@ namespace OpenRA.Launcher
switch (s.Substring(0, i))
{
case "Title":
m.Title = value;
title = value;
break;
case "Version":
m.Version = value;
version = value;
break;
case "Author":
m.Author = value;
author = value;
break;
case "Description":
m.Description = value;
description = value;
break;
case "Requires":
m.Requires = value;
requires = value;
break;
case "Standalone":
m.Standalone = bool.Parse(value);
standalone = bool.Parse(value);
break;
default:
break;
}
}
return m;
return new Mod(title, version, author, description, requires, standalone);
}
void RefreshMods()
@@ -99,6 +104,7 @@ namespace OpenRA.Launcher
void RefreshModTree(TreeView treeView, string[] modList)
{
treeView.Nodes.Clear();
Dictionary<string, TreeNode> nodes;
nodes = modList.Where(x => allMods[x].Standalone).ToDictionary(x => x, x => new TreeNode(x));
string[] rootMods = modList.Where(x => allMods[x].Standalone).ToArray();
@@ -148,5 +154,111 @@ namespace OpenRA.Launcher
treeView.Invalidate();
}
void TreeViewSelect(object sender, TreeViewEventArgs e)
{
SelectMod(e.Node.Text);
}
void ListViewSelect(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
SelectMod(listView1.SelectedItems[0].Text);
else
SelectMod("");
}
void treeView1_Enter(object sender, EventArgs e)
{
if (treeView1.SelectedNode != null)
SelectMod(treeView1.SelectedNode.Text);
else
SelectMod("");
}
void SelectMod(string mod)
{
if (!allMods.ContainsKey(mod))
propertyGrid1.SelectedObject = null;
else
propertyGrid1.SelectedObject = allMods[mod];
}
void ActivateMod(object sender, EventArgs e)
{
if (treeView1.SelectedNode == null) return;
string mod = treeView1.SelectedNode.Text;
if (!allMods.ContainsKey(mod)) return;
if (activeMods.Contains(mod)) return;
Mod m = allMods[mod];
Stack<string> toAdd = new Stack<string>();
toAdd.Push(mod);
while (!string.IsNullOrEmpty(m.Requires))
{
string r = m.Requires;
if (!allMods.ContainsKey(r))
{
MessageBox.Show(string.Format("A requirement for the mod \"{0}\" is missing. Please install \"{1}\" or the game may not run properly.", mod, r));
return;
}
if (!activeMods.Contains(r))
toAdd.Push(r);
mod = r;
m = allMods[mod];
}
while (toAdd.Count > 0)
activeMods.Add(toAdd.Pop());
listView1.Items.Clear();
listView1.Items.AddRange(activeMods.Select(x => new ListViewItem(x)).ToArray());
}
void DeactivateMod(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count < 1) return;
string mod = listView1.SelectedItems[0].Text;
List<string> toRemove = new List<string>();
Stack<string> nodes = new Stack<string>();
nodes.Push(mod);
string currentNode;
while (nodes.Count > 0)
{
currentNode = nodes.Pop();
toRemove.Add(currentNode);
foreach (string n in activeMods.Where(x => allMods[x].Requires == currentNode))
nodes.Push(n);
}
listView1.SuspendLayout();
foreach (string s in toRemove)
{
listView1.Items.Remove(listView1.Items.OfType<ListViewItem>().Where(x => x.Text == s).SingleOrDefault());
activeMods.Remove(s);
}
listView1.ResumeLayout();
}
}
class Mod
{
public string Title { get; private set; }
public string Version { get; private set; }
public string Author { get; private set; }
public string Description { get; private set; }
public string Requires { get; private set; }
public bool Standalone { get; private set; }
public Mod(string title, string version, string author, string description, string requires, bool standalone)
{
Title = title;
Version = version;
Author = author;
Description = description;
Requires = requires;
Standalone = standalone;
}
}
}

View File

@@ -0,0 +1,131 @@
namespace OpenRA.Launcher
{
partial class InstallPackagesDialog
{
/// <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.label1 = new System.Windows.Forms.Label();
this.cancelButton = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(280, 89);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// 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(218, 163);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 1;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(109, 163);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(103, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Continue...";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// radioButton1
//
this.radioButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(16, 113);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(138, 17);
this.radioButton1.TabIndex = 3;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Download From Internet";
this.radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(16, 136);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(96, 17);
this.radioButton2.TabIndex = 4;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Install From CD";
this.radioButton2.UseVisualStyleBackColor = true;
//
// folderBrowserDialog1
//
this.folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer;
this.folderBrowserDialog1.ShowNewFolderButton = false;
//
// InstallPackagesDialog
//
this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(305, 198);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.button2);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InstallPackagesDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Install Mod Files";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
}
}

View File

@@ -0,0 +1,52 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System;
using System.IO;
using System.Windows.Forms;
namespace OpenRA.Launcher
{
public partial class InstallPackagesDialog : Form
{
string mod;
public InstallPackagesDialog(string mod)
{
InitializeComponent();
Util.UacShield(button2);
this.mod = mod;
if (mod == "cnc") radioButton2.Enabled = false;
label1.Text = string.Format("In order to play OpenRA with the mod \"{0}\", you must install the original game files. " +
"These can either be downloaded or for some mods be installed from a CD copy of the original game. " +
"Please select your choice below and click continue", mod);
}
private void button2_Click(object sender, EventArgs e)
{
UtilityProgramResponse response = null;
if (radioButton1.Checked)
response = UtilityProgram.CallWithAdmin("--download-packages", mod);
if (radioButton2.Checked)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
response = UtilityProgram.CallWithAdmin(string.Format("--install-{0}-packages", mod),
folderBrowserDialog1.SelectedPath + Path.DirectorySeparatorChar);
}
if (response.IsError)
DialogResult = DialogResult.No;
else
DialogResult = DialogResult.OK;
Close();
}
}
}

View 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="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -59,6 +59,7 @@
this.launchButton.TabIndex = 1;
this.launchButton.Text = "Launch OpenRA";
this.launchButton.UseVisualStyleBackColor = true;
this.launchButton.Click += new System.EventHandler(this.LaunchGame);
//
// tableLayoutPanel1
//
@@ -107,6 +108,7 @@
// configGameButton
//
this.configGameButton.Anchor = System.Windows.Forms.AnchorStyles.None;
this.configGameButton.Enabled = false;
this.configGameButton.Location = new System.Drawing.Point(51, 239);
this.configGameButton.Name = "configGameButton";
this.configGameButton.Size = new System.Drawing.Size(192, 50);

View File

@@ -1,12 +1,18 @@
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;
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace OpenRA.Launcher
{
@@ -25,13 +31,50 @@ namespace OpenRA.Launcher
else
currentMods = response.Response.Split(',');
UpdateModLabel();
}
void UpdateModLabel()
{
label1.Text = string.Format("Current Mods: {0}", currentMods.Length > 0 ? string.Join(",", currentMods) : "ra");
}
private void ConfigureMods(object sender, EventArgs e)
void ConfigureMods(object sender, EventArgs e)
{
var d = new ConfigureModsDialog(currentMods);
d.ShowDialog();
if (d.ShowDialog() != DialogResult.OK)
return;
currentMods = d.ActiveMods.ToArray();
UpdateModLabel();
}
void LaunchGame(object sender, EventArgs e)
{
string[] officialMods = { "ra", "cnc" };
bool allOk = true;
foreach(string s in officialMods)
if (currentMods.Contains(s))
allOk = CheckAndInstallPackages(s);
if (!allOk) return;
Process p = new Process();
p.StartInfo.FileName = "OpenRA.Game.exe";
p.StartInfo.Arguments = "Game.Mods=" + string.Join(",", currentMods);
p.Start();
}
bool CheckAndInstallPackages(string mod)
{
string packageDir = "mods" + Path.DirectorySeparatorChar + mod + Path.DirectorySeparatorChar + "packages";
if (Directory.Exists(packageDir) &&
Directory.GetFiles(packageDir, "*.mix").Length > 0) return true;
var dialog = new InstallPackagesDialog(mod);
if (dialog.ShowDialog() != DialogResult.OK) return false;
return true;
}
}
}

View File

@@ -165,7 +165,7 @@
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAZiS0dEAP8A/wD/oL2n
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAAAAZiS0dEAP8A/wD/oL2n
kwAAAAd0SU1FB9oKFAwuMM5+jWQAABigSURBVHhe7V0JeBRVtu6tunrNvpCk093ZE8Lq7jiOzLznMj5l
1HHX5+e4v3n6XGeeKKMOjiggIIIIioAKI4hsiiAooMgmi2yyL7LJJoo4EAjp7v/9p5LM9Nevk05C0i1S
9/vOV9VVt+69deqce/9z7rm3DQY96RzQOaBzQOeAzoGEcMDhcIxOSMV6pToHEs0Bq9XqpgIgKys7LdFt

View File

@@ -48,6 +48,12 @@
<Compile Include="ConfigureModsDialog.Designer.cs">
<DependentUpon>ConfigureModsDialog.cs</DependentUpon>
</Compile>
<Compile Include="InstallPackagesDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="InstallPackagesDialog.Designer.cs">
<DependentUpon>InstallPackagesDialog.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -72,6 +78,9 @@
<EmbeddedResource Include="ConfigureModsDialog.resx">
<DependentUpon>ConfigureModsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="InstallPackagesDialog.resx">
<DependentUpon>InstallPackagesDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>