Replace the lobby chat textfield with the widget; teamchat and ingame chat don't work yet
This commit is contained in:
@@ -29,39 +29,7 @@ namespace OpenRA
|
||||
class Chat
|
||||
{
|
||||
const int logLength = 10;
|
||||
|
||||
public List<ChatLine> recentLines = new List<ChatLine>();
|
||||
public string typing = "";
|
||||
public bool isChatting = true;
|
||||
public bool isTeamChat = false;
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
if( isChatting && typing.Length > 0 )
|
||||
Game.IssueOrder( isTeamChat ? Order.TeamChat( typing ) : Order.Chat( typing ) );
|
||||
|
||||
typing = "";
|
||||
if( Game.orderManager.GameStarted )
|
||||
isChatting ^= true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
typing = "";
|
||||
isChatting = false;
|
||||
recentLines.Clear();
|
||||
}
|
||||
|
||||
public void TypeChar(char c)
|
||||
{
|
||||
if (c == '\b' || c == 0x7f)
|
||||
{
|
||||
if (typing.Length > 0)
|
||||
typing = typing.Remove(typing.Length - 1);
|
||||
}
|
||||
else if (!char.IsControl(c))
|
||||
typing += c;
|
||||
}
|
||||
|
||||
public void AddLine(Session.Client p, string text)
|
||||
{
|
||||
|
||||
@@ -173,7 +173,6 @@ namespace OpenRA
|
||||
var typingBox = new Rectangle(r.Left + 20, r.Bottom - 77, r.Width - 40, 27);
|
||||
var chatBox = new Rectangle(r.Left + 20, r.Bottom - 269, r.Width - 40, 190);
|
||||
|
||||
DrawDialogBackground(typingBox, "dialog2");
|
||||
DrawDialogBackground(chatBox, "dialog3");
|
||||
|
||||
DrawChat(typingBox, chatBox);
|
||||
@@ -192,14 +191,6 @@ namespace OpenRA
|
||||
var chatpos = new int2(chatLogArea.X + 10, chatLogArea.Bottom - 6);
|
||||
ChatWidth = chatLogArea.Width - 10;
|
||||
|
||||
renderer.Device.EnableScissor(typingArea.Left, typingArea.Top, typingArea.Width, typingArea.Height);
|
||||
if (Game.chat.isChatting)
|
||||
RenderChatLine(new ChatLine { Owner = Game.chat.isTeamChat ? "TeamChat:" : "Chat:", Text = Game.chat.typing },
|
||||
new int2(typingArea.X + 10, typingArea.Y + 6));
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
renderer.Device.DisableScissor();
|
||||
|
||||
renderer.Device.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
||||
foreach (var line in Game.chat.recentLines.AsEnumerable().Reverse())
|
||||
{
|
||||
@@ -222,8 +213,8 @@ namespace OpenRA
|
||||
public int2 lastMousePos;
|
||||
public bool HandleInput(World world, MouseInput mi)
|
||||
{
|
||||
if (selectedWidget != null)
|
||||
return selectedWidget.HandleInput(mi);
|
||||
if (selectedWidget != null && selectedWidget.HandleInput(mi))
|
||||
return true;
|
||||
|
||||
if (rootWidget.HandleInput(mi))
|
||||
return true;
|
||||
|
||||
@@ -405,7 +405,7 @@ namespace OpenRA
|
||||
{
|
||||
LoadMap(LobbyInfo.GlobalSettings.Map);
|
||||
if (orderManager.GameStarted) return;
|
||||
chat.Reset();
|
||||
Chrome.selectedWidget = null;
|
||||
|
||||
world.Queries = new World.AllQueries(world);
|
||||
|
||||
@@ -497,15 +497,6 @@ namespace OpenRA
|
||||
if (chrome.HandleKeyPress(e, modifiers))
|
||||
return;
|
||||
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
chat.Toggle();
|
||||
chat.isTeamChat = modifiers.HasModifier(Modifiers.Shift);
|
||||
}
|
||||
else if (Game.chat.isChatting)
|
||||
chat.TypeChar(e.KeyChar);
|
||||
else
|
||||
{
|
||||
var c = RemapKeys.ContainsKey(e.KeyChar) ? RemapKeys[e.KeyChar] : e.KeyChar;
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
@@ -518,8 +509,9 @@ namespace OpenRA
|
||||
if (c == 09)
|
||||
BuildPaletteWidget.TabChange((Control.ModifierKeys & Keys.Shift) == Keys.Shift ? true : false);
|
||||
|
||||
// Todo: move this into the widget
|
||||
BuildPaletteWidget.DoBuildingHotkey(c, world);
|
||||
}
|
||||
|
||||
|
||||
if (sync != Game.world.SyncHash())
|
||||
throw new InvalidOperationException("Desync in OnKeyPress");
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
class TextFieldWidget : Widget
|
||||
{
|
||||
string TextBuffer = "zomg text";
|
||||
string TextBuffer = "";
|
||||
public int VisualHeight = 1;
|
||||
|
||||
public TextFieldWidget()
|
||||
@@ -52,24 +52,41 @@ namespace OpenRA.Widgets
|
||||
if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y))
|
||||
return base.HandleInput(mi);
|
||||
|
||||
|
||||
if (base.HandleInput(mi))
|
||||
return true;
|
||||
|
||||
if (mi.Event == MouseInputEvent.Down)
|
||||
{
|
||||
Chrome.selectedWidget = this;
|
||||
Focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Focus()
|
||||
{
|
||||
Chrome.selectedWidget = this;
|
||||
blinkCycle = 10;
|
||||
showCursor = true;
|
||||
}
|
||||
|
||||
public override bool HandleKeyPress(System.Windows.Forms.KeyPressEventArgs e, Modifiers modifiers)
|
||||
{
|
||||
if (base.HandleKeyPress(e,modifiers))
|
||||
return true;
|
||||
|
||||
// Only take input if we are selected
|
||||
if (Chrome.selectedWidget != this)
|
||||
return false;
|
||||
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
if (TextBuffer.Length > 0)
|
||||
Game.IssueOrder( Order.Chat( TextBuffer ) );
|
||||
TextBuffer = "";
|
||||
}
|
||||
|
||||
TypeChar(e.KeyChar);
|
||||
return true;
|
||||
}
|
||||
@@ -101,8 +118,7 @@ namespace OpenRA.Widgets
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
int margin = 5;
|
||||
var font = Game.chrome.renderer.BoldFont;
|
||||
|
||||
var font = Game.chrome.renderer.RegularFont;
|
||||
|
||||
var text = TextBuffer + ((showCursor && Chrome.selectedWidget == this) ? "|" : "");
|
||||
var textSize = font.Measure(TextBuffer);
|
||||
|
||||
@@ -491,19 +491,20 @@ Container:
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Change Map
|
||||
Label@LABEL_LOBBY_TEAM:
|
||||
Id:LABEL_LOBBY_TEAM
|
||||
Width:70
|
||||
Height:25
|
||||
X:0
|
||||
Y:PARENT_BOTTOM - 75
|
||||
Text:Chat:
|
||||
Align:Right
|
||||
TextField@CHAT_TEXTFIELD:
|
||||
Id:CHAT_TEXTFIELD
|
||||
Visible:true
|
||||
X:PARENT_RIGHT-550
|
||||
Y:300
|
||||
Width:300
|
||||
Height:25
|
||||
TextField@CHAT_TEXTFIELD2:
|
||||
Id:CHAT_TEXTFIELD2
|
||||
Visible:true
|
||||
X:PARENT_RIGHT-550
|
||||
Y:250
|
||||
Width:300
|
||||
X:75
|
||||
Y:PARENT_BOTTOM - 75
|
||||
Width:700
|
||||
Height:25
|
||||
Button@DISCONNECT_BUTTON:
|
||||
Id:DISCONNECT_BUTTON
|
||||
|
||||
Reference in New Issue
Block a user