Merge pull request #3983 from pchote/polish-chat-input
Polish chat input.
This commit is contained in:
@@ -129,7 +129,6 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
public string[] Mods = { "ra" };
|
public string[] Mods = { "ra" };
|
||||||
|
|
||||||
public bool TeamChatToggle = false;
|
|
||||||
public bool ShowShellmap = true;
|
public bool ShowShellmap = true;
|
||||||
|
|
||||||
public bool ViewportEdgeScroll = true;
|
public bool ViewportEdgeScroll = true;
|
||||||
|
|||||||
@@ -185,7 +185,6 @@
|
|||||||
<Compile Include="Widgets\BackgroundWidget.cs" />
|
<Compile Include="Widgets\BackgroundWidget.cs" />
|
||||||
<Compile Include="Widgets\ButtonWidget.cs" />
|
<Compile Include="Widgets\ButtonWidget.cs" />
|
||||||
<Compile Include="Widgets\ChatDisplayWidget.cs" />
|
<Compile Include="Widgets\ChatDisplayWidget.cs" />
|
||||||
<Compile Include="Widgets\ChatEntryWidget.cs" />
|
|
||||||
<Compile Include="Widgets\CheckboxWidget.cs" />
|
<Compile Include="Widgets\CheckboxWidget.cs" />
|
||||||
<Compile Include="Widgets\ChromeMetrics.cs" />
|
<Compile Include="Widgets\ChromeMetrics.cs" />
|
||||||
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,10 +19,9 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
public readonly int RemoveTime = 0;
|
public readonly int RemoveTime = 0;
|
||||||
public readonly bool UseContrast = false;
|
public readonly bool UseContrast = false;
|
||||||
|
public string Notification = "";
|
||||||
|
|
||||||
const int logLength = 9;
|
const int logLength = 9;
|
||||||
public string Notification = "";
|
|
||||||
public bool DrawBackground = true;
|
|
||||||
int ticksUntilRemove = 0;
|
int ticksUntilRemove = 0;
|
||||||
|
|
||||||
internal List<ChatLine> recentLines = new List<ChatLine>();
|
internal List<ChatLine> recentLines = new List<ChatLine>();
|
||||||
@@ -35,13 +35,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 + 5, chatLogArea.Bottom - 5);
|
||||||
|
|
||||||
if (DrawBackground)
|
|
||||||
WidgetUtils.DrawPanel("dialog3", chatLogArea);
|
|
||||||
|
|
||||||
var font = Game.Renderer.Fonts["Regular"];
|
var font = Game.Renderer.Fonts["Regular"];
|
||||||
|
|
||||||
Game.Renderer.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
Game.Renderer.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
||||||
|
|
||||||
foreach (var line in recentLines.AsEnumerable().Reverse())
|
foreach (var line in recentLines.AsEnumerable().Reverse())
|
||||||
@@ -52,12 +48,14 @@ namespace OpenRA.Widgets
|
|||||||
if (!string.IsNullOrEmpty(line.Owner))
|
if (!string.IsNullOrEmpty(line.Owner))
|
||||||
{
|
{
|
||||||
owner = line.Owner + ":";
|
owner = line.Owner + ":";
|
||||||
inset = font.Measure(owner).X + 10;
|
inset = font.Measure(owner).X + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = WidgetUtils.WrapText(line.Text, chatLogArea.Width - inset, font);
|
var text = WidgetUtils.WrapText(line.Text, chatLogArea.Width - inset - 6, font);
|
||||||
var textLines = text.Split(new[] { '\n' }).Count();
|
chatpos.Y -= Math.Max(15, font.Measure(text).Y) + 5;
|
||||||
chatpos.Y -= 20 * textLines;
|
|
||||||
|
if (chatpos.Y < pos.Y)
|
||||||
|
break;
|
||||||
|
|
||||||
if (owner != null)
|
if (owner != null)
|
||||||
{
|
{
|
||||||
@@ -80,12 +78,14 @@ namespace OpenRA.Widgets
|
|||||||
if (Notification != null)
|
if (Notification != null)
|
||||||
Sound.Play(Notification);
|
Sound.Play(Notification);
|
||||||
|
|
||||||
while (recentLines.Count > logLength) recentLines.RemoveAt(0);
|
while (recentLines.Count > logLength)
|
||||||
|
recentLines.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveLine()
|
public void RemoveLine()
|
||||||
{
|
{
|
||||||
if (recentLines.Count > 0) recentLines.RemoveAt(0);
|
if (recentLines.Count > 0)
|
||||||
|
recentLines.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearChat()
|
public void ClearChat()
|
||||||
@@ -95,8 +95,12 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
if (RemoveTime == 0) return;
|
if (RemoveTime == 0)
|
||||||
if (--ticksUntilRemove > 0) return;
|
return;
|
||||||
|
|
||||||
|
if (--ticksUntilRemove > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
ticksUntilRemove = RemoveTime;
|
ticksUntilRemove = RemoveTime;
|
||||||
RemoveLine();
|
RemoveLine();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.Network;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
|
||||||
{
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
public class ChatEntryWidget : Widget
|
|
||||||
{
|
|
||||||
string content = "";
|
|
||||||
bool composing = false;
|
|
||||||
bool teamChat = false;
|
|
||||||
public readonly bool UseContrast = false;
|
|
||||||
|
|
||||||
readonly OrderManager orderManager;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
internal ChatEntryWidget( OrderManager orderManager )
|
|
||||||
{
|
|
||||||
this.orderManager = orderManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw()
|
|
||||||
{
|
|
||||||
if (composing)
|
|
||||||
{
|
|
||||||
var text = teamChat ? "Chat (Team): " : "Chat (All): ";
|
|
||||||
var w = Game.Renderer.Fonts["Bold"].Measure(text).X;
|
|
||||||
|
|
||||||
Game.Renderer.Fonts["Bold"].DrawTextWithContrast(text, RenderOrigin + new float2(3, 7), Color.White, Color.Black, UseContrast ? 1 : 0);
|
|
||||||
Game.Renderer.Fonts["Regular"].DrawTextWithContrast(content, RenderOrigin + new float2(3 + w, 7), Color.White, Color.Black, UseContrast ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
|
|
||||||
|
|
||||||
public override bool HandleKeyPress(KeyInput e)
|
|
||||||
{
|
|
||||||
if (e.Event == KeyInputEvent.Up) return false;
|
|
||||||
|
|
||||||
if (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER)
|
|
||||||
{
|
|
||||||
if (composing)
|
|
||||||
{
|
|
||||||
if (e.Modifiers.HasModifier(Modifiers.Shift))
|
|
||||||
{
|
|
||||||
teamChat ^= true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
composing = false;
|
|
||||||
if (content != "")
|
|
||||||
orderManager.IssueOrder(Order.Chat(teamChat, content));
|
|
||||||
content = "";
|
|
||||||
|
|
||||||
YieldKeyboardFocus();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TakeKeyboardFocus();
|
|
||||||
composing = true;
|
|
||||||
teamChat = (Game.Settings.Game.TeamChatToggle && teamChat)
|
|
||||||
^ e.Modifiers.HasModifier(Modifiers.Shift);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (composing)
|
|
||||||
{
|
|
||||||
if (e.Key == Keycode.ESCAPE)
|
|
||||||
{
|
|
||||||
composing = false;
|
|
||||||
content = "";
|
|
||||||
YieldKeyboardFocus();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Keycode.BACKSPACE)
|
|
||||||
{
|
|
||||||
if (content.Length > 0)
|
|
||||||
content = content.Remove(content.Length - 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (e.IsValidInput())
|
|
||||||
{
|
|
||||||
content += e.UnicodeChar.ToString();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,8 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
public interface ILayout { void AdjustChild(Widget w); void AdjustChildren(); }
|
public interface ILayout { void AdjustChild(Widget w); void AdjustChildren(); }
|
||||||
|
|
||||||
|
public enum ScrollPanelAlign { Bottom, Top }
|
||||||
|
|
||||||
public class ScrollPanelWidget : Widget
|
public class ScrollPanelWidget : Widget
|
||||||
{
|
{
|
||||||
public int ScrollbarWidth = 24;
|
public int ScrollbarWidth = 24;
|
||||||
@@ -28,6 +30,7 @@ namespace OpenRA.Widgets
|
|||||||
public int ContentHeight = 0;
|
public int ContentHeight = 0;
|
||||||
public ILayout Layout;
|
public ILayout Layout;
|
||||||
public int MinimumThumbSize = 10;
|
public int MinimumThumbSize = 10;
|
||||||
|
public ScrollPanelAlign Align = ScrollPanelAlign.Top;
|
||||||
protected float ListOffset = 0;
|
protected float ListOffset = 0;
|
||||||
protected bool UpPressed = false;
|
protected bool UpPressed = false;
|
||||||
protected bool DownPressed = false;
|
protected bool DownPressed = false;
|
||||||
@@ -135,12 +138,15 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public void ScrollToBottom()
|
public void ScrollToBottom()
|
||||||
{
|
{
|
||||||
ListOffset = Math.Min(0,Bounds.Height - ContentHeight);
|
ListOffset = Align == ScrollPanelAlign.Top ?
|
||||||
|
Math.Min(0, Bounds.Height - ContentHeight) :
|
||||||
|
Bounds.Height - ContentHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollToTop()
|
public void ScrollToTop()
|
||||||
{
|
{
|
||||||
ListOffset = 0;
|
ListOffset = Align == ScrollPanelAlign.Top ? 0 :
|
||||||
|
Math.Max(0, Bounds.Height - ContentHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ScrolledToBottom
|
public bool ScrolledToBottom
|
||||||
|
|||||||
@@ -35,17 +35,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
() => world.OrderGenerator is T ? icon + "-active" : icon;
|
() => world.OrderGenerator is T ? icon + "-active" : icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddChatLine(Color c, string from, string text)
|
|
||||||
{
|
|
||||||
ingameRoot.Get<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnregisterEvents()
|
|
||||||
{
|
|
||||||
Game.AddChatLine -= AddChatLine;
|
|
||||||
Game.BeforeGameStart -= UnregisterEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncIngameChromeLogic(Widget widget, World world)
|
public CncIngameChromeLogic(Widget widget, World world)
|
||||||
{
|
{
|
||||||
@@ -53,9 +42,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
world.WorldActor.Trait<CncMenuPaletteEffect>()
|
world.WorldActor.Trait<CncMenuPaletteEffect>()
|
||||||
.Fade(CncMenuPaletteEffect.EffectType.None);
|
.Fade(CncMenuPaletteEffect.EffectType.None);
|
||||||
|
|
||||||
Game.AddChatLine += AddChatLine;
|
|
||||||
Game.BeforeGameStart += UnregisterEvents;
|
|
||||||
|
|
||||||
ingameRoot = widget.Get("INGAME_ROOT");
|
ingameRoot = widget.Get("INGAME_ROOT");
|
||||||
var playerRoot = ingameRoot.Get("PLAYER_ROOT");
|
var playerRoot = ingameRoot.Get("PLAYER_ROOT");
|
||||||
|
|
||||||
@@ -64,6 +50,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
InitObserverWidgets(world, playerRoot);
|
InitObserverWidgets(world, playerRoot);
|
||||||
else
|
else
|
||||||
InitPlayerWidgets(world, playerRoot);
|
InitPlayerWidgets(world, playerRoot);
|
||||||
|
|
||||||
|
Game.LoadWidget(world, "CHAT_PANEL", playerRoot, new WidgetArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OptionsClicked()
|
public void OptionsClicked()
|
||||||
|
|||||||
@@ -153,10 +153,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gameSettings);
|
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gameSettings);
|
||||||
mouseScrollDropdown.GetText = () => gameSettings.MouseScroll.ToString();
|
mouseScrollDropdown.GetText = () => gameSettings.MouseScroll.ToString();
|
||||||
|
|
||||||
var teamchatCheckbox = inputPane.Get<CheckboxWidget>("TEAMCHAT_CHECKBOX");
|
|
||||||
teamchatCheckbox.IsChecked = () => gameSettings.TeamChatToggle;
|
|
||||||
teamchatCheckbox.OnClick = () => gameSettings.TeamChatToggle ^= true;
|
|
||||||
|
|
||||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
playerSettings.Name = nameTextfield.Text;
|
playerSettings.Name = nameTextfield.Text;
|
||||||
|
|||||||
@@ -10,71 +10,65 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Widgets;
|
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class IngameChatLogic
|
public class IngameChatLogic
|
||||||
{
|
{
|
||||||
internal World World;
|
readonly ContainerWidget chatOverlay;
|
||||||
internal readonly ContainerWidget ChatOverlay;
|
readonly ChatDisplayWidget chatOverlayDisplay;
|
||||||
internal readonly ChatDisplayWidget ChatOverlayDisplay;
|
|
||||||
|
|
||||||
|
readonly ContainerWidget chatChrome;
|
||||||
|
readonly ScrollPanelWidget chatScrollPanel;
|
||||||
|
readonly ContainerWidget chatTemplate;
|
||||||
|
readonly TextFieldWidget chatText;
|
||||||
|
|
||||||
internal readonly ContainerWidget ChatChrome;
|
bool teamChat;
|
||||||
internal readonly ScrollPanelWidget ChatScrollPanel;
|
|
||||||
internal readonly ContainerWidget ChatTemplate;
|
|
||||||
internal readonly TextFieldWidget ChatText;
|
|
||||||
|
|
||||||
private bool teamChat = false;
|
|
||||||
internal bool TeamChat
|
|
||||||
{
|
|
||||||
get { return World.LocalPlayer == null ? false : teamChat; }
|
|
||||||
set { teamChat = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public IngameChatLogic(Widget widget, OrderManager orderManager, World world)
|
public IngameChatLogic(Widget widget, OrderManager orderManager, World world)
|
||||||
{
|
{
|
||||||
World = world;
|
teamChat = world.LocalPlayer != null;
|
||||||
var chatPanel = (ContainerWidget) widget;
|
|
||||||
|
|
||||||
|
var chatPanel = (ContainerWidget)widget;
|
||||||
|
chatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
|
||||||
|
chatOverlayDisplay = chatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
|
||||||
|
chatOverlay.Visible = false;
|
||||||
|
|
||||||
ChatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
|
chatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
|
||||||
ChatOverlayDisplay = ChatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
|
chatChrome.Visible = true;
|
||||||
ChatOverlay.Visible = false;
|
|
||||||
|
|
||||||
ChatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
|
var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
|
||||||
ChatChrome.Visible = true;
|
chatMode.GetText = () => teamChat ? "Team" : "All";
|
||||||
|
chatMode.OnClick = () => teamChat ^= true;
|
||||||
|
chatMode.IsDisabled = () => world.LocalPlayer == null;
|
||||||
|
|
||||||
var chatMode = ChatChrome.Get<ButtonWidget>("CHAT_MODE");
|
chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||||
chatMode.GetText = () => TeamChat ? "Team" : "All";
|
chatText.OnTabKey = () => { teamChat ^= true; return true; };
|
||||||
chatMode.OnClick = () => TeamChat = !TeamChat;
|
chatText.OnEnterKey = () =>
|
||||||
|
|
||||||
ChatText = ChatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
|
||||||
ChatText.OnTabKey = () => { TeamChat = !TeamChat; return true; };
|
|
||||||
ChatText.OnEnterKey = () =>
|
|
||||||
{
|
{
|
||||||
ChatText.Text = ChatText.Text.Trim();
|
var team = teamChat && world.LocalPlayer != null;
|
||||||
if (ChatText.Text != "")
|
if (chatText.Text != "")
|
||||||
orderManager.IssueOrder(Order.Chat(TeamChat, ChatText.Text));
|
orderManager.IssueOrder(Order.Chat(team, chatText.Text.Trim()));
|
||||||
|
|
||||||
CloseChat();
|
CloseChat();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
ChatText.OnEscKey = () => {CloseChat(); return true; };
|
|
||||||
|
|
||||||
var chatClose = ChatChrome.Get<ButtonWidget>("CHAT_CLOSE");
|
chatText.OnEscKey = () => { CloseChat(); return true; };
|
||||||
|
|
||||||
|
var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
|
||||||
chatClose.OnClick += () => CloseChat();
|
chatClose.OnClick += () => CloseChat();
|
||||||
|
|
||||||
chatPanel.OnKeyPress = (e) =>
|
chatPanel.OnKeyPress = (e) =>
|
||||||
{
|
{
|
||||||
if (e.Event == KeyInputEvent.Up) return false;
|
if (e.Event == KeyInputEvent.Up)
|
||||||
if (!IsOpen && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER))
|
return false;
|
||||||
|
|
||||||
|
if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER))
|
||||||
{
|
{
|
||||||
var shift = e.Modifiers.HasModifier(Modifiers.Shift);
|
|
||||||
var toggle = Game.Settings.Game.TeamChatToggle ;
|
|
||||||
TeamChat = (!toggle && shift) || ( toggle && (TeamChat ^ shift) );
|
|
||||||
OpenChat();
|
OpenChat();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -82,14 +76,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChatScrollPanel = ChatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
|
chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
|
||||||
ChatTemplate = ChatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
|
chatTemplate = chatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
|
||||||
|
chatScrollPanel.RemoveChildren();
|
||||||
|
|
||||||
Game.AddChatLine += AddChatLine;
|
Game.AddChatLine += AddChatLine;
|
||||||
Game.BeforeGameStart += UnregisterEvents;
|
Game.BeforeGameStart += UnregisterEvents;
|
||||||
|
|
||||||
CloseChat();
|
CloseChat();
|
||||||
ChatOverlayDisplay.AddLine(Color.White, null, "Use RETURN key to open chat window...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterEvents()
|
void UnregisterEvents()
|
||||||
@@ -100,33 +94,32 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
public void OpenChat()
|
public void OpenChat()
|
||||||
{
|
{
|
||||||
ChatText.Text = "";
|
chatText.Text = "";
|
||||||
ChatOverlay.Visible = false;
|
chatOverlay.Visible = false;
|
||||||
ChatChrome.Visible = true;
|
chatChrome.Visible = true;
|
||||||
ChatText.TakeKeyboardFocus();
|
chatScrollPanel.ScrollToBottom();
|
||||||
|
chatText.TakeKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseChat()
|
public void CloseChat()
|
||||||
{
|
{
|
||||||
ChatOverlay.Visible = true;
|
chatOverlay.Visible = true;
|
||||||
ChatChrome.Visible = false;
|
chatChrome.Visible = false;
|
||||||
ChatText.YieldKeyboardFocus();
|
chatText.YieldKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOpen { get { return ChatChrome.IsVisible(); } }
|
|
||||||
|
|
||||||
public void AddChatLine(Color c, string from, string text)
|
public void AddChatLine(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
|
chatOverlayDisplay.AddLine(c, from, text);
|
||||||
|
|
||||||
ChatOverlayDisplay.AddLine(c, from, text);
|
var template = chatTemplate.Clone();
|
||||||
|
|
||||||
var template = ChatTemplate.Clone();
|
|
||||||
var nameLabel = template.Get<LabelWidget>("NAME");
|
var nameLabel = template.Get<LabelWidget>("NAME");
|
||||||
var textLabel = template.Get<LabelWidget>("TEXT");
|
var textLabel = template.Get<LabelWidget>("TEXT");
|
||||||
|
|
||||||
var name = "";
|
var name = "";
|
||||||
if (!string.IsNullOrEmpty(from))
|
if (!string.IsNullOrEmpty(from))
|
||||||
name = from + ":";
|
name = from + ":";
|
||||||
|
|
||||||
var font = Game.Renderer.Fonts[nameLabel.Font];
|
var font = Game.Renderer.Fonts[nameLabel.Font];
|
||||||
var nameSize = font.Measure(from);
|
var nameSize = font.Measure(from);
|
||||||
|
|
||||||
@@ -146,10 +139,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
template.Bounds.Height += dh;
|
template.Bounds.Height += dh;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatScrollPanel.AddChild(template);
|
chatScrollPanel.AddChild(template);
|
||||||
ChatScrollPanel.ScrollToBottom();
|
chatScrollPanel.ScrollToBottom();
|
||||||
Sound.PlayNotification(null, "Sounds", "ChatLine", null);
|
Sound.PlayNotification(null, "Sounds", "ChatLine", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +65,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted;
|
inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted;
|
||||||
inversescroll.OnClick = () => Game.Settings.Game.MouseScroll = (Game.Settings.Game.MouseScroll == MouseScrollType.Inverted) ? MouseScrollType.Standard : MouseScrollType.Inverted;
|
inversescroll.OnClick = () => Game.Settings.Game.MouseScroll = (Game.Settings.Game.MouseScroll == MouseScrollType.Inverted) ? MouseScrollType.Standard : MouseScrollType.Inverted;
|
||||||
|
|
||||||
var teamchatCheckbox = general.Get<CheckboxWidget>("TEAMCHAT_TOGGLE");
|
|
||||||
teamchatCheckbox.IsChecked = () => Game.Settings.Game.TeamChatToggle;
|
|
||||||
teamchatCheckbox.OnClick = () => Game.Settings.Game.TeamChatToggle ^= true;
|
|
||||||
|
|
||||||
var showShellmapCheckbox = general.Get<CheckboxWidget>("SHOW_SHELLMAP");
|
var showShellmapCheckbox = general.Get<CheckboxWidget>("SHOW_SHELLMAP");
|
||||||
showShellmapCheckbox.IsChecked = () => Game.Settings.Game.ShowShellmap;
|
showShellmapCheckbox.IsChecked = () => Game.Settings.Game.ShowShellmap;
|
||||||
showShellmapCheckbox.OnClick = () => Game.Settings.Game.ShowShellmap ^= true;
|
showShellmapCheckbox.OnClick = () => Game.Settings.Game.ShowShellmap ^= true;
|
||||||
|
|||||||
66
mods/cnc/chrome/ingame-chat.yaml
Normal file
66
mods/cnc/chrome/ingame-chat.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
Container@CHAT_PANEL:
|
||||||
|
X:(WINDOW_RIGHT - WIDTH) / 2
|
||||||
|
Y:WINDOW_BOTTOM - HEIGHT - 15
|
||||||
|
Width:550
|
||||||
|
Height:194
|
||||||
|
Logic:IngameChatLogic
|
||||||
|
Children:
|
||||||
|
Container@CHAT_OVERLAY:
|
||||||
|
Width:PARENT_RIGHT-24
|
||||||
|
Height:PARENT_BOTTOM-25
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
ChatDisplay@CHAT_DISPLAY:
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
RemoveTime:250
|
||||||
|
UseContrast: yes
|
||||||
|
Container@CHAT_CHROME:
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
Children:
|
||||||
|
Button@CHAT_MODE:
|
||||||
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
|
Width:50
|
||||||
|
Height:25
|
||||||
|
Text:Team
|
||||||
|
Font:Bold
|
||||||
|
TextField@CHAT_TEXTFIELD:
|
||||||
|
X:55
|
||||||
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
|
Width:466
|
||||||
|
Height:25
|
||||||
|
Button@CHAT_CLOSE:
|
||||||
|
X:526
|
||||||
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
|
Width:24
|
||||||
|
Height:25
|
||||||
|
Children:
|
||||||
|
Image:
|
||||||
|
ImageCollection:lobby-bits
|
||||||
|
ImageName:kick
|
||||||
|
X:6
|
||||||
|
Y:8
|
||||||
|
ScrollPanel@CHAT_SCROLLPANEL:
|
||||||
|
Y:PARENT_BOTTOM - HEIGHT - 30
|
||||||
|
Width:550
|
||||||
|
Height:164
|
||||||
|
ItemSpacing:4
|
||||||
|
Align:Bottom
|
||||||
|
Children:
|
||||||
|
Container@CHAT_TEMPLATE:
|
||||||
|
X:2
|
||||||
|
Width:PARENT_RIGHT-27
|
||||||
|
Height:16
|
||||||
|
Children:
|
||||||
|
Label@NAME:
|
||||||
|
X:3
|
||||||
|
Width:50
|
||||||
|
Height:15
|
||||||
|
VAlign:Top
|
||||||
|
Label@TEXT:
|
||||||
|
X:12
|
||||||
|
Width:PARENT_RIGHT - 17
|
||||||
|
Height:15
|
||||||
|
WordWrap:true
|
||||||
|
VAlign:Top
|
||||||
@@ -7,21 +7,6 @@ Container@INGAME_ROOT:
|
|||||||
StrategicProgress@STRATEGIC_PROGRESS:
|
StrategicProgress@STRATEGIC_PROGRESS:
|
||||||
X: WINDOW_RIGHT/2
|
X: WINDOW_RIGHT/2
|
||||||
Y: 40
|
Y: 40
|
||||||
ChatDisplay@CHAT_DISPLAY:
|
|
||||||
X:250
|
|
||||||
Y:WINDOW_BOTTOM - HEIGHT - 30
|
|
||||||
Width: 760
|
|
||||||
Height: 200
|
|
||||||
DrawBackground: False
|
|
||||||
RemoveTime:250
|
|
||||||
UseContrast: yes
|
|
||||||
Notification: scold1.aud
|
|
||||||
ChatEntry@CHAT_ENTRY:
|
|
||||||
X:250
|
|
||||||
Y:WINDOW_BOTTOM - HEIGHT
|
|
||||||
Width: 760
|
|
||||||
Height: 30
|
|
||||||
UseContrast: yes
|
|
||||||
Container@PERFORMANCE_INFO:
|
Container@PERFORMANCE_INFO:
|
||||||
Logic:PerfDebugLogic
|
Logic:PerfDebugLogic
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -293,20 +293,6 @@ Container@SETTINGS_PANEL:
|
|||||||
Height:25
|
Height:25
|
||||||
Font:Regular
|
Font:Regular
|
||||||
Text:Enabled
|
Text:Enabled
|
||||||
Label@KEYBOARD_TITLE:
|
|
||||||
X:375
|
|
||||||
Y:20
|
|
||||||
Width:340
|
|
||||||
Font:Bold
|
|
||||||
Text:Keyboard Input
|
|
||||||
Align:Center
|
|
||||||
Checkbox@TEAMCHAT_CHECKBOX:
|
|
||||||
X:375
|
|
||||||
Y:35
|
|
||||||
Width:240
|
|
||||||
Height:20
|
|
||||||
Font:Regular
|
|
||||||
Text:Shift-Enter Toggles Team Chat
|
|
||||||
Button@GENERAL_BUTTON:
|
Button@GENERAL_BUTTON:
|
||||||
Y:319
|
Y:319
|
||||||
Width:140
|
Width:140
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ ChromeLayout:
|
|||||||
mods/cnc/chrome/mapchooser.yaml
|
mods/cnc/chrome/mapchooser.yaml
|
||||||
mods/cnc/chrome/replaybrowser.yaml
|
mods/cnc/chrome/replaybrowser.yaml
|
||||||
mods/cnc/chrome/ingame.yaml
|
mods/cnc/chrome/ingame.yaml
|
||||||
|
mods/cnc/chrome/ingame-chat.yaml
|
||||||
mods/cnc/chrome/ingamemenu.yaml
|
mods/cnc/chrome/ingamemenu.yaml
|
||||||
mods/cnc/chrome/music.yaml
|
mods/cnc/chrome/music.yaml
|
||||||
mods/cnc/chrome/modchooser.yaml
|
mods/cnc/chrome/modchooser.yaml
|
||||||
|
|||||||
@@ -2,59 +2,50 @@ Container@CHAT_PANEL:
|
|||||||
X:(WINDOW_RIGHT - WIDTH) / 2
|
X:(WINDOW_RIGHT - WIDTH) / 2
|
||||||
Y:WINDOW_BOTTOM - HEIGHT - 15
|
Y:WINDOW_BOTTOM - HEIGHT - 15
|
||||||
Width:550
|
Width:550
|
||||||
Height:180
|
Height:194
|
||||||
Logic:IngameChatLogic
|
Logic:IngameChatLogic
|
||||||
Children:
|
Children:
|
||||||
Container@CHAT_OVERLAY:
|
Container@CHAT_OVERLAY:
|
||||||
X:0
|
Width:PARENT_RIGHT-24
|
||||||
Y:0
|
Height:PARENT_BOTTOM-25
|
||||||
Width:PARENT_RIGHT
|
Visible:false
|
||||||
Height:PARENT_BOTTOM-30
|
|
||||||
Visible: false
|
|
||||||
Children:
|
Children:
|
||||||
ChatDisplay@CHAT_DISPLAY:
|
ChatDisplay@CHAT_DISPLAY:
|
||||||
X:0
|
Width:PARENT_RIGHT
|
||||||
Y:0
|
Height:PARENT_BOTTOM
|
||||||
Width: PARENT_RIGHT
|
|
||||||
Height: PARENT_BOTTOM
|
|
||||||
DrawBackground: False
|
|
||||||
RemoveTime:250
|
RemoveTime:250
|
||||||
UseContrast: yes
|
UseContrast: yes
|
||||||
Container@CHAT_CHROME:
|
Container@CHAT_CHROME:
|
||||||
X:0
|
|
||||||
Y:0
|
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
Children:
|
Children:
|
||||||
Button@CHAT_MODE:
|
Button@CHAT_MODE:
|
||||||
X:0
|
|
||||||
Y:PARENT_BOTTOM - HEIGHT
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
Width: 50
|
Width:50
|
||||||
Height: 25
|
Height:25
|
||||||
Text: Team
|
Text:Team
|
||||||
Font: Bold
|
Font:Bold
|
||||||
TextField@CHAT_TEXTFIELD:
|
TextField@CHAT_TEXTFIELD:
|
||||||
X:55
|
X:55
|
||||||
Y:PARENT_BOTTOM - HEIGHT
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
Width:465
|
Width:466
|
||||||
Height:25
|
Height:25
|
||||||
Button@CHAT_CLOSE:
|
Button@CHAT_CLOSE:
|
||||||
X:525
|
X:526
|
||||||
Y:PARENT_BOTTOM - HEIGHT
|
Y:PARENT_BOTTOM - HEIGHT
|
||||||
Width: 25
|
Width:24
|
||||||
Height: 25
|
Height:25
|
||||||
Text: X
|
Text:X
|
||||||
Font: Bold
|
Font:Bold
|
||||||
ScrollPanel@CHAT_SCROLLPANEL:
|
ScrollPanel@CHAT_SCROLLPANEL:
|
||||||
X:0
|
|
||||||
Y:PARENT_BOTTOM - HEIGHT - 30
|
Y:PARENT_BOTTOM - HEIGHT - 30
|
||||||
Width:550
|
Width:550
|
||||||
Height:150
|
Height:164
|
||||||
ItemSpacing:1
|
ItemSpacing:4
|
||||||
|
Align:Bottom
|
||||||
Children:
|
Children:
|
||||||
Container@CHAT_TEMPLATE:
|
Container@CHAT_TEMPLATE:
|
||||||
X:2
|
X:2
|
||||||
Y:0
|
|
||||||
Width:PARENT_RIGHT-27
|
Width:PARENT_RIGHT-27
|
||||||
Height:16
|
Height:16
|
||||||
Children:
|
Children:
|
||||||
@@ -64,8 +55,8 @@ Container@CHAT_PANEL:
|
|||||||
Height:15
|
Height:15
|
||||||
VAlign:Top
|
VAlign:Top
|
||||||
Label@TEXT:
|
Label@TEXT:
|
||||||
X:10
|
X:12
|
||||||
Width:PARENT_RIGHT - 60
|
Width:PARENT_RIGHT - 17
|
||||||
Height:15
|
Height:15
|
||||||
WordWrap:true
|
WordWrap:true
|
||||||
VAlign:Top
|
VAlign:Top
|
||||||
|
|||||||
@@ -104,12 +104,6 @@ Background@SETTINGS_MENU:
|
|||||||
Width:200
|
Width:200
|
||||||
Height:20
|
Height:20
|
||||||
Text: Invert Mouse Drag Scrolling
|
Text: Invert Mouse Drag Scrolling
|
||||||
Checkbox@TEAMCHAT_TOGGLE:
|
|
||||||
X:0
|
|
||||||
Y:120
|
|
||||||
Width:200
|
|
||||||
Height:20
|
|
||||||
Text: Shift-Enter Toggles Team Chat
|
|
||||||
Checkbox@SHOW_SHELLMAP:
|
Checkbox@SHOW_SHELLMAP:
|
||||||
X:0
|
X:0
|
||||||
Y:150
|
Y:150
|
||||||
|
|||||||
Reference in New Issue
Block a user