Rename LobbyPreview.Map to LobbyLogic.MapPreview.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
static readonly Action DoNothing = () => { };
|
static readonly Action DoNothing = () => { };
|
||||||
|
|
||||||
public MapPreview Map = MapCache.UnknownMap;
|
public MapPreview MapPreview = MapCache.UnknownMap;
|
||||||
|
|
||||||
readonly Action onStart;
|
readonly Action onStart;
|
||||||
readonly Action onExit;
|
readonly Action onExit;
|
||||||
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var onSelect = new Action<string>(uid =>
|
var onSelect = new Action<string>(uid =>
|
||||||
{
|
{
|
||||||
// Don't select the same map again
|
// Don't select the same map again
|
||||||
if (uid == Map.Uid)
|
if (uid == MapPreview.Uid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
orderManager.IssueOrder(Order.Command("map " + uid));
|
orderManager.IssueOrder(Order.Command("map " + uid));
|
||||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "initialMap", Map.Uid },
|
{ "initialMap", MapPreview.Uid },
|
||||||
{ "initialTab", MapClassification.System },
|
{ "initialTab", MapClassification.System },
|
||||||
{ "onExit", DoNothing },
|
{ "onExit", DoNothing },
|
||||||
{ "onSelect", Game.IsHost ? onSelect : null },
|
{ "onSelect", Game.IsHost ? onSelect : null },
|
||||||
@@ -190,7 +190,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var slotsButton = lobby.GetOrNull<DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON");
|
var slotsButton = lobby.GetOrNull<DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON");
|
||||||
if (slotsButton != null)
|
if (slotsButton != null)
|
||||||
{
|
{
|
||||||
slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players || Map.RuleStatus != MapRuleStatus.Cached ||
|
slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players || MapPreview.RuleStatus != MapRuleStatus.Cached ||
|
||||||
(orderManager.LobbyInfo.Slots.Values.All(s => !s.AllowBots) &&
|
(orderManager.LobbyInfo.Slots.Values.All(s => !s.AllowBots) &&
|
||||||
orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) == 0);
|
orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) == 0);
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var optionsTab = lobby.Get<ButtonWidget>("OPTIONS_TAB");
|
var optionsTab = lobby.Get<ButtonWidget>("OPTIONS_TAB");
|
||||||
optionsTab.IsHighlighted = () => panel == PanelType.Options;
|
optionsTab.IsHighlighted = () => panel == PanelType.Options;
|
||||||
optionsTab.IsDisabled = () => Map.RuleStatus != MapRuleStatus.Cached || panel == PanelType.Kick || panel == PanelType.ForceStart;
|
optionsTab.IsDisabled = () => MapPreview.RuleStatus != MapRuleStatus.Cached || panel == PanelType.Kick || panel == PanelType.ForceStart;
|
||||||
optionsTab.OnClick = () => panel = PanelType.Options;
|
optionsTab.OnClick = () => panel = PanelType.Options;
|
||||||
|
|
||||||
var playersTab = lobby.Get<ButtonWidget>("PLAYERS_TAB");
|
var playersTab = lobby.Get<ButtonWidget>("PLAYERS_TAB");
|
||||||
@@ -317,9 +317,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
||||||
if (startGameButton != null)
|
if (startGameButton != null)
|
||||||
{
|
{
|
||||||
startGameButton.IsDisabled = () => configurationDisabled() || Map.RuleStatus != MapRuleStatus.Cached ||
|
startGameButton.IsDisabled = () => configurationDisabled() || MapPreview.RuleStatus != MapRuleStatus.Cached ||
|
||||||
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) ||
|
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) ||
|
||||||
(orderManager.LobbyInfo.GlobalSettings.DisableSingleplayer && orderManager.LobbyInfo.IsSinglePlayer);
|
(orderManager.LobbyInfo.GlobalSettings.DisableSingleplayer && orderManager.LobbyInfo.IsSinglePlayer);
|
||||||
|
|
||||||
startGameButton.OnClick = () =>
|
startGameButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
// Bots and admins don't count
|
// Bots and admins don't count
|
||||||
@@ -341,7 +342,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (allowCheats != null)
|
if (allowCheats != null)
|
||||||
{
|
{
|
||||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
||||||
allowCheats.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Cheats.HasValue || configurationDisabled();
|
allowCheats.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.Cheats.HasValue || configurationDisabled();
|
||||||
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
||||||
}
|
}
|
||||||
@@ -350,7 +351,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (crates != null)
|
if (crates != null)
|
||||||
{
|
{
|
||||||
crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates;
|
crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates;
|
||||||
crates.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Crates.HasValue || configurationDisabled();
|
crates.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.Crates.HasValue || configurationDisabled();
|
||||||
crates.OnClick = () => orderManager.IssueOrder(Order.Command(
|
crates.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates)));
|
"crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates)));
|
||||||
}
|
}
|
||||||
@@ -359,7 +360,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (creeps != null)
|
if (creeps != null)
|
||||||
{
|
{
|
||||||
creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps;
|
creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps;
|
||||||
creeps.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Creeps.HasValue || configurationDisabled();
|
creeps.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.Creeps.HasValue || configurationDisabled();
|
||||||
creeps.OnClick = () => orderManager.IssueOrder(Order.Command(
|
creeps.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps)));
|
"creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps)));
|
||||||
}
|
}
|
||||||
@@ -368,7 +369,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (allybuildradius != null)
|
if (allybuildradius != null)
|
||||||
{
|
{
|
||||||
allybuildradius.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius;
|
allybuildradius.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius;
|
||||||
allybuildradius.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.AllyBuildRadius.HasValue || configurationDisabled();
|
allybuildradius.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.AllyBuildRadius.HasValue || configurationDisabled();
|
||||||
allybuildradius.OnClick = () => orderManager.IssueOrder(Order.Command(
|
allybuildradius.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius)));
|
"allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius)));
|
||||||
}
|
}
|
||||||
@@ -377,7 +378,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (shortGame != null)
|
if (shortGame != null)
|
||||||
{
|
{
|
||||||
shortGame.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.ShortGame;
|
shortGame.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.ShortGame;
|
||||||
shortGame.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.ShortGame.HasValue || configurationDisabled();
|
shortGame.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.ShortGame.HasValue || configurationDisabled();
|
||||||
shortGame.OnClick = () => orderManager.IssueOrder(Order.Command(
|
shortGame.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"shortgame {0}".F(!orderManager.LobbyInfo.GlobalSettings.ShortGame)));
|
"shortgame {0}".F(!orderManager.LobbyInfo.GlobalSettings.ShortGame)));
|
||||||
}
|
}
|
||||||
@@ -385,12 +386,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var difficulty = optionsBin.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
var difficulty = optionsBin.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
||||||
if (difficulty != null)
|
if (difficulty != null)
|
||||||
{
|
{
|
||||||
difficulty.IsVisible = () => Map.Status == MapStatus.Available && Map.Map.Options.Difficulties.Any();
|
difficulty.IsVisible = () => MapPreview.Status == MapStatus.Available && MapPreview.Map.Options.Difficulties.Any();
|
||||||
difficulty.IsDisabled = () => Map.Status != MapStatus.Available || configurationDisabled();
|
difficulty.IsDisabled = () => MapPreview.Status != MapStatus.Available || configurationDisabled();
|
||||||
difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty;
|
difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty;
|
||||||
difficulty.OnMouseDown = _ =>
|
difficulty.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
var options = Map.Map.Options.Difficulties.Select(d => new DropDownOption
|
var options = MapPreview.Map.Options.Difficulties.Select(d => new DropDownOption
|
||||||
{
|
{
|
||||||
Title = d,
|
Title = d,
|
||||||
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d,
|
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d,
|
||||||
@@ -419,10 +420,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return selectedClass != null ? selectedClass : c;
|
return selectedClass != null ? selectedClass : c;
|
||||||
};
|
};
|
||||||
|
|
||||||
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available ||
|
startingUnits.IsDisabled = () => MapPreview.Status != MapStatus.Available ||
|
||||||
!Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
|
!MapPreview.Map.Options.ConfigurableStartingUnits || configurationDisabled();
|
||||||
startingUnits.GetText = () => Map.Status != MapStatus.Available ||
|
startingUnits.GetText = () => MapPreview.Status != MapStatus.Available ||
|
||||||
!Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
|
!MapPreview.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
|
||||||
startingUnits.OnMouseDown = _ =>
|
startingUnits.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
var options = classes.Select(c => new DropDownOption
|
var options = classes.Select(c => new DropDownOption
|
||||||
@@ -448,10 +449,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var startingCash = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON");
|
var startingCash = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON");
|
||||||
if (startingCash != null)
|
if (startingCash != null)
|
||||||
{
|
{
|
||||||
startingCash.IsDisabled = () => Map.Status != MapStatus.Available ||
|
startingCash.IsDisabled = () => MapPreview.Status != MapStatus.Available ||
|
||||||
Map.Map.Options.StartingCash.HasValue || configurationDisabled();
|
MapPreview.Map.Options.StartingCash.HasValue || configurationDisabled();
|
||||||
startingCash.GetText = () => Map.Status != MapStatus.Available ||
|
startingCash.GetText = () => MapPreview.Status != MapStatus.Available ||
|
||||||
Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
|
MapPreview.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
|
||||||
startingCash.OnMouseDown = _ =>
|
startingCash.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
var options = modRules.Actors["player"].TraitInfo<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
|
var options = modRules.Actors["player"].TraitInfo<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
|
||||||
@@ -482,10 +483,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (techLevelDescription != null)
|
if (techLevelDescription != null)
|
||||||
techLevelDescription.IsVisible = () => techTraits.Count > 0;
|
techLevelDescription.IsVisible = () => techTraits.Count > 0;
|
||||||
|
|
||||||
techLevel.IsDisabled = () => Map.Status != MapStatus.Available ||
|
techLevel.IsDisabled = () => MapPreview.Status != MapStatus.Available ||
|
||||||
Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1;
|
MapPreview.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1;
|
||||||
techLevel.GetText = () => Map.Status != MapStatus.Available ||
|
techLevel.GetText = () => MapPreview.Status != MapStatus.Available ||
|
||||||
Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel);
|
MapPreview.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel);
|
||||||
techLevel.OnMouseDown = _ =>
|
techLevel.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
var options = techTraits.Select(c => new DropDownOption
|
var options = techTraits.Select(c => new DropDownOption
|
||||||
@@ -511,10 +512,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var speeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
|
var speeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
|
||||||
|
|
||||||
gameSpeed.IsDisabled = () => Map.Status != MapStatus.Available || configurationDisabled();
|
gameSpeed.IsDisabled = () => MapPreview.Status != MapStatus.Available || configurationDisabled();
|
||||||
gameSpeed.GetText = () =>
|
gameSpeed.GetText = () =>
|
||||||
{
|
{
|
||||||
if (Map.Status != MapStatus.Available)
|
if (MapPreview.Status != MapStatus.Available)
|
||||||
return "Not Available";
|
return "Not Available";
|
||||||
|
|
||||||
GameSpeed speed;
|
GameSpeed speed;
|
||||||
@@ -548,7 +549,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (exploredMap != null)
|
if (exploredMap != null)
|
||||||
{
|
{
|
||||||
exploredMap.IsChecked = () => !orderManager.LobbyInfo.GlobalSettings.Shroud;
|
exploredMap.IsChecked = () => !orderManager.LobbyInfo.GlobalSettings.Shroud;
|
||||||
exploredMap.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Shroud.HasValue || configurationDisabled();
|
exploredMap.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.Shroud.HasValue || configurationDisabled();
|
||||||
exploredMap.OnClick = () => orderManager.IssueOrder(Order.Command(
|
exploredMap.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
|
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
|
||||||
}
|
}
|
||||||
@@ -557,7 +558,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (enableFog != null)
|
if (enableFog != null)
|
||||||
{
|
{
|
||||||
enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog;
|
enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog;
|
||||||
enableFog.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Fog.HasValue || configurationDisabled();
|
enableFog.IsDisabled = () => MapPreview.Status != MapStatus.Available || MapPreview.Map.Options.Fog.HasValue || configurationDisabled();
|
||||||
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
|
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
|
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
|
||||||
}
|
}
|
||||||
@@ -733,31 +734,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
void UpdateCurrentMap()
|
void UpdateCurrentMap()
|
||||||
{
|
{
|
||||||
var uid = orderManager.LobbyInfo.GlobalSettings.Map;
|
var uid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||||
if (Map.Uid == uid)
|
if (MapPreview.Uid == uid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Map = Game.ModData.MapCache[uid];
|
MapPreview = Game.ModData.MapCache[uid];
|
||||||
if (Map.Status == MapStatus.Available)
|
if (MapPreview.Status == MapStatus.Available)
|
||||||
{
|
{
|
||||||
// Maps need to be validated and pre-loaded before they can be accessed
|
// Maps need to be validated and pre-loaded before they can be accessed
|
||||||
new Thread(_ =>
|
new Thread(_ =>
|
||||||
{
|
{
|
||||||
var map = Map;
|
var mapPreview = MapPreview;
|
||||||
map.CacheRules();
|
mapPreview.CacheRules();
|
||||||
Game.RunAfterTick(() =>
|
Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
// Map may have changed in the meantime
|
// Map may have changed in the meantime
|
||||||
if (map != Map)
|
if (mapPreview != MapPreview)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (map.RuleStatus != MapRuleStatus.Invalid)
|
if (mapPreview.RuleStatus != MapRuleStatus.Invalid)
|
||||||
{
|
{
|
||||||
// Tell the server that we have the map
|
// Tell the server that we have the map
|
||||||
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
|
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
|
||||||
|
|
||||||
// Restore default starting cash if the last map set it to something invalid
|
// Restore default starting cash if the last map set it to something invalid
|
||||||
var pri = modRules.Actors["player"].TraitInfo<PlayerResourcesInfo>();
|
var pri = modRules.Actors["player"].TraitInfo<PlayerResourcesInfo>();
|
||||||
if (!Map.Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
|
if (!MapPreview.Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
|
||||||
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
|
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -816,9 +817,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
|
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
|
||||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
|
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
|
||||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map);
|
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, MapPreview);
|
||||||
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map);
|
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, MapPreview);
|
||||||
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, Map);
|
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, MapPreview);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,79 +25,80 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var available = widget.GetOrNull("MAP_AVAILABLE");
|
var available = widget.GetOrNull("MAP_AVAILABLE");
|
||||||
if (available != null)
|
if (available != null)
|
||||||
{
|
{
|
||||||
available.IsVisible = () => lobby.Map.Status == MapStatus.Available && lobby.Map.RuleStatus == MapRuleStatus.Cached;
|
available.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && lobby.MapPreview.RuleStatus == MapRuleStatus.Cached;
|
||||||
|
|
||||||
var preview = available.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = available.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => lobby.Map;
|
preview.Preview = () => lobby.MapPreview;
|
||||||
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
|
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.MapPreview, mi);
|
||||||
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
|
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.MapPreview);
|
||||||
|
|
||||||
var titleLabel = available.GetOrNull<LabelWidget>("MAP_TITLE");
|
var titleLabel = available.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||||
if (titleLabel != null)
|
if (titleLabel != null)
|
||||||
{
|
{
|
||||||
var font = Game.Renderer.Fonts[titleLabel.Font];
|
var font = Game.Renderer.Fonts[titleLabel.Font];
|
||||||
var title = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font));
|
var title = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font));
|
||||||
titleLabel.GetText = () => title.Update(lobby.Map);
|
titleLabel.GetText = () => title.Update(lobby.MapPreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
var typeLabel = available.GetOrNull<LabelWidget>("MAP_TYPE");
|
var typeLabel = available.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||||
if (typeLabel != null)
|
if (typeLabel != null)
|
||||||
typeLabel.GetText = () => lobby.Map.Type;
|
typeLabel.GetText = () => lobby.MapPreview.Type;
|
||||||
|
|
||||||
var authorLabel = available.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
var authorLabel = available.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
||||||
if (authorLabel != null)
|
if (authorLabel != null)
|
||||||
{
|
{
|
||||||
var font = Game.Renderer.Fonts[authorLabel.Font];
|
var font = Game.Renderer.Fonts[authorLabel.Font];
|
||||||
var author = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText("Created by {0}".F(lobby.Map.Author), authorLabel.Bounds.Width, font));
|
var author = new CachedTransform<MapPreview, string>(
|
||||||
authorLabel.GetText = () => author.Update(lobby.Map);
|
m => WidgetUtils.TruncateText("Created by {0}".F(lobby.MapPreview.Author), authorLabel.Bounds.Width, font));
|
||||||
|
authorLabel.GetText = () => author.Update(lobby.MapPreview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var invalid = widget.GetOrNull("MAP_INVALID");
|
var invalid = widget.GetOrNull("MAP_INVALID");
|
||||||
if (invalid != null)
|
if (invalid != null)
|
||||||
{
|
{
|
||||||
invalid.IsVisible = () => lobby.Map.Status == MapStatus.Available && lobby.Map.RuleStatus == MapRuleStatus.Invalid;
|
invalid.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && lobby.MapPreview.RuleStatus == MapRuleStatus.Invalid;
|
||||||
|
|
||||||
var preview = invalid.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = invalid.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => lobby.Map;
|
preview.Preview = () => lobby.MapPreview;
|
||||||
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
|
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.MapPreview, mi);
|
||||||
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
|
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.MapPreview);
|
||||||
|
|
||||||
var title = invalid.GetOrNull<LabelWidget>("MAP_TITLE");
|
var title = invalid.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title.GetText = () => lobby.Map.Title;
|
title.GetText = () => lobby.MapPreview.Title;
|
||||||
|
|
||||||
var type = invalid.GetOrNull<LabelWidget>("MAP_TYPE");
|
var type = invalid.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||||
if (type != null)
|
if (type != null)
|
||||||
type.GetText = () => lobby.Map.Type;
|
type.GetText = () => lobby.MapPreview.Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
var download = widget.GetOrNull("MAP_DOWNLOADABLE");
|
var download = widget.GetOrNull("MAP_DOWNLOADABLE");
|
||||||
if (download != null)
|
if (download != null)
|
||||||
{
|
{
|
||||||
download.IsVisible = () => lobby.Map.Status == MapStatus.DownloadAvailable;
|
download.IsVisible = () => lobby.MapPreview.Status == MapStatus.DownloadAvailable;
|
||||||
|
|
||||||
var preview = download.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = download.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => lobby.Map;
|
preview.Preview = () => lobby.MapPreview;
|
||||||
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
|
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.MapPreview, mi);
|
||||||
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
|
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.MapPreview);
|
||||||
|
|
||||||
var title = download.GetOrNull<LabelWidget>("MAP_TITLE");
|
var title = download.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title.GetText = () => lobby.Map.Title;
|
title.GetText = () => lobby.MapPreview.Title;
|
||||||
|
|
||||||
var type = download.GetOrNull<LabelWidget>("MAP_TYPE");
|
var type = download.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||||
if (type != null)
|
if (type != null)
|
||||||
type.GetText = () => lobby.Map.Type;
|
type.GetText = () => lobby.MapPreview.Type;
|
||||||
|
|
||||||
var author = download.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
var author = download.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
||||||
if (author != null)
|
if (author != null)
|
||||||
author.GetText = () => "Created by {0}".F(lobby.Map.Author);
|
author.GetText = () => "Created by {0}".F(lobby.MapPreview.Author);
|
||||||
|
|
||||||
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
|
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
|
||||||
if (install != null)
|
if (install != null)
|
||||||
{
|
{
|
||||||
install.OnClick = () => lobby.Map.Install();
|
install.OnClick = () => lobby.MapPreview.Install();
|
||||||
install.IsHighlighted = () => installHighlighted;
|
install.IsHighlighted = () => installHighlighted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,71 +107,72 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (progress != null)
|
if (progress != null)
|
||||||
{
|
{
|
||||||
progress.IsVisible = () =>
|
progress.IsVisible = () =>
|
||||||
(lobby.Map.Status != MapStatus.Available || lobby.Map.RuleStatus == MapRuleStatus.Unknown) &&
|
(lobby.MapPreview.Status != MapStatus.Available || lobby.MapPreview.RuleStatus == MapRuleStatus.Unknown) &&
|
||||||
lobby.Map.Status != MapStatus.DownloadAvailable;
|
lobby.MapPreview.Status != MapStatus.DownloadAvailable;
|
||||||
|
|
||||||
var preview = progress.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = progress.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => lobby.Map;
|
preview.Preview = () => lobby.MapPreview;
|
||||||
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.Map, mi);
|
preview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint(orderManager, preview, lobby.MapPreview, mi);
|
||||||
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.Map);
|
preview.SpawnOccupants = () => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, lobby.MapPreview);
|
||||||
|
|
||||||
var title = progress.GetOrNull<LabelWidget>("MAP_TITLE");
|
var title = progress.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title.GetText = () => lobby.Map.Title;
|
title.GetText = () => lobby.MapPreview.Title;
|
||||||
|
|
||||||
var type = progress.GetOrNull<LabelWidget>("MAP_TYPE");
|
var type = progress.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||||
if (type != null)
|
if (type != null)
|
||||||
type.GetText = () => lobby.Map.Type;
|
type.GetText = () => lobby.MapPreview.Type;
|
||||||
|
|
||||||
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
|
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
|
||||||
if (statusSearching != null)
|
if (statusSearching != null)
|
||||||
statusSearching.IsVisible = () => lobby.Map.Status == MapStatus.Searching;
|
statusSearching.IsVisible = () => lobby.MapPreview.Status == MapStatus.Searching;
|
||||||
|
|
||||||
var statusUnavailable = progress.GetOrNull("MAP_STATUS_UNAVAILABLE");
|
var statusUnavailable = progress.GetOrNull("MAP_STATUS_UNAVAILABLE");
|
||||||
if (statusUnavailable != null)
|
if (statusUnavailable != null)
|
||||||
statusUnavailable.IsVisible = () => lobby.Map.Status == MapStatus.Unavailable;
|
statusUnavailable.IsVisible = () => lobby.MapPreview.Status == MapStatus.Unavailable;
|
||||||
|
|
||||||
var statusError = progress.GetOrNull("MAP_STATUS_ERROR");
|
var statusError = progress.GetOrNull("MAP_STATUS_ERROR");
|
||||||
if (statusError != null)
|
if (statusError != null)
|
||||||
statusError.IsVisible = () => lobby.Map.Status == MapStatus.DownloadError;
|
statusError.IsVisible = () => lobby.MapPreview.Status == MapStatus.DownloadError;
|
||||||
|
|
||||||
var statusDownloading = progress.GetOrNull<LabelWidget>("MAP_STATUS_DOWNLOADING");
|
var statusDownloading = progress.GetOrNull<LabelWidget>("MAP_STATUS_DOWNLOADING");
|
||||||
if (statusDownloading != null)
|
if (statusDownloading != null)
|
||||||
{
|
{
|
||||||
statusDownloading.IsVisible = () => lobby.Map.Status == MapStatus.Downloading;
|
statusDownloading.IsVisible = () => lobby.MapPreview.Status == MapStatus.Downloading;
|
||||||
statusDownloading.GetText = () =>
|
statusDownloading.GetText = () =>
|
||||||
{
|
{
|
||||||
if (lobby.Map.DownloadBytes == 0)
|
if (lobby.MapPreview.DownloadBytes == 0)
|
||||||
return "Connecting...";
|
return "Connecting...";
|
||||||
|
|
||||||
// Server does not provide the total file length
|
// Server does not provide the total file length
|
||||||
if (lobby.Map.DownloadPercentage == 0)
|
if (lobby.MapPreview.DownloadPercentage == 0)
|
||||||
return "Downloading {0} kB".F(lobby.Map.DownloadBytes / 1024);
|
return "Downloading {0} kB".F(lobby.MapPreview.DownloadBytes / 1024);
|
||||||
|
|
||||||
return "Downloading {0} kB ({1}%)".F(lobby.Map.DownloadBytes / 1024, lobby.Map.DownloadPercentage);
|
return "Downloading {0} kB ({1}%)".F(lobby.MapPreview.DownloadBytes / 1024, lobby.MapPreview.DownloadPercentage);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var retry = progress.GetOrNull<ButtonWidget>("MAP_RETRY");
|
var retry = progress.GetOrNull<ButtonWidget>("MAP_RETRY");
|
||||||
if (retry != null)
|
if (retry != null)
|
||||||
{
|
{
|
||||||
retry.IsVisible = () => (lobby.Map.Status == MapStatus.DownloadError || lobby.Map.Status == MapStatus.Unavailable) && lobby.Map != MapCache.UnknownMap;
|
retry.IsVisible = () => (lobby.MapPreview.Status == MapStatus.DownloadError || lobby.MapPreview.Status == MapStatus.Unavailable) &&
|
||||||
|
lobby.MapPreview != MapCache.UnknownMap;
|
||||||
retry.OnClick = () =>
|
retry.OnClick = () =>
|
||||||
{
|
{
|
||||||
if (lobby.Map.Status == MapStatus.DownloadError)
|
if (lobby.MapPreview.Status == MapStatus.DownloadError)
|
||||||
lobby.Map.Install();
|
lobby.MapPreview.Install();
|
||||||
else if (lobby.Map.Status == MapStatus.Unavailable)
|
else if (lobby.MapPreview.Status == MapStatus.Unavailable)
|
||||||
Game.ModData.MapCache.QueryRemoteMapDetails(new[] { lobby.Map.Uid });
|
Game.ModData.MapCache.QueryRemoteMapDetails(new[] { lobby.MapPreview.Uid });
|
||||||
};
|
};
|
||||||
|
|
||||||
retry.GetText = () => lobby.Map.Status == MapStatus.DownloadError ? "Retry Install" : "Retry Search";
|
retry.GetText = () => lobby.MapPreview.Status == MapStatus.DownloadError ? "Retry Install" : "Retry Search";
|
||||||
}
|
}
|
||||||
|
|
||||||
var progressbar = progress.GetOrNull<ProgressBarWidget>("MAP_PROGRESSBAR");
|
var progressbar = progress.GetOrNull<ProgressBarWidget>("MAP_PROGRESSBAR");
|
||||||
if (progressbar != null)
|
if (progressbar != null)
|
||||||
{
|
{
|
||||||
progressbar.IsIndeterminate = () => lobby.Map.DownloadPercentage == 0;
|
progressbar.IsIndeterminate = () => lobby.MapPreview.DownloadPercentage == 0;
|
||||||
progressbar.GetPercentage = () => lobby.Map.DownloadPercentage;
|
progressbar.GetPercentage = () => lobby.MapPreview.DownloadPercentage;
|
||||||
progressbar.IsVisible = () => !retry.IsVisible();
|
progressbar.IsVisible = () => !retry.IsVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user