Skip to content

Commit

Permalink
Config Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MeowServer committed Aug 5, 2024
1 parent bebb7af commit 5e4f670
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
16 changes: 10 additions & 6 deletions TextChatMeow/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HintServiceMeow.Core.Enum;
using UnityEngine;

namespace TextChatMeow
Expand All @@ -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;
Expand All @@ -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查看聊天指令";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace TextChatMeow
{
internal class PlayerMessageHandler
internal class DisplayManager
{
private static Config Config => Plugin.instance.Config;

private static readonly List<PlayerMessageHandler> MessagesManagers = new List<PlayerMessageHandler>();
private static readonly List<DisplayManager> MessagesManagers = new List<DisplayManager>();

private static CoroutineHandle _autoUpdateCoroutine = Timing.RunCoroutine(AutoUpdateMethod());

Expand All @@ -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<Hint> _messageSlots = new List<Hint>()
{
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);
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions TextChatMeow/MessageHandler/MessageClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions TextChatMeow/MessageHandler/MessagesList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static IEnumerator<float> 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";
Expand All @@ -103,7 +103,7 @@ private static IEnumerator<float> 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) );
}

}
Expand Down
4 changes: 2 additions & 2 deletions TextChatMeow/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion TextChatMeow/TextChatMeow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
<Compile Include="API\SystemMessageSender.cs" />
<Compile Include="Commands\IChatCommand.cs" />
<Compile Include="Commands\CommandTools.cs" />
<Compile Include="MessageHandler\PlayerMessageHandler.cs" />
<Compile Include="MessageHandler\DisplayManager.cs" />
<Compile Include="MessageHandler\MessagesList.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Commands\Commands.cs" />
Expand Down

0 comments on commit 5e4f670

Please sign in to comment.