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:
committed by
Paul Chote
parent
f98f3d0b39
commit
da384af339
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user