Skip to content

Commit

Permalink
Fix login=false bugs and add default language settings to hide langua…
Browse files Browse the repository at this point in the history
…geChoise
  • Loading branch information
leohubert committed Jan 9, 2018
1 parent e212acb commit 0bbbc02
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 27 deletions.
18 changes: 15 additions & 3 deletions LauncherArma3/LauncherArma3/Arma3/launcherMain.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @Author: hubert_i
* @Date: 2018-01-09T22:20:28+01:00
* @Email: leo.hubert@epitech.eu
* @Last modified by: hubert_i
* @Last modified time: 2018-01-09T22:54:37+01:00
*/



using System;
using System.Drawing;
using System.Windows.Forms;
Expand Down Expand Up @@ -134,6 +144,7 @@ private void launcherMain_Load(object sender, EventArgs e)
changeGameButton.Location = new Point(826, 65);
}
setLanguage();
loadServerStatus();
if (File.Exists(appdata + communityName + "/armaDest"))
{
armaDirectory = File.ReadAllText(appdata + communityName + "/armaDest");
Expand Down Expand Up @@ -281,9 +292,11 @@ private async void autoRefresh()
Thread thread = new Thread(() =>
{
loadServerStatus();
loadIGinfos();
if (sessionToken != null)
getNotification();
{
loadIGinfos();
getNotification();
}
});
thread.Start();
}
Expand Down Expand Up @@ -1721,4 +1734,3 @@ private void changeGameButton_Click(object sender, EventArgs e)
}
}
}

23 changes: 19 additions & 4 deletions LauncherArma3/LauncherArma3/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @Author: hubert_i
* @Date: 2018-01-09T22:20:28+01:00
* @Email: leo.hubert@epitech.eu
* @Last modified by: hubert_i
* @Last modified time: 2018-01-09T23:00:16+01:00
*/



using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -19,16 +29,17 @@ static void Main()

string communityName = "Emodyz"; /* Your serverName */
string apiUrl = "http://51.255.171.192:8080/"; /* Link to API launcher Arma 3 */

/* FTP NO FUNCTIONAL */

string ftp_url = "ftp://yoururl";
string ftp_user = "username";
string ftp_pass = "passwd";

/* FTP NO FUNCTIONAL */

bool modDev = true; /* enable or disable modDev */
string defaultLanguage = null; /* set to "FR" or "EN" or other for disable just set to null */

/* ANOTHER VARIABLE */

Expand All @@ -40,14 +51,18 @@ static void Main()

if (!Directory.Exists(appdata + communityName))
Directory.CreateDirectory(appdata + communityName);
if (File.Exists(appdata + communityName + "/language.lang"))
if (defaultLanguage != null)
{
Application.Run(new loginForm(communityName, apiUrl, ftp_url, ftp_user, ftp_pass, modDev, defaultLanguage));
}
else if (File.Exists(appdata + communityName + "/language.lang"))
{
Application.Run(new loginForm(communityName, apiUrl, ftp_url, ftp_user, ftp_pass, modDev));
}
else
{
Application.Run(new languageChoice(communityName, false));
Application.Run(new loginForm(communityName, apiUrl, ftp_url, ftp_user, ftp_pass, modDev));
Application.Run(new loginForm(communityName, apiUrl, ftp_url, ftp_user, ftp_pass, modDev, defaultLanguage));
}
}
}
Expand Down
57 changes: 37 additions & 20 deletions LauncherArma3/LauncherArma3/loginForm.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @Author: hubert_i
* @Date: 2018-01-09T22:20:28+01:00
* @Email: leo.hubert@epitech.eu
* @Last modified by: hubert_i
* @Last modified time: 2018-01-09T23:01:37+01:00
*/



using LauncherArma3.Properties;
using MaterialSkin;
using MetroFramework;
Expand Down Expand Up @@ -64,14 +74,15 @@ public partial class loginForm : MetroFramework.Forms.MetroForm
bool notif = false;
int taskforce;
string vtaskforce;
string defaultLanguage

/* TRANSLATE PART */

XmlReader translate = XmlReader.Create(new StringReader(Resources.translate));
Dictionary<string, string> translateDic = new Dictionary<string, string>();


public loginForm(string _communityName, string api, string ftpUrl, string ftpUser, string ftpPass, bool mod)
public loginForm(string _communityName, string api, string ftpUrl, string ftpUser, string ftpPass, bool mod, string _defaultLanguage)
{
InitializeComponent();
materialSkinManager = MaterialSkinManager.Instance;
Expand All @@ -83,6 +94,7 @@ public loginForm(string _communityName, string api, string ftpUrl, string ftpUse
ftp_user = ftpUser;
ftp_pass = ftpPass;
modDev = mod;
defaultLanguage = _defaultLanguage;
}

private void loginForm_Load(object sender, EventArgs e)
Expand All @@ -91,21 +103,26 @@ private void loginForm_Load(object sender, EventArgs e)
{
sessionToken = File.ReadAllText(appdata + communityName + "/token.bin2hex");
}
if (File.Exists(appdata + communityName + "/language.lang"))
if (defaultLanguage != null)
{
language = defaultLanguage;
loadLanguage();
}
else if (File.Exists(appdata + communityName + "/language.lang"))
{
language = File.ReadAllText(appdata + communityName + "/language.lang");
loadLanguage();
}
if (modDev == true)
{
notifView("Warning ! Dev mod enabled !");
notifView("Warning ! Dev mod enabled !");
}
if (translateDic["reverse"] == "true")
{
this.RightToLeft = RightToLeft.Yes;
this.RightToLeftLayout = true;
}

}

private void checkOptions(object sender, EventArgs e)
Expand Down Expand Up @@ -166,7 +183,7 @@ private void checkOptions(object sender, EventArgs e)
newsTitle.Text = res.maintenance_title;
newsContent.Text = res.maintenance_content;
}
maintenanceRefresh.RunWorkerAsync();
maintenanceRefresh.RunWorkerAsync();
return;
}

Expand Down Expand Up @@ -195,7 +212,7 @@ private void checkOptions(object sender, EventArgs e)
if (!File.Exists(appdata + communityName + "/autoConnect"))
{
using (var chooseServer = new serverChoose(apiUrl, communityName, translateDic, appdata))
{
{
var result = chooseServer.ShowDialog();
if (result == DialogResult.OK)
{
Expand All @@ -217,7 +234,7 @@ private void checkOptions(object sender, EventArgs e)
switch (serverGame)
{
case "arma3":
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user,
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user,
ftp_pass, vLast, taskforce, vtaskforce, modDev, serverIP, translateDic, showIGinfo, serverName, serverID,
modPackName, downloadPath, serverLocked, serverMaintenance, serverPass))
{
Expand Down Expand Up @@ -291,7 +308,7 @@ private async void loginButton_Click(object sender, EventArgs e)

IRestResponse response = client.Execute(request);
var content = response.Content;

dynamic res = JObject.Parse(content.ToString());

if (res.status == "42")
Expand All @@ -306,7 +323,7 @@ private async void loginButton_Click(object sender, EventArgs e)
// Reset form
startLauncher = true;
stat = 1;
}
}
else
{
string message = res.message;
Expand Down Expand Up @@ -343,20 +360,20 @@ private async void loginButton_Click(object sender, EventArgs e)
getServerInfo(serverID);
}
else
this.Close();
this.Close();
}
}
else
{
string id = File.ReadAllText(appdata + communityName + "/autoConnect");

//GET SERVER INFO
getServerInfo(id);
getServerInfo(id);
}
switch (serverGame)
{
case "arma3":
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user, ftp_pass,
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user, ftp_pass,
vLast, taskforce, vtaskforce, modDev, serverIP, translateDic, showIGinfo, serverName, serverID, modPackName, downloadPath,
serverLocked, serverMaintenance, serverPass))
{
Expand Down Expand Up @@ -421,7 +438,7 @@ void getServerInfo(string id)
serverLocked = false;
}
else if (res.status == "04")
{
{
using (var chooseServer = new serverChoose(apiUrl, communityName, translateDic, appdata))
{
var result = chooseServer.ShowDialog();
Expand Down Expand Up @@ -465,7 +482,7 @@ void loginWithToken()
if (!File.Exists(appdata + communityName + "/autoConnect"))
{
using (var chooseServer = new serverChoose(apiUrl, communityName, translateDic, appdata))
{
{
var result = chooseServer.ShowDialog();
if (result == DialogResult.OK)
{
Expand All @@ -489,7 +506,7 @@ void loginWithToken()
switch (serverGame)
{
case "arma3":
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user, ftp_pass, vLast, taskforce,
using (var launcher = new launcherMain(communityName, apiUrl, webSite, teamSpeak, sessionToken, ftp_url, ftp_user, ftp_pass, vLast, taskforce,
vtaskforce, modDev, serverIP, translateDic, showIGinfo, serverName, serverID, modPackName, downloadPath, serverLocked, serverMaintenance,
serverPass))
{
Expand Down Expand Up @@ -590,7 +607,7 @@ void loadLanguage()
translate.ReadToFollowing("error404");
translateDic.Add("error404", translate.ReadElementContentAsString());
translate.ReadToFollowing("errorInternet");
translateDic.Add("errorInternet", translate.ReadElementContentAsString());
translateDic.Add("errorInternet", translate.ReadElementContentAsString());
translate.ReadToFollowing("errorUpdate");
translateDic.Add("errorUpdate", translate.ReadElementContentAsString());
translate.ReadToFollowing("updateCancel");
Expand Down Expand Up @@ -736,15 +753,15 @@ void loadLanguage()
translate.ReadToFollowing("serverMaintenance");
translateDic.Add("serverMaintenance", translate.ReadElementContentAsString());
translate.ReadToFollowing("serverLocked");
translateDic.Add("serverLocked", translate.ReadElementContentAsString());
translateDic.Add("serverLocked", translate.ReadElementContentAsString());

loginButton.Text = translateDic["logIn"];
registerLink.Text = translateDic["registerLink"];
loginUsername.Hint = translateDic["username"];
loginPassword.Hint = translateDic["password"];
loginRemember.Text = translateDic["remember"];
newPassword.Text = translateDic["forgotPass"];
registerMessage.Text = translateDic["registerMsg"];
registerMessage.Text = translateDic["registerMsg"];
this.Refresh();
}
catch
Expand Down Expand Up @@ -837,7 +854,7 @@ private void maintenanceRefresh_DoWork(object sender, DoWorkEventArgs e)
newsContent.Text = res.maintenance_content;
}
}
});
});
if (res.maintenance == "0")
{
maintenance = false;
Expand All @@ -862,7 +879,7 @@ private void callRefresh(object sender, RunWorkerCompletedEventArgs e)
this.Refresh();
}
else
maintenanceRefresh.RunWorkerAsync();
maintenanceRefresh.RunWorkerAsync();
}

void launcherUpdate()
Expand Down

0 comments on commit 0bbbc02

Please sign in to comment.