Add filters to the replay browser dialog
This closes issue #2152. The filters added are: * Game type (singleplayer / multiplayer) * Date * Duration * Outcome * Player name Other changes: * Added a 'CollapseHiddenChildren' option to the ScrollPanelWidget to make hidden children take up no space. * Removed the extension (.rep) from the replay filenames in the replay browser.
This commit is contained in:
@@ -53,6 +53,8 @@ namespace OpenRA.FileFormats
|
|||||||
if (endGameTimestampUtc.Kind == DateTimeKind.Unspecified)
|
if (endGameTimestampUtc.Kind == DateTimeKind.Unspecified)
|
||||||
throw new ArgumentException("The 'Kind' property of the timestamp must be specified", "endGameTimestampUtc");
|
throw new ArgumentException("The 'Kind' property of the timestamp must be specified", "endGameTimestampUtc");
|
||||||
EndTimestampUtc = endGameTimestampUtc.ToUniversalTime();
|
EndTimestampUtc = endGameTimestampUtc.ToUniversalTime();
|
||||||
|
|
||||||
|
Outcome = outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplayMetadata(BinaryReader reader)
|
ReplayMetadata(BinaryReader reader)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace OpenRA.Widgets
|
|||||||
widget.ContentHeight = widget.ItemSpacing;
|
widget.ContentHeight = widget.ItemSpacing;
|
||||||
|
|
||||||
w.Bounds.Y = widget.ContentHeight;
|
w.Bounds.Y = widget.ContentHeight;
|
||||||
|
if (!widget.CollapseHiddenChildren || w.IsVisible())
|
||||||
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
|
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ namespace OpenRA.Widgets
|
|||||||
foreach (var w in widget.Children)
|
foreach (var w in widget.Children)
|
||||||
{
|
{
|
||||||
w.Bounds.Y = widget.ContentHeight;
|
w.Bounds.Y = widget.ContentHeight;
|
||||||
|
if (!widget.CollapseHiddenChildren || w.IsVisible())
|
||||||
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
|
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace OpenRA.Widgets
|
|||||||
public ILayout Layout;
|
public ILayout Layout;
|
||||||
public int MinimumThumbSize = 10;
|
public int MinimumThumbSize = 10;
|
||||||
public ScrollPanelAlign Align = ScrollPanelAlign.Top;
|
public ScrollPanelAlign Align = ScrollPanelAlign.Top;
|
||||||
|
public bool CollapseHiddenChildren = false;
|
||||||
protected float ListOffset = 0;
|
protected float ListOffset = 0;
|
||||||
protected bool UpPressed = false;
|
protected bool UpPressed = false;
|
||||||
protected bool DownPressed = false;
|
protected bool DownPressed = false;
|
||||||
|
|||||||
@@ -15,21 +15,23 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class ReplayBrowserLogic
|
public class ReplayBrowserLogic
|
||||||
{
|
{
|
||||||
|
static Filter filter = new Filter();
|
||||||
|
|
||||||
Widget panel;
|
Widget panel;
|
||||||
ScrollPanelWidget playerList;
|
ScrollPanelWidget playerList;
|
||||||
ScrollItemWidget playerTemplate, playerHeader;
|
ScrollItemWidget playerTemplate, playerHeader;
|
||||||
|
List<ReplayMetadata> replays;
|
||||||
|
Dictionary<ReplayMetadata, bool> replayVis = new Dictionary<ReplayMetadata, bool>();
|
||||||
|
|
||||||
MapPreview selectedMap = MapCache.UnknownMap;
|
|
||||||
Dictionary<CPos, Session.Client> selectedSpawns;
|
Dictionary<CPos, Session.Client> selectedSpawns;
|
||||||
string selectedFilename;
|
ReplayMetadata selectedReplay;
|
||||||
string selectedDuration;
|
|
||||||
bool selectedValid;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
|
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
|
||||||
@@ -52,47 +54,315 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
rl.RemoveChildren();
|
rl.RemoveChildren();
|
||||||
if (Directory.Exists(dir))
|
if (Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
List<ReplayMetadata> replays;
|
|
||||||
|
|
||||||
using (new Support.PerfTimer("Load replays"))
|
using (new Support.PerfTimer("Load replays"))
|
||||||
{
|
{
|
||||||
replays = Directory
|
replays = Directory
|
||||||
.GetFiles(dir, "*.rep")
|
.GetFiles(dir, "*.rep")
|
||||||
.Select((filename) => ReplayMetadata.Read(filename))
|
.Select((filename) => ReplayMetadata.Read(filename))
|
||||||
.Where((r) => r != null)
|
.Where((r) => r != null)
|
||||||
.OrderByDescending((r) => Path.GetFileName(r.FilePath))
|
.OrderByDescending(r => r.StartTimestampUtc)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var replay in replays)
|
foreach (var replay in replays)
|
||||||
AddReplay(rl, replay, template);
|
AddReplay(rl, replay, template);
|
||||||
|
|
||||||
SelectReplay(replays.FirstOrDefault());
|
ApplyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
var watch = panel.Get<ButtonWidget>("WATCH_BUTTON");
|
var watch = panel.Get<ButtonWidget>("WATCH_BUTTON");
|
||||||
watch.IsDisabled = () => !selectedValid || selectedMap.Status != MapStatus.Available;
|
watch.IsDisabled = () => selectedReplay == null || selectedReplay.MapPreview.Status != MapStatus.Available;
|
||||||
watch.OnClick = () => { WatchReplay(); onStart(); };
|
watch.OnClick = () => { WatchReplay(); onStart(); };
|
||||||
|
|
||||||
panel.Get("REPLAY_INFO").IsVisible = () => selectedFilename != null;
|
panel.Get("REPLAY_INFO").IsVisible = () => selectedReplay != null;
|
||||||
|
|
||||||
var preview = panel.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = panel.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.SpawnClients = () => selectedSpawns;
|
preview.SpawnClients = () => selectedSpawns;
|
||||||
preview.Preview = () => selectedMap;
|
preview.Preview = () => selectedReplay != null ? selectedReplay.MapPreview : null;
|
||||||
|
|
||||||
var title = panel.GetOrNull<LabelWidget>("MAP_TITLE");
|
var title = panel.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title.GetText = () => selectedMap.Title;
|
title.GetText = () => selectedReplay != null ? selectedReplay.MapPreview.Title : null;
|
||||||
|
|
||||||
var type = panel.GetOrNull<LabelWidget>("MAP_TYPE");
|
var type = panel.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||||
if (type != null)
|
if (type != null)
|
||||||
type.GetText = () => selectedMap.Type;
|
type.GetText = () => selectedReplay.MapPreview.Type;
|
||||||
|
|
||||||
panel.Get<LabelWidget>("DURATION").GetText = () => selectedDuration;
|
panel.Get<LabelWidget>("DURATION").GetText = () => WidgetUtils.FormatTimeSeconds((int)selectedReplay.Duration.TotalSeconds);
|
||||||
|
|
||||||
|
SetupFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupFilters()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Game type
|
||||||
|
//
|
||||||
|
{
|
||||||
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_GAMETYPE_DROPDOWNBUTTON");
|
||||||
|
if (ddb != null)
|
||||||
|
{
|
||||||
|
// Using list to maintain the order
|
||||||
|
var options = new List<KeyValuePair<GameType, string>>
|
||||||
|
{
|
||||||
|
new KeyValuePair<GameType, string>(GameType.Any, ddb.GetText()),
|
||||||
|
new KeyValuePair<GameType, string>(GameType.Singleplayer, "Singleplayer"),
|
||||||
|
new KeyValuePair<GameType, string>(GameType.Multiplayer, "Multiplayer")
|
||||||
|
};
|
||||||
|
var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
|
ddb.GetText = () => lookup[filter.Type];
|
||||||
|
ddb.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
Func<KeyValuePair<GameType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(
|
||||||
|
tpl,
|
||||||
|
() => filter.Type == option.Key,
|
||||||
|
() => { filter.Type = option.Key; ApplyFilter(); }
|
||||||
|
);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Date type
|
||||||
|
//
|
||||||
|
{
|
||||||
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DATE_DROPDOWNBUTTON");
|
||||||
|
if (ddb != null)
|
||||||
|
{
|
||||||
|
// Using list to maintain the order
|
||||||
|
var options = new List<KeyValuePair<DateType, string>>
|
||||||
|
{
|
||||||
|
new KeyValuePair<DateType, string>(DateType.Any, ddb.GetText()),
|
||||||
|
new KeyValuePair<DateType, string>(DateType.Today, "Today"),
|
||||||
|
new KeyValuePair<DateType, string>(DateType.LastWeek, "Last Week"),
|
||||||
|
new KeyValuePair<DateType, string>(DateType.LastMonth, "Last Month")
|
||||||
|
};
|
||||||
|
var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
|
ddb.GetText = () => lookup[filter.Date];
|
||||||
|
ddb.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
Func<KeyValuePair<DateType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(
|
||||||
|
tpl,
|
||||||
|
() => filter.Date == option.Key,
|
||||||
|
() => { filter.Date = option.Key; ApplyFilter(); }
|
||||||
|
);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Duration
|
||||||
|
//
|
||||||
|
{
|
||||||
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_DURATION_DROPDOWNBUTTON");
|
||||||
|
if (ddb != null)
|
||||||
|
{
|
||||||
|
// Using list to maintain the order
|
||||||
|
var options = new List<KeyValuePair<DurationType, string>>
|
||||||
|
{
|
||||||
|
new KeyValuePair<DurationType, string>(DurationType.Any, ddb.GetText()),
|
||||||
|
new KeyValuePair<DurationType, string>(DurationType.VeryShort, "Under 5 min"),
|
||||||
|
new KeyValuePair<DurationType, string>(DurationType.Short, "Short (10 min)"),
|
||||||
|
new KeyValuePair<DurationType, string>(DurationType.Medium, "Medium (30 min)"),
|
||||||
|
new KeyValuePair<DurationType, string>(DurationType.Long, "Long (60+ min)")
|
||||||
|
};
|
||||||
|
var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
|
ddb.GetText = () => lookup[filter.Duration];
|
||||||
|
ddb.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
Func<KeyValuePair<DurationType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(
|
||||||
|
tpl,
|
||||||
|
() => filter.Duration == option.Key,
|
||||||
|
() => { filter.Duration = option.Key; ApplyFilter(); }
|
||||||
|
);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Outcome
|
||||||
|
//
|
||||||
|
{
|
||||||
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_OUTCOME_DROPDOWNBUTTON");
|
||||||
|
if (ddb != null)
|
||||||
|
{
|
||||||
|
// Using list to maintain the order
|
||||||
|
var options = new List<KeyValuePair<WinState, string>>
|
||||||
|
{
|
||||||
|
new KeyValuePair<WinState, string>(WinState.Undefined, ddb.GetText()),
|
||||||
|
new KeyValuePair<WinState, string>(WinState.Won, "Won"),
|
||||||
|
new KeyValuePair<WinState, string>(WinState.Lost, "Lost")
|
||||||
|
};
|
||||||
|
var lookup = options.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
|
ddb.GetText = () => lookup[filter.Outcome];
|
||||||
|
ddb.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
Func<KeyValuePair<WinState, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(
|
||||||
|
tpl,
|
||||||
|
() => filter.Outcome == option.Key,
|
||||||
|
() => { filter.Outcome = option.Key; ApplyFilter(); }
|
||||||
|
);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Players
|
||||||
|
//
|
||||||
|
{
|
||||||
|
var ddb = panel.GetOrNull<DropDownButtonWidget>("FLT_PLAYER_DROPDOWNBUTTON");
|
||||||
|
if (ddb != null)
|
||||||
|
{
|
||||||
|
var options = new HashSet<string>(replays.SelectMany(r => r.Session.Value.Clients.Select(c => c.Name)), StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
options.Sort(StringComparer.OrdinalIgnoreCase);
|
||||||
|
options.Insert(0, null); // no filter
|
||||||
|
|
||||||
|
var nobodyText = ddb.GetText();
|
||||||
|
ddb.GetText = () => string.IsNullOrEmpty(filter.PlayerName) ? nobodyText : filter.PlayerName;
|
||||||
|
ddb.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(
|
||||||
|
tpl,
|
||||||
|
() => string.Compare(filter.PlayerName, option, true) == 0,
|
||||||
|
() => { filter.PlayerName = option; ApplyFilter(); }
|
||||||
|
);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? nobodyText;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count * 30, options, setupItem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EvaluateReplayVisibility(ReplayMetadata replay)
|
||||||
|
{
|
||||||
|
// Game type
|
||||||
|
if ((filter.Type == GameType.Multiplayer && replay.Session.Value.IsSinglePlayer) || (filter.Type == GameType.Singleplayer && !replay.Session.Value.IsSinglePlayer))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Date type
|
||||||
|
if (filter.Date != DateType.Any)
|
||||||
|
{
|
||||||
|
TimeSpan t;
|
||||||
|
switch (filter.Date)
|
||||||
|
{
|
||||||
|
case DateType.Today:
|
||||||
|
t = TimeSpan.FromDays(1d);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DateType.LastWeek:
|
||||||
|
t = TimeSpan.FromDays(7d);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DateType.LastMonth:
|
||||||
|
default:
|
||||||
|
t = TimeSpan.FromDays(30d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (replay.StartTimestampUtc < DateTime.UtcNow.Subtract(t))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Duration
|
||||||
|
if (filter.Duration != DurationType.Any)
|
||||||
|
{
|
||||||
|
double minutes = replay.Duration.TotalMinutes;
|
||||||
|
switch (filter.Duration)
|
||||||
|
{
|
||||||
|
case DurationType.VeryShort:
|
||||||
|
if (minutes >= 5)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DurationType.Short:
|
||||||
|
if (minutes < 5 || minutes >= 20)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DurationType.Medium:
|
||||||
|
if (minutes < 20 || minutes >= 60)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DurationType.Long:
|
||||||
|
if (minutes < 60)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Outcome
|
||||||
|
if (filter.Outcome != WinState.Undefined && filter.Outcome != replay.Outcome)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Player
|
||||||
|
if (!string.IsNullOrEmpty(filter.PlayerName))
|
||||||
|
{
|
||||||
|
var player = replay.Session.Value.Clients.Find(c => string.Compare(filter.PlayerName, c.Name, true) == 0);
|
||||||
|
if (player == null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyFilter()
|
||||||
|
{
|
||||||
|
foreach (var replay in replays)
|
||||||
|
replayVis[replay] = EvaluateReplayVisibility(replay);
|
||||||
|
|
||||||
|
if (selectedReplay == null || replayVis[selectedReplay] == false)
|
||||||
|
SelectFirstVisibleReplay();
|
||||||
|
|
||||||
|
panel.Get<ScrollPanelWidget>("REPLAY_LIST").Layout.AdjustChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectFirstVisibleReplay()
|
||||||
|
{
|
||||||
|
SelectReplay(replays.FirstOrDefault(r => replayVis[r]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectReplay(ReplayMetadata replay)
|
void SelectReplay(ReplayMetadata replay)
|
||||||
{
|
{
|
||||||
|
selectedReplay = replay;
|
||||||
|
selectedSpawns = (selectedReplay != null) ? LobbyUtils.GetSpawnClients(selectedReplay.Session.Value, selectedReplay.MapPreview) : null;
|
||||||
|
|
||||||
if (replay == null)
|
if (replay == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -100,12 +370,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var lobby = replay.Session.Value;
|
var lobby = replay.Session.Value;
|
||||||
|
|
||||||
selectedFilename = replay.FilePath;
|
|
||||||
selectedMap = Game.modData.MapCache[lobby.GlobalSettings.Map];
|
|
||||||
selectedSpawns = LobbyUtils.GetSpawnClients(lobby, selectedMap);
|
|
||||||
selectedDuration = WidgetUtils.FormatTimeSeconds((int)replay.Duration.TotalSeconds);
|
|
||||||
selectedValid = true;
|
|
||||||
|
|
||||||
var clients = lobby.Clients.Where(c => c.Slot != null)
|
var clients = lobby.Clients.Where(c => c.Slot != null)
|
||||||
.GroupBy(c => c.Team)
|
.GroupBy(c => c.Team)
|
||||||
.OrderBy(g => g.Key);
|
.OrderBy(g => g.Key);
|
||||||
@@ -153,17 +417,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Write("debug", "Exception while parsing replay: {0}", e);
|
Log.Write("debug", "Exception while parsing replay: {0}", e);
|
||||||
selectedFilename = null;
|
SelectReplay(null);
|
||||||
selectedValid = false;
|
|
||||||
selectedMap = MapCache.UnknownMap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchReplay()
|
void WatchReplay()
|
||||||
{
|
{
|
||||||
if (selectedFilename != null)
|
if (selectedReplay != null)
|
||||||
{
|
{
|
||||||
Game.JoinReplay(selectedFilename);
|
Game.JoinReplay(selectedReplay.FilePath);
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,12 +433,43 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
void AddReplay(ScrollPanelWidget list, ReplayMetadata replay, ScrollItemWidget template)
|
void AddReplay(ScrollPanelWidget list, ReplayMetadata replay, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => selectedFilename == replay.FilePath,
|
() => selectedReplay == replay,
|
||||||
() => SelectReplay(replay),
|
() => SelectReplay(replay),
|
||||||
() => WatchReplay());
|
() => WatchReplay());
|
||||||
var f = Path.GetFileName(replay.FilePath);
|
var f = Path.GetFileNameWithoutExtension(replay.FilePath);
|
||||||
item.Get<LabelWidget>("TITLE").GetText = () => f;
|
item.Get<LabelWidget>("TITLE").GetText = () => f;
|
||||||
|
item.IsVisible = () => { bool visible; return replayVis.TryGetValue(replay, out visible) && visible; };
|
||||||
list.AddChild(item);
|
list.AddChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Filter
|
||||||
|
{
|
||||||
|
public GameType Type;
|
||||||
|
public DateType Date;
|
||||||
|
public DurationType Duration;
|
||||||
|
public WinState Outcome = WinState.Undefined;
|
||||||
|
public string PlayerName;
|
||||||
|
}
|
||||||
|
enum GameType
|
||||||
|
{
|
||||||
|
Any,
|
||||||
|
Singleplayer,
|
||||||
|
Multiplayer
|
||||||
|
}
|
||||||
|
enum DateType
|
||||||
|
{
|
||||||
|
Any,
|
||||||
|
Today,
|
||||||
|
LastWeek,
|
||||||
|
LastMonth
|
||||||
|
}
|
||||||
|
enum DurationType
|
||||||
|
{
|
||||||
|
Any,
|
||||||
|
VeryShort,
|
||||||
|
Short,
|
||||||
|
Medium,
|
||||||
|
Long
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,109 @@ Background@REPLAYBROWSER_PANEL:
|
|||||||
Logic: ReplayBrowserLogic
|
Logic: ReplayBrowserLogic
|
||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 530
|
Width: 490
|
||||||
Height: 535
|
Height: 535
|
||||||
Children:
|
Children:
|
||||||
Label@REPLAYBROWSER_LABEL_TITLE:
|
Container@FILTERS:
|
||||||
|
X: 20
|
||||||
Y: 20
|
Y: 20
|
||||||
|
Width: 280
|
||||||
|
Height: 180
|
||||||
|
Children:
|
||||||
|
Label@FILTERS_TITLE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Text: Filter
|
||||||
|
Label@FLT_GAMETYPE_DESC:
|
||||||
|
X: 0
|
||||||
|
Y: 30
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Text: Type:
|
||||||
|
Align: Right
|
||||||
|
DropDownButton@FLT_GAMETYPE_DROPDOWNBUTTON:
|
||||||
|
X: 85
|
||||||
|
Y: 30
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Font: Regular
|
||||||
|
Text: Any
|
||||||
|
Label@FLT_DATE_DESC:
|
||||||
|
X: 0
|
||||||
|
Y: 60
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Text: Date:
|
||||||
|
Align: Right
|
||||||
|
DropDownButton@FLT_DATE_DROPDOWNBUTTON:
|
||||||
|
X: 85
|
||||||
|
Y: 60
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Font: Regular
|
||||||
|
Text: Any
|
||||||
|
Label@FLT_PLAYER_DESC:
|
||||||
|
X: 0
|
||||||
|
Y: 90
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Text: Player:
|
||||||
|
Align: Right
|
||||||
|
DropDownButton@FLT_PLAYER_DROPDOWNBUTTON:
|
||||||
|
X: 85
|
||||||
|
Y: 90
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Font: Regular
|
||||||
|
Text: Anyone
|
||||||
|
Label@FLT_OUTCOME_DESC:
|
||||||
|
X: 0
|
||||||
|
Y: 120
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Text: Outcome:
|
||||||
|
Align: Right
|
||||||
|
DropDownButton@FLT_OUTCOME_DROPDOWNBUTTON:
|
||||||
|
X: 85
|
||||||
|
Y: 120
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Font: Regular
|
||||||
|
Text: Any
|
||||||
|
Label@FLT_DURATION_DESC:
|
||||||
|
X: 0
|
||||||
|
Y: 150
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Text: Duration:
|
||||||
|
Align: Right
|
||||||
|
DropDownButton@FLT_DURATION_DROPDOWNBUTTON:
|
||||||
|
X: 85
|
||||||
|
Y: 150
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Font: Regular
|
||||||
|
Text: Any
|
||||||
|
Container@REPLAY_LIST_CONTAINER:
|
||||||
|
X: 20
|
||||||
|
Y: 210
|
||||||
|
Width: 245
|
||||||
|
Height: PARENT_BOTTOM - 270
|
||||||
|
Children:
|
||||||
|
Label@REPLAYBROWSER_LABEL_TITLE:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: 25
|
Height: 25
|
||||||
Text: Choose Replay
|
Text: Choose Replay
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Bold
|
Font: Bold
|
||||||
ScrollPanel@REPLAY_LIST:
|
ScrollPanel@REPLAY_LIST:
|
||||||
X: 20
|
X: 0
|
||||||
Y: 50
|
Y: 30
|
||||||
Width: 282
|
Width: PARENT_RIGHT
|
||||||
Height: 430
|
Height: PARENT_BOTTOM - 25
|
||||||
|
CollapseHiddenChildren: True
|
||||||
Children:
|
Children:
|
||||||
ScrollItem@REPLAY_TEMPLATE:
|
ScrollItem@REPLAY_TEMPLATE:
|
||||||
Width: PARENT_RIGHT-27
|
Width: PARENT_RIGHT-27
|
||||||
@@ -28,9 +116,20 @@ Background@REPLAYBROWSER_PANEL:
|
|||||||
X: 10
|
X: 10
|
||||||
Width: PARENT_RIGHT-20
|
Width: PARENT_RIGHT-20
|
||||||
Height: 25
|
Height: 25
|
||||||
Background@MAP_BG:
|
Container@MAP_BG_CONTAINER:
|
||||||
X: PARENT_RIGHT-WIDTH-20
|
X: PARENT_RIGHT-WIDTH-20
|
||||||
Y: 50
|
Y: 20
|
||||||
|
Width: 194
|
||||||
|
Height: 194
|
||||||
|
Children:
|
||||||
|
Label@MAP_BG_TITLE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Text: Preview
|
||||||
|
Align: Center
|
||||||
|
Font: Bold
|
||||||
|
Background@MAP_BG:
|
||||||
|
Y: 30
|
||||||
Width: 194
|
Width: 194
|
||||||
Height: 194
|
Height: 194
|
||||||
Background: dialog3
|
Background: dialog3
|
||||||
|
|||||||
Reference in New Issue
Block a user