Hide chat

This commit is contained in:
oldnapalm
2021-07-12 20:28:26 -03:00
parent 780051af4d
commit 57eb2954d9

View File

@ -20,12 +20,31 @@ namespace CoopClient
get { return CurrentFocused; }
set
{
if (value && Hidden)
{
Hidden = false;
}
MainScaleForm.CallFunction("SET_FOCUS", value ? 2 : 1, 2, "ALL");
CurrentFocused = value;
}
}
private DateTime LastMessageTime { get; set; }
private bool CurrentHidden { get; set; }
private bool Hidden
{
get { return CurrentHidden; }
set
{
MainScaleForm.CallFunction(value ? "hide" : "showFeed");
CurrentHidden = value;
}
}
public Chat()
{
MainScaleForm = new Scaleform("multiplayer_chat");
@ -43,8 +62,16 @@ namespace CoopClient
}
public void Tick()
{
if (LastMessageTime.AddSeconds(15) < DateTime.UtcNow && !Focused && !Hidden)
{
Hidden = true;
}
if (!Hidden)
{
MainScaleForm.Render2D();
}
if (!CurrentFocused)
{
@ -57,6 +84,8 @@ namespace CoopClient
public void AddMessage(string sender, string msg)
{
MainScaleForm.CallFunction("ADD_MESSAGE", sender + ":", msg);
LastMessageTime = DateTime.UtcNow;
Hidden = false;
}
public void OnKeyDown(Keys key)
@ -89,11 +118,8 @@ namespace CoopClient
case (char)8:
if (CurrentInput.Length > 0)
{
MainScaleForm.CallFunction("SET_FOCUS", 1, 2, "ALL");
MainScaleForm.CallFunction("SET_FOCUS", 2, 2, "ALL");
CurrentInput = CurrentInput.Substring(0, CurrentInput.Length - 1);
MainScaleForm.CallFunction("ADD_TEXT", CurrentInput);
CurrentInput = CurrentInput.Remove(CurrentInput.Length - 1);
MainScaleForm.CallFunction("DELETE_TEXT");
}
return;
case (char)13: