Use ScrollItem for ra map browser
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
Map Map = null;
|
Map Map = null;
|
||||||
Widget scrollpanel;
|
Widget scrollpanel;
|
||||||
Widget itemTemplate;
|
ScrollItemWidget itemTemplate;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal MapChooserDelegate(
|
internal MapChooserDelegate(
|
||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
|
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
|
||||||
//bg.GetWidget<ButtonWidget>("BUTTON_INSTALL").OnMouseUp = mi => InstallMap();
|
//bg.GetWidget<ButtonWidget>("BUTTON_INSTALL").OnMouseUp = mi => InstallMap();
|
||||||
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
||||||
itemTemplate = scrollpanel.GetWidget<ContainerWidget>("MAP_TEMPLATE");
|
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
||||||
EnumerateMaps();
|
EnumerateMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,15 +72,11 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
if (!map.Selectable)
|
if (!map.Selectable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var template = itemTemplate.Clone() as ContainerWidget;
|
var item = ScrollItemWidget.Setup(itemTemplate, () => Map == map, () => Map = map);
|
||||||
template.Id = "MAP_{0}".F(map.Uid);
|
item.GetWidget<LabelWidget>("TITLE").GetText = () => map.Title;
|
||||||
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
item.GetWidget<LabelWidget>("PLAYERS").GetText = () => "{0}".F(map.PlayerCount);
|
||||||
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; Map = map; return true; };
|
item.GetWidget<LabelWidget>("TYPE").GetText = () => map.Type;
|
||||||
template.IsVisible = () => true;
|
scrollpanel.AddChild(item);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -450,9 +450,9 @@ Background@MAP_CHOOSER:
|
|||||||
Width:504
|
Width:504
|
||||||
Height:474
|
Height:474
|
||||||
Children:
|
Children:
|
||||||
Container@MAP_TEMPLATE:
|
ScrollItem@MAP_TEMPLATE:
|
||||||
Id:MAP_TEMPLATE
|
Id:MAP_TEMPLATE
|
||||||
Width:PARENT_RIGHT-28
|
Width:PARENT_RIGHT-27
|
||||||
Height:25
|
Height:25
|
||||||
X:2
|
X:2
|
||||||
Y:0
|
Y:0
|
||||||
|
|||||||
Reference in New Issue
Block a user