From 44ab94f03a102ad55ba5ca41363eb64795ac0fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 16 Jun 2014 10:16:54 +0200 Subject: [PATCH 1/3] limit replay browser dropdown box height to something sane closes #5641 --- OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs index 0723d236e5..dbff9e7d0f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -163,7 +163,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -200,7 +200,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -231,7 +231,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -262,7 +262,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -299,7 +299,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } @@ -332,7 +332,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem); + ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem); }; } } From 88480e0dc2b1b586cdf3f5dc3c47e348717a77ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 16 Jun 2014 10:17:30 +0200 Subject: [PATCH 2/3] make it clear that this does not need to match content height --- OpenRA.Game/Widgets/DropDownButtonWidget.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Widgets/DropDownButtonWidget.cs b/OpenRA.Game/Widgets/DropDownButtonWidget.cs index edf97a7ba3..d30db90d50 100644 --- a/OpenRA.Game/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Game/Widgets/DropDownButtonWidget.cs @@ -87,7 +87,7 @@ namespace OpenRA.Widgets Ui.Root.AddChild(panel); } - public void ShowDropDown(string panelTemplate, int height, IEnumerable options, Func setupItem) + public void ShowDropDown(string panelTemplate, int maxHeight, IEnumerable options, Func setupItem) { var substitutions = new Dictionary() {{ "DROPDOWN_WIDTH", Bounds.Width }}; var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() @@ -106,7 +106,7 @@ namespace OpenRA.Widgets panel.AddChild(item); } - panel.Bounds.Height = Math.Min(height, panel.ContentHeight); + panel.Bounds.Height = Math.Min(maxHeight, panel.ContentHeight); AttachPanel(panel); } From 83e33b99e8946897d6d7cabb5f91a16c3bf1812e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 16 Jun 2014 10:22:10 +0200 Subject: [PATCH 3/3] StyleCop --- .../Widgets/Logic/ReplayBrowserLogic.cs | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs index dbff9e7d0f..d087f76fc5 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs @@ -96,9 +96,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void SetupFilters() { - // // Game type - // { var ddb = panel.GetOrNull("FLT_GAMETYPE_DROPDOWNBUTTON"); if (ddb != null) @@ -120,8 +118,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => filter.Type == option.First, - () => { filter.Type = option.First; ApplyFilter(); } - ); + () => { filter.Type = option.First; ApplyFilter(); }); item.Get("LABEL").GetText = () => option.Second; return item; }; @@ -131,9 +128,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Date type - // { var ddb = panel.GetOrNull("FLT_DATE_DROPDOWNBUTTON"); if (ddb != null) @@ -157,8 +152,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => filter.Date == option.First, - () => { filter.Date = option.First; ApplyFilter(); } - ); + () => { filter.Date = option.First; ApplyFilter(); }); + item.Get("LABEL").GetText = () => option.Second; return item; }; @@ -168,9 +163,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Duration - // { var ddb = panel.GetOrNull("FLT_DURATION_DROPDOWNBUTTON"); if (ddb != null) @@ -194,8 +187,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => filter.Duration == option.First, - () => { filter.Duration = option.First; ApplyFilter(); } - ); + () => { filter.Duration = option.First; ApplyFilter(); }); item.Get("LABEL").GetText = () => option.Second; return item; }; @@ -205,9 +197,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Map - // { var ddb = panel.GetOrNull("FLT_MAPNAME_DROPDOWNBUTTON"); if (ddb != null) @@ -225,8 +215,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => string.Compare(filter.MapName, option, true) == 0, - () => { filter.MapName = option; ApplyFilter(); } - ); + () => { filter.MapName = option; ApplyFilter(); }); item.Get("LABEL").GetText = () => option ?? anyText; return item; }; @@ -236,9 +225,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Players - // { var ddb = panel.GetOrNull("FLT_PLAYER_DROPDOWNBUTTON"); if (ddb != null) @@ -256,8 +243,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => string.Compare(filter.PlayerName, option, true) == 0, - () => { filter.PlayerName = option; ApplyFilter(); } - ); + () => { filter.PlayerName = option; ApplyFilter(); }); item.Get("LABEL").GetText = () => option ?? anyText; return item; }; @@ -267,9 +253,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Outcome (depends on Player) - // { var ddb = panel.GetOrNull("FLT_OUTCOME_DROPDOWNBUTTON"); if (ddb != null) @@ -293,8 +277,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => filter.Outcome == option.First, - () => { filter.Outcome = option.First; ApplyFilter(); } - ); + () => { filter.Outcome = option.First; ApplyFilter(); }); item.Get("LABEL").GetText = () => option.Second; return item; }; @@ -304,9 +287,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Faction (depends on Player) - // { var ddb = panel.GetOrNull("FLT_FACTION_DROPDOWNBUTTON"); if (ddb != null) @@ -326,8 +307,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup( tpl, () => string.Compare(filter.Faction, option, true) == 0, - () => { filter.Faction = option; ApplyFilter(); } - ); + () => { filter.Faction = option; ApplyFilter(); }); item.Get("LABEL").GetText = () => option ?? anyText; return item; }; @@ -337,9 +317,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } - // // Reset button - // { var button = panel.Get("FLT_RESET_BUTTON"); button.IsDisabled = () => filter.IsEmpty; @@ -508,6 +486,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic t = TimeSpan.FromDays(30d); break; } + if (replay.GameInfo.StartTimeUtc < DateTime.UtcNow - t) return false; } @@ -610,7 +589,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var group = kv.Key; if (group.Length > 0) { - var header = ScrollItemWidget.Setup(playerHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(playerHeader, () => true, () => { }); header.Get("LABEL").GetText = () => group; playerList.AddChild(header); } @@ -700,12 +679,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic } } } + enum GameType { Any, Singleplayer, Multiplayer } + enum DateType { Any, @@ -714,6 +695,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic LastFortnight, LastMonth } + enum DurationType { Any,