From 705414fa2a2941f64973a5d2f60a027b269ff2ab Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:03:32 +0800 Subject: [PATCH] Add config option EnableBattleMessage --- NebulaModel/DataStructures/Chat/ChatMessageType.cs | 9 +++++---- NebulaModel/MultiplayerOptions.cs | 4 ++++ NebulaModel/Utils/ChatUtils.cs | 3 +++ NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs | 1 + NebulaWorld/SimulatedWorld.cs | 9 ++------- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/NebulaModel/DataStructures/Chat/ChatMessageType.cs b/NebulaModel/DataStructures/Chat/ChatMessageType.cs index 9aa26e3ed..b56534615 100644 --- a/NebulaModel/DataStructures/Chat/ChatMessageType.cs +++ b/NebulaModel/DataStructures/Chat/ChatMessageType.cs @@ -5,8 +5,9 @@ public enum ChatMessageType PlayerMessage = 0, SystemInfoMessage = 1, SystemWarnMessage = 2, - CommandUsageMessage = 3, - CommandOutputMessage = 4, - CommandErrorMessage = 5, - PlayerMessagePrivate = 6 + BattleMessage = 3, + CommandUsageMessage = 4, + CommandOutputMessage = 5, + CommandErrorMessage = 6, + PlayerMessagePrivate = 7 } diff --git a/NebulaModel/MultiplayerOptions.cs b/NebulaModel/MultiplayerOptions.cs index 71180dc8a..b9eed4492 100644 --- a/NebulaModel/MultiplayerOptions.cs +++ b/NebulaModel/MultiplayerOptions.cs @@ -142,6 +142,10 @@ public bool StreamerMode [Category("Chat")] public bool EnableInfoMessage { get; set; } = true; + [DisplayName("Show battle notification message")] + [Category("Chat")] + public bool EnableBattleMessage { get; set; } = true; + [DisplayName("Default chat position")] [Category("Chat")] public ChatPosition DefaultChatPosition { get; set; } = ChatPosition.LeftMiddle; diff --git a/NebulaModel/Utils/ChatUtils.cs b/NebulaModel/Utils/ChatUtils.cs index fc75a0120..69f8b8f3d 100644 --- a/NebulaModel/Utils/ChatUtils.cs +++ b/NebulaModel/Utils/ChatUtils.cs @@ -98,6 +98,9 @@ public static Color GetMessageColor(ChatMessageType messageType) case ChatMessageType.SystemWarnMessage: return new Color(1, 0.95f, 0, 1); + case ChatMessageType.BattleMessage: + return Color.cyan; + case ChatMessageType.CommandUsageMessage: return new Color(1, 0.65f, 0, 1); diff --git a/NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs b/NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs index 4f3a7553a..820d8a8e3 100644 --- a/NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs +++ b/NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs @@ -203,6 +203,7 @@ public ChatMessage SendLocalChatMessage(string text, ChatMessageType messageType { case ChatMessageType.SystemInfoMessage when !Config.Options.EnableInfoMessage: case ChatMessageType.SystemWarnMessage when !Config.Options.EnableWarnMessage: + case ChatMessageType.BattleMessage when !Config.Options.EnableBattleMessage: return null; case ChatMessageType.PlayerMessage: break; diff --git a/NebulaWorld/SimulatedWorld.cs b/NebulaWorld/SimulatedWorld.cs index b576dd470..7b5f89443 100644 --- a/NebulaWorld/SimulatedWorld.cs +++ b/NebulaWorld/SimulatedWorld.cs @@ -294,7 +294,7 @@ public void SpawnRemotePlayerModel(IPlayerData playerData) var planetname = GameMain.galaxy.PlanetById(playerData.LocalPlanetId)?.displayName ?? "In space"; var message = string.Format("[{0:HH:mm}] {1} connected ({2})".Translate(), DateTime.Now, playerData.Username, planetname); - SendChatMessage(message); + ChatManager.Instance.SendChatMessage(message, ChatMessageType.SystemInfoMessage); } } @@ -308,7 +308,7 @@ public void DestroyRemotePlayerModel(ushort playerId) } // Show disconnected message var message = string.Format("[{0:HH:mm}] {1} disconnected".Translate(), DateTime.Now, player.Username); - SendChatMessage(message); + ChatManager.Instance.SendChatMessage(message, ChatMessageType.SystemInfoMessage); player.Destroy(); remotePlayersModels.Remove(playerId); @@ -584,11 +584,6 @@ public static int GetUniverseObserveLevel() return level; } - private static void SendChatMessage(string text, ChatMessageType messageType = ChatMessageType.SystemInfoMessage) - { - ChatManager.Instance.SendChatMessage(text, messageType); - } - private sealed class ThreadSafe { internal readonly Dictionary RemotePlayersModels = new();