Use ScrollItem for ra replay browser
This commit is contained in:
@@ -22,12 +22,14 @@ namespace OpenRA.Widgets
|
||||
: base()
|
||||
{
|
||||
IsVisible = () => false;
|
||||
VisualHeight = 0;
|
||||
}
|
||||
|
||||
protected ScrollItemWidget(ScrollItemWidget other)
|
||||
: base(other)
|
||||
{
|
||||
IsVisible = () => false;
|
||||
VisualHeight = 0;
|
||||
}
|
||||
|
||||
public Func<bool> IsSelected = () => false;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
||||
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
|
||||
|
||||
var template = widget.GetWidget<LabelWidget>("REPLAY_TEMPLATE");
|
||||
var template = widget.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
|
||||
CurrentReplay = null;
|
||||
|
||||
rl.RemoveChildren();
|
||||
@@ -87,15 +87,14 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
}
|
||||
}
|
||||
|
||||
void AddReplay(ScrollPanelWidget list, string filename, LabelWidget template)
|
||||
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
|
||||
{
|
||||
var entry = template.Clone() as LabelWidget;
|
||||
entry.Id = "REPLAY_";
|
||||
entry.GetText = () => " {0}".F(Path.GetFileName(filename));
|
||||
entry.GetBackground = () => (CurrentReplay == filename) ? "dialog2" : null;
|
||||
entry.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; CurrentReplay = filename; return true; };
|
||||
entry.IsVisible = () => true;
|
||||
list.AddChild(entry);
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => CurrentReplay == filename,
|
||||
() => CurrentReplay = filename);
|
||||
var f = Path.GetFileName(filename);
|
||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
||||
list.AddChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,19 @@ Background@REPLAYBROWSER_BG:
|
||||
Width:390
|
||||
Height:300
|
||||
Children:
|
||||
Label@REPLAY_TEMPLATE:
|
||||
ScrollItem@REPLAY_TEMPLATE:
|
||||
Id:REPLAY_TEMPLATE
|
||||
Width:PARENT_RIGHT-28
|
||||
Width:PARENT_RIGHT-27
|
||||
Height:25
|
||||
X:2
|
||||
Y:0
|
||||
Visible:false
|
||||
Children:
|
||||
Label@TITLE:
|
||||
X:10
|
||||
Id:TITLE
|
||||
Width:PARENT_RIGHT-20
|
||||
Height:25
|
||||
Container@REPLAY_INFO:
|
||||
Id:REPLAY_INFO
|
||||
X:0
|
||||
|
||||
Reference in New Issue
Block a user