Use ScrollItem for ra map browser

This commit is contained in:
Paul Chote
2011-05-22 14:22:03 +12:00
parent db417545e6
commit 46c870b967
2 changed files with 10 additions and 14 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{
Map Map = null;
Widget scrollpanel;
Widget itemTemplate;
ScrollItemWidget itemTemplate;
[ObjectCreator.UseCtor]
internal MapChooserDelegate(
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
//bg.GetWidget<ButtonWidget>("BUTTON_INSTALL").OnMouseUp = mi => InstallMap();
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
itemTemplate = scrollpanel.GetWidget<ContainerWidget>("MAP_TEMPLATE");
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
EnumerateMaps();
}
@@ -71,16 +71,12 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
var map = kv.Value;
if (!map.Selectable)
continue;
var template = itemTemplate.Clone() as ContainerWidget;
template.Id = "MAP_{0}".F(map.Uid);
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; Map = map; return true; };
template.IsVisible = () => true;
template.GetWidget<LabelWidget>("TITLE").GetText = () => map.Title;
template.GetWidget<LabelWidget>("PLAYERS").GetText = () => "{0}".F(map.PlayerCount);
template.GetWidget<LabelWidget>("TYPE").GetText = () => map.Type;
scrollpanel.AddChild(template);
var item = ScrollItemWidget.Setup(itemTemplate, () => Map == map, () => Map = map);
item.GetWidget<LabelWidget>("TITLE").GetText = () => map.Title;
item.GetWidget<LabelWidget>("PLAYERS").GetText = () => "{0}".F(map.PlayerCount);
item.GetWidget<LabelWidget>("TYPE").GetText = () => map.Type;
scrollpanel.AddChild(item);
}
}

View File

@@ -450,9 +450,9 @@ Background@MAP_CHOOSER:
Width:504
Height:474
Children:
Container@MAP_TEMPLATE:
ScrollItem@MAP_TEMPLATE:
Id:MAP_TEMPLATE
Width:PARENT_RIGHT-28
Width:PARENT_RIGHT-27
Height:25
X:2
Y:0