Merge pull request #5646 from Mailaender/replay-dropdown-polish
Polished the Replay Browser dropdowns
This commit is contained in:
@@ -87,7 +87,7 @@ namespace OpenRA.Widgets
|
|||||||
Ui.Root.AddChild(panel);
|
Ui.Root.AddChild(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowDropDown<T>(string panelTemplate, int height, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
|
public void ShowDropDown<T>(string panelTemplate, int maxHeight, IEnumerable<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", Bounds.Width }};
|
||||||
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs()
|
||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Widgets
|
|||||||
panel.AddChild(item);
|
panel.AddChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.Bounds.Height = Math.Min(height, panel.ContentHeight);
|
panel.Bounds.Height = Math.Min(maxHeight, panel.ContentHeight);
|
||||||
AttachPanel(panel);
|
AttachPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,9 +96,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
void SetupFilters()
|
void SetupFilters()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// Game type
|
// Game type
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_GAMETYPE_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_GAMETYPE_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -120,20 +118,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => filter.Type == option.First,
|
() => filter.Type == option.First,
|
||||||
() => { filter.Type = option.First; ApplyFilter(); }
|
() => { filter.Type = option.First; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Date type
|
// Date type
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DATE_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DATE_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -157,20 +152,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => filter.Date == option.First,
|
() => filter.Date == option.First,
|
||||||
() => { filter.Date = option.First; ApplyFilter(); }
|
() => { filter.Date = option.First; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Duration
|
// Duration
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DURATION_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DURATION_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -194,20 +187,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => filter.Duration == option.First,
|
() => filter.Duration == option.First,
|
||||||
() => { filter.Duration = option.First; ApplyFilter(); }
|
() => { filter.Duration = option.First; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Map
|
// Map
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_MAPNAME_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_MAPNAME_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -225,20 +215,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => string.Compare(filter.MapName, option, true) == 0,
|
() => string.Compare(filter.MapName, option, true) == 0,
|
||||||
() => { filter.MapName = option; ApplyFilter(); }
|
() => { filter.MapName = option; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Players
|
// Players
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_PLAYER_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_PLAYER_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -256,20 +243,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => string.Compare(filter.PlayerName, option, true) == 0,
|
() => string.Compare(filter.PlayerName, option, true) == 0,
|
||||||
() => { filter.PlayerName = option; ApplyFilter(); }
|
() => { filter.PlayerName = option; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Outcome (depends on Player)
|
// Outcome (depends on Player)
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_OUTCOME_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_OUTCOME_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -293,20 +277,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => filter.Outcome == option.First,
|
() => filter.Outcome == option.First,
|
||||||
() => { filter.Outcome = option.First; ApplyFilter(); }
|
() => { filter.Outcome = option.First; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Faction (depends on Player)
|
// Faction (depends on Player)
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_FACTION_DROPDOWNBUTTON");
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_FACTION_DROPDOWNBUTTON");
|
||||||
if (ddb != null)
|
if (ddb != null)
|
||||||
@@ -326,20 +307,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
() => string.Compare(filter.Faction, option, true) == 0,
|
() => string.Compare(filter.Faction, option, true) == 0,
|
||||||
() => { filter.Faction = option; ApplyFilter(); }
|
() => { filter.Faction = option; ApplyFilter(); });
|
||||||
);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Reset button
|
// Reset button
|
||||||
//
|
|
||||||
{
|
{
|
||||||
var button = panel.Get<ButtonWidget>("FLT_RESET_BUTTON");
|
var button = panel.Get<ButtonWidget>("FLT_RESET_BUTTON");
|
||||||
button.IsDisabled = () => filter.IsEmpty;
|
button.IsDisabled = () => filter.IsEmpty;
|
||||||
@@ -508,6 +486,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
t = TimeSpan.FromDays(30d);
|
t = TimeSpan.FromDays(30d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replay.GameInfo.StartTimeUtc < DateTime.UtcNow - t)
|
if (replay.GameInfo.StartTimeUtc < DateTime.UtcNow - t)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -700,12 +679,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GameType
|
enum GameType
|
||||||
{
|
{
|
||||||
Any,
|
Any,
|
||||||
Singleplayer,
|
Singleplayer,
|
||||||
Multiplayer
|
Multiplayer
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DateType
|
enum DateType
|
||||||
{
|
{
|
||||||
Any,
|
Any,
|
||||||
@@ -714,6 +695,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
LastFortnight,
|
LastFortnight,
|
||||||
LastMonth
|
LastMonth
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DurationType
|
enum DurationType
|
||||||
{
|
{
|
||||||
Any,
|
Any,
|
||||||
|
|||||||
Reference in New Issue
Block a user