-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #522 from kremnev8/Chat
Add improved chat
- Loading branch information
Showing
337 changed files
with
576,107 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using NebulaModel.Packets.Players; | ||
using NebulaModel.Utils; | ||
using System; | ||
using TMPro; | ||
using UnityEngine; | ||
using Object = UnityEngine.Object; | ||
|
||
namespace NebulaModel.DataStructures | ||
{ | ||
/// <summary> | ||
/// This is what is rendered in the chat area (already sent chat messages) | ||
/// </summary> | ||
[Serializable] | ||
public class ChatMessage | ||
{ | ||
private string text; | ||
private ChatMessageType messageType; | ||
|
||
public TMP_Text textObject; | ||
public TMP_Text notificationText; | ||
|
||
|
||
public string Text | ||
{ | ||
get => text; | ||
set | ||
{ | ||
textObject.text = value; | ||
if (notificationText != null) | ||
{ | ||
notificationText.text = value; | ||
} | ||
|
||
text = value; | ||
} | ||
} | ||
|
||
public ChatMessageType MessageType | ||
{ | ||
get => messageType; | ||
set | ||
{ | ||
textObject.color = ChatUtils.GetMessageColor(value); | ||
if (notificationText != null) | ||
{ | ||
notificationText.color = textObject.color; | ||
} | ||
|
||
messageType = value; | ||
} | ||
} | ||
|
||
public ChatMessage(GameObject textObj, string message, ChatMessageType messageType) | ||
{ | ||
textObject = textObj.GetComponent<TMP_Text>(); | ||
Text = message; | ||
MessageType = messageType; | ||
} | ||
|
||
public void DestroyMessage() | ||
{ | ||
Object.Destroy(textObject.gameObject); | ||
if (notificationText != null) | ||
{ | ||
Object.Destroy(notificationText.gameObject); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace NebulaModel.DataStructures | ||
{ | ||
public enum ChatMessageType | ||
{ | ||
PlayerMessage = 0, | ||
SystemMessage = 1, | ||
CommandUsageMessage = 2, | ||
CommandOutputMessage = 3, | ||
CommandErrorMessage = 4, | ||
PlayerMessagePrivate = 5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace NebulaModel.DataStructures | ||
{ | ||
public enum ChatPosition | ||
{ | ||
LeftMiddle = 0, | ||
RightMiddle = 1, | ||
LeftTop = 2, | ||
RightTop = 3 | ||
} | ||
|
||
public enum ChatSize | ||
{ | ||
Small = 0, | ||
Medium = 1, | ||
Big = 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Net; | ||
|
||
namespace NebulaModel.Networking | ||
{ | ||
public interface IClient | ||
{ | ||
IPEndPoint ServerEndpoint { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NebulaModel.Networking | ||
{ | ||
public interface IServer | ||
{ | ||
int Port { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace NebulaModel.Packets.Players | ||
{ | ||
public class ChatCommandWhisperPacket | ||
{ | ||
public string SenderUsername { get; set; } | ||
public string RecipientUsername { get; set; } | ||
public string Message { get; set; } | ||
|
||
public ChatCommandWhisperPacket() { } | ||
|
||
public ChatCommandWhisperPacket(string sender, string recipient, string message) | ||
{ | ||
SenderUsername = sender; | ||
RecipientUsername = recipient; | ||
Message = message; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace NebulaModel.Packets.Players | ||
{ | ||
public class ChatCommandWhoPacket | ||
{ | ||
public bool IsRequest { get; set; } | ||
public string ResponsePayload { get; set; } | ||
|
||
public ChatCommandWhoPacket() { } | ||
|
||
public ChatCommandWhoPacket(bool isRequest, string responsePayload) | ||
{ | ||
IsRequest = isRequest; | ||
#if DEBUG | ||
if (!isRequest) | ||
{ | ||
Assert.False(string.IsNullOrEmpty(responsePayload)); | ||
} | ||
#endif | ||
ResponsePayload = responsePayload; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using NebulaModel.DataStructures; | ||
using System; | ||
|
||
namespace NebulaModel.Packets.Players | ||
{ | ||
public class NewChatMessagePacket | ||
{ | ||
public ChatMessageType MessageType { get; set; } | ||
public string MessageText { get; set; } | ||
public long SentAt { get; set; } | ||
public string UserName { get; set; } | ||
|
||
public NewChatMessagePacket() { } | ||
|
||
public NewChatMessagePacket(ChatMessageType messageType, string messageText, DateTime sentAt, string userName) | ||
{ | ||
MessageType = messageType; | ||
MessageText = messageText; | ||
SentAt = sentAt.ToBinary(); | ||
UserName = userName; | ||
} | ||
} | ||
} |
Oops, something went wrong.