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 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 class GameInfoLogic : ChromeLogic
{ {
readonly World world; readonly World world;
readonly ModData modData;
readonly Action<bool> hideMenu; readonly Action<bool> hideMenu;
readonly IObjectivesPanel iop; readonly IObjectivesPanel iop;
IngameInfoPanel activePanel; IngameInfoPanel activePanel;
bool hasError; bool hasError;
[ObjectCreator.UseCtor] [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)>() var panels = new Dictionary<IngameInfoPanel, (string Panel, string Label, Action<ButtonWidget, Widget> Setup)>()
{ {
{ IngameInfoPanel.Objectives, ("OBJECTIVES_PANEL", "Objectives", SetupObjectivesPanel) }, { IngameInfoPanel.Objectives, ("OBJECTIVES_PANEL", "Objectives", SetupObjectivesPanel) },
{ IngameInfoPanel.Map, ("MAP_PANEL", "Briefing", SetupMapPanel) }, { IngameInfoPanel.Map, ("MAP_PANEL", "Briefing", SetupMapPanel) },
{ IngameInfoPanel.LobbbyOptions, ("LOBBY_OPTIONS_PANEL", "Options", SetupLobbyOptionsPanel) },
{ IngameInfoPanel.Debug, ("DEBUG_PANEL", "Debug", SetupDebugPanel) }, { IngameInfoPanel.Debug, ("DEBUG_PANEL", "Debug", SetupDebugPanel) },
{ IngameInfoPanel.Chat, ("CHAT_PANEL", "Chat", SetupChatPanel) } { IngameInfoPanel.Chat, ("CHAT_PANEL", "Chat", SetupChatPanel) }
}; };
this.world = world; this.world = world;
this.modData = modData;
this.hideMenu = hideMenu; this.hideMenu = hideMenu;
activePanel = initialPanel; activePanel = initialPanel;
@@ -58,6 +61,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (missionData != null && !string.IsNullOrEmpty(missionData.Briefing)) if (missionData != null && !string.IsNullOrEmpty(missionData.Briefing))
visiblePanels.Add(IngameInfoPanel.Map); visiblePanels.Add(IngameInfoPanel.Map);
// Lobby Options tab
visiblePanels.Add(IngameInfoPanel.LobbbyOptions);
// Debug/Cheats tab // Debug/Cheats tab
// Can't use DeveloperMode.Enabled because there is a hardcoded hack to *always* // 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 // 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()); 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) void SetupDebugPanel(ButtonWidget debugTabButton, Widget debugPanelContainer)
{ {
if (debugTabButton != null) 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: Container@CHAT_PANEL:
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Container@LOBBY_OPTIONS_PANEL:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM

View File

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

View File

@@ -123,6 +123,7 @@ ChromeLayout:
cnc|chrome/ingame-infoscripterror.yaml cnc|chrome/ingame-infoscripterror.yaml
cnc|chrome/ingame-infoobjectives.yaml cnc|chrome/ingame-infoobjectives.yaml
cnc|chrome/ingame-infostats.yaml cnc|chrome/ingame-infostats.yaml
cnc|chrome/ingame-info-lobby-options.yaml
cnc|chrome/ingame-debuginfo.yaml cnc|chrome/ingame-debuginfo.yaml
cnc|chrome/music.yaml cnc|chrome/music.yaml
cnc|chrome/settings.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 Y: 65
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: PARENT_BOTTOM 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-infobriefing.yaml
common|chrome/ingame-infoobjectives.yaml common|chrome/ingame-infoobjectives.yaml
d2k|chrome/ingame-infostats.yaml d2k|chrome/ingame-infostats.yaml
common|chrome/ingame-info-lobby-options.yaml
d2k|chrome/ingame-observer.yaml d2k|chrome/ingame-observer.yaml
d2k|chrome/ingame-player.yaml d2k|chrome/ingame-player.yaml
common|chrome/ingame-perf.yaml common|chrome/ingame-perf.yaml

View File

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

View File

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