Move Windows launcher compilation to packaging scripts.
This commit is contained in:
BIN
packaging/windows/OpenRA.ico
Normal file
BIN
packaging/windows/OpenRA.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
154
packaging/windows/WindowsLauncher.cs.in
Normal file
154
packaging/windows/WindowsLauncher.cs.in
Normal file
@@ -0,0 +1,154 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
class WindowsLauncher
|
||||
{
|
||||
static Process gameProcess;
|
||||
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var launcherPath = Assembly.GetExecutingAssembly().Location;
|
||||
var directory = Path.GetDirectoryName(launcherPath);
|
||||
var enginePath = Path.Combine(directory, "OpenRA.Game.exe");
|
||||
|
||||
Directory.SetCurrentDirectory(directory);
|
||||
|
||||
var engineArgs = args
|
||||
.Append("Engine.LaunchPath=" + launcherPath)
|
||||
.Select(arg => "\"" + arg + "\"");
|
||||
|
||||
var psi = new ProcessStartInfo(enginePath, string.Join(" ", engineArgs));
|
||||
|
||||
try
|
||||
{
|
||||
gameProcess = Process.Start(psi);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameProcess == null)
|
||||
return;
|
||||
|
||||
gameProcess.EnableRaisingEvents = true;
|
||||
gameProcess.Exited += GameProcessExited;
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
|
||||
static void ShowErrorDialog()
|
||||
{
|
||||
var form = new Form
|
||||
{
|
||||
Size = new Size(315, 140),
|
||||
Text = "Fatal Error",
|
||||
MinimizeBox = false,
|
||||
MaximizeBox = false,
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog,
|
||||
StartPosition = FormStartPosition.CenterScreen,
|
||||
TopLevel = true,
|
||||
Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)
|
||||
};
|
||||
|
||||
var notice = new Label
|
||||
{
|
||||
Location = new Point(10, 10),
|
||||
AutoSize = true,
|
||||
Text = "OpenRA has encountered a fatal error and must close.{0}Refer to the crash logs and FAQ for more information.".F(Environment.NewLine),
|
||||
TextAlign = ContentAlignment.TopCenter
|
||||
};
|
||||
|
||||
var viewLogs = new Button
|
||||
{
|
||||
Location = new Point(10, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "View Logs"
|
||||
};
|
||||
|
||||
var viewFaq = new Button
|
||||
{
|
||||
Location = new Point(90, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "View FAQ"
|
||||
};
|
||||
|
||||
var quit = new Button
|
||||
{
|
||||
Location = new Point(225, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "Quit",
|
||||
DialogResult = DialogResult.Cancel
|
||||
};
|
||||
|
||||
form.Controls.Add(notice);
|
||||
form.Controls.Add(viewLogs);
|
||||
form.Controls.Add(viewFaq);
|
||||
form.Controls.Add(quit);
|
||||
|
||||
viewLogs.Click += ViewLogsClicked;
|
||||
viewFaq.Click += ViewFaqClicked;
|
||||
form.FormClosed += FormClosed;
|
||||
|
||||
SystemSounds.Exclamation.Play();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
static void GameProcessExited(object sender, EventArgs e)
|
||||
{
|
||||
if (gameProcess.ExitCode != (int)RunStatus.Success)
|
||||
ShowErrorDialog();
|
||||
|
||||
Exit();
|
||||
}
|
||||
|
||||
static void ViewLogsClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(Platform.ResolvePath("^", "Logs"));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
static void ViewFaqClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start("http://wiki.openra.net/FAQ");
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
static void FormClosed(object sender, EventArgs e)
|
||||
{
|
||||
Exit();
|
||||
}
|
||||
|
||||
static void Exit()
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,20 @@ BUILTDIR="$2"
|
||||
SRCDIR="$3"
|
||||
OUTPUTDIR="$4"
|
||||
|
||||
LAUNCHER_LIBS="-r:System.dll -r:System.Drawing.dll -r:System.Windows.Forms.dll -r:${BUILTDIR}/OpenRA.Game.exe"
|
||||
FAQ_URL="http://wiki.openra.net/FAQ"
|
||||
|
||||
function makelauncher()
|
||||
{
|
||||
sed "s|DISPLAY_NAME|$2|" WindowsLauncher.cs.in | sed "s|MOD_ID|$3|" | sed "s|FAQ_URL|${FAQ_URL}|" > WindowsLauncher.cs
|
||||
mcs -sdk:4.5 WindowsLauncher.cs -warn:4 -codepage:utf8 -warnaserror -out:"$1" -t:winexe ${LAUNCHER_LIBS} -win32icon:"$4"
|
||||
rm WindowsLauncher.cs
|
||||
mono ${SRCDIR}/fixheader.exe $1 > /dev/null
|
||||
}
|
||||
|
||||
echo "Compiling Windows launcher"
|
||||
makelauncher ${BUILTDIR}/OpenRA.exe "OpenRA" "" OpenRA.ico
|
||||
|
||||
if [ -x /usr/bin/makensis ]; then
|
||||
echo "Building Windows setup.exe"
|
||||
makensis -V2 -DSRCDIR="$BUILTDIR" -DDEPSDIR="${SRCDIR}/thirdparty/download/windows" OpenRA.nsi
|
||||
|
||||
Reference in New Issue
Block a user