Skip to content

Commit

Permalink
Add config option EnableBattleMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Mar 9, 2024
1 parent 031e9c6 commit 705414f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions NebulaModel/DataStructures/Chat/ChatMessageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions NebulaModel/MultiplayerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions NebulaModel/Utils/ChatUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions NebulaWorld/MonoBehaviours/Local/Chat/ChatWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 2 additions & 7 deletions NebulaWorld/SimulatedWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
Expand Down Expand Up @@ -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<ushort, RemotePlayerModel> RemotePlayersModels = new();
Expand Down

0 comments on commit 705414f

Please sign in to comment.