1
0
Fork 0

Multilang errors, Client logs

This commit is contained in:
sheychen 2016-11-17 13:59:30 +01:00
parent ae6754a832
commit 14ce77fe62
20 changed files with 59 additions and 29 deletions

View File

@ -34,4 +34,19 @@ TooShort;Trop court;Too short
TooLong;Trop long;Too long TooLong;Trop long;Too long
Update;Actualiser;Update Update;Actualiser;Update
AnyParty;Aucune partie;Any party AnyParty;Aucune partie;Any party
Password;Mot de passe;Password Password;Mot de passe;Password
ClientSide;Cote client;Client side
CantFind:Introuvable;Can't find
Connected:Connecte;Connected
AllreadyTaken;Deja pris;Allready taken
AnyCommand;Aucune commande;Any command
IncorrectArgs;Arguements incorrects;Incorrect Arguements
ExecuteException;Exception d'execution;Execute exception
Access;Acces refuse;Access denied
Allready;Deja fait;Allready do
Format;Format incorrect;Incorrect format
Full;Plein;Full
Close;Fermee;Close
Owner;Proprietaire;Owner
AnyMessage;Aucun message;Any message
MustBeConnected;Doit etre connecte;Must be connected
Can't render this file because it has a wrong number of fields in line 39.

View File

@ -59,11 +59,13 @@ namespace Galactic_Colors_Control_Console
if (host[0] == '*') if (host[0] == '*')
{ {
host = host.Substring(1); host = host.Substring(1);
logger.Write("Validate error " + host, Logger.logType.error);
Common.ConsoleWrite(host, ConsoleColor.Red); Common.ConsoleWrite(host, ConsoleColor.Red);
client.ResetHost(); client.ResetHost();
} }
else else
{ {
logger.Write("Validate " + host, Logger.logType.info);
Common.ConsoleWrite(multilang.Get("Use", config.lang) + " " + host + "? y/n"); Common.ConsoleWrite(multilang.Get("Use", config.lang) + " " + host + "? y/n");
ConsoleKeyInfo c = new ConsoleKeyInfo(); ConsoleKeyInfo c = new ConsoleKeyInfo();
while (c.Key != ConsoleKey.Y && c.Key != ConsoleKey.N) while (c.Key != ConsoleKey.Y && c.Key != ConsoleKey.N)
@ -82,7 +84,8 @@ namespace Galactic_Colors_Control_Console
} }
Common.ConsoleWrite(multilang.Get("Loading", config.lang)); Common.ConsoleWrite(multilang.Get("Loading", config.lang));
if (client.ConnectHost()) //Try connection if (client.ConnectHost()) //Try connection
{//TODO Cleaner {
logger.Write("Connected", Logger.logType.warm);
run = true; run = true;
bool connected = false; bool connected = false;
//Identifaction //Identifaction
@ -93,9 +96,10 @@ namespace Galactic_Colors_Control_Console
if (username.Length > 3) if (username.Length > 3)
{ {
ResultData res = client.Request(new string[2] { "connect", username }); ResultData res = client.Request(new string[2] { "connect", username });
if(res.type == ResultTypes.OK) { connected = true; } if(res.type == ResultTypes.OK) { connected = true; logger.Write("Identification", Logger.logType.info); }
else else
{ {
logger.Write("Identification error " + res.result, Logger.logType.info);
Common.ConsoleWrite(multilang.GetResultText(res, config.lang)); Common.ConsoleWrite(multilang.GetResultText(res, config.lang));
} }
} }
@ -152,6 +156,7 @@ namespace Galactic_Colors_Control_Console
} }
} }
} }
logger.Write("Play", Logger.logType.info, Logger.logConsole.hide);
Common.ConsoleWrite(multilang.Get("Play", config.lang)); Common.ConsoleWrite(multilang.Get("Play", config.lang));
while (run) while (run)
{ {
@ -162,6 +167,7 @@ namespace Galactic_Colors_Control_Console
} }
else else
{ {
logger.Write("Connection error", Logger.logType.error);
Common.ConsoleWrite(multilang.Get("CantConnect", config.lang), ConsoleColor.Red); Common.ConsoleWrite(multilang.Get("CantConnect", config.lang), ConsoleColor.Red);
} }
run = false; run = false;

View File

@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Input;
using MyMonoGame.GUI; using MyMonoGame.GUI;
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
namespace Galactic_Colors_Control_GUI namespace Galactic_Colors_Control_GUI
{ {
@ -74,6 +75,7 @@ namespace Galactic_Colors_Control_GUI
protected override void Initialize() protected override void Initialize()
{ {
config = config.Load(); config = config.Load();
logger.Write("Galactic Colors Control GUI " + Assembly.GetEntryAssembly().GetName().Version.ToString(), Logger.logType.fatal);
logger.Initialise(config.logPath, config.logBackColor, config.logForeColor, config.logLevel, Program._debug, Program._dev); logger.Initialise(config.logPath, config.logBackColor, config.logForeColor, config.logLevel, Program._debug, Program._dev);
multilang.Load(); multilang.Load();
if (Program._debug) { logger.Write("CLIENT IS IN DEBUG MODE !", Logger.logType.error, Logger.logConsole.show); } if (Program._debug) { logger.Write("CLIENT IS IN DEBUG MODE !", Logger.logType.error, Logger.logConsole.show); }

View File

@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics;
using MyMonoGame.GUI; using MyMonoGame.GUI;
using System.Threading; using System.Threading;
using System; using System;
using Galactic_Colors_Control_Common;
namespace Galactic_Colors_Control_GUI.States namespace Galactic_Colors_Control_GUI.States
{ {
@ -119,7 +120,8 @@ namespace Galactic_Colors_Control_GUI.States
message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang); message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang);
message.text = Host; message.text = Host;
showOKMessage = true; showOKMessage = true;
Game.singleton.client.ResetHost(); ; Game.singleton.client.ResetHost();
Game.singleton.logger.Write("Validate : " + Host, Logger.logType.info);
} }
else else
{ {
@ -135,10 +137,12 @@ namespace Galactic_Colors_Control_GUI.States
showLoading = true; showLoading = true;
if (Game.singleton.client.ConnectHost()) if (Game.singleton.client.ConnectHost())
{ {
Game.singleton.logger.Write("Connected", Logger.logType.info);
Game.singleton.gameState = new IndentificationState(); Game.singleton.gameState = new IndentificationState();
} }
else else
{ {
Game.singleton.logger.Write("Connect error", Logger.logType.error);
message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang); message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang);
message.text = string.Empty; message.text = string.Empty;
showOKMessage = true; showOKMessage = true;

View File

@ -1,5 +1,4 @@
//TODO add party support using Galactic_Colors_Control_Common;
using Galactic_Colors_Control_Common;
using Galactic_Colors_Control_Common.Protocol; using Galactic_Colors_Control_Common.Protocol;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@ -97,6 +96,7 @@ namespace Galactic_Colors_Control_GUI.States
EventData eve = ((EventDataArgs)e).Data; EventData eve = ((EventDataArgs)e).Data;
if (eve.type == EventTypes.ServerKick) if (eve.type == EventTypes.ServerKick)
{ {
Game.singleton.logger.Write("Server kick" + eve.data, Logger.logType.warm);
message.title = Game.singleton.multilang.Get("ServerKick", Game.singleton.config.lang); message.title = Game.singleton.multilang.Get("ServerKick", Game.singleton.config.lang);
message.text = Common.ArrayToString(eve.data); message.text = Common.ArrayToString(eve.data);
showOKMessage = true; showOKMessage = true;

View File

@ -5,6 +5,7 @@ using MyMonoGame.GUI;
using System.Reflection; using System.Reflection;
using Galactic_Colors_Control; using Galactic_Colors_Control;
using System.Threading; using System.Threading;
using Galactic_Colors_Control_Common;
namespace Galactic_Colors_Control_GUI.States namespace Galactic_Colors_Control_GUI.States
{ {
@ -43,6 +44,7 @@ namespace Galactic_Colors_Control_GUI.States
{ {
locked = true; locked = true;
Game.singleton.GUI.ResetFocus(); Game.singleton.GUI.ResetFocus();
Game.singleton.logger.Write("Game exit", Logger.logType.warm);
Game.singleton.gameState = new TitleState(); Game.singleton.gameState = new TitleState();
new Thread(() => new Thread(() =>
{ {

View File

@ -131,7 +131,6 @@ namespace Galactic_Colors_Control_GUI.States
private void PartyJoin() private void PartyJoin()
{ {
//TODO
showLoading = true; showLoading = true;
if (id != -1) if (id != -1)
{ {
@ -139,10 +138,12 @@ namespace Galactic_Colors_Control_GUI.States
ResultData res = Game.singleton.client.Request(request); ResultData res = Game.singleton.client.Request(request);
if (res.type == ResultTypes.OK) if (res.type == ResultTypes.OK)
{ {
Game.singleton.logger.Write("Join party " + id.ToString(), Logger.logType.info);
Game.singleton.gameState = new GameState(); Game.singleton.gameState = new GameState();
} }
else else
{ {
Game.singleton.logger.Write("Join error " + res.result, Logger.logType.error);
message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang); message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang);
message.text = Common.ArrayToString(res.result); message.text = Common.ArrayToString(res.result);
showOKMessage = true; showOKMessage = true;

View File

@ -28,7 +28,7 @@ namespace Galactic_Colors_Control_Server.Commands
} }
else else
{ {
return new RequestResult(ResultTypes.Error, Common.Strings("Client Side")); return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
} }
} }
} }

View File

@ -25,7 +25,7 @@ namespace Galactic_Colors_Control_Server.Commands
if (Utilities.GetName(client) == args[2]) { target = client; } if (Utilities.GetName(client) == args[2]) { target = client; }
} }
if (target == null) if (target == null)
return new RequestResult(ResultTypes.Error, Common.Strings("Can't find")); return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
Program.logger.Write(args[2] + " was kick by server.", Logger.logType.info, Logger.logConsole.show); Program.logger.Write(args[2] + " was kick by server.", Logger.logType.info, Logger.logConsole.show);
if (args.Length > 2) if (args.Length > 2)

View File

@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands
if (Utilities.GetName(client) == args[2]) { target = client; } if (Utilities.GetName(client) == args[2]) { target = client; }
} }
if (target == null) if (target == null)
return new RequestResult(ResultTypes.Error, Common.Strings("Can't find")); return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
string text = ""; string text = "";
text += ("Name : " + Utilities.GetName(target) + Environment.NewLine); text += ("Name : " + Utilities.GetName(target) + Environment.NewLine);

View File

@ -24,7 +24,7 @@ namespace Galactic_Colors_Control_Server.Commands
return new RequestResult(ResultTypes.Error, Common.Strings("Connected")); return new RequestResult(ResultTypes.Error, Common.Strings("Connected"));
if (args[1].Length < 3) if (args[1].Length < 3)
return new RequestResult(ResultTypes.Error, Common.Strings("Too Short")); return new RequestResult(ResultTypes.Error, Common.Strings("TooShort"));
Program.logger.Write("Identifiaction request from " + Utilities.GetName(soc), Logger.logType.debug); Program.logger.Write("Identifiaction request from " + Utilities.GetName(soc), Logger.logType.debug);
bool allreadyconnected = false; bool allreadyconnected = false;
@ -34,7 +34,7 @@ namespace Galactic_Colors_Control_Server.Commands
if (client.pseudo == args[1]) { allreadyconnected = true; break; } if (client.pseudo == args[1]) { allreadyconnected = true; break; }
} }
if (allreadyconnected) if (allreadyconnected)
return new RequestResult(ResultTypes.Error, Common.Strings("Taken")); return new RequestResult(ResultTypes.Error, Common.Strings("AllreadyTaken"));
Program.clients[soc].status = 0; Program.clients[soc].status = 0;
Program.clients[soc].pseudo = args[1]; Program.clients[soc].pseudo = args[1];

View File

@ -66,10 +66,10 @@ namespace Galactic_Colors_Control_Server.Commands
ICommand command = null; ICommand command = null;
args = args.Skip(1).ToArray(); args = args.Skip(1).ToArray();
if (!Manager.TryGetCommand(args, ref command)) if (!Manager.TryGetCommand(args, ref command))
return new RequestResult(ResultTypes.Error, Common.Strings("Any Command")); return new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
if (!Manager.CanAccess(command, soc, server)) if (!Manager.CanAccess(command, soc, server))
return new RequestResult(ResultTypes.Error, Common.Strings("Any Command")); return new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
return new RequestResult(ResultTypes.OK, Common.Strings(command.HelpText)); return new RequestResult(ResultTypes.OK, Common.Strings(command.HelpText));
} }

View File

@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands
} }
else else
{ {
return new RequestResult(ResultTypes.Error, Common.Strings("Incorrect argument")); return new RequestResult(ResultTypes.Error, Common.Strings("IncorrectArgs"));
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace Galactic_Colors_Control_Server.Commands
public enum CommandGroup { root, server, party, client } public enum CommandGroup { root, server, party, client }
private static RequestResult AnyCommand = new RequestResult(ResultTypes.Error, Common.Strings("Any Command")); private static RequestResult AnyCommand = new RequestResult(ResultTypes.Error, Common.Strings("AnyCommand"));
/// <summary> /// <summary>
/// Find all ICommand and add them to commands /// Find all ICommand and add them to commands
@ -46,13 +46,13 @@ namespace Galactic_Colors_Control_Server.Commands
return AnyCommand; return AnyCommand;
if (!server && command.IsClientSide) if (!server && command.IsClientSide)
return new RequestResult(ResultTypes.Error, Common.Strings("Client Side")); return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
if (args.Length - (command.Group == 0 ? 0 : 1) <= command.minArgs) if (args.Length - (command.Group == 0 ? 0 : 1) <= command.minArgs)
return new RequestResult(ResultTypes.Error, new string[2] { "Too Short", command.minArgs.ToString() }); return new RequestResult(ResultTypes.Error, new string[2] { "TooShort", command.minArgs.ToString() });
if (args.Length - (command.Group == 0 ? 1 : 2) > command.maxArgs) if (args.Length - (command.Group == 0 ? 1 : 2) > command.maxArgs)
return new RequestResult(ResultTypes.Error, new string[2] { "Too Long", command.maxArgs.ToString() }); return new RequestResult(ResultTypes.Error, new string[2] { "TooLong", command.maxArgs.ToString() });
try try
{ {
@ -61,7 +61,7 @@ namespace Galactic_Colors_Control_Server.Commands
catch (Exception e) catch (Exception e)
{ {
Program.logger.Write("Command " + args[0] + " Exception : " + e.Message, Logger.logType.error); Program.logger.Write("Command " + args[0] + " Exception : " + e.Message, Logger.logType.error);
return new RequestResult(ResultTypes.Error, Common.Strings("Execute Exception")); return new RequestResult(ResultTypes.Error, Common.Strings("ExecuteException"));
} }
} }

View File

@ -27,10 +27,10 @@ namespace Galactic_Colors_Control_Server.Commands
return new RequestResult(ResultTypes.Error, Common.Strings("Format")); return new RequestResult(ResultTypes.Error, Common.Strings("Format"));
if (size < 1) if (size < 1)
return new RequestResult(ResultTypes.Error, Common.Strings("Too Small")); return new RequestResult(ResultTypes.Error, Common.Strings("TooSmall"));
if (size > Program.config.size) if (size > Program.config.size)
return new RequestResult(ResultTypes.Error, Common.Strings("Too Big")); return new RequestResult(ResultTypes.Error, Common.Strings("TooBig"));
if (Program.parties.Count >= Program.config.partysize) if (Program.parties.Count >= Program.config.partysize)
return new RequestResult(ResultTypes.Error, Common.Strings("Full")); return new RequestResult(ResultTypes.Error, Common.Strings("Full"));

View File

@ -25,10 +25,10 @@ namespace Galactic_Colors_Control_Server.Commands
int id; int id;
if (!int.TryParse(args[2], out id)) if (!int.TryParse(args[2], out id))
return new RequestResult(ResultTypes.Error, Common.Strings("Any Party")); return new RequestResult(ResultTypes.Error, Common.Strings("Format"));
if (!Program.parties.ContainsKey(id)) if (!Program.parties.ContainsKey(id))
return new RequestResult(ResultTypes.Error, Common.Strings("Can't Find")); return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
Party party = Program.parties[id]; Party party = Program.parties[id];
if (args.Length == 3) if (args.Length == 3)

View File

@ -29,7 +29,7 @@ namespace Galactic_Colors_Control_Server.Commands
if (Utilities.GetName(client) == args[2]) { target = client; } if (Utilities.GetName(client) == args[2]) { target = client; }
} }
if (target == null) if (target == null)
return new RequestResult(ResultTypes.Error, Common.Strings("Can't find")); return new RequestResult(ResultTypes.Error, Common.Strings("CantFind"));
Utilities.Send(target, new EventData(EventTypes.PartyKick, args.Length > 3 ? Common.Strings(args[2]) : null)); Utilities.Send(target, new EventData(EventTypes.PartyKick, args.Length > 3 ? Common.Strings(args[2]) : null));
return Manager.Execute(new string[2] { "party", "leave" }, target, false); return Manager.Execute(new string[2] { "party", "leave" }, target, false);

View File

@ -31,7 +31,7 @@ namespace Galactic_Colors_Control_Server.Commands
} }
if (!Program.parties[partyId].SetPassword(args[2], args[3])) if (!Program.parties[partyId].SetPassword(args[2], args[3]))
return new RequestResult(ResultTypes.Error, Common.Strings("Can't Change")); return new RequestResult(ResultTypes.Error, Common.Strings("Password"));
return new RequestResult(ResultTypes.OK); return new RequestResult(ResultTypes.OK);
} }

View File

@ -19,7 +19,7 @@ namespace Galactic_Colors_Control_Server.Commands
public RequestResult Execute(string[] args, Socket soc, bool server = false) public RequestResult Execute(string[] args, Socket soc, bool server = false)
{ {
return new RequestResult(ResultTypes.Error, Common.Strings("Client Side")); return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide"));
} }
} }
} }

View File

@ -20,10 +20,10 @@ namespace Galactic_Colors_Control_Server.Commands
public RequestResult Execute(string[] args, Socket soc, bool server = false) public RequestResult Execute(string[] args, Socket soc, bool server = false)
{ {
if (args[1].Length == 0) if (args[1].Length == 0)
return new RequestResult(ResultTypes.Error, Common.Strings("Any Message")); return new RequestResult(ResultTypes.Error, Common.Strings("AnyMessage"));
if (!Utilities.IsConnect(soc)) if (!Utilities.IsConnect(soc))
return new RequestResult(ResultTypes.Error, Common.Strings("Must Be Connected")); return new RequestResult(ResultTypes.Error, Common.Strings("MustBeConnected"));
int party = -1; int party = -1;
party = Utilities.GetParty(soc); party = Utilities.GetParty(soc);