Enforce a line length limit.

This commit is contained in:
RoosterDragon
2015-03-11 23:57:41 +00:00
parent 721ba5e9c3
commit 1515ac54f6
34 changed files with 156 additions and 57 deletions

View File

@@ -114,7 +114,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var frameContainer = panel.GetOrNull("FRAME_SELECTOR");
if (frameContainer != null)
frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1);
frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) ||
(isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1);
frameSlider = panel.Get<SliderWidget>("FRAME_SLIDER");
if (frameSlider != null)

View File

@@ -26,7 +26,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
powerIcon.GetImageName = () => powerManager.ExcessPower < 0 ? "power-critical" : "power-normal";
power.GetColor = () => powerManager.ExcessPower < 0 ? Color.Red : Color.White;
power.GetText = () => powerManager.PowerProvided == 1000000 ? "inf" : powerManager.ExcessPower.ToString();
power.GetTooltipText = () => "Power Usage: " + powerManager.PowerDrained.ToString() + (powerManager.PowerProvided != 1000000 ? "/" + powerManager.PowerProvided.ToString() : "");
power.GetTooltipText = () => "Power Usage: " + powerManager.PowerDrained.ToString() +
(powerManager.PowerProvided != 1000000 ? "/" + powerManager.PowerProvided.ToString() : "");
}
}
}

View File

@@ -46,7 +46,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
tooltipContainer.BeforeRender = () =>
{
var latencyPrefixSize = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText() + " ").X;
var width = Math.Max(locationFont.Measure(location.GetText()).X, Math.Max(adminFont.Measure(admin.GetText()).X, Math.Max(addressFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X)));
var locationWidth = locationFont.Measure(location.GetText()).X;
var adminWidth = adminFont.Measure(admin.GetText()).X;
var addressWidth = addressFont.Measure(ip.GetText()).X;
var latencyWidth = latencyPrefixSize + latencyFont.Measure(latency.GetText()).X;
var width = Math.Max(locationWidth, Math.Max(adminWidth, Math.Max(addressWidth, latencyWidth)));
widget.Bounds.Width = width + 2 * margin;
latency.Bounds.Width = widget.Bounds.Width;
ip.Bounds.Width = widget.Bounds.Width;

View File

@@ -408,8 +408,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return selectedClass != null ? selectedClass : c;
};
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
startingUnits.GetText = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available ||
!Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
startingUnits.GetText = () => Map.Status != MapStatus.Available ||
!Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
startingUnits.OnMouseDown = _ =>
{
var options = classes.Select(c => new DropDownOption
@@ -435,8 +437,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var startingCash = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON");
if (startingCash != null)
{
startingCash.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue || configurationDisabled();
startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
startingCash.IsDisabled = () => Map.Status != MapStatus.Available ||
Map.Map.Options.StartingCash.HasValue || configurationDisabled();
startingCash.GetText = () => Map.Status != MapStatus.Available ||
Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
startingCash.OnMouseDown = _ =>
{
var options = modRules.Actors["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
@@ -463,8 +467,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var techTraits = modRules.Actors["player"].Traits.WithInterface<ProvidesTechPrerequisiteInfo>().ToList();
techLevel.IsVisible = () => techTraits.Count > 0;
optionsBin.GetOrNull<LabelWidget>("TECHLEVEL_DESC").IsVisible = () => techTraits.Count > 0;
techLevel.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1;
techLevel.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel);
techLevel.IsDisabled = () => Map.Status != MapStatus.Available ||
Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1;
techLevel.GetText = () => Map.Status != MapStatus.Available ||
Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel);
techLevel.OnMouseDown = _ =>
{
var options = techTraits.Select(c => new DropDownOption

View File

@@ -90,7 +90,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var progress = widget.GetOrNull("MAP_PROGRESS");
if (progress != null)
{
progress.IsVisible = () => (lobby.Map.Status != MapStatus.Available || lobby.Map.RuleStatus == MapRuleStatus.Unknown) && lobby.Map.Status != MapStatus.DownloadAvailable;
progress.IsVisible = () =>
(lobby.Map.Status != MapStatus.Available || lobby.Map.RuleStatus == MapRuleStatus.Unknown) &&
lobby.Map.Status != MapStatus.DownloadAvailable;
var preview = progress.Get<MapPreviewWidget>("MAP_PREVIEW");
preview.Preview = () => lobby.Map;

View File

@@ -114,7 +114,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var maps = Game.ModData.MapCache
.Where(m => m.Status == MapStatus.Available && (m.Map.Visibility & filter) != 0)
.Where(m => gameMode == null || m.Type == gameMode)
.Where(m => mapFilter == null || m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 || m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0)
.Where(m => mapFilter == null ||
m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0 ||
m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0)
.OrderBy(m => m.PlayerCount)
.ThenBy(m => m.Title);
@@ -126,7 +128,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Access the minimap to trigger async generation of the minimap.
preview.GetMinimap();
var item = ScrollItemWidget.Setup(preview.Uid, itemTemplate, () => selectedUid == preview.Uid, () => selectedUid = preview.Uid, () => { Ui.CloseWindow(); onSelect(preview.Uid); });
var item = ScrollItemWidget.Setup(preview.Uid, itemTemplate, () => selectedUid == preview.Uid,
() => selectedUid = preview.Uid, () => { Ui.CloseWindow(); onSelect(preview.Uid); });
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanel.RenderBounds);
var titleLabel = item.Get<LabelWidget>("TITLE");

View File

@@ -299,7 +299,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
ddb.IsDisabled = () => string.IsNullOrEmpty(filter.PlayerName);
var options = replays.SelectMany(r => r.GameInfo.Players.Select(p => p.FactionName).Where(n => !string.IsNullOrEmpty(n))).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
var options = replays
.SelectMany(r => r.GameInfo.Players.Select(p => p.FactionName).Where(n => !string.IsNullOrEmpty(n)))
.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
options.Sort(StringComparer.OrdinalIgnoreCase);
options.Insert(0, null); // no filter