Display lobby options in-game on a dedicated tab

This commit is contained in:
Ivaylo Draganov
2021-02-08 19:14:32 +02:00
committed by Paul Chote
parent fc5f8fcd31
commit 3e0834b4ef
10 changed files with 129 additions and 10 deletions

View File

@@ -18,28 +18,31 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
public enum IngameInfoPanel { AutoSelect, Map, Objectives, Debug, Chat }
public enum IngameInfoPanel { AutoSelect, Map, Objectives, Debug, Chat, LobbbyOptions }
class GameInfoLogic : ChromeLogic
{
readonly World world;
readonly ModData modData;
readonly Action<bool> hideMenu;
readonly IObjectivesPanel iop;
IngameInfoPanel activePanel;
bool hasError;
[ObjectCreator.UseCtor]
public GameInfoLogic(Widget widget, World world, IngameInfoPanel initialPanel, Action<bool> hideMenu)
public GameInfoLogic(Widget widget, ModData modData, World world, IngameInfoPanel initialPanel, Action<bool> hideMenu)
{
var panels = new Dictionary<IngameInfoPanel, (string Panel, string Label, Action<ButtonWidget, Widget> Setup)>()
{
{ IngameInfoPanel.Objectives, ("OBJECTIVES_PANEL", "Objectives", SetupObjectivesPanel) },
{ IngameInfoPanel.Map, ("MAP_PANEL", "Briefing", SetupMapPanel) },
{ IngameInfoPanel.LobbbyOptions, ("LOBBY_OPTIONS_PANEL", "Options", SetupLobbyOptionsPanel) },
{ IngameInfoPanel.Debug, ("DEBUG_PANEL", "Debug", SetupDebugPanel) },
{ IngameInfoPanel.Chat, ("CHAT_PANEL", "Chat", SetupChatPanel) }
};
this.world = world;
this.modData = modData;
this.hideMenu = hideMenu;
activePanel = initialPanel;
@@ -58,6 +61,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (missionData != null && !string.IsNullOrEmpty(missionData.Briefing))
visiblePanels.Add(IngameInfoPanel.Map);
// Lobby Options tab
visiblePanels.Add(IngameInfoPanel.LobbbyOptions);
// Debug/Cheats tab
// Can't use DeveloperMode.Enabled because there is a hardcoded hack to *always*
// enable developer mode for singleplayer games, but we only want to show the button
@@ -135,6 +141,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Game.LoadWidget(world, "MAP_PANEL", mapPanelContainer, new WidgetArgs());
}
void SetupLobbyOptionsPanel(ButtonWidget mapTabButton, Widget optionsPanelContainer)
{
Game.LoadWidget(world, "LOBBY_OPTIONS_PANEL", optionsPanelContainer, new WidgetArgs()
{
{ "getMap", (Func<MapPreview>)(() => modData.MapCache[world.Map.Uid]) },
{ "configurationDisabled", (Func<bool>)(() => true) }
});
}
void SetupDebugPanel(ButtonWidget debugTabButton, Widget debugPanelContainer)
{
if (debugTabButton != null)

View File

@@ -0,0 +1,48 @@
Container@LOBBY_OPTIONS_PANEL:
Height: PARENT_BOTTOM
Width: PARENT_RIGHT
Children:
ScrollPanel:
Logic: LobbyOptionsLogic
X: 15
Y: 15
Width: 482
Height: 345
Children:
Container@LOBBY_OPTIONS:
X: 18
Y: 9
Width: PARENT_RIGHT - 24 - 18
Children:
Container@CHECKBOX_ROW_TEMPLATE:
Height: 34
Children:
Checkbox@A:
Width: 220
Height: 20
Font: Regular
Visible: False
TooltipContainer: TOOLTIP_CONTAINER
Checkbox@B:
X: 225
Width: 220
Height: 20
Font: Regular
Visible: False
TooltipContainer: TOOLTIP_CONTAINER
Container@DROPDOWN_ROW_TEMPLATE:
Height: 34
Width: PARENT_RIGHT
Children:
Label@A_DESC:
Width: 140
Height: 25
Align: Right
Visible: False
DropDownButton@A:
X: 145
Width: 180
Height: 25
Font: Regular
Visible: False
TooltipContainer: TOOLTIP_CONTAINER

View File

@@ -116,3 +116,6 @@ Container@GAME_INFO_PANEL:
Container@CHAT_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Container@LOBBY_OPTIONS_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM

View File

@@ -8,20 +8,20 @@ Container@SKIRMISH_STATS:
Children:
Label@MISSION:
X: 15
Y: 12
Width: 85
Height: 25
Y: 17
Width: 80
Height: 20
Font: MediumBold
Text: Mission:
Label@STATS_STATUS:
X: 100
Y: 12
Width: PARENT_RIGHT - 10
Height: 25
X: 95
Y: 17
Width: PARENT_RIGHT - 110
Height: 20
Font: MediumBold
Checkbox@STATS_CHECKBOX:
X: 15
Y: 45
Y: 50
Width: 482
Height: 20
Font: Bold

View File

@@ -123,6 +123,7 @@ ChromeLayout:
cnc|chrome/ingame-infoscripterror.yaml
cnc|chrome/ingame-infoobjectives.yaml
cnc|chrome/ingame-infostats.yaml
cnc|chrome/ingame-info-lobby-options.yaml
cnc|chrome/ingame-debuginfo.yaml
cnc|chrome/music.yaml
cnc|chrome/settings.yaml

View File

@@ -0,0 +1,45 @@
Container@LOBBY_OPTIONS_PANEL:
Height: PARENT_BOTTOM
Width: PARENT_RIGHT
Children:
ScrollPanel:
Logic: LobbyOptionsLogic
X: 20
Y: 20
Width: 482
Height: 350
Children:
Container@LOBBY_OPTIONS:
X: 10
Y: 9
Width: PARENT_RIGHT - 10 - 24
Children:
Container@CHECKBOX_ROW_TEMPLATE:
Height: 30
Children:
Checkbox@A:
Width: 220
Height: 20
Visible: False
TooltipContainer: TOOLTIP_CONTAINER
Checkbox@B:
X: 225
Width: 220
Height: 20
Visible: False
TooltipContainer: TOOLTIP_CONTAINER
Container@DROPDOWN_ROW_TEMPLATE:
Height: 30
Width: PARENT_RIGHT
Children:
Label@A_DESC:
Width: 140
Height: 25
Align: Right
Visible: False
DropDownButton@A:
X: 145
Width: 180
Height: 25
Visible: False
TooltipContainer: TOOLTIP_CONTAINER

View File

@@ -146,3 +146,7 @@ Container@GAME_INFO_PANEL:
Y: 65
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Container@LOBBY_OPTIONS_PANEL:
Y: 65
Width: PARENT_RIGHT
Height: PARENT_BOTTOM

View File

@@ -76,6 +76,7 @@ ChromeLayout:
common|chrome/ingame-infobriefing.yaml
common|chrome/ingame-infoobjectives.yaml
d2k|chrome/ingame-infostats.yaml
common|chrome/ingame-info-lobby-options.yaml
d2k|chrome/ingame-observer.yaml
d2k|chrome/ingame-player.yaml
common|chrome/ingame-perf.yaml

View File

@@ -92,6 +92,7 @@ ChromeLayout:
common|chrome/ingame-infobriefing.yaml
common|chrome/ingame-infoobjectives.yaml
common|chrome/ingame-infostats.yaml
common|chrome/ingame-info-lobby-options.yaml
common|chrome/ingame-menu.yaml
ra|chrome/ingame-observer.yaml
ra|chrome/ingame-player.yaml

View File

@@ -138,6 +138,7 @@ ChromeLayout:
common|chrome/ingame-infobriefing.yaml
common|chrome/ingame-infoobjectives.yaml
common|chrome/ingame-infostats.yaml
common|chrome/ingame-info-lobby-options.yaml
ts|chrome/ingame-observer.yaml
ts|chrome/ingame-player.yaml
common|chrome/ingame-perf.yaml