Use the newly polished text entry in C&C.
This commit is contained in:
@@ -130,7 +130,6 @@ namespace OpenRA.GameRules
|
||||
{
|
||||
public string[] Mods = { "ra" };
|
||||
|
||||
public bool TeamChatToggle = false;
|
||||
public bool ShowShellmap = true;
|
||||
|
||||
public bool ViewportEdgeScroll = true;
|
||||
|
||||
@@ -185,7 +185,6 @@
|
||||
<Compile Include="Widgets\BackgroundWidget.cs" />
|
||||
<Compile Include="Widgets\ButtonWidget.cs" />
|
||||
<Compile Include="Widgets\ChatDisplayWidget.cs" />
|
||||
<Compile Include="Widgets\ChatEntryWidget.cs" />
|
||||
<Compile Include="Widgets\CheckboxWidget.cs" />
|
||||
<Compile Include="Widgets\ChromeMetrics.cs" />
|
||||
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,17 +35,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
() => 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]
|
||||
public CncIngameChromeLogic(Widget widget, World world)
|
||||
{
|
||||
@@ -53,9 +42,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
world.WorldActor.Trait<CncMenuPaletteEffect>()
|
||||
.Fade(CncMenuPaletteEffect.EffectType.None);
|
||||
|
||||
Game.AddChatLine += AddChatLine;
|
||||
Game.BeforeGameStart += UnregisterEvents;
|
||||
|
||||
ingameRoot = widget.Get("INGAME_ROOT");
|
||||
var playerRoot = ingameRoot.Get("PLAYER_ROOT");
|
||||
|
||||
@@ -64,6 +50,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
InitObserverWidgets(world, playerRoot);
|
||||
else
|
||||
InitPlayerWidgets(world, playerRoot);
|
||||
|
||||
Game.LoadWidget(world, "CHAT_PANEL", playerRoot, new WidgetArgs());
|
||||
}
|
||||
|
||||
public void OptionsClicked()
|
||||
|
||||
@@ -153,10 +153,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gameSettings);
|
||||
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 = () =>
|
||||
{
|
||||
playerSettings.Name = nameTextfield.Text;
|
||||
|
||||
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:
|
||||
X: WINDOW_RIGHT/2
|
||||
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:
|
||||
Logic:PerfDebugLogic
|
||||
Children:
|
||||
|
||||
@@ -293,20 +293,6 @@ Container@SETTINGS_PANEL:
|
||||
Height:25
|
||||
Font:Regular
|
||||
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:
|
||||
Y:319
|
||||
Width:140
|
||||
|
||||
@@ -76,6 +76,7 @@ ChromeLayout:
|
||||
mods/cnc/chrome/mapchooser.yaml
|
||||
mods/cnc/chrome/replaybrowser.yaml
|
||||
mods/cnc/chrome/ingame.yaml
|
||||
mods/cnc/chrome/ingame-chat.yaml
|
||||
mods/cnc/chrome/ingamemenu.yaml
|
||||
mods/cnc/chrome/music.yaml
|
||||
mods/cnc/chrome/modchooser.yaml
|
||||
|
||||
Reference in New Issue
Block a user