public static bool InitWithArguments(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
//Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
OperatingSystem os = Environment.OSVersion;
PlatformID pid = os.Platform;
ILocator gameLocator;
bool linux = pid == PlatformID.MacOSX || pid == PlatformID.Unix;
if (linux) gameLocator = new LinuxLocator();
else gameLocator = new WindowsLocator();
bool useDX = false;
#region User resolution parmeters
foreach (var arg in args)
{
if (char.IsDigit(arg[0]))
{
//attempt parsing resoulution
try
{
var split = arg.Split("x".ToCharArray());
int ScreenWidth = int.Parse(split[0]);
int ScreenHeight = int.Parse(split[1]);
GlobalSettings.Default.GraphicsWidth = ScreenWidth;
GlobalSettings.Default.GraphicsHeight = ScreenHeight;
}
catch (Exception) { }
}
else if (arg[0] == '-')
{
var cmd = arg.Substring(1);
if (cmd.StartsWith("lang"))
{
GlobalSettings.Default.LanguageCode = byte.Parse(cmd.Substring(4));
}
else
{
//normal style param
switch (cmd)
{
case "dx11":
case "dx":
useDX = true;
break;
case "gl":
case "ogl":
useDX = false;
break;
}
}
}
else
{
if (arg.Equals("w", StringComparison.InvariantCultureIgnoreCase))
GlobalSettings.Default.Windowed = true;
else if (arg.Equals("f", StringComparison.InvariantCultureIgnoreCase))
GlobalSettings.Default.Windowed = false;
}
}
#endregion
UseDX = MonogameLinker.Link(useDX);
/*if (GlobalSettings.Default.Windowed == false && !UseDX)
{
//temporary while SDL issues are fixed
MessageBox.Show("Fullscreen is currently disabled on OpenGL. Please switch to DirectX (-dx flag) if you really need to use fullscreen.");
}*/
var path = gameLocator.FindTheSimsOnline();
if (UseDX) GlobalSettings.Default.AntiAlias = false;
if (path != null)
{
FSOEnvironment.ContentDir = "Content/";
FSOEnvironment.GFXContentDir = "Content/" + (UseDX ? "DX/" : "OGL/");
FSOEnvironment.Linux = linux;
FSOEnvironment.DirectX = UseDX;
if (GlobalSettings.Default.LanguageCode == 0) GlobalSettings.Default.LanguageCode = 1;
Files.Formats.IFF.Chunks.STR.DefaultLangCode = (Files.Formats.IFF.Chunks.STRLangCode)GlobalSettings.Default.LanguageCode;
GlobalSettings.Default.StartupPath = path;
GlobalSettings.Default.ClientVersion = GetClientVersion();
return true;
}
else
{
//MessageBox.Show("The Sims Online was not found on your system. FreeSO will not be able to run without access to the original game files.");
return false;
}
}