Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
265 lines (213 sloc) 9.11 KB
using Jan18101997.ExileLauncher.Config;
using Jan18101997.ExileLauncher.Mods;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Jan18101997.ExileLauncher.GUI.Pages
{
public partial class pageMainMenue : Page
{
public pageMainMenue()
{
InitializeComponent();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
initVersionInfo();
}
/// <summary>
/// Starts a Thread for checking the newest Version online + Displaing it
/// </summary>
private void initVersionInfo()
{
currentVersionInfo.ButtonText = "checking..." + Environment.NewLine;
Thread t = new Thread(delegate() //Thread for checking the newes Version
{
int ModCount = 0;
int ErrorCount = 0;
int OutdatedCount = 0;
foreach (IMod item in Settings.Mods)
{
ModCount++;
string mv = null;
try
{
mv = item.getModVersion();
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
ErrorCount++;
}
if (mv != AppSettings.getPropertyValue<string>(item.getModID() + "_InstallVersion"))
{
OutdatedCount++;
}
}
Dispatcher.Invoke(new Action(() => currentVersionInfo.ButtonText = "Your Mods:" + Environment.NewLine + "Mods: " + ModCount + Environment.NewLine + "Outdated: " + OutdatedCount + Environment.NewLine + "Error: " + ErrorCount));
AllowDownloadClick = true;
});
t.IsBackground = true;
t.Start();
}
bool AllowDownloadClick = false;
private void twitch_Click(object sender, MouseButtonEventArgs e)
{
try
{
Process.Start(Config.Settings.LinksTwitchAdress);
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
MessageBox.Show("There was an error!" + Environment.NewLine + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void teamSpeak_Click(object sender, MouseButtonEventArgs e)
{
try
{
Process.Start(Config.Settings.LinksTeamspeakAdress);
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
MessageBox.Show("There was an error!" + Environment.NewLine + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void forum_Click(object sender, MouseButtonEventArgs e)
{
try
{
Process.Start(Config.Settings.LinksForumAdress);
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
MessageBox.Show("There was an error!" + Environment.NewLine + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void download_Click(object sender, MouseButtonEventArgs e)
{
if (AllowDownloadClick == false)
MessageBox.Show("Please wait until versioncheck is done!", "Please wait...", MessageBoxButton.OK, MessageBoxImage.Information);
else
if (e.LeftButton == MouseButtonState.Pressed)
App.Navigate(typeof(pageDownload));
else if (e.RightButton == MouseButtonState.Pressed)
initVersionInfo();
}
private void gameSettings_Click(object sender, MouseButtonEventArgs e)
{
App.Navigate(typeof(pageGameSettings));
}
private void about_Click(object sender, MouseButtonEventArgs e)
{
App.Navigate(typeof(pageAbout));
}
/// <summary>
/// launches the game (same event for launchGame and directConnect)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lauchGame_Click(object sender, MouseButtonEventArgs e)
{
Jan18101997.GUI.Controlls.CustomButton c = sender as Jan18101997.GUI.Controlls.CustomButton;
string args = "-nolauncher -useBE -mod=";
bool missingMod = false;
bool outOfDate = false;
DirectConnect dc = null;
if (AppSettings.getPropertyValue<bool>("LaunchOptionsDisableLogs"))
args += "-nologs ";
if (AppSettings.getPropertyValue<bool>("LaunchOptionsEnableHyperThreading"))
args += "-enableHT ";
if (AppSettings.getPropertyValue<bool>("LaunchOptionsNoPause"))
args += "-noPause ";
if (AppSettings.getPropertyValue<bool>("LaunchOptionsNoSplashScreen"))
args += "-nosplash ";
if (AppSettings.getPropertyValue<bool>("LaunchOptionsSkipIntro"))
args += "-skipIntro ";
if (AppSettings.getPropertyValue<bool>("LaunchOptionsWindowesMode"))
args += "-window ";
args += AppSettings.getPropertyValue<string>("LaunchOptionsCustom");
if (c.Name == "launchDirectConnect") //if directConnect Button add connection args
{
if (Settings.DirectConnect == null) //you can ignore the invisible code message ;)
{
args += "-connect=" + AppSettings.getPropertyValue<string>("DirectConnectHost") + " ";
args += "-port=" + AppSettings.getPropertyValue<string>("DirectConnectPort") + " ";
}
else
{
DirectConnectSelect dcs = new DirectConnectSelect();
if (dcs.ShowDialog() == true)
{
dc = dcs.DC;
args += "-connect=" + dc.IP + " ";
args += "-port=" + dc.Port+ " ";
}
}
}
for (int i = 0; i < Settings.Mods.Length; i++)
{
IMod mod = Settings.Mods[i];
if (dc != null)
{
bool requires = false;
foreach (Type item in dc.Requires)
{
if(mod.GetType() == item)
{
requires = true;
break;
}
}
if (requires == false)
return;
App.WriteOutput(this, "Requires " + mod.GetType());
}
args += mod.getModParameter();
if (Directory.Exists(AppSettings.getPropertyValue<string>("GamePath") + "\\" + Settings.Mods[i].getModParameter()) == false)
missingMod = true;
if (i == Settings.Mods.Length - 1)
args += " ";
else
args += ";";
string modVersion = "Error!";
try
{
modVersion = Settings.Mods[i].getModVersion();
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
}
if (AppSettings.getPropertyValue<string>(Settings.Mods[i].getModID() + "_InstallVersion") != modVersion)
outOfDate = true;
}
if (missingMod && MessageBox.Show("One ore more mods are not Installed. " + Environment.NewLine + "Do you still want to launch the game?" + Environment.NewLine + Environment.NewLine + "Fix: Open installpage and reinstall the current Version.", "Not installed!", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
return;
if (outOfDate && MessageBox.Show("One ore more mods are out of date! " + Environment.NewLine + "Do you still want to launch the game?", "Out of date", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
return;
App.GameProcess = new Process();
App.GameProcess.StartInfo.FileName = AppSettings.getPropertyValue<string>("GamePath") + "\\arma3.exe";
App.GameProcess.StartInfo.Arguments = args;
try
{
App.GameProcess.Start();
App.WriteOutput(this, args);
App.Navigate(typeof(pageGameRunning));
}
catch (Exception ex)
{
App.WriteOutput(this, ex);
MessageBox.Show("Unable to start \"arma3.exe\"!" + Environment.NewLine + "Error: " + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
You can’t perform that action at this time.