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)