diff --git a/TextChatMeow/Config.cs b/TextChatMeow/Config.cs index b1e5967..0618436 100644 --- a/TextChatMeow/Config.cs +++ b/TextChatMeow/Config.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using HintServiceMeow.Core.Enum; using UnityEngine; namespace TextChatMeow @@ -19,24 +20,27 @@ public class Config : IConfig public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; + public HintAlignment MessageAlignment { get; set; } = HintAlignment.Left; + public float MessageYCoordinate { get; set; } = 800; + [Description("Should the tip disappear after a while?")] public bool TipDisappears { get; set; } = true; - [Description("Should the message disappear after a while? Do not close this when AddCountDown is active, otherwise error may occur.")] + [Description("Should the message disappear after a while? Do not close this when CountDownTip is active, otherwise error may occur.")] public bool MessagesDisappears { get; set; } = true; [Description("Should the tip have a countdown in front of them? This will only be active when MessagesDisappears is active.")] - public bool AddCountDown { get; set; } = false; + public bool CountDownTip { get; set; } = false; [Description("How long should the tip display before it disappears?")] - public int TipDisplayTime { get; set; } = 10; + public int TipDisappearTime { get; set; } = 10; [Description("How long should a message display before it disappears?")] - public int MessagesHideTime { get; set; } = 10; + public int MessagesDisappearTime { get; set; } = 10; [Description("Proximity Chat Config\nAllow proximity chat?")] public bool AllowProximityChat { get; set; } = true; [Description("How far should the message goes?")] public int ProximityChatDistance { get; set; } = 20; [Description("Allow chat between SCP and Human using proximity chat?")] - public bool SCPAndHumanProximityChat { get; set; } = false; + public bool ScpAndHumanProximityChat { get; set; } = false; [Description("Allow chat through radio?")] public bool AllowRadioChat { get; set; } = true; @@ -49,7 +53,7 @@ public class Config : IConfig [Description("Allow spectators chat with alives using public chat?")] public bool AllowSpectatorsChatWithPublic { get; set; } = false; [Description("Allow chat between SCP and Human using public chat?")] - public bool SCPAndHumanPublicChat { get; set; } = false; + public bool ScpAndHumanPublicChat { get; set; } = false; [Description("Translation for chat tip")] public string ChatTip { get; set; } = "输入.help查看聊天指令"; diff --git a/TextChatMeow/MessageHandler/PlayerMessageHandler.cs b/TextChatMeow/MessageHandler/DisplayManager.cs similarity index 83% rename from TextChatMeow/MessageHandler/PlayerMessageHandler.cs rename to TextChatMeow/MessageHandler/DisplayManager.cs index ca3ed2a..8a8d675 100644 --- a/TextChatMeow/MessageHandler/PlayerMessageHandler.cs +++ b/TextChatMeow/MessageHandler/DisplayManager.cs @@ -11,11 +11,11 @@ namespace TextChatMeow { - internal class PlayerMessageHandler + internal class DisplayManager { private static Config Config => Plugin.instance.Config; - private static readonly List MessagesManagers = new List(); + private static readonly List MessagesManagers = new List(); private static CoroutineHandle _autoUpdateCoroutine = Timing.RunCoroutine(AutoUpdateMethod()); @@ -25,30 +25,30 @@ internal class PlayerMessageHandler private readonly Hint _textChatTip = new Hint { - YCoordinate = 700, - Alignment = HintAlignment.Left, + YCoordinate = Config.MessageYCoordinate, + Alignment = Config.MessageAlignment, }; private readonly List _messageSlots = new List() { new Hint { - YCoordinate = 700, - Alignment = HintAlignment.Left, + YCoordinate = Config.MessageYCoordinate + 25, + Alignment = Config.MessageAlignment, }, new Hint { - YCoordinate = 720, - Alignment = HintAlignment.Left, + YCoordinate = Config.MessageYCoordinate + 50, + Alignment = Config.MessageAlignment, }, new Hint { - YCoordinate = 740, - Alignment = HintAlignment.Left, + YCoordinate = Config.MessageYCoordinate + 75, + Alignment = Config.MessageAlignment, } }; - public PlayerMessageHandler(VerifiedEventArgs ev) + public DisplayManager(VerifiedEventArgs ev) { var playerDisplay = PlayerDisplay.Get(ev.Player); this._player = Player.Get(playerDisplay.ReferenceHub); @@ -98,9 +98,9 @@ public void UpdateMessage() string text = string.Empty; - if (Plugin.instance.Config.AddCountDown && Plugin.instance.Config.MessagesDisappears) + if (Plugin.instance.Config.CountDownTip && Plugin.instance.Config.MessagesDisappears) { - int countdown = Plugin.instance.Config.MessagesHideTime - (int)(DateTime.Now - message.TimeSent).TotalSeconds; + int countdown = Plugin.instance.Config.MessagesDisappearTime - (int)(DateTime.Now - message.TimeSent).TotalSeconds; text += $"[{countdown}]";//Add countdown in front of the message (if enabled } @@ -121,7 +121,7 @@ public void UpdateMessage() //Set tip's visibility based on the message's visibility try { - TimeSpan tipTimeToDisplay = TimeSpan.FromSeconds(Plugin.instance.Config.TipDisplayTime); + TimeSpan tipTimeToDisplay = TimeSpan.FromSeconds(Plugin.instance.Config.TipDisappearTime); if (Plugin.instance.Config.TipDisappears == false||_messageSlots.Any(x => !x.Hide) || _timeCreated + tipTimeToDisplay >= DateTime.Now) { diff --git a/TextChatMeow/MessageHandler/MessageClass.cs b/TextChatMeow/MessageHandler/MessageClass.cs index 5faecab..de154e0 100644 --- a/TextChatMeow/MessageHandler/MessageClass.cs +++ b/TextChatMeow/MessageHandler/MessageClass.cs @@ -145,7 +145,7 @@ public ProximityChatMessage(string message, Player sender) continue; } - if (!Plugin.instance.Config.SCPAndHumanProximityChat) + if (!Plugin.instance.Config.ScpAndHumanProximityChat) { if (sender.Role.Team == Team.SCPs && player.Role.Team != Team.SCPs) { @@ -274,7 +274,7 @@ public override bool CanSee(Player receiver) { if (receiver == null) return false; if (sendFromDead != receiver.IsDead && !Plugin.instance.Config.AllowSpectatorsChatWithPublic) return false; - if (sendFromSCP != receiver.IsScp && !Plugin.instance.Config.SCPAndHumanPublicChat) return false; + if (sendFromSCP != receiver.IsScp && !Plugin.instance.Config.ScpAndHumanPublicChat) return false; return true; } diff --git a/TextChatMeow/MessageHandler/MessagesList.cs b/TextChatMeow/MessageHandler/MessagesList.cs index 593cf6e..06cb617 100644 --- a/TextChatMeow/MessageHandler/MessagesList.cs +++ b/TextChatMeow/MessageHandler/MessagesList.cs @@ -88,7 +88,7 @@ private static IEnumerator MessageListCoroutineMethod() foreach(var message in messageList) { - if(DateTime.Now - message.TimeSent >= TimeSpan.FromSeconds(Plugin.instance.Config.MessagesHideTime)) + if(DateTime.Now - message.TimeSent >= TimeSpan.FromSeconds(Plugin.instance.Config.MessagesDisappearTime)) { DebugInfo += "Total Time Displayed: " + (DateTime.Now - message.TimeSent) + " | "; DebugInfo += $"{message.ToString()}\n"; @@ -103,7 +103,7 @@ private static IEnumerator MessageListCoroutineMethod() //Clear time out messages if (messageList.Count > 0 && Plugin.instance.Config.MessagesDisappears) { - _messageList?.RemoveAll(x => DateTime.Now - x.TimeSent >= TimeSpan.FromSeconds(Plugin.instance.Config.MessagesHideTime) ); + _messageList?.RemoveAll(x => DateTime.Now - x.TimeSent >= TimeSpan.FromSeconds(Plugin.instance.Config.MessagesDisappearTime) ); } } diff --git a/TextChatMeow/Plugin.cs b/TextChatMeow/Plugin.cs index 9d4d62d..0fe0045 100644 --- a/TextChatMeow/Plugin.cs +++ b/TextChatMeow/Plugin.cs @@ -70,12 +70,12 @@ public static class EventHandler { public static void CreateNewMessageManager(VerifiedEventArgs ev) { - new PlayerMessageHandler(ev); + new DisplayManager(ev); } public static void DeleteMessageManager(LeftEventArgs ev) { - PlayerMessageHandler.RemoveMessageManager(ev.Player); + DisplayManager.RemoveMessageManager(ev.Player); } } } diff --git a/TextChatMeow/TextChatMeow.csproj b/TextChatMeow/TextChatMeow.csproj index 1d94d60..8d452c6 100644 --- a/TextChatMeow/TextChatMeow.csproj +++ b/TextChatMeow/TextChatMeow.csproj @@ -309,7 +309,7 @@ - +