Make TextFieldWidget generic; Hook up teamchat and make it actually work in the lobby
This commit is contained in:
@@ -43,8 +43,9 @@ namespace OpenRA.Network
|
|||||||
if (client != null && Chrome.chatWidget != null)
|
if (client != null && Chrome.chatWidget != null)
|
||||||
{
|
{
|
||||||
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
||||||
var isAlly = player != null && Game.world.LocalPlayer != null
|
var isAlly = (world.GameHasStarted) ?
|
||||||
&& player.Stances[Game.world.LocalPlayer] == Stance.Ally;
|
player != null && Game.world.LocalPlayer != null && player.Stances[Game.world.LocalPlayer] == Stance.Ally :
|
||||||
|
client.Team == Game.LocalClient.Team;
|
||||||
|
|
||||||
if (isAlly)
|
if (isAlly)
|
||||||
Chrome.chatWidget.AddLine(client, "(Team) " + order.TargetString);
|
Chrome.chatWidget.AddLine(client, "(Team) " + order.TargetString);
|
||||||
|
|||||||
@@ -69,6 +69,23 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||||
Chrome.chatWidget = lobby.GetWidget("CHAT_DISPLAY") as ChatDisplayWidget;
|
Chrome.chatWidget = lobby.GetWidget("CHAT_DISPLAY") as ChatDisplayWidget;
|
||||||
|
|
||||||
|
|
||||||
|
bool teamChat = false;
|
||||||
|
var chatLabel = lobby.GetWidget("LABEL_CHATTYPE") as LabelWidget;
|
||||||
|
var chatTextField = lobby.GetWidget("CHAT_TEXTFIELD") as TextFieldWidget;
|
||||||
|
chatTextField.OnEnterKey = text =>
|
||||||
|
{
|
||||||
|
var order = (teamChat) ? Order.TeamChat( text ) : Order.Chat( text );
|
||||||
|
Game.IssueOrder( order );
|
||||||
|
};
|
||||||
|
|
||||||
|
chatTextField.OnTabKey = text =>
|
||||||
|
{
|
||||||
|
teamChat ^= true;
|
||||||
|
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayerList()
|
void UpdatePlayerList()
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
class TextFieldWidget : Widget
|
class TextFieldWidget : Widget
|
||||||
{
|
{
|
||||||
string TextBuffer = "";
|
public string TextBuffer = "";
|
||||||
public int VisualHeight = 1;
|
public int VisualHeight = 1;
|
||||||
|
public Action<string> OnEnterKey = text => {};
|
||||||
|
public Action<string> OnTabKey = text => {};
|
||||||
|
|
||||||
public TextFieldWidget()
|
public TextFieldWidget()
|
||||||
: base()
|
: base()
|
||||||
@@ -83,10 +85,13 @@ namespace OpenRA.Widgets
|
|||||||
if (e.KeyChar == '\r')
|
if (e.KeyChar == '\r')
|
||||||
{
|
{
|
||||||
if (TextBuffer.Length > 0)
|
if (TextBuffer.Length > 0)
|
||||||
Game.IssueOrder( Order.Chat( TextBuffer ) );
|
OnEnterKey(TextBuffer);
|
||||||
TextBuffer = "";
|
TextBuffer = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.KeyChar == '\t')
|
||||||
|
OnTabKey(TextBuffer);
|
||||||
|
|
||||||
TypeChar(e.KeyChar);
|
TypeChar(e.KeyChar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,8 +500,8 @@ Container:
|
|||||||
Height:190
|
Height:190
|
||||||
Notification: beepy2.aud
|
Notification: beepy2.aud
|
||||||
#rabeep1.aud for ra
|
#rabeep1.aud for ra
|
||||||
Label@LABEL_LOBBY_TEAM:
|
Label@LABEL_CHATTYPE:
|
||||||
Id:LABEL_LOBBY_TEAM
|
Id:LABEL_CHATTYPE
|
||||||
Width:70
|
Width:70
|
||||||
Height:25
|
Height:25
|
||||||
X:0
|
X:0
|
||||||
|
|||||||
Reference in New Issue
Block a user