From 14ce77fe62748f1a4d47a809a2c4cb30909120a4 Mon Sep 17 00:00:00 2001 From: sheychen Date: Thu, 17 Nov 2016 13:59:30 +0100 Subject: [PATCH] Multilang errors, Client logs --- .../Resources/Lang.csv | 17 ++++++++++++++++- Galactic Colors Control Console/Program.cs | 10 ++++++++-- Galactic Colors Control GUI/Game.cs | 2 ++ .../States/ConnectState.cs | 6 +++++- Galactic Colors Control GUI/States/GameState.cs | 4 ++-- .../States/MainMenuState.cs | 2 ++ .../States/PartyState.cs | 3 ++- .../Commands/ClearCommand.cs | 2 +- .../Commands/Client/KickCommand.cs | 2 +- .../Commands/Client/StatusCommand.cs | 2 +- .../Commands/ConnectCommand.cs | 4 ++-- .../Commands/HelpCommand.cs | 4 ++-- .../Commands/LogLevelCommand.cs | 2 +- .../Commands/Manager.cs | 10 +++++----- .../Commands/Party/PartyCreateCommand.cs | 4 ++-- .../Commands/Party/PartyJoinCommand.cs | 4 ++-- .../Commands/Party/PartyKickCommand.cs | 2 +- .../Commands/Party/PartyPasswordCommand.cs | 2 +- .../Commands/PingCommand.cs | 2 +- .../Commands/SayCommand.cs | 4 ++-- 20 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Galactic Colors Control Common/Resources/Lang.csv b/Galactic Colors Control Common/Resources/Lang.csv index 7eeef11..487c2e7 100644 --- a/Galactic Colors Control Common/Resources/Lang.csv +++ b/Galactic Colors Control Common/Resources/Lang.csv @@ -34,4 +34,19 @@ TooShort;Trop court;Too short TooLong;Trop long;Too long Update;Actualiser;Update AnyParty;Aucune partie;Any party -Password;Mot de passe;Password \ No newline at end of file +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 \ No newline at end of file diff --git a/Galactic Colors Control Console/Program.cs b/Galactic Colors Control Console/Program.cs index f3af682..fd90b80 100644 --- a/Galactic Colors Control Console/Program.cs +++ b/Galactic Colors Control Console/Program.cs @@ -59,11 +59,13 @@ namespace Galactic_Colors_Control_Console if (host[0] == '*') { host = host.Substring(1); + logger.Write("Validate error " + host, Logger.logType.error); Common.ConsoleWrite(host, ConsoleColor.Red); client.ResetHost(); } else { + logger.Write("Validate " + host, Logger.logType.info); Common.ConsoleWrite(multilang.Get("Use", config.lang) + " " + host + "? y/n"); ConsoleKeyInfo c = new ConsoleKeyInfo(); 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)); if (client.ConnectHost()) //Try connection - {//TODO Cleaner + { + logger.Write("Connected", Logger.logType.warm); run = true; bool connected = false; //Identifaction @@ -93,9 +96,10 @@ namespace Galactic_Colors_Control_Console if (username.Length > 3) { 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 { + logger.Write("Identification error " + res.result, Logger.logType.info); 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)); while (run) { @@ -162,6 +167,7 @@ namespace Galactic_Colors_Control_Console } else { + logger.Write("Connection error", Logger.logType.error); Common.ConsoleWrite(multilang.Get("CantConnect", config.lang), ConsoleColor.Red); } run = false; diff --git a/Galactic Colors Control GUI/Game.cs b/Galactic Colors Control GUI/Game.cs index 8ca535c..9df80d0 100644 --- a/Galactic Colors Control GUI/Game.cs +++ b/Galactic Colors Control GUI/Game.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Input; using MyMonoGame.GUI; using System; using System.IO; +using System.Reflection; namespace Galactic_Colors_Control_GUI { @@ -74,6 +75,7 @@ namespace Galactic_Colors_Control_GUI protected override void Initialize() { 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); multilang.Load(); if (Program._debug) { logger.Write("CLIENT IS IN DEBUG MODE !", Logger.logType.error, Logger.logConsole.show); } diff --git a/Galactic Colors Control GUI/States/ConnectState.cs b/Galactic Colors Control GUI/States/ConnectState.cs index 39d7e11..5f6dc35 100644 --- a/Galactic Colors Control GUI/States/ConnectState.cs +++ b/Galactic Colors Control GUI/States/ConnectState.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using MyMonoGame.GUI; using System.Threading; using System; +using Galactic_Colors_Control_Common; 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.text = Host; showOKMessage = true; - Game.singleton.client.ResetHost(); ; + Game.singleton.client.ResetHost(); + Game.singleton.logger.Write("Validate : " + Host, Logger.logType.info); } else { @@ -135,10 +137,12 @@ namespace Galactic_Colors_Control_GUI.States showLoading = true; if (Game.singleton.client.ConnectHost()) { + Game.singleton.logger.Write("Connected", Logger.logType.info); Game.singleton.gameState = new IndentificationState(); } else { + Game.singleton.logger.Write("Connect error", Logger.logType.error); message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang); message.text = string.Empty; showOKMessage = true; diff --git a/Galactic Colors Control GUI/States/GameState.cs b/Galactic Colors Control GUI/States/GameState.cs index 89241a4..9437281 100644 --- a/Galactic Colors Control GUI/States/GameState.cs +++ b/Galactic Colors Control GUI/States/GameState.cs @@ -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 Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -97,6 +96,7 @@ namespace Galactic_Colors_Control_GUI.States EventData eve = ((EventDataArgs)e).Data; 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.text = Common.ArrayToString(eve.data); showOKMessage = true; diff --git a/Galactic Colors Control GUI/States/MainMenuState.cs b/Galactic Colors Control GUI/States/MainMenuState.cs index b478995..cac61b7 100644 --- a/Galactic Colors Control GUI/States/MainMenuState.cs +++ b/Galactic Colors Control GUI/States/MainMenuState.cs @@ -5,6 +5,7 @@ using MyMonoGame.GUI; using System.Reflection; using Galactic_Colors_Control; using System.Threading; +using Galactic_Colors_Control_Common; namespace Galactic_Colors_Control_GUI.States { @@ -43,6 +44,7 @@ namespace Galactic_Colors_Control_GUI.States { locked = true; Game.singleton.GUI.ResetFocus(); + Game.singleton.logger.Write("Game exit", Logger.logType.warm); Game.singleton.gameState = new TitleState(); new Thread(() => { diff --git a/Galactic Colors Control GUI/States/PartyState.cs b/Galactic Colors Control GUI/States/PartyState.cs index f177605..fe84d9b 100644 --- a/Galactic Colors Control GUI/States/PartyState.cs +++ b/Galactic Colors Control GUI/States/PartyState.cs @@ -131,7 +131,6 @@ namespace Galactic_Colors_Control_GUI.States private void PartyJoin() { - //TODO showLoading = true; if (id != -1) { @@ -139,10 +138,12 @@ namespace Galactic_Colors_Control_GUI.States ResultData res = Game.singleton.client.Request(request); if (res.type == ResultTypes.OK) { + Game.singleton.logger.Write("Join party " + id.ToString(), Logger.logType.info); Game.singleton.gameState = new GameState(); } else { + Game.singleton.logger.Write("Join error " + res.result, Logger.logType.error); message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang); message.text = Common.ArrayToString(res.result); showOKMessage = true; diff --git a/Galactic Colors Control Server/Commands/ClearCommand.cs b/Galactic Colors Control Server/Commands/ClearCommand.cs index d423891..71bbcf0 100644 --- a/Galactic Colors Control Server/Commands/ClearCommand.cs +++ b/Galactic Colors Control Server/Commands/ClearCommand.cs @@ -28,7 +28,7 @@ namespace Galactic_Colors_Control_Server.Commands } else { - return new RequestResult(ResultTypes.Error, Common.Strings("Client Side")); + return new RequestResult(ResultTypes.Error, Common.Strings("ClientSide")); } } } diff --git a/Galactic Colors Control Server/Commands/Client/KickCommand.cs b/Galactic Colors Control Server/Commands/Client/KickCommand.cs index a59f9a4..1fea922 100644 --- a/Galactic Colors Control Server/Commands/Client/KickCommand.cs +++ b/Galactic Colors Control Server/Commands/Client/KickCommand.cs @@ -25,7 +25,7 @@ namespace Galactic_Colors_Control_Server.Commands if (Utilities.GetName(client) == args[2]) { target = client; } } 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); if (args.Length > 2) diff --git a/Galactic Colors Control Server/Commands/Client/StatusCommand.cs b/Galactic Colors Control Server/Commands/Client/StatusCommand.cs index 54ef8dc..9ef53a1 100644 --- a/Galactic Colors Control Server/Commands/Client/StatusCommand.cs +++ b/Galactic Colors Control Server/Commands/Client/StatusCommand.cs @@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands if (Utilities.GetName(client) == args[2]) { target = client; } } if (target == null) - return new RequestResult(ResultTypes.Error, Common.Strings("Can't find")); + return new RequestResult(ResultTypes.Error, Common.Strings("CantFind")); string text = ""; text += ("Name : " + Utilities.GetName(target) + Environment.NewLine); diff --git a/Galactic Colors Control Server/Commands/ConnectCommand.cs b/Galactic Colors Control Server/Commands/ConnectCommand.cs index 0a6728d..54bf0ab 100644 --- a/Galactic Colors Control Server/Commands/ConnectCommand.cs +++ b/Galactic Colors Control Server/Commands/ConnectCommand.cs @@ -24,7 +24,7 @@ namespace Galactic_Colors_Control_Server.Commands return new RequestResult(ResultTypes.Error, Common.Strings("Connected")); 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); bool allreadyconnected = false; @@ -34,7 +34,7 @@ namespace Galactic_Colors_Control_Server.Commands if (client.pseudo == args[1]) { allreadyconnected = true; break; } } 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].pseudo = args[1]; diff --git a/Galactic Colors Control Server/Commands/HelpCommand.cs b/Galactic Colors Control Server/Commands/HelpCommand.cs index b410a07..4169c46 100644 --- a/Galactic Colors Control Server/Commands/HelpCommand.cs +++ b/Galactic Colors Control Server/Commands/HelpCommand.cs @@ -66,10 +66,10 @@ namespace Galactic_Colors_Control_Server.Commands ICommand command = null; args = args.Skip(1).ToArray(); 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)) - 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)); } diff --git a/Galactic Colors Control Server/Commands/LogLevelCommand.cs b/Galactic Colors Control Server/Commands/LogLevelCommand.cs index c461946..04caa7c 100644 --- a/Galactic Colors Control Server/Commands/LogLevelCommand.cs +++ b/Galactic Colors Control Server/Commands/LogLevelCommand.cs @@ -27,7 +27,7 @@ namespace Galactic_Colors_Control_Server.Commands } else { - return new RequestResult(ResultTypes.Error, Common.Strings("Incorrect argument")); + return new RequestResult(ResultTypes.Error, Common.Strings("IncorrectArgs")); } } } diff --git a/Galactic Colors Control Server/Commands/Manager.cs b/Galactic Colors Control Server/Commands/Manager.cs index 1375ad3..35eea72 100644 --- a/Galactic Colors Control Server/Commands/Manager.cs +++ b/Galactic Colors Control Server/Commands/Manager.cs @@ -14,7 +14,7 @@ namespace Galactic_Colors_Control_Server.Commands 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")); /// /// Find all ICommand and add them to commands @@ -46,13 +46,13 @@ namespace Galactic_Colors_Control_Server.Commands return AnyCommand; 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) - 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) - 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 { @@ -61,7 +61,7 @@ namespace Galactic_Colors_Control_Server.Commands catch (Exception e) { 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")); } } diff --git a/Galactic Colors Control Server/Commands/Party/PartyCreateCommand.cs b/Galactic Colors Control Server/Commands/Party/PartyCreateCommand.cs index 5480f8c..d117eb1 100644 --- a/Galactic Colors Control Server/Commands/Party/PartyCreateCommand.cs +++ b/Galactic Colors Control Server/Commands/Party/PartyCreateCommand.cs @@ -27,10 +27,10 @@ namespace Galactic_Colors_Control_Server.Commands return new RequestResult(ResultTypes.Error, Common.Strings("Format")); 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) - return new RequestResult(ResultTypes.Error, Common.Strings("Too Big")); + return new RequestResult(ResultTypes.Error, Common.Strings("TooBig")); if (Program.parties.Count >= Program.config.partysize) return new RequestResult(ResultTypes.Error, Common.Strings("Full")); diff --git a/Galactic Colors Control Server/Commands/Party/PartyJoinCommand.cs b/Galactic Colors Control Server/Commands/Party/PartyJoinCommand.cs index 312579e..77c6b77 100644 --- a/Galactic Colors Control Server/Commands/Party/PartyJoinCommand.cs +++ b/Galactic Colors Control Server/Commands/Party/PartyJoinCommand.cs @@ -25,10 +25,10 @@ namespace Galactic_Colors_Control_Server.Commands int 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)) - return new RequestResult(ResultTypes.Error, Common.Strings("Can't Find")); + return new RequestResult(ResultTypes.Error, Common.Strings("CantFind")); Party party = Program.parties[id]; if (args.Length == 3) diff --git a/Galactic Colors Control Server/Commands/Party/PartyKickCommand.cs b/Galactic Colors Control Server/Commands/Party/PartyKickCommand.cs index dec2ac9..71e88f3 100644 --- a/Galactic Colors Control Server/Commands/Party/PartyKickCommand.cs +++ b/Galactic Colors Control Server/Commands/Party/PartyKickCommand.cs @@ -29,7 +29,7 @@ namespace Galactic_Colors_Control_Server.Commands if (Utilities.GetName(client) == args[2]) { target = client; } } 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)); return Manager.Execute(new string[2] { "party", "leave" }, target, false); diff --git a/Galactic Colors Control Server/Commands/Party/PartyPasswordCommand.cs b/Galactic Colors Control Server/Commands/Party/PartyPasswordCommand.cs index c4e4d03..fffb0ef 100644 --- a/Galactic Colors Control Server/Commands/Party/PartyPasswordCommand.cs +++ b/Galactic Colors Control Server/Commands/Party/PartyPasswordCommand.cs @@ -31,7 +31,7 @@ namespace Galactic_Colors_Control_Server.Commands } 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); } diff --git a/Galactic Colors Control Server/Commands/PingCommand.cs b/Galactic Colors Control Server/Commands/PingCommand.cs index 6f7b0ee..80746f0 100644 --- a/Galactic Colors Control Server/Commands/PingCommand.cs +++ b/Galactic Colors Control Server/Commands/PingCommand.cs @@ -19,7 +19,7 @@ namespace Galactic_Colors_Control_Server.Commands 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")); } } } \ No newline at end of file diff --git a/Galactic Colors Control Server/Commands/SayCommand.cs b/Galactic Colors Control Server/Commands/SayCommand.cs index 14008d8..ef519c0 100644 --- a/Galactic Colors Control Server/Commands/SayCommand.cs +++ b/Galactic Colors Control Server/Commands/SayCommand.cs @@ -20,10 +20,10 @@ namespace Galactic_Colors_Control_Server.Commands public RequestResult Execute(string[] args, Socket soc, bool server = false) { 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)) - return new RequestResult(ResultTypes.Error, Common.Strings("Must Be Connected")); + return new RequestResult(ResultTypes.Error, Common.Strings("MustBeConnected")); int party = -1; party = Utilities.GetParty(soc);