Merge pull request #9692 from pchote/lobby-irc

Integrate global chat with the lobby.
This commit is contained in:
Oliver Brakmann
2015-10-21 21:04:54 +02:00
12 changed files with 425 additions and 114 deletions

View File

@@ -37,6 +37,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
enum PanelType { Players, Options, Music, Kick, ForceStart }
PanelType panel = PanelType.Players;
enum ChatPanelType { Lobby, Global }
ChatPanelType chatPanel = ChatPanelType.Lobby;
readonly Widget lobby;
readonly Widget editablePlayerTemplate;
readonly Widget nonEditablePlayerTemplate;
@@ -45,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget nonEditableSpectatorTemplate;
readonly Widget newSpectatorTemplate;
readonly ScrollPanelWidget chatPanel;
readonly ScrollPanelWidget lobbyChatPanel;
readonly Widget chatTemplate;
readonly ScrollPanelWidget players;
@@ -567,6 +570,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (skirmishMode)
disconnectButton.Text = "Back";
var globalChat = Game.LoadWidget(null, "LOBBY_GLOBALCHAT_PANEL", lobby.Get("GLOBALCHAT_ROOT"), new WidgetArgs());
var globalChatInput = globalChat.Get<TextFieldWidget>("CHAT_TEXTFIELD");
globalChat.IsVisible = () => chatPanel == ChatPanelType.Global;
var globalChatTab = lobby.Get<ButtonWidget>("GLOBALCHAT_TAB");
globalChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Global;
globalChatTab.OnClick = () =>
{
chatPanel = ChatPanelType.Global;
globalChatInput.TakeKeyboardFocus();
};
var lobbyChat = lobby.Get("LOBBYCHAT");
lobbyChat.IsVisible = () => chatPanel == ChatPanelType.Lobby;
chatLabel = lobby.Get<LabelWidget>("LABEL_CHATTYPE");
var chatTextField = lobby.Get<TextFieldWidget>("CHAT_TEXTFIELD");
chatTextField.TakeKeyboardFocus();
@@ -576,7 +595,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true;
// Always scroll to bottom when we've typed something
chatPanel.ScrollToBottom();
lobbyChatPanel.ScrollToBottom();
orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text));
chatTextField.Text = "";
@@ -597,9 +616,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatTextField.OnEscKey = () => { chatTextField.Text = ""; return true; };
chatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
chatTemplate = chatPanel.Get("CHAT_TEMPLATE");
chatPanel.RemoveChildren();
var lobbyChatTab = lobby.Get<ButtonWidget>("LOBBYCHAT_TAB");
lobbyChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Lobby;
lobbyChatTab.OnClick = () =>
{
chatPanel = ChatPanelType.Lobby;
chatTextField.TakeKeyboardFocus();
};
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE");
lobbyChatPanel.RemoveChildren();
var settingsButton = lobby.GetOrNull<ButtonWidget>("SETTINGS_BUTTON");
if (settingsButton != null)
@@ -655,10 +682,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
template.Bounds.Height += dh;
}
var scrolledToBottom = chatPanel.ScrolledToBottom;
chatPanel.AddChild(template);
var scrolledToBottom = lobbyChatPanel.ScrolledToBottom;
lobbyChatPanel.AddChild(template);
if (scrolledToBottom)
chatPanel.ScrollToBottom(smooth: true);
lobbyChatPanel.ScrollToBottom(smooth: true);
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}

View File

@@ -28,6 +28,8 @@ namespace OpenRA.Mods.Common.Widgets
public int LeftMargin = 5;
public int RightMargin = 5;
public bool Disabled = false;
public Func<bool> OnEnterKey = () => false;
public Func<bool> OnTabKey = () => false;
public Func<bool> OnEscKey = () => false;
@@ -36,14 +38,18 @@ namespace OpenRA.Mods.Common.Widgets
public Action OnTextEdited = () => { };
public int CursorPosition { get; set; }
public Func<bool> IsDisabled = () => false;
public Func<bool> IsDisabled;
public Func<bool> IsValid = () => true;
public string Font = ChromeMetrics.Get<string>("TextfieldFont");
public Color TextColor = ChromeMetrics.Get<Color>("TextfieldColor");
public Color TextColorDisabled = ChromeMetrics.Get<Color>("TextfieldColorDisabled");
public Color TextColorInvalid = ChromeMetrics.Get<Color>("TextfieldColorInvalid");
public TextFieldWidget() { }
public TextFieldWidget()
{
IsDisabled = () => Disabled;
}
protected TextFieldWidget(TextFieldWidget widget)
: base(widget)
{
@@ -54,6 +60,7 @@ namespace OpenRA.Mods.Common.Widgets
TextColorDisabled = widget.TextColorDisabled;
TextColorInvalid = widget.TextColorInvalid;
VisualHeight = widget.VisualHeight;
IsDisabled = widget.IsDisabled;
}
public override bool YieldKeyboardFocus()

View File

@@ -0,0 +1,119 @@
Container@LOBBY_GLOBALCHAT_PANEL:
Logic: GlobalChatLogic
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Container@GLOBALCHAT_MAIN_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Background@TOPIC:
Width: 582
Height: 20
Background: panel-transparent
Children:
Label@CHANNEL_TOPIC:
X: 10
Y: 0-1
Width: PARENT_RIGHT - 20
Height: PARENT_BOTTOM
Font: TinyBold
Align: Center
ScrollPanel@HISTORY_PANEL:
Width: 582
Y: 19
Height: PARENT_BOTTOM - 19
ItemSpacing: 5
Children:
Label@HISTORY_TEMPLATE:
X: 5
Width: 530
Height: 25
WordWrap: True
TextField@CHAT_TEXTFIELD:
X: 200
Y: PARENT_BOTTOM + 5
Width: 382
Height: 25
LeftMargin: 60
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 55
Height: 25
Align: Right
Text: Global:
ScrollPanel@NICKNAME_PANEL:
X: 596
Width: PARENT_RIGHT - 596
Height: PARENT_BOTTOM
Children:
Container@NICKNAME_TEMPLATE:
Height: 20
Width: PARENT_RIGHT-25
Children:
Image@INDICATOR:
ImageCollection: lobby-bits
ImageName: admin
X: 4
Y: 9
Label@NICK:
X: 15
Width: PARENT_RIGHT-15
Height: 20
Button@DISCONNECT_BUTTON:
X: 596
Y: PARENT_BOTTOM + 5
Width: PARENT_RIGHT - 596
Height: 25
Text: Leave Chat
Font: Bold
Background@GLOBALCHAT_CONNECT_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Background: scrollpanel-bg
Children:
Label@GLOBAL_CHAT_LABEL:
Y: PARENT_BOTTOM / 4
Width: PARENT_RIGHT
Align: Center
Text: Global Chat
Font: Bold
Label@NICKNAME_LABEL:
X: 200
Y: PARENT_BOTTOM / 4 + 35
Text: Nickname:
TextField@NICKNAME_TEXTFIELD:
X: 270
Y: PARENT_BOTTOM / 4 + 25
Width: 150
Height: 25
Checkbox@CONNECT_AUTOMATICALLY_CHECKBOX:
X: 270
Y: PARENT_BOTTOM / 4 + 75
Height: 20
Width: 180
Font: Regular
Text: Connect Automatically
Button@CONNECT_BUTTON:
X: 430
Y: PARENT_BOTTOM / 4 + 25
Width: 100
Height: 25
Text: Connect
Font: Bold
TextField@FAKE_CHAT:
X: 200
Y: PARENT_BOTTOM + 5
Width: PARENT_RIGHT - 200
Height: 25
LeftMargin: 60
Disabled: true
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 55
Height: 25
Align: Right
Text: Global:

View File

@@ -1,9 +1,9 @@
Container@SERVER_LOBBY:
Logic: LobbyLogic
X: (WINDOW_RIGHT - WIDTH)/2
Y: (WINDOW_BOTTOM - 500)/2
Y: (WINDOW_BOTTOM - 560)/2
Width: 800
Height: 535
Height: 575
Children:
ColorPreviewManager@COLOR_MANAGER:
Label@SERVER_NAME:
@@ -14,7 +14,7 @@ Container@SERVER_LOBBY:
Align: Center
Background@bg:
Width: 800
Height: 500
Height: 540
Background: panel-black
Children:
Container@MAP_PREVIEW_ROOT:
@@ -57,63 +57,78 @@ Container@SERVER_LOBBY:
Y: 30
Width: 582
Height: 219
ScrollPanel@CHAT_DISPLAY:
Button@LOBBYCHAT_TAB:
X: 15
Y: PARENT_BOTTOM - 46
Width: 95
Height: 31
Text: Lobby
Button@GLOBALCHAT_TAB:
X: 115
Y: PARENT_BOTTOM - 46
Width: 95
Height: 31
Text: Global
Container@LOBBYCHAT:
X: 15
Y: 285
Width: PARENT_RIGHT - 30
Height: PARENT_BOTTOM - 324
TopBottomSpacing: 2
ItemSpacing: 2
Height: PARENT_BOTTOM - 300
Children:
Container@CHAT_TEMPLATE:
Width: PARENT_RIGHT-27
Height: 16
X: 2
Y: 0
ScrollPanel@CHAT_DISPLAY:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 30
TopBottomSpacing: 2
ItemSpacing: 2
Children:
Label@TIME:
X: 3
Width: 50
Height: 15
VAlign: Top
Label@NAME:
X: 45
Width: 50
Height: 15
VAlign: Top
Label@TEXT:
X: 55
Width: PARENT_RIGHT - 60
Height: 15
WordWrap: true
VAlign: Top
TextField@CHAT_TEXTFIELD:
X: 15
Y: PARENT_BOTTOM - HEIGHT - 15
Width: PARENT_RIGHT - 30
Height: 25
LeftMargin: 50
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 45
Container@CHAT_TEMPLATE:
Width: PARENT_RIGHT-27
Height: 16
X: 2
Y: 0
Children:
Label@TIME:
X: 3
Width: 50
Height: 15
VAlign: Top
Label@NAME:
X: 45
Width: 50
Height: 15
VAlign: Top
Label@TEXT:
X: 55
Width: PARENT_RIGHT - 60
Height: 15
WordWrap: true
VAlign: Top
TextField@CHAT_TEXTFIELD:
X: 200
Y: PARENT_BOTTOM - HEIGHT
Width: PARENT_RIGHT - 200
Height: 25
Align: Right
Text: Chat:
LeftMargin: 50
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 45
Height: 25
Align: Right
Text: Chat:
Container@GLOBALCHAT_ROOT:
X: 15
Y: 285
Width: PARENT_RIGHT - 30
Height: PARENT_BOTTOM - 330
Button@DISCONNECT_BUTTON:
Y: 499
Y: 539
Width: 140
Height: 35
Text: Leave Game
Button@SETTINGS_BUTTON:
X: 150
Y: 499
Width: 140
Height: 35
Text: Settings
Button@START_GAME_BUTTON:
X: PARENT_RIGHT - WIDTH
Y: 499
Y: 539
Width: 140
Height: 35
Text: Start Game

View File

@@ -1,9 +1,9 @@
Container@MAPCHOOSER_PANEL:
Logic: MapChooserLogic
X: (WINDOW_RIGHT - WIDTH)/2
Y: (WINDOW_BOTTOM - 500)/2
Y: (WINDOW_BOTTOM - 560)/2
Width: 800
Height: 535
Height: 575
Children:
Label@TITLE:
Width: PARENT_RIGHT
@@ -14,7 +14,7 @@ Container@MAPCHOOSER_PANEL:
Text: Select Map
Background@bg:
Width: PARENT_RIGHT
Height: 500
Height: 540
Background: panel-black
Children:
Label@FILTER_DESC:
@@ -114,34 +114,33 @@ Container@MAPCHOOSER_PANEL:
Font: Tiny
Button@BUTTON_CANCEL:
Key: escape
X: 0
Y: 499
Y: 539
Width: 140
Height: 35
Text: Cancel
Button@RANDOMMAP_BUTTON:
Key: space
X: PARENT_RIGHT - 150 - WIDTH
Y: 499
Y: 539
Width: 140
Height: 35
Text: Random
Button@DELETE_MAP_BUTTON:
X: PARENT_RIGHT - 300 - WIDTH
Y: 499
Y: 539
Width: 140
Height: 35
Text: Delete Map
Button@DELETE_ALL_MAPS_BUTTON:
X: PARENT_RIGHT - 450 - WIDTH
Y: 499
Y: 539
Width: 140
Height: 35
Text: Delete All Maps
Button@BUTTON_OK:
Key: return
X: PARENT_RIGHT - WIDTH
Y: 499
Y: 539
Width: 140
Height: 35
Text: Ok

View File

@@ -100,6 +100,7 @@ ChromeLayout:
./mods/cnc/chrome/lobby-options.yaml
./mods/cnc/chrome/lobby-music.yaml
./mods/cnc/chrome/lobby-kickdialogs.yaml
./mods/cnc/chrome/lobby-globalchat.yaml
./mods/cnc/chrome/connection.yaml
./mods/cnc/chrome/color-picker.yaml
./mods/cnc/chrome/mapchooser.yaml

View File

@@ -90,6 +90,7 @@ ChromeLayout:
./mods/d2k/chrome/lobby-options.yaml
./mods/ra/chrome/lobby-music.yaml
./mods/ra/chrome/lobby-kickdialogs.yaml
./mods/ra/chrome/lobby-globalchat.yaml
./mods/d2k/chrome/color-picker.yaml
./mods/ra/chrome/map-chooser.yaml
./mods/ra/chrome/create-server.yaml

View File

@@ -20,7 +20,7 @@ Container@GLOBALCHAT_PANEL:
Font: TinyBold
Align: Center
ScrollPanel@HISTORY_PANEL:
Y:20
Y: 20
Width: 565
Height: PARENT_BOTTOM - 50
ItemSpacing: 5

View File

@@ -0,0 +1,118 @@
Container@LOBBY_GLOBALCHAT_PANEL:
Logic: GlobalChatLogic
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Container@GLOBALCHAT_MAIN_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Background@TOPIC:
Width: 582
Height: 20
Background: dialog2
Children:
Label@CHANNEL_TOPIC:
X: 10
Y: 0-1
Width: PARENT_RIGHT - 20
Height: PARENT_BOTTOM
Font: TinyBold
Align: Center
ScrollPanel@HISTORY_PANEL:
Y: 20
Width: 582
Height: PARENT_BOTTOM - 50
ItemSpacing: 5
Children:
Label@HISTORY_TEMPLATE:
X: 5
Width: 530
Height: 25
WordWrap: True
TextField@CHAT_TEXTFIELD:
X: 205
Y: PARENT_BOTTOM - 25
Width: 582-205
Height: 25
LeftMargin: 60
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 55
Height: 25
Align: Right
Text: Global:
ScrollPanel@NICKNAME_PANEL:
X: 596
Width: PARENT_RIGHT - 596
Height: PARENT_BOTTOM - 30
Children:
Container@NICKNAME_TEMPLATE:
Height: 20
Width: PARENT_RIGHT-25
Children:
Image@INDICATOR:
ImageCollection: lobby-bits
ImageName: admin
X: 4
Y: 9
Label@NICK:
X: 15
Width: PARENT_RIGHT-15
Height: 20
Button@DISCONNECT_BUTTON:
X: 596
Y: PARENT_BOTTOM - 25
Width: PARENT_RIGHT - 596
Height: 25
Text: Leave Chat
Font: Bold
Background@GLOBALCHAT_CONNECT_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM-30
Background: scrollpanel-bg
Children:
Label@GLOBAL_CHAT_LABEL:
Y: PARENT_BOTTOM / 4
Width: PARENT_RIGHT
Align: Center
Text: Global Chat
Font: Bold
Label@NICKNAME_LABEL:
X: 200
Y: PARENT_BOTTOM / 4 + 35
Text: Nickname:
TextField@NICKNAME_TEXTFIELD:
X: 270
Y: PARENT_BOTTOM / 4 + 25
Width: 150
Height: 25
Checkbox@CONNECT_AUTOMATICALLY_CHECKBOX:
X: 270
Y: PARENT_BOTTOM / 4 + 75
Height: 20
Width: 180
Font: Regular
Text: Connect Automatically
Button@CONNECT_BUTTON:
X: 430
Y: PARENT_BOTTOM / 4 + 25
Width: 100
Height: 25
Text: Connect
Font: Bold
TextField@FAKE_CHAT:
X: 205
Y: PARENT_BOTTOM + 5
Width: PARENT_RIGHT - 205
Height: 25
LeftMargin: 60
Disabled: true
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 55
Height: 25
Align: Right
Text: Global:

View File

@@ -21,28 +21,28 @@ Background@SERVER_LOBBY:
DropDownButton@SLOTS_DROPDOWNBUTTON:
X: 20
Y: 291
Width: 180
Width: 200
Height: 25
Font: Bold
Text: Slot Admin
Button@PLAYERS_TAB:
X: 243
X: 225
Y: 285
Width: 120
Width: 126
Height: 31
Font: Bold
Text: Players
Button@OPTIONS_TAB:
X: 363
X: 351
Y: 285
Width: 120
Width: 126
Height: 31
Font: Bold
Text: Options
Button@MUSIC_TAB:
X: 483
X: 477
Y: 285
Width: 120
Width: 126
Height: 31
Font: Bold
Text: Music
@@ -58,49 +58,71 @@ Background@SERVER_LOBBY:
Height: 25
Text: Change Map
Font: Bold
ScrollPanel@CHAT_DISPLAY:
Button@LOBBYCHAT_TAB:
X: 20
Y: PARENT_BOTTOM - HEIGHT - 52
Y: PARENT_BOTTOM - 81
Width: 100
Height: 31
Text: Lobby
Font: Bold
Button@GLOBALCHAT_TAB:
X: 120
Y: PARENT_BOTTOM - 81
Width: 100
Height: 31
Text: Global
Font: Bold
Container@LOBBYCHAT:
X: 20
Y: PARENT_BOTTOM - HEIGHT - 50
Width: PARENT_RIGHT - 40
Height: 227
TopBottomSpacing: 2
ItemSpacing: 2
Height: 229
Children:
Container@CHAT_TEMPLATE:
Width: PARENT_RIGHT-27
Height: 16
X: 2
Y: 0
ScrollPanel@CHAT_DISPLAY:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 30
TopBottomSpacing: 2
ItemSpacing: 2
Children:
Label@TIME:
X: 3
Width: 50
Height: 15
VAlign: Top
Label@NAME:
X: 45
Width: 50
Height: 15
VAlign: Top
Label@TEXT:
X: 55
Width: PARENT_RIGHT - 60
Height: 15
WordWrap: true
VAlign: Top
TextField@CHAT_TEXTFIELD:
X: 20
Y: PARENT_BOTTOM - HEIGHT - 20
Width: PARENT_RIGHT - 300
Height: 25
LeftMargin: 50
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 45
Container@CHAT_TEMPLATE:
Width: PARENT_RIGHT-27
Height: 16
X: 2
Children:
Label@TIME:
X: 3
Width: 50
Height: 15
VAlign: Top
Label@NAME:
X: 45
Width: 50
Height: 15
VAlign: Top
Label@TEXT:
X: 55
Width: PARENT_RIGHT - 60
Height: 15
WordWrap: true
VAlign: Top
TextField@CHAT_TEXTFIELD:
X: 205
Y: PARENT_BOTTOM - HEIGHT
Width: PARENT_RIGHT - 205
Height: 25
Align: Right
Text: Chat:
LeftMargin: 50
Children:
Label@LABEL_CHATTYPE:
Y: 0-1
Width: 45
Height: 25
Align: Right
Text: Chat:
Container@GLOBALCHAT_ROOT:
X: 20
Y: PARENT_BOTTOM - HEIGHT - 50
Width: PARENT_RIGHT - 40
Height: 229
Button@START_GAME_BUTTON:
X: PARENT_RIGHT - WIDTH - 150
Y: PARENT_BOTTOM - HEIGHT - 20
@@ -113,7 +135,7 @@ Background@SERVER_LOBBY:
Y: PARENT_BOTTOM - HEIGHT - 20
Width: 120
Height: 25
Text: Disconnect
Text: Leave Game
Font: Bold
Container@FACTION_DROPDOWN_PANEL_ROOT:
TooltipContainer@TOOLTIP_CONTAINER:

View File

@@ -101,6 +101,7 @@ ChromeLayout:
./mods/ra/chrome/lobby-options.yaml
./mods/ra/chrome/lobby-music.yaml
./mods/ra/chrome/lobby-kickdialogs.yaml
./mods/ra/chrome/lobby-globalchat.yaml
./mods/ra/chrome/color-picker.yaml
./mods/ra/chrome/map-chooser.yaml
./mods/ra/chrome/create-server.yaml

View File

@@ -155,6 +155,7 @@ ChromeLayout:
./mods/ra/chrome/lobby-options.yaml
./mods/ra/chrome/lobby-music.yaml
./mods/ra/chrome/lobby-kickdialogs.yaml
./mods/ra/chrome/lobby-globalchat.yaml
./mods/ts/chrome/color-picker.yaml
./mods/ra/chrome/map-chooser.yaml
./mods/ra/chrome/create-server.yaml