emulation of old chat system
This commit is contained in:
@@ -28,6 +28,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
const int logLength = 10;
|
const int logLength = 10;
|
||||||
public string Notification = "";
|
public string Notification = "";
|
||||||
|
public bool DrawBackground = true;
|
||||||
|
|
||||||
public List<ChatLine> recentLines = new List<ChatLine>();
|
public List<ChatLine> recentLines = new List<ChatLine>();
|
||||||
|
|
||||||
@@ -42,7 +43,9 @@ namespace OpenRA.Widgets
|
|||||||
var pos = RenderOrigin;
|
var pos = RenderOrigin;
|
||||||
var chatLogArea = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
var chatLogArea = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
||||||
var chatpos = new int2(chatLogArea.X + 10, chatLogArea.Bottom - 6);
|
var chatpos = new int2(chatLogArea.X + 10, chatLogArea.Bottom - 6);
|
||||||
WidgetUtils.DrawPanel("dialog3", chatLogArea);
|
|
||||||
|
if (DrawBackground)
|
||||||
|
WidgetUtils.DrawPanel("dialog3", chatLogArea);
|
||||||
|
|
||||||
var renderer = Game.chrome.renderer;
|
var renderer = Game.chrome.renderer;
|
||||||
var font = renderer.RegularFont;
|
var font = renderer.RegularFont;
|
||||||
|
|||||||
@@ -26,20 +26,27 @@ namespace OpenRA.Widgets
|
|||||||
// a dirty hack of a widget, which likes to steal the focus when \r is pressed, and then
|
// a dirty hack of a widget, which likes to steal the focus when \r is pressed, and then
|
||||||
// refuse to give it up until \r is pressed again.
|
// refuse to give it up until \r is pressed again.
|
||||||
|
|
||||||
|
// this emulates the previous chat support, with one improvement: shift+enter can toggle the
|
||||||
|
// team/all mode *while* composing, not just on beginning to compose.
|
||||||
|
|
||||||
class ChatEntryWidget : Widget
|
class ChatEntryWidget : Widget
|
||||||
{
|
{
|
||||||
string content = "";
|
string content = "";
|
||||||
bool composing = true;
|
bool composing = false;
|
||||||
|
bool teamChat = false;
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
//if (!composing)
|
if (composing)
|
||||||
// return;
|
{
|
||||||
|
var text = teamChat ? "Chat (Team): " : "Chat (All): ";
|
||||||
|
var w = Game.chrome.renderer.BoldFont.Measure(text).X;
|
||||||
|
|
||||||
Game.chrome.renderer.BoldFont.DrawText("Chat:", RenderOrigin + new float2(3, 7), Color.White);
|
Game.chrome.renderer.BoldFont.DrawText(text, RenderOrigin + new float2(3, 7), Color.White);
|
||||||
Game.chrome.renderer.RegularFont.DrawText(content, RenderOrigin + new float2(40, 7), Color.White);
|
Game.chrome.renderer.RegularFont.DrawText(content, RenderOrigin + new float2(3 + w, 7), Color.White);
|
||||||
|
|
||||||
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool LoseFocus(MouseInput mi)
|
public override bool LoseFocus(MouseInput mi)
|
||||||
@@ -47,15 +54,25 @@ namespace OpenRA.Widgets
|
|||||||
return composing ? false : base.LoseFocus(mi);
|
return composing ? false : base.LoseFocus(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandleInput(MouseInput mi) { return false; }
|
||||||
|
|
||||||
public override bool HandleKeyPress(KeyPressEventArgs e, Modifiers modifiers)
|
public override bool HandleKeyPress(KeyPressEventArgs e, Modifiers modifiers)
|
||||||
{
|
{
|
||||||
if (e.KeyChar == '\r')
|
if (e.KeyChar == '\r')
|
||||||
{
|
{
|
||||||
if (composing)
|
if (composing)
|
||||||
{
|
{
|
||||||
|
if (modifiers.HasModifier(Modifiers.Shift))
|
||||||
|
{
|
||||||
|
teamChat ^= true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
composing = false;
|
composing = false;
|
||||||
if (content != "")
|
if (content != "")
|
||||||
Game.IssueOrder(Order.Chat(content));
|
Game.IssueOrder(teamChat
|
||||||
|
? Order.TeamChat(content)
|
||||||
|
: Order.Chat(content));
|
||||||
content = "";
|
content = "";
|
||||||
|
|
||||||
LoseFocus();
|
LoseFocus();
|
||||||
@@ -64,6 +81,8 @@ namespace OpenRA.Widgets
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TakeFocus(new MouseInput());
|
TakeFocus(new MouseInput());
|
||||||
|
composing = true;
|
||||||
|
teamChat ^= modifiers.HasModifier(Modifiers.Shift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +93,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
if (content.Length > 0)
|
if (content.Length > 0)
|
||||||
content = content.Remove(content.Length - 1);
|
content = content.Remove(content.Length - 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (!char.IsControl(e.KeyChar))
|
else if (!char.IsControl(e.KeyChar))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,21 +5,6 @@ Container@ROOT:
|
|||||||
Delegate:IngameChromeDelegate
|
Delegate:IngameChromeDelegate
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
ChatDisplay@INGAME_CHAT_DISPLAY:
|
|
||||||
Id:INGAME_CHAT_DISPLAY
|
|
||||||
X:220
|
|
||||||
Y:WINDOW_BOTTOM - HEIGHT - 30
|
|
||||||
Width: 760
|
|
||||||
Height: 200
|
|
||||||
Visible: True
|
|
||||||
Delegate: ChatDelegate
|
|
||||||
ChatEntry@INGAME_CHAT_ENTRY:
|
|
||||||
Id:INGAME_CHAT_ENTRY
|
|
||||||
X:220
|
|
||||||
Y:WINDOW_BOTTOM - HEIGHT
|
|
||||||
Width: 760
|
|
||||||
Height: 30
|
|
||||||
Visible: True
|
|
||||||
PostGame@POSTGAME_TEXT:
|
PostGame@POSTGAME_TEXT:
|
||||||
Id:POSTGAME_TEXT
|
Id:POSTGAME_TEXT
|
||||||
X:0
|
X:0
|
||||||
@@ -140,6 +125,24 @@ Container@ROOT:
|
|||||||
Text:Diplomacy
|
Text:Diplomacy
|
||||||
Align:Center
|
Align:Center
|
||||||
Bold:True
|
Bold:True
|
||||||
|
ChatDisplay@INGAME_CHAT_DISPLAY:
|
||||||
|
Id:INGAME_CHAT_DISPLAY
|
||||||
|
X:250
|
||||||
|
Y:WINDOW_BOTTOM - HEIGHT - 30
|
||||||
|
Width: 760
|
||||||
|
Height: 200
|
||||||
|
Visible: True
|
||||||
|
Delegate: ChatDelegate
|
||||||
|
ClickThrough: True
|
||||||
|
DrawBackground: False
|
||||||
|
ChatEntry@INGAME_CHAT_ENTRY:
|
||||||
|
Id:INGAME_CHAT_ENTRY
|
||||||
|
X:250
|
||||||
|
Y:WINDOW_BOTTOM - HEIGHT
|
||||||
|
Width: 760
|
||||||
|
Height: 30
|
||||||
|
Visible: True
|
||||||
|
ClickThrough: True
|
||||||
Background@PERF_BG:
|
Background@PERF_BG:
|
||||||
ClickThrough:true
|
ClickThrough:true
|
||||||
Id:PERF_BG
|
Id:PERF_BG
|
||||||
|
|||||||
Reference in New Issue
Block a user