diff --git a/NebulaNetwork/Client.cs b/NebulaNetwork/Client.cs index a5d623671..a4aa5dfca 100644 --- a/NebulaNetwork/Client.cs +++ b/NebulaNetwork/Client.cs @@ -257,8 +257,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) if (e.Code == (ushort)DisconnectionReason.ModIsMissing) { InGamePopup.ShowWarning( - "Mod Mismatch", - $"You are missing mod {e.Reason}", + "Mod Mismatch".Translate(), + string.Format("You are missing mod {0}".Translate(), e.Reason), "OK".Translate(), Multiplayer.LeaveGame); return; @@ -267,8 +267,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) if (e.Code == (ushort)DisconnectionReason.ModIsMissingOnServer) { InGamePopup.ShowWarning( - "Mod Mismatch", - $"Server is missing mod {e.Reason}", + "Mod Mismatch".Translate(), + string.Format("Server is missing mod {0}".Translate(), e.Reason), "OK".Translate(), Multiplayer.LeaveGame); return; @@ -278,8 +278,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) { string[] versions = e.Reason.Split(';'); InGamePopup.ShowWarning( - "Mod Version Mismatch", - $"Your mod {versions[0]} version is not the same as the Host version.\nYou:{versions[1]} - Remote:{versions[2]}", + "Mod Version Mismatch".Translate(), + string.Format("Your mod {0} version is not the same as the Host version.\nYou:{1} - Remote:{2}".Translate(), versions[0], versions[1], versions[2]), "OK".Translate(), Multiplayer.LeaveGame); return; @@ -289,8 +289,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) { string[] versions = e.Reason.Split(';'); InGamePopup.ShowWarning( - "Game Version Mismatch", - $"Your version of the game is not the same as the one used by the Host.\nYou:{versions[0]} - Remote:{versions[1]}", + "Game Version Mismatch".Translate(), + string.Format("Your version of the game is not the same as the one used by the Host.\nYou:{0} - Remote:{1}".Translate(), versions[0], versions[1]), "OK".Translate(), Multiplayer.LeaveGame); return; @@ -299,8 +299,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) if (e.Code == (ushort)DisconnectionReason.ProtocolError && websocketAuthenticationFailure) { InGamePopup.AskInput( - "Server Requires Password", - "Server is protected. Please enter the correct password:", + "Server Requires Password".Translate(), + "Server is protected. Please enter the correct password:".Translate(), InputField.ContentType.Password, serverPassword, (password) => @@ -318,8 +318,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) if (e.Code == (ushort)DisconnectionReason.HostStillLoading) { InGamePopup.ShowWarning( - "Server Busy", - "Server is not ready to join. Please try again later.", + "Server Busy".Translate(), + "Server is not ready to join. Please try again later.".Translate(), "OK".Translate(), Multiplayer.LeaveGame); return; @@ -328,8 +328,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) if (Multiplayer.Session.IsGameLoaded || Multiplayer.Session.IsInLobby) { InGamePopup.ShowWarning( - "Connection Lost", - $"You have been disconnected from the server.\n{e.Reason}", + "Connection Lost".Translate(), + "You have been disconnected from the server.".Translate() + "\n" + e.Reason, "Quit", Multiplayer.LeaveGame); if (Multiplayer.Session.IsInLobby) @@ -343,8 +343,8 @@ private void ClientSocket_OnClose(object sender, CloseEventArgs e) { Log.Warn("Disconnect code: " + e.Code + ", reason:" + e.Reason); InGamePopup.ShowWarning( - "Server Unavailable", - $"Could not reach the server, please try again later.", + "Server Unavailable".Translate(), + "Could not reach the server, please try again later.".Translate(), "OK".Translate(), Multiplayer.LeaveGame); } diff --git a/NebulaNetwork/Ngrok/NgrokManager.cs b/NebulaNetwork/Ngrok/NgrokManager.cs index d3346a9a7..6660dde67 100644 --- a/NebulaNetwork/Ngrok/NgrokManager.cs +++ b/NebulaNetwork/Ngrok/NgrokManager.cs @@ -44,7 +44,7 @@ public NgrokManager(int port, string authtoken = null, string region = null) if (string.IsNullOrEmpty(_authtoken)) { - NebulaModel.Logger.Log.WarnInform("Ngrok support was enabled, however no Authtoken was provided"); + NebulaModel.Logger.Log.WarnInform("Ngrok support was enabled, however no Authtoken was provided".Translate()); return; } @@ -52,7 +52,7 @@ public NgrokManager(int port, string authtoken = null, string region = null) string[] availableRegions = { "us", "eu", "au", "ap", "sa", "jp", "in" }; if (!string.IsNullOrEmpty(_region) && !availableRegions.Any(_region.Contains)) { - NebulaModel.Logger.Log.WarnInform("Unsupported Ngrok region was provided, defaulting to autodetection"); + NebulaModel.Logger.Log.WarnInform("Unsupported Ngrok region was provided, defaulting to autodetection".Translate()); _region = null; } @@ -67,10 +67,10 @@ public NgrokManager(int port, string authtoken = null, string region = null) UnityDispatchQueue.RunOnMainThread(() => { InGamePopup.ShowWarning( - "Ngrok download and installation confirmation", - "Ngrok support is enabled, however it has not been downloaded and installed yet, do you want to automatically download and install Ngrok?", - "Accept", - "Reject", + "Ngrok download and installation confirmation".Translate(), + "Ngrok support is enabled, however it has not been downloaded and installed yet, do you want to automatically download and install Ngrok?".Translate(), + "Accept".Translate(), + "Reject".Translate(), () => downloadAndInstallConfirmationSource.TrySetResult(true), () => downloadAndInstallConfirmationSource.TrySetResult(false) ); @@ -79,7 +79,7 @@ public NgrokManager(int port, string authtoken = null, string region = null) var hasDownloadAndInstallBeenConfirmed = await downloadAndInstallConfirmationSource.Task; if (!hasDownloadAndInstallBeenConfirmed) { - NebulaModel.Logger.Log.Warn("Failed to download or install Ngrok, because user rejected Ngrok download and install confirmation!"); + NebulaModel.Logger.Log.Warn("Failed to download or install Ngrok, because user rejected Ngrok download and install confirmation!".Translate()); return; } @@ -89,7 +89,7 @@ public NgrokManager(int port, string authtoken = null, string region = null) } catch { - NebulaModel.Logger.Log.WarnInform("Failed to download or install Ngrok!"); + NebulaModel.Logger.Log.WarnInform("Failed to download or install Ngrok!".Translate()); throw; } @@ -97,13 +97,13 @@ public NgrokManager(int port, string authtoken = null, string region = null) if (!StartNgrok()) { - NebulaModel.Logger.Log.WarnInform($"Failed to start Ngrok tunnel! LastErrorCode: {NgrokLastErrorCode}"); + NebulaModel.Logger.Log.WarnInform(string.Format("Failed to start Ngrok tunnel! LastErrorCode: {0}".Translate(), NgrokLastErrorCode)); return; } if (!IsNgrokActive()) { - NebulaModel.Logger.Log.WarnInform($"Ngrok tunnel has exited prematurely! LastErrorCode: {NgrokLastErrorCode}"); + NebulaModel.Logger.Log.WarnInform(string.Format("Ngrok tunnel has exited prematurely! LastErrorCode: {0}".Translate(), NgrokLastErrorCode)); return; } @@ -130,7 +130,7 @@ private async Task DownloadAndInstallNgrok() File.WriteAllLines(_ngrokConfigPath, new string[] { "version: 2" }); - NebulaModel.Logger.Log.WarnInform("Ngrok install completed in the plugin folder"); + NebulaModel.Logger.Log.WarnInform("Ngrok install completed in the plugin folder".Translate()); } private bool IsNgrokInstalled() @@ -217,7 +217,7 @@ private void ErrorDataReceivedEventHandler(object sender, DataReceivedEventArgs if (errorCodeMatches.Count > 0) { NgrokLastErrorCode = errorCodeMatches[errorCodeMatches.Count - 1].Value; - NebulaModel.Logger.Log.WarnInform($"Ngrok Error! Code: {NgrokLastErrorCode}"); + NebulaModel.Logger.Log.WarnInform(string.Format("Ngrok Error! Code: {0}".Translate(), NgrokLastErrorCode)); } } } diff --git a/NebulaNetwork/PacketProcessors/Chat/ChatCommandWhisperProcessor.cs b/NebulaNetwork/PacketProcessors/Chat/ChatCommandWhisperProcessor.cs index 62c7ac484..55ea64700 100644 --- a/NebulaNetwork/PacketProcessors/Chat/ChatCommandWhisperProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Chat/ChatCommandWhisperProcessor.cs @@ -33,7 +33,7 @@ public override void ProcessPacket(ChatCommandWhisperPacket packet, NebulaConnec { Log.Warn($"Recipient not found {packet.RecipientUsername}"); INebulaPlayer sender = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn); - sender.SendPacket(new ChatCommandWhisperPacket("SYSTEM", packet.SenderUsername, $"User not found {packet.RecipientUsername}")); + sender.SendPacket(new ChatCommandWhisperPacket("SYSTEM".Translate(), packet.SenderUsername, string.Format("User not found {0}".Translate(), packet.RecipientUsername))); return; } diff --git a/NebulaNetwork/PacketProcessors/Chat/RemoteServerCommmandProcessor.cs b/NebulaNetwork/PacketProcessors/Chat/RemoteServerCommmandProcessor.cs index d6bc91f6e..da3d6436f 100644 --- a/NebulaNetwork/PacketProcessors/Chat/RemoteServerCommmandProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Chat/RemoteServerCommmandProcessor.cs @@ -25,12 +25,12 @@ internal class RemoteServerCommmandProcessor : PacketProcessor 0) { - return $"Cooldown: {cdtime}s"; + return string.Format("Cooldown: {0}s".Translate(), cdtime); } LastLoginTime = DateTime.Now; IPlayerData playerData = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn)?.Data; @@ -98,11 +98,11 @@ private string Login(NebulaConnection conn, string passwordHash) string hash = CryptoUtils.Hash(Config.Options.RemoteAccessPassword + salt); if (hash != passwordHash) { - return "Password incorrect!"; + return "Password incorrect!".Translate(); } } allowedConnections.Add(conn); - return "Login success!"; + return "Login success!".Translate(); } private static string List(string numString) @@ -126,7 +126,7 @@ private static string List(string numString) Array.Sort(dates, names); StringBuilder sb = new(); - sb.AppendLine($"Save list on server: ({num}/{files.Length})"); + sb.AppendLine(string.Format("Save list on server: ({0}/{1})".Translate(), num, files.Length)); for (int i = files.Length - num; i < files.Length; i++) { sb.AppendLine($"{dates[i]} {names[i]}"); @@ -142,11 +142,11 @@ private string Save(string saveName) // Save game and report result to the client LastSaveTime = DateTime.Now; saveName = string.IsNullOrEmpty(saveName) ? GameSave.LastExit : saveName; - return $"Save {saveName} : " + (GameSave.SaveCurrentGame(saveName) ? "Success" : "Fail"); + return string.Format("Save {0} : {1}".Translate(), saveName, GameSave.SaveCurrentGame(saveName) ? "Success".Translate() : "Fail".Translate()); } else { - return $"Cooldown: {countDown}s"; + return string.Format("Cooldown: {0}s".Translate(), countDown); } } @@ -154,7 +154,7 @@ private static string Load(string saveName) { if (!GameSave.SaveExist(saveName)) { - return $"{saveName} doesn't exist"; + return string.Format("{0} doesn't exist".Translate(), saveName); } Log.Info($"Received command to load {saveName}"); diff --git a/NebulaNetwork/PacketProcessors/Factory/Entity/BuildEntityRequestProcessor.cs b/NebulaNetwork/PacketProcessors/Factory/Entity/BuildEntityRequestProcessor.cs index 7cd9186f9..5927c4962 100644 --- a/NebulaNetwork/PacketProcessors/Factory/Entity/BuildEntityRequestProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Factory/Entity/BuildEntityRequestProcessor.cs @@ -41,7 +41,7 @@ public override void ProcessPacket(BuildEntityRequest packet, NebulaConnection c GameMain.gpuiManager.specifyPlanet = GameMain.galaxy.PlanetById(packet.PlanetId); if (packet.EntityId != -1 && packet.EntityId != NebulaWorld.Factory.FactoryManager.GetNextEntityId(planet.factory)) { - string warningText = $"(Desync) EntityId mismatch {packet.EntityId} != {NebulaWorld.Factory.FactoryManager.GetNextEntityId(planet.factory)} on planet {planet.id}. Clients should reconnect!"; + string warningText = string.Format("(Desync) EntityId mismatch {0} != {1} on planet {2}. Clients should reconnect!".Translate(), packet.EntityId, NebulaWorld.Factory.FactoryManager.GetNextEntityId(planet.factory), planet.displayName); Log.WarnInform(warningText); NebulaWorld.Warning.WarningManager.DisplayTemporaryWarning(warningText, 5000); } diff --git a/NebulaNetwork/PacketProcessors/Session/HandshakeResponseProcessor.cs b/NebulaNetwork/PacketProcessors/Session/HandshakeResponseProcessor.cs index 472bf0e0d..cf54afe14 100644 --- a/NebulaNetwork/PacketProcessors/Session/HandshakeResponseProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Session/HandshakeResponseProcessor.cs @@ -44,7 +44,7 @@ public override void ProcessPacket(HandshakeResponse packet, NebulaConnection co gameDesc.isSandboxMode = packet.IsSandboxMode; DSPGame.StartGameSkipPrologue(gameDesc); - InGamePopup.ShowInfo("Loading", "Loading state from server, please wait", null); + InGamePopup.ShowInfo("Loading".Translate(), "Loading state from server, please wait".Translate(), null); Multiplayer.Session.NumPlayers = packet.NumPlayers; DiscordManager.UpdateRichPresence(partyId: packet.DiscordPartyId); diff --git a/NebulaNetwork/PacketProcessors/Session/StartGameMessageProcessor.cs b/NebulaNetwork/PacketProcessors/Session/StartGameMessageProcessor.cs index fcc2d9f88..68c59775f 100644 --- a/NebulaNetwork/PacketProcessors/Session/StartGameMessageProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Session/StartGameMessageProcessor.cs @@ -81,11 +81,11 @@ public override void ProcessPacket(StartGameMessage packet, NebulaConnection con DSPGame.StartGameSkipPrologue(UIRoot.instance.galaxySelect.gameDesc); - InGamePopup.ShowInfo("Loading", "Loading state from server, please wait", null); + InGamePopup.ShowInfo("Loading".Translate(), "Loading state from server, please wait".Translate(), null); } else { - InGamePopup.ShowInfo("Please Wait", "The host is not ready to let you in, please wait!", "Okay"); + InGamePopup.ShowInfo("Unavailable".Translate(), "The host is not ready to let you in, please wait!".Translate(), "OK".Translate()); } } } diff --git a/NebulaNetwork/Server.cs b/NebulaNetwork/Server.cs index 25b9f7723..627ed9235 100644 --- a/NebulaNetwork/Server.cs +++ b/NebulaNetwork/Server.cs @@ -87,11 +87,11 @@ public override void Start() } catch (NatDeviceNotFoundException) { - Log.WarnInform("No UPnp or Pmp compatible/enabled NAT device found"); + Log.WarnInform("No UPnp or Pmp compatible/enabled NAT device found".Translate()); } catch (MappingException) { - Log.WarnInform("Could not create UPnp or Pmp port mapping"); + Log.WarnInform("Could not create UPnp or Pmp port mapping".Translate()); } }); } @@ -128,7 +128,7 @@ public override void Start() socket.Start(); }catch(System.InvalidOperationException e) { - InGamePopup.ShowError("Error", "An error occurred while hosting the game: " + e.Message, "Close"); + InGamePopup.ShowError("Error", "An error occurred while hosting the game: ".Translate() + e.Message, "Close".Translate()); Stop(); Multiplayer.LeaveGame(); return; @@ -301,7 +301,7 @@ protected override void OnOpen() if (Multiplayer.Session.IsGameLoaded == false && Multiplayer.Session.IsInLobby == false) { // Reject any connection that occurs while the host's game is loading. - Context.WebSocket.Close((ushort)DisconnectionReason.HostStillLoading, "Host still loading, please try again later."); + Context.WebSocket.Close((ushort)DisconnectionReason.HostStillLoading, "Host still loading, please try again later.".Translate()); return; } diff --git a/NebulaPatcher/Patches/Dynamic/DESelection_Patch.cs b/NebulaPatcher/Patches/Dynamic/DESelection_Patch.cs index 8fa275d92..90da62ab1 100644 --- a/NebulaPatcher/Patches/Dynamic/DESelection_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/DESelection_Patch.cs @@ -49,7 +49,7 @@ public static bool SetViewStar_Prefix(DESelection __instance, ref StarData starD } else { - InGamePopup.ShowInfo("Loading", $"Loading Dyson sphere {starData.displayName}, please wait...", null); + InGamePopup.ShowInfo("Loading".Translate(), string.Format("Loading Dyson sphere {0}, please wait".Translate(), starData.displayName), null); } // Restore comboBox back to original star UIComboBox dysonBox = UIRoot.instance.uiGame.dysonEditor.controlPanel.topFunction.dysonBox; diff --git a/NebulaPatcher/Patches/Dynamic/GameLoader_Patch.cs b/NebulaPatcher/Patches/Dynamic/GameLoader_Patch.cs index 066fbee23..25073ef9f 100644 --- a/NebulaPatcher/Patches/Dynamic/GameLoader_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/GameLoader_Patch.cs @@ -12,7 +12,7 @@ internal class GameLoader_Patch public static void FixedUpdate_Postfix(int ___frame) { string content = GameStatesManager.FragmentSize > 0 ? GameStatesManager.LoadingMessage() : NebulaModel.Logger.Log.LastInfoMsg; - InGamePopup.UpdateMessage("Loading", "Loading state from server, please wait\n" + content); + InGamePopup.UpdateMessage("Loading".Translate(), "Loading state from server, please wait".Translate() + "\n" + content); if (Multiplayer.IsActive && ___frame >= 11) { Multiplayer.Session.OnGameLoadCompleted(); diff --git a/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs index c757f6220..74852b0ff 100644 --- a/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs @@ -38,14 +38,20 @@ public static void _OnOpen_Postfix(UIGalaxySelect __instance) // show lobby hints if needed if (Config.Options.ShowLobbyHints) { - InGamePopup.ShowInfo("The Lobby", - "We changed the start of a new multiplayer game a bit and want to give you a quick overview of the new feature.\n\n" + + string message; + if ("Nebula_LobbyMessage".Translate() != "Nebula_LobbyMessage") // Translation exists + message = "Nebula_LobbyMessage".Translate(); + else + message = "We changed the start of a new multiplayer game a bit and want to give you a quick overview of the new feature.\n\n" + "Clients can now join while the host is in the galaxy selection screen, and they will also land there if it is their first time connecting to the currently hosted save.\n\n" + "You can now click on any star to bring up the solar system preview. From there you can click on any planet to bring up its details.\n" + "Note that when using GalacticScale 2 this process can take a bit longer.\n\n" + - "By clicking a planet while having its detail panel open you will set it as your birth planet.\n\n" + - "By clicking into outer space you will go one detail level up.\n\n" + - "We hope you enjoy this new feature!", + "By clicking a planet while having its detail panel open you will set it as your birth planet.\n" + + "By clicking into outer space you will go one detail level up. Scroll to zoom in/out. Press Alt to see star names.\n\n" + + "Alt + ~ can open in-game chat. We hope you enjoy this new feature!"; + + InGamePopup.ShowInfo("The Lobby".Translate(), + message, "Okay, cool :)", CloseLobbyInfo); } diff --git a/NebulaPatcher/Patches/Dynamic/UIGame_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIGame_Patch.cs index f2cb2f09f..e9ff54321 100644 --- a/NebulaPatcher/Patches/Dynamic/UIGame_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIGame_Patch.cs @@ -27,7 +27,7 @@ public static bool StarmapChangingToMilkyWay_Prefix(UIGame __instance) { if (Multiplayer.IsActive) { - InGamePopup.ShowInfo("Access Denied", "Milky Way is disabled in multiplayer game.", "OK"); + InGamePopup.ShowInfo("Unavailable".Translate(), "Milky Way is disabled in multiplayer game.".Translate(), "OK".Translate()); return false; } return true; diff --git a/NebulaPatcher/Patches/Dynamic/UIMainMenu_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIMainMenu_Patch.cs index 3f1667b5a..a903220cd 100644 --- a/NebulaPatcher/Patches/Dynamic/UIMainMenu_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIMainMenu_Patch.cs @@ -72,7 +72,7 @@ private static void AddMultiplayerButton() multiplayerButton = Object.Instantiate(buttonTemplate, mainMenuButtonGroup, false); multiplayerButton.name = "button-multiplayer"; multiplayerButton.anchoredPosition = new Vector2(multiplayerButton.anchoredPosition.x, multiplayerButton.anchoredPosition.y + multiplayerButton.sizeDelta.y + 10); - OverrideButton(multiplayerButton, "Multiplayer", OnMultiplayerButtonClick); + OverrideButton(multiplayerButton, "Multiplayer".Translate(), OnMultiplayerButtonClick); } public static void OnMultiplayerButtonClick() @@ -88,10 +88,10 @@ private static void AddMultiplayerSubMenu() multiplayerSubMenu = Object.Instantiate(mainMenuButtonGroup, mainMenuButtonGroup.parent, true); multiplayerSubMenu.name = "multiplayer-menu"; - OverrideButton(multiplayerSubMenu.Find("button-multiplayer").GetComponent(), "New Game (Host)", OnMultiplayerNewGameButtonClick); - OverrideButton(multiplayerSubMenu.Find("button-new").GetComponent(), "Load Game (Host)", OnMultiplayerLoadGameButtonClick); - OverrideButton(multiplayerSubMenu.Find("button-continue").GetComponent(), "Join Game", OnMultiplayerJoinGameButtonClick); - OverrideButton(multiplayerSubMenu.Find("button-load").GetComponent(), "Back", OnMultiplayerBackButtonClick); + OverrideButton(multiplayerSubMenu.Find("button-multiplayer").GetComponent(), "New Game (Host)".Translate(), OnMultiplayerNewGameButtonClick); + OverrideButton(multiplayerSubMenu.Find("button-new").GetComponent(), "Load Game (Host)".Translate(), OnMultiplayerLoadGameButtonClick); + OverrideButton(multiplayerSubMenu.Find("button-continue").GetComponent(), "Join Game".Translate(), OnMultiplayerJoinGameButtonClick); + OverrideButton(multiplayerSubMenu.Find("button-load").GetComponent(), "Back".Translate(), OnMultiplayerBackButtonClick); multiplayerSubMenu.Find("button-options").gameObject.SetActive(false); multiplayerSubMenu.Find("button-credits").gameObject.SetActive(false); @@ -173,13 +173,13 @@ private static void AddMultiplayerJoinMenu() { Transform topTitle = child; topTitle.GetComponent().enabled = false; - topTitle.GetComponent().text = "Multiplayer"; + topTitle.GetComponent().text = "Multiplayer".Translate(); } else if (child.name == "galaxy-seed") { Transform hostIpField = child; hostIpField.GetComponent().enabled = false; - hostIpField.GetComponent().text = "Host IP Address"; + hostIpField.GetComponent().text = "Host IP Address".Translate(); hostIpField.name = "Host IP Address"; hostIPAddressInput = hostIpField.GetComponentInChildren(); hostIPAddressInput.onEndEdit.RemoveAllListeners(); @@ -199,7 +199,7 @@ private static void AddMultiplayerJoinMenu() } else if (child.name == "start-button") { - OverrideButton(multiplayerMenu.Find("start-button").GetComponent(), "Join Game", OnJoinGameButtonClick); + OverrideButton(multiplayerMenu.Find("start-button").GetComponent(), "Join Game".Translate(), OnJoinGameButtonClick); } else if (child.name == "cancel-button") { @@ -213,7 +213,7 @@ private static void AddMultiplayerJoinMenu() } Transform passwordField = Object.Instantiate(multiplayerMenu.Find("Host IP Address"), multiplayerMenu, false); passwordField.localPosition = galaxySelectTemplate.Find("star-count").localPosition; - passwordField.GetComponent().text = "Password (optional)"; + passwordField.GetComponent().text = "Password (optional)".Translate(); passwordField.name = "Password (optional)"; passwordInput = passwordField.GetComponentInChildren(); passwordInput.contentType = InputField.ContentType.Password; @@ -306,7 +306,7 @@ public static void JoinGame(string ip, string password = "") private static IEnumerator TryConnectToServer(string ip, int port, bool isIP, string password) { - InGamePopup.ShowInfo("Connecting", $"Connecting to server...", null, null); + InGamePopup.ShowInfo("Connecting".Translate(), "Connecting to server...".Translate(), null, null); multiplayerMenu.gameObject.SetActive(false); // We need to wait here to have time to display the Connecting popup since the game freezes during the connection. @@ -316,7 +316,7 @@ private static IEnumerator TryConnectToServer(string ip, int port, bool isIP, st { InGamePopup.FadeOut(); //re-enabling the menu again after failed connect attempt - InGamePopup.ShowWarning("Connect failed", $"Was not able to connect to server", "OK"); + InGamePopup.ShowWarning("Connect failed".Translate(), "Was not able to connect to server".Translate(), "OK"); multiplayerMenu.gameObject.SetActive(true); } else diff --git a/NebulaPatcher/Patches/Dynamic/UIOptionWindow_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIOptionWindow_Patch.cs index 0fc8bca4c..c68ba5d0f 100644 --- a/NebulaPatcher/Patches/Dynamic/UIOptionWindow_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIOptionWindow_Patch.cs @@ -88,7 +88,7 @@ public static void _OnCreate_Postfix(UIOptionWindow __instance) // Update multiplayer tab text Text tabText = multiplayerTab.GetComponentInChildren(); tabText.GetComponent().enabled = false; - tabText.text = "Multiplayer"; + tabText.text = "Multiplayer".Translate(); Text[] tabTexts = __instance.tabTexts; Text[] newTabTexts = tabTexts.AddToArray(tabText); __instance.tabTexts = newTabTexts; @@ -145,7 +145,7 @@ public static void _OnCreate_Postfix(UIOptionWindow __instance) subtabButtons.Add(subtab.GetComponent()); subtab.name = $"tab-button-{subtabButtons.Count}"; Text subtabText = subtab.GetComponentInChildren(); - subtabText.text = "General"; + subtabText.text = "General".Translate(); subtabTexts.Add(subtabText); subtabTemplate = subtab; subtabContents.Add(new GameObject("General").transform); @@ -279,10 +279,10 @@ private static void AddMultiplayerOptionsProperties() int index = 0; if (categoryAttribute != null) { - index = subtabTexts.FindIndex((text) => text.text == categoryAttribute.Category); + index = subtabTexts.FindIndex((text) => text.text.Translate() == categoryAttribute.Category.Translate()); if (index == -1) { - CreateSubtab(categoryAttribute.Category); + CreateSubtab(categoryAttribute.Category.Translate()); index = subtabTexts.Count - 1; } } @@ -342,7 +342,7 @@ private static void CreateBooleanControl(DisplayNameAttribute control, Descripti if(value != (bool)prop.GetValue(tempMultiplayerOptions, null)) { toggle.isOn = !value; - InGamePopup.ShowInfo("Info", "This setting can only be changed while not in game", "Okay"); + InGamePopup.ShowInfo("Unavailable".Translate(), "This setting can only be changed while not in game".Translate(), "OK".Translate()); } return; } @@ -487,11 +487,11 @@ private static void SetupUIElement(RectTransform element, DisplayNameAttribute d if(descriptionAttr != null) { element.gameObject.AddComponent(); - element.gameObject.GetComponent().Title = display.DisplayName; - element.gameObject.GetComponent().Text = descriptionAttr.Description; + element.gameObject.GetComponent().Title = display.DisplayName.Translate(); + element.gameObject.GetComponent().Text = descriptionAttr.Description.Translate(); } element.GetComponent().enabled = false; - element.GetComponent().text = display.DisplayName; + element.GetComponent().text = display.DisplayName.Translate(); } } } diff --git a/NebulaWorld/Chat/ChatLinks/CopyTextChatLinkHandler.cs b/NebulaWorld/Chat/ChatLinks/CopyTextChatLinkHandler.cs index 2101d45a0..f03da9e3d 100644 --- a/NebulaWorld/Chat/ChatLinks/CopyTextChatLinkHandler.cs +++ b/NebulaWorld/Chat/ChatLinks/CopyTextChatLinkHandler.cs @@ -16,7 +16,7 @@ public void OnClick(string data) public void OnHover(string data, ChatLinkTrigger trigger, ref MonoBehaviour tipObject) { - if (!data.Equals("")) + if (!string.IsNullOrEmpty(data)) { UpdateTip(trigger, ref tipObject); } @@ -36,7 +36,7 @@ private static void UpdateTip(ChatLinkTrigger trigger, ref MonoBehaviour tipObje UIButtonTip buttonTip = tipObject as UIButtonTip; if (buttonTip == null) { - buttonTip = UIButtonTip.Create(false, "Copy", "Click to copy to clipboard", Corner, offset, 0, rect, "", ""); + buttonTip = UIButtonTip.Create(false, "Copy".Translate(), "Click to copy to clipboard".Translate(), Corner, offset, 0, rect, "", ""); if (tipObject != null) { Object.Destroy(tipObject.gameObject); @@ -48,12 +48,12 @@ private static void UpdateTip(ChatLinkTrigger trigger, ref MonoBehaviour tipObje if (!buttonTip.gameObject.activeSelf) { buttonTip.gameObject.SetActive(true); - buttonTip.SetTip(false, "Copy", "Click to copy to clipboard", Corner, offset, 0, rect, "", ""); + buttonTip.SetTip(false, "Copy".Translate(), "Click to copy to clipboard".Translate(), Corner, offset, 0, rect, "", ""); } - if (buttonTip != null && buttonTip.isActiveAndEnabled && !buttonTip.titleComp.Equals("Copy")) + if (buttonTip.isActiveAndEnabled && !buttonTip.titleComp.text.Equals("Copy")) { - buttonTip.SetTip(false, "Copy", "Click to copy to clipboard", Corner, offset, 0, rect, "", ""); + buttonTip.SetTip(false, "Copy".Translate(), "Click to copy to clipboard".Translate(), Corner, offset, 0, rect, "", ""); } } diff --git a/NebulaWorld/Chat/ChatLinks/NavigateChatLinkHandler.cs b/NebulaWorld/Chat/ChatLinks/NavigateChatLinkHandler.cs new file mode 100644 index 000000000..7c9221318 --- /dev/null +++ b/NebulaWorld/Chat/ChatLinks/NavigateChatLinkHandler.cs @@ -0,0 +1,83 @@ +using NebulaModel.DataStructures; +using NebulaWorld.MonoBehaviours.Local; +using System.Collections.Generic; +using UnityEngine; + +namespace NebulaWorld.Chat +{ + public class NavigateChatLinkHandler : IChatLinkHandler + { + public void OnClick(string data) + { + using (Multiplayer.Session.World.GetRemotePlayersModels(out Dictionary remotePlayersModels)) + { + foreach (KeyValuePair model in remotePlayersModels) + { + if (model.Value.Movement.Username == data) + { + // handle indicator position update in RemotePlayerMovement.cs + GameMain.mainPlayer.navigation.indicatorAstroId = 100000 + model.Value.Movement.PlayerID; + ChatManager.Instance.SendChatMessage("Starting navigation to ".Translate() + model.Value.Movement.Username, ChatMessageType.CommandOutputMessage); + return; + } + } + } + } + public void OnHover(string data, ChatLinkTrigger trigger, ref MonoBehaviour tipObject) + { + if (!string.IsNullOrEmpty(data)) + { + UpdateTip(trigger, ref tipObject); + } + else if (tipObject is UIButtonTip) + { + Object.Destroy(tipObject.gameObject); + } + } + + private static void UpdateTip(ChatLinkTrigger trigger, ref MonoBehaviour tipObject) + { + RectTransform rect = (RectTransform)trigger.transform; + + RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, trigger.camera, out Vector2 offset); + offset -= new Vector2(rect.sizeDelta.x / 2, 3f); + + UIButtonTip buttonTip = tipObject as UIButtonTip; + if (buttonTip == null) + { + buttonTip = UIButtonTip.Create(false, "Navigate".Translate(), "Click to create a navigate line to the target.".Translate(), 2, offset, 0, rect, "", ""); + if (tipObject != null) + { + Object.Destroy(tipObject.gameObject); + } + + tipObject = buttonTip; + } + + if (!buttonTip.gameObject.activeSelf) + { + buttonTip.gameObject.SetActive(true); + buttonTip.SetTip(false, "Navigate".Translate(), "Click to create a navigate line to the target.".Translate(), 2, offset, 0, rect, "", ""); + } + + if (buttonTip.isActiveAndEnabled && !buttonTip.titleComp.text.Equals("Navigate")) + { + buttonTip.SetTip(false, "Navigate".Translate(), "Click to create a navigate line to the target.".Translate(), 2, offset, 0, rect, "", ""); + } + } + + + public string GetIconName(string data) + { + return string.Empty; + } + public string GetDisplayRichText(string data) + { + return FormatNavigateString(data); + } + public static string FormatNavigateString(string data) + { + return $"{data}"; + } + } +} diff --git a/NebulaWorld/Chat/ChatLinks/SignalChatLinkHandler.cs b/NebulaWorld/Chat/ChatLinks/SignalChatLinkHandler.cs index 01f0c160e..5d392483f 100644 --- a/NebulaWorld/Chat/ChatLinks/SignalChatLinkHandler.cs +++ b/NebulaWorld/Chat/ChatLinks/SignalChatLinkHandler.cs @@ -77,7 +77,7 @@ public string GetIconName(string data) public string GetDisplayRichText(string data) { int signalId = GetSignalId(data); - if (signalId <= 0) return ""; + if (signalId <= 0) return string.Empty; return $"[ {ProtoUtils.GetSignalDisplayName(signalId)}]"; } diff --git a/NebulaWorld/Chat/Commands/ClearCommandHandler.cs b/NebulaWorld/Chat/Commands/ClearCommandHandler.cs index 464c8b469..d81c3a188 100644 --- a/NebulaWorld/Chat/Commands/ClearCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/ClearCommandHandler.cs @@ -26,7 +26,7 @@ public string[] GetUsage() public string GetDescription() { - return "Clear all chat messages (locally)"; + return "Clear all chat messages (locally)".Translate(); } } } \ No newline at end of file diff --git a/NebulaWorld/Chat/Commands/HelpCommandHandler.cs b/NebulaWorld/Chat/Commands/HelpCommandHandler.cs index e2fe8d9bd..15d67b578 100644 --- a/NebulaWorld/Chat/Commands/HelpCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/HelpCommandHandler.cs @@ -23,7 +23,7 @@ public void Execute(ChatWindow window, string[] parameters) } else { - output = $"Command {FullCommandName(commandName)} was not found! Use {FullCommandName("help")} to get list of known commands."; + output = string.Format("Command {0} was not found! Use /help to get list of known commands.".Translate(), FullCommandName(commandName)); window.SendLocalChatMessage(output, ChatMessageType.CommandErrorMessage); } return; @@ -43,18 +43,18 @@ private static string GetCommandDetailsOutput(string commandName) string aliasList = ChatCommandRegistry.GetCommandAliases(commandName).Join(FullCommandName); StringBuilder sb = new StringBuilder(); - sb.Append($"Command {commandName} - {handler.GetDescription()}\n"); - sb.Append($"Aliases: {aliasList}\n"); + sb.Append("Command ".Translate()).Append(commandName).Append(" - ").Append(handler.GetDescription()).Append('\n'); + sb.Append("Aliases: ".Translate()).Append(aliasList).Append('\n'); foreach (string usage in handler.GetUsage()) { - sb.Append($"Usage: {FullCommandName(commandName)} {usage}\n"); + sb.Append("Usage: ".Translate()).Append(FullCommandName(commandName)).Append(' ').Append(usage).Append('\n'); } return sb.ToString(); } private static string GetCommandListOutput() { - StringBuilder sb = new StringBuilder("Known commands:"); + StringBuilder sb = new StringBuilder("Known commands:".Translate()); foreach (var kv in ChatCommandRegistry.commands) { @@ -69,7 +69,7 @@ private static string GetCommandListOutput() sb.Append($" - {kv.Value.GetDescription()}"); } - sb.Append($"\nFor detailed information about command use {FullCommandName("help")} "); + sb.Append('\n').Append("For detailed information about command use /help ".Translate()); string output = sb.ToString(); return output; @@ -82,7 +82,7 @@ private static string FullCommandName(string name) public string GetDescription() { - return "Get list of existing commands and their usage"; + return "Get list of existing commands and their usage".Translate(); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/Commands/InfoCommandHandler.cs b/NebulaWorld/Chat/Commands/InfoCommandHandler.cs index 39af0bae3..1a97f2b2f 100644 --- a/NebulaWorld/Chat/Commands/InfoCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/InfoCommandHandler.cs @@ -18,7 +18,7 @@ public void Execute(ChatWindow window, string[] parameters) { if (!Multiplayer.IsActive) { - window.SendLocalChatMessage("This command can only be used in multiplayer!", ChatMessageType.CommandErrorMessage); + window.SendLocalChatMessage("This command can only be used in multiplayer!".Translate(), ChatMessageType.CommandErrorMessage); return; } @@ -29,10 +29,10 @@ public void Execute(ChatWindow window, string[] parameters) string output = GetServerInfoText( server, new IPUtils.IpInfo { - LANAddress = "Pending...", - WANv4Address = "Pending...", - WANv6Address = "Pending...", - PortStatus = "Pending...", + LANAddress = "Pending...".Translate(), + WANv4Address = "Pending...".Translate(), + WANv6Address = "Pending...".Translate(), + PortStatus = "Pending...".Translate(), DataState = IPUtils.DataState.Unset }, full @@ -56,38 +56,38 @@ public void Execute(ChatWindow window, string[] parameters) public static string GetServerInfoText(IServer server, IPUtils.IpInfo ipInfo, bool full) { - StringBuilder sb = new("Server info:"); + StringBuilder sb = new("Server info:".Translate()); string lan = ipInfo.LANAddress; if (IPUtils.IsIPv4(lan)) { lan = $"{FormatCopyString($"{ipInfo.LANAddress}:{server.Port}")}"; } - sb.Append($"\n Local IP address: {lan}"); + sb.Append("\n ").Append("Local IP address: ".Translate()).Append(lan); string wanv4 = ipInfo.WANv4Address; if(IPUtils.IsIPv4(wanv4)) { wanv4 = $"{FormatCopyString($"{ipInfo.WANv4Address}:{server.Port}", true, IPFilter)}"; } - sb.Append($"\n WANv4 IP address: {wanv4}"); + sb.Append("\n ").Append("WANv4 IP address: ".Translate()).Append(wanv4); string wanv6 = ipInfo.WANv6Address; if (IPUtils.IsIPv6(wanv6)) { wanv6 = $"{FormatCopyString($"{ipInfo.WANv6Address}:{server.Port}", true, IPFilter)}"; } - sb.Append($"\n WANv6 IP address: {wanv6}"); + sb.Append("\n ").Append("WANv6 IP address: ".Translate()).Append(wanv6); if (server.NgrokEnabled) { if (server.NgrokActive) { - sb.Append($"\n Ngrok address: {FormatCopyString(server.NgrokAddress, true, NgrokAddressFilter)}"); + sb.Append("\n ").Append("Ngrok address: ".Translate()).Append(FormatCopyString(server.NgrokAddress, true, NgrokAddressFilter)); } else { - sb.Append($"\n Ngrok address: Tunnel Inactive!"); + sb.Append("\n ").Append("Ngrok address: Tunnel Inactive!".Translate()); } if (server.NgrokLastErrorCode != null) @@ -96,26 +96,27 @@ public static string GetServerInfoText(IServer server, IPUtils.IpInfo ipInfo, bo } } - sb.Append($"\n Port status: {ipInfo.PortStatus}"); - sb.Append($"\n Data State: {ipInfo.DataState}"); + sb.Append("\n ").Append("Port status: ".Translate()).Append(ipInfo.PortStatus); + sb.Append("\n ").Append("Data state: ".Translate()).Append(ipInfo.DataState); TimeSpan timeSpan = DateTime.Now.Subtract(Multiplayer.Session.StartTime); - sb.Append($"\n Uptime: {(int) Math.Round(timeSpan.TotalHours)}:{timeSpan.Minutes}:{timeSpan.Seconds} up"); + sb.Append("\n ").Append("Uptime: ".Translate()).Append($"{(int) Math.Round(timeSpan.TotalHours)}:{timeSpan.Minutes}:{timeSpan.Seconds}"); - sb.Append("\n\nGame info:"); - sb.Append($"\n Game Version: {GameConfig.gameVersion.ToFullString()}"); - sb.Append($"\n Mod Version: {ThisAssembly.AssemblyFileVersion}"); + sb.Append("\n\n").Append("Game info:".Translate()); + sb.Append("\n ").Append("Game Version: ".Translate()).Append(GameConfig.gameVersion.ToFullString()); + sb.Append("\n ").Append("Mod Version: ".Translate()).Append(ThisAssembly.AssemblyFileVersion); if (full) { - sb.Append("\n\nMods installed:"); + sb.Append("\n\n").Append("Mods installed:".Translate()); + int index = 1; foreach (var kv in Chainloader.PluginInfos) { - sb.Append($"\n {kv.Key} - {kv.Value.Metadata.Version}"); + sb.Append($"\n[{index++:D2}] {kv.Value.Metadata.Name} - {kv.Value.Metadata.Version}"); } } else { - sb.Append($"\nUse '{ChatCommandRegistry.CommandPrefix}info full' to see mod list."); + sb.Append('\n').Append("Use '/info full' to see mod list.".Translate()); } return sb.ToString(); @@ -123,25 +124,26 @@ public static string GetServerInfoText(IServer server, IPUtils.IpInfo ipInfo, bo private static string GetClientInfoText(IClient client, bool full) { - StringBuilder sb = new("Client info:"); + StringBuilder sb = new("Client info:".Translate()); string ipAddress = client.ServerEndpoint.ToString(); - sb.Append($"\n Host IP address: {FormatCopyString(ipAddress, true)}"); - sb.Append($"\n Game Version: {GameConfig.gameVersion.ToFullString()}"); - sb.Append($"\n Mod Version: {ThisAssembly.AssemblyFileVersion}"); + sb.Append("\n ").Append("Host IP address: ".Translate()).Append(FormatCopyString(ipAddress, true)); + sb.Append("\n ").Append("Game Version: ".Translate()).Append(GameConfig.gameVersion.ToFullString()); + sb.Append("\n ").Append("Mod Version: ".Translate()).Append(ThisAssembly.AssemblyFileVersion); if (full) { - sb.Append("\n\nMods installed:"); + sb.Append("\n\n").Append("Mods installed:".Translate()); + int index = 1; foreach (var kv in Chainloader.PluginInfos) { - sb.Append($"\n {kv.Key} - {kv.Value.Metadata.Version}"); + sb.Append($"\n[{index++:D2}] {kv.Value.Metadata.Name} - {kv.Value.Metadata.Version}"); } } else { - sb.Append($"\nUse '{ChatCommandRegistry.CommandPrefix}info full' to see mod list."); + sb.Append('\n').Append("Use '/info full' to see mod list.".Translate()); } return sb.ToString(); @@ -201,7 +203,7 @@ private static string ReplaceChars(string s, string targetSymbols, char newVal) public string GetDescription() { - return "Get information about server"; + return "Get information about server".Translate(); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/Commands/NavigateCommandHandler.cs b/NebulaWorld/Chat/Commands/NavigateCommandHandler.cs index 0cff24b02..c7f539e55 100644 --- a/NebulaWorld/Chat/Commands/NavigateCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/NavigateCommandHandler.cs @@ -19,7 +19,7 @@ public void Execute(ChatWindow window, string[] parameters) PlanetData planet = GameMain.galaxy.PlanetById(astroID); StarData star = GameMain.galaxy.StarById(astroID); - window.SendLocalChatMessage("Starting navigation to " + ((planet != null) ? planet.displayName : star.displayName), ChatMessageType.CommandOutputMessage); + window.SendLocalChatMessage("Starting navigation to ".Translate() + ((planet != null) ? planet.displayName : star.displayName), ChatMessageType.CommandOutputMessage); return; } } @@ -28,7 +28,7 @@ public void Execute(ChatWindow window, string[] parameters) if(parameters[0] == "clear" || parameters[0] == "c") { GameMain.mainPlayer.navigation.indicatorAstroId = 0; - window.SendLocalChatMessage("navigation cleared", ChatMessageType.CommandOutputMessage); + window.SendLocalChatMessage("navigation cleared".Translate(), ChatMessageType.CommandOutputMessage); return; } if(parameters[0] == "player" || parameters[0] == "p") @@ -46,7 +46,7 @@ public void Execute(ChatWindow window, string[] parameters) { // handle indicator position update in RemotePlayerMovement.cs GameMain.mainPlayer.navigation.indicatorAstroId = 100000 + ID; - window.SendLocalChatMessage("Starting navigation to " + model.Value.Movement.Username, ChatMessageType.CommandOutputMessage); + window.SendLocalChatMessage("Starting navigation to ".Translate() + model.Value.Movement.Username, ChatMessageType.CommandOutputMessage); return; } } @@ -63,7 +63,7 @@ public void Execute(ChatWindow window, string[] parameters) { // handle indicator position update in RemotePlayerMovement.cs GameMain.mainPlayer.navigation.indicatorAstroId = 100000 + model.Value.Movement.PlayerID; - window.SendLocalChatMessage("Starting navigation to " + model.Value.Movement.Username, ChatMessageType.CommandOutputMessage); + window.SendLocalChatMessage("Starting navigation to ".Translate() + model.Value.Movement.Username, ChatMessageType.CommandOutputMessage); return; } } @@ -84,19 +84,19 @@ public void Execute(ChatWindow window, string[] parameters) if(planet.displayName == parameters[0]) { GameMain.mainPlayer.navigation.indicatorAstroId = planet.id; - window.SendLocalChatMessage("Starting navigation to " + planet.displayName, ChatMessageType.CommandOutputMessage); + window.SendLocalChatMessage("Starting navigation to ".Translate() + planet.displayName, ChatMessageType.CommandOutputMessage); return; } } } } - window.SendLocalChatMessage("Failed to start navigation, please check your input.", ChatMessageType.CommandErrorMessage); + window.SendLocalChatMessage("Failed to start navigation, please check your input.".Translate(), ChatMessageType.CommandErrorMessage); } public string GetDescription() { - return "Start navigating to a specified destination"; + return "Start navigating to a specified destination".Translate(); } public string[] GetUsage() { diff --git a/NebulaWorld/Chat/Commands/PingCommandHandler.cs b/NebulaWorld/Chat/Commands/PingCommandHandler.cs index da55bd15c..e12894a48 100644 --- a/NebulaWorld/Chat/Commands/PingCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/PingCommandHandler.cs @@ -34,7 +34,7 @@ private async Task DelayedResponse(int time) public string GetDescription() { - return "Test command"; + return "Test command".Translate(); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/Commands/ReconnectCommandHandler.cs b/NebulaWorld/Chat/Commands/ReconnectCommandHandler.cs index 60469e4c6..aad923bec 100644 --- a/NebulaWorld/Chat/Commands/ReconnectCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/ReconnectCommandHandler.cs @@ -10,7 +10,7 @@ public void Execute(ChatWindow window, string[] parameters) { if (!Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost) { - window.SendLocalChatMessage("This command can only be used in multiplayer and as client!", ChatMessageType.CommandErrorMessage); + window.SendLocalChatMessage("This command can only be used in multiplayer and as client!".Translate(), ChatMessageType.CommandErrorMessage); return; } GameStatesManager.DoFastReconnect(); @@ -23,7 +23,7 @@ public string[] GetUsage() public string GetDescription() { - return "performs a reconnect."; + return "Perform a reconnect.".Translate(); } } } diff --git a/NebulaWorld/Chat/Commands/ServerCommandHandler.cs b/NebulaWorld/Chat/Commands/ServerCommandHandler.cs index b68cfca8c..5a24f08d9 100644 --- a/NebulaWorld/Chat/Commands/ServerCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/ServerCommandHandler.cs @@ -11,7 +11,7 @@ public void Execute(ChatWindow window, string[] parameters) { if (parameters.Length < 1) { - throw new ChatCommandUsageException("Not enough arguments!"); + throw new ChatCommandUsageException("Not enough arguments!".Translate()); } if (parameters[0] == "login") { @@ -47,13 +47,13 @@ public void Execute(ChatWindow window, string[] parameters) } else { - throw new ChatCommandUsageException("Unknown command! Available commands: {login, list, save, load, info}"); + throw new ChatCommandUsageException("Unknown command! Available commands: {login, list, save, load, info}".Translate()); } } public string GetDescription() { - return "Tell dedicated server to save/load"; + return "Tell remote server to save/load".Translate(); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/Commands/SystemCommandHandler.cs b/NebulaWorld/Chat/Commands/SystemCommandHandler.cs index 1be06c3ff..1357be369 100644 --- a/NebulaWorld/Chat/Commands/SystemCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/SystemCommandHandler.cs @@ -28,21 +28,21 @@ public void Execute(ChatWindow window, string[] parameters) { foreach (PlanetData planet in star.planets) { - resp += planet.displayName + " (" + planet.id + ")" + ((planet.orbitAroundPlanet != null) ? " (moon)" : "") + "\r\n"; + resp += planet.displayName + " (" + planet.id + ")" + ((planet.orbitAroundPlanet != null) ? " (moon)".Translate() : "") + "\r\n"; } } } if (resp == "") { - resp = "Could not find given star '" + input + "'"; + resp = string.Format("Could not find given star '{0}'".Translate(), input); } window.SendLocalChatMessage(resp, ChatMessageType.CommandOutputMessage); } public string GetDescription() { - return "List planets in a system"; + return "List planets in a system".Translate(); } public string[] GetUsage() { diff --git a/NebulaWorld/Chat/Commands/WhisperCommandHandler.cs b/NebulaWorld/Chat/Commands/WhisperCommandHandler.cs index fdea1a161..40f52601d 100644 --- a/NebulaWorld/Chat/Commands/WhisperCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/WhisperCommandHandler.cs @@ -13,13 +13,13 @@ public void Execute(ChatWindow window, string[] parameters) { if (parameters.Length < 2) { - throw new ChatCommandUsageException("Not enough arguments!"); + throw new ChatCommandUsageException("Not enough arguments!".Translate()); } string senderUsername = Multiplayer.Session?.LocalPlayer?.Data?.Username ?? "UNKNOWN"; if (senderUsername == "UNKNOWN" || Multiplayer.Session == null || Multiplayer.Session.LocalPlayer == null ) { - window.SendLocalChatMessage("Not connected, can't send message", ChatMessageType.CommandErrorMessage); + window.SendLocalChatMessage("Not connected, can't send message".Translate(), ChatMessageType.CommandErrorMessage); return; } @@ -35,7 +35,7 @@ public void Execute(ChatWindow window, string[] parameters) INebulaPlayer recipient = Multiplayer.Session.Network.PlayerManager.GetConnectedPlayerByUsername(recipientUserName); if (recipient == null) { - window.SendLocalChatMessage($"Player not found: {recipientUserName}", ChatMessageType.CommandErrorMessage); + window.SendLocalChatMessage("Player not found: ".Translate() + recipientUserName, ChatMessageType.CommandErrorMessage); return; } @@ -49,7 +49,7 @@ public void Execute(ChatWindow window, string[] parameters) public string GetDescription() { - return $"Send direct message to player. Use {ChatCommandRegistry.CommandPrefix}who for valid user names"; + return string.Format("Send direct message to player. Use /who for valid user names".Translate()); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/Commands/WhoCommandHandler.cs b/NebulaWorld/Chat/Commands/WhoCommandHandler.cs index 8d3d01af4..e6d9e4d34 100644 --- a/NebulaWorld/Chat/Commands/WhoCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/WhoCommandHandler.cs @@ -3,6 +3,7 @@ using NebulaModel.Packets.Players; using NebulaWorld.MonoBehaviours.Local; using System.Text; +using static NebulaWorld.Chat.NavigateChatLinkHandler; namespace NebulaWorld.Chat.Commands { @@ -26,9 +27,9 @@ public void Execute(ChatWindow window, string[] parameters) public string GetDescription() { - return "List all players"; + return "List all players and their locations".Translate(); } - + public string[] GetUsage() { return new string[] { "" }; @@ -36,7 +37,7 @@ public string[] GetUsage() public static string BuildResultPayload(IPlayerData[] allPlayers, ILocalPlayer hostPlayer) { - StringBuilder sb = new StringBuilder($"/who results: ({allPlayers.Length} players)\r\n"); + StringBuilder sb = new StringBuilder(string.Format("/who results: ({0} players)\r\n".Translate(), allPlayers.Length)); foreach (IPlayerData playerData in allPlayers) { sb.Append(BuildWhoMessageTextForPlayer(playerData, hostPlayer)).Append("\r\n"); @@ -47,10 +48,10 @@ public static string BuildResultPayload(IPlayerData[] allPlayers, ILocalPlayer h private static string BuildWhoMessageTextForPlayer(IPlayerData playerData, ILocalPlayer localPlayer) { - StringBuilder sb = new StringBuilder($"Player {playerData.Username} ({playerData.PlayerId})"); + StringBuilder sb = new StringBuilder(string.Format("[{0}] {1}", playerData.PlayerId, FormatNavigateString(playerData.Username))); if (localPlayer.Id == playerData.PlayerId) { - sb.Append(" (host)"); + sb.Append(" (host)".Translate()); } string playerPlanetString = null; @@ -59,7 +60,7 @@ private static string BuildWhoMessageTextForPlayer(IPlayerData playerData, ILoca PlanetData playerPlanet = GameMain.galaxy.PlanetById(playerData.LocalPlanetId); if (playerPlanet != null) { - playerPlanetString = $", planet {playerPlanet.name}"; + playerPlanetString = ", " + playerPlanet.name; } } @@ -69,7 +70,7 @@ private static string BuildWhoMessageTextForPlayer(IPlayerData playerData, ILoca StarData starData = GameMain.galaxy.StarById(playerData.LocalStarId); if (starData != null) { - playerSystemString = $", in system {starData.name}"; + playerSystemString = ", " + starData.name; } } @@ -80,7 +81,7 @@ private static string BuildWhoMessageTextForPlayer(IPlayerData playerData, ILoca } else { - sb.Append(", in space"); + sb.Append(", in space".Translate()); } if (!string.IsNullOrWhiteSpace(playerSystemString)) @@ -89,7 +90,7 @@ private static string BuildWhoMessageTextForPlayer(IPlayerData playerData, ILoca } else { - sb.Append($", at coordinates {playerData.UPosition}"); + sb.Append(", at coordinates ".Translate() + playerData.UPosition); } return sb.ToString(); diff --git a/NebulaWorld/Chat/Commands/XConsoleCommandHandler.cs b/NebulaWorld/Chat/Commands/XConsoleCommandHandler.cs index 6bc80e52b..2745e10f7 100644 --- a/NebulaWorld/Chat/Commands/XConsoleCommandHandler.cs +++ b/NebulaWorld/Chat/Commands/XConsoleCommandHandler.cs @@ -16,7 +16,7 @@ public void Execute(ChatWindow window, string[] parameters) string output = xConsole.consoleText; if (output.EndsWith("Bad command.\r\n")) { - output = $">> {commandText}\n>> Bad command. Use /x -help to get list of known commands."; + output = $">> {commandText}\n" + ">> Bad command. Use /x -help to get list of known commands.".Translate(); window.SendLocalChatMessage(output, ChatMessageType.CommandErrorMessage); } else @@ -30,7 +30,7 @@ public void Execute(ChatWindow window, string[] parameters) public string GetDescription() { - return "Execute developer console command"; + return "Execute developer console command".Translate(); } public string[] GetUsage() diff --git a/NebulaWorld/Chat/RichChatLinkRegistry.cs b/NebulaWorld/Chat/RichChatLinkRegistry.cs index 6c6e5996b..abb2005fa 100644 --- a/NebulaWorld/Chat/RichChatLinkRegistry.cs +++ b/NebulaWorld/Chat/RichChatLinkRegistry.cs @@ -80,6 +80,7 @@ static RichChatLinkRegistry() { RegisterChatLinkHandler("signal", new SignalChatLinkHandler()); RegisterChatLinkHandler("copytext", new CopyTextChatLinkHandler()); + RegisterChatLinkHandler("navigate", new NavigateChatLinkHandler()); } } } \ No newline at end of file diff --git a/NebulaWorld/Factory/BuildToolManager.cs b/NebulaWorld/Factory/BuildToolManager.cs index ac8af1a71..fe00a8ab0 100644 --- a/NebulaWorld/Factory/BuildToolManager.cs +++ b/NebulaWorld/Factory/BuildToolManager.cs @@ -115,7 +115,7 @@ public void CreatePrebuildsRequest(CreatePrebuildsRequest packet) { if (packet.PrebuildId != Multiplayer.Session.Factories.GetNextPrebuildId(packet.PlanetId)) { - string warningText = $"(Desync) PrebuildId mismatch on {packet.PlanetId} planet: {packet.PrebuildId} != {Multiplayer.Session.Factories.GetNextPrebuildId(planet.factory)}. Please reconnect!"; + string warningText = string.Format("(Desync) PrebuildId mismatch {0} != {1} on planet {2}. Please reconnect!", packet.PrebuildId, Multiplayer.Session.Factories.GetNextPrebuildId(planet.factory), planet.displayName); Log.WarnInform(warningText); NebulaWorld.Warning.WarningManager.DisplayTemporaryWarning(warningText, 15000); } @@ -272,7 +272,7 @@ public bool InitialCheck(Vector3 pos) if ((now - LastCheckTime) < WAIT_TIME && LastPosition == pos) { //Stop client from sending prebuilds at the same position - UIRealtimeTip.Popup("Please wait for server respond"); + UIRealtimeTip.Popup("Please wait for server respond".Translate()); return false; } LastCheckTime = now; diff --git a/NebulaWorld/SimulatedWorld.cs b/NebulaWorld/SimulatedWorld.cs index 02f70da99..120567617 100644 --- a/NebulaWorld/SimulatedWorld.cs +++ b/NebulaWorld/SimulatedWorld.cs @@ -201,7 +201,7 @@ public void OnPlayerJoining(string Username) IsPlayerJoining = true; Multiplayer.Session.CanPause = true; GameMain.isFullscreenPaused = true; - InGamePopup.ShowInfo("Loading", Username + " joining the game, please wait\n(Use BulletTime mod to unfreeze the game)", null); + InGamePopup.ShowInfo("Loading".Translate(), string.Format("{0} joining the game, please wait\n(Use BulletTime mod to unfreeze the game)".Translate(), Username), null); } } @@ -274,7 +274,7 @@ public void SpawnRemotePlayerModel(IPlayerData playerData) // Show conneted message string planetname = GameMain.galaxy.PlanetById(playerData.LocalPlanetId)?.displayName ?? "In space"; - string message = string.Format("[{0:HH:mm}] {1} connected ({2})", DateTime.Now, playerData.Username, planetname); + string message = string.Format("[{0:HH:mm}] {1} connected ({2})".Translate(), DateTime.Now, playerData.Username, planetname); SendChatMessage(message, ChatMessageType.SystemInfoMessage); } } @@ -287,7 +287,7 @@ public void DestroyRemotePlayerModel(ushort playerId) if (remotePlayersModels.TryGetValue(playerId, out RemotePlayerModel player)) { // Show disconnected message - string message = string.Format("[{0:HH:mm}] {1} disconnected", DateTime.Now, player.Username); + string message = string.Format("[{0:HH:mm}] {1} disconnected".Translate(), DateTime.Now, player.Username); SendChatMessage(message, ChatMessageType.SystemInfoMessage); player.Destroy(); diff --git a/NebulaWorld/Universe/DysonSphereManager.cs b/NebulaWorld/Universe/DysonSphereManager.cs index 48f5967f8..561be52fb 100644 --- a/NebulaWorld/Universe/DysonSphereManager.cs +++ b/NebulaWorld/Universe/DysonSphereManager.cs @@ -153,7 +153,7 @@ public void RequestDysonSphere(int starIndex, bool showInfo = true) ClearSelection(starIndex); if (showInfo) { - InGamePopup.ShowInfo("Loading", $"Loading Dyson sphere {starData.displayName}, please wait...", null); + InGamePopup.ShowInfo("Loading".Translate(), string.Format("Loading Dyson sphere {0}, please wait".Translate(), starData.displayName), null); } } @@ -186,8 +186,8 @@ public void HandleDesync(int starIndex, INebulaConnection conn) if (IsNormal) { IsNormal = false; - InGamePopup.ShowWarning("Desync", $"Dyson sphere id[{starIndex}] {GameMain.galaxy.stars[starIndex].displayName} is desynced.", - "Reload", () => RequestDysonSphere(starIndex)); + InGamePopup.ShowWarning("Desync".Translate(), string.Format("Dyson sphere id[{0}] {1} is desynced.".Translate(), starIndex, GameMain.galaxy.stars[starIndex].displayName), + "Reload".Translate(), () => RequestDysonSphere(starIndex)); } } }