grid layout mapchooser in cnc too

This commit is contained in:
Chris Forbes
2011-10-09 11:12:57 +13:00
parent d6f4b61b1c
commit 57308773a2
2 changed files with 35 additions and 192 deletions

View File

@@ -30,21 +30,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)]; map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];
var mapPreview = widget.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
if (mapPreview != null)
mapPreview.Map = () => map;
if (WidgetUtils.ActiveModTitle() != "Red Alert") // hack
{
widget.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => map.Title;
widget.GetWidget<LabelWidget>("CURMAP_AUTHOR").GetText = () => map.Author;
widget.GetWidget<LabelWidget>("CURMAP_DESC").GetText = () => map.Description;
widget.GetWidget<LabelWidget>("CURMAP_DESC_LABEL").IsVisible = () => map.Description != null;
widget.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => "{0}x{1}".F(map.Bounds.Width, map.Bounds.Height);
widget.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => Rules.TileSets[map.Tileset].Name;
widget.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => map.PlayerCount.ToString();
}
widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); }; widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); }; widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };
@@ -86,11 +71,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void EnumerateMaps() void EnumerateMaps()
{ {
scrollpanel.RemoveChildren(); scrollpanel.RemoveChildren();
scrollpanel.Layout = new GridLayout(scrollpanel);
// hack for RA's new 2d mapchooser
if (WidgetUtils.ActiveModTitle() == "Red Alert")
scrollpanel.Layout = new GridLayout(scrollpanel);
scrollpanel.ScrollToTop(); scrollpanel.ScrollToTop();
var maps = Game.modData.AvailableMaps var maps = Game.modData.AvailableMaps
@@ -107,21 +88,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var titleLabel = item.GetWidget<LabelWidget>("TITLE"); var titleLabel = item.GetWidget<LabelWidget>("TITLE");
titleLabel.GetText = () => m.Title; titleLabel.GetText = () => m.Title;
var playersLabel = item.GetWidget<LabelWidget>("PLAYERS");
if (playersLabel != null)
playersLabel.GetText = () => "{0}".F(m.PlayerCount);
var previewWidget = item.GetWidget<MapPreviewWidget>("PREVIEW"); var previewWidget = item.GetWidget<MapPreviewWidget>("PREVIEW");
if (previewWidget != null) previewWidget.IgnoreMouseOver = true;
{ previewWidget.IgnoreMouseInput = true;
previewWidget.IgnoreMouseOver = true; previewWidget.Map = () => m;
previewWidget.IgnoreMouseInput = true;
previewWidget.Map = () => m;
}
var typeWidget = item.GetWidget<LabelWidget>("TYPE");
if (typeWidget != null)
typeWidget.GetText = () => m.Type;
var detailsWidget = item.GetWidget<LabelWidget>("DETAILS"); var detailsWidget = item.GetWidget<LabelWidget>("DETAILS");
if (detailsWidget != null) if (detailsWidget != null)

View File

@@ -7,188 +7,61 @@ Container@MAPCHOOSER_PANEL:
Height:535 Height:535
Children: Children:
Label@TITLE: Label@TITLE:
Width:740 Width:790
Y:0-25 Y:0-25
Font:BigBold Font:BigBold
Contrast:true Contrast:true
Align:Center Align:Center
Text: Select Map Text: Select Map
Background@bg: Background@bg:
Width:740 Width:790
Height:500 Height:500
Background:panel-black Background:panel-black
Children: Children:
Background@MAP_BG:
X:PARENT_RIGHT-15-WIDTH
Y:30
Width:194
Height:194
Background:panel-gray
Children:
MapPreview@MAP_PREVIEW:
Id:MAP_PREVIEW
X:1
Y:1
Width:192
Height:192
ScrollPanel@MAP_LIST: ScrollPanel@MAP_LIST:
Id:MAP_LIST Id:MAP_LIST
X:15 X:15
Y:30 Y:30
Width:504 Width:PARENT_RIGHT - 30
Height:455 Height:455
Children: Children:
ScrollItem@MAP_TEMPLATE: ScrollItem@MAP_TEMPLATE:
Id:MAP_TEMPLATE Id:MAP_TEMPLATE
Width:PARENT_RIGHT-27 Width:180
Height:25 Height:208
X:2 X:2
Y:0 Y:0
Visible:false
Children: Children:
Label@TITLE: Label@TITLE:
X:10 X:2
Y:PARENT_BOTTOM-47
Id:TITLE Id:TITLE
Width:PARENT_RIGHT-100 Width:PARENT_RIGHT-4
Height:25 Height:25
Label@PLAYERS: Align:Center
Id:PLAYERS Label@DETAILS:
X:PARENT_RIGHT-150 Id:DETAILS
Width:30 Width:PARENT_RIGHT-4
X:2
Y:PARENT_BOTTOM-35
Align:Center
Height:25 Height:25
Label@TYPE: Font:Tiny
Id:TYPE Label@AUTHOR:
Width:90 Id:AUTHOR
X:PARENT_RIGHT-100 Width:PARENT_RIGHT-4
Align:Right X:2
Y:PARENT_BOTTOM-26
Align:Center
Height:25 Height:25
Container@LABEL_CONTAINER: Font:Tiny
X:25 MapPreview@PREVIEW:
Y:5 Id:PREVIEW
Children: X:(PARENT_RIGHT - WIDTH)/2
Label@TITLE: Y:4
Width:125 Width:160
Height:25 Height:160
X:0
Y:0
Text:Title
Align:Center
Font:Bold
Label@PLAYERS:
Text:Players
Font:Bold
Width:50
X:294
Height:25
Label@TYPE:
Text:Type
Font:Bold
Width:50
X:410
Height:25
Container@MAP_LABEL_CONTAINER:
X:PARENT_RIGHT-15-WIDTH-10
Y:232
Width:192
Height:200
Children:
Label@CURMAP_TITLE_LABEL:
Id:CURMAP_TITLE_LABEL
X:0
Y:0
Align:Right
Width:70
Height:20
Text:Title:
Font:Bold
Label@CURMAP_TITLE:
Id:CURMAP_TITLE
X:75
Y:0
Align:Left
Width:70
Height:20
Label@CURMAP_AUTHOR_LABEL:
Id:CURMAP_AUTHOR_LABEL
X:0
Y:20
Align:Right
Width:70
Height:20
Text:Author:
Font:Bold
Label@CURMAP_AUTHOR:
Id:CURMAP_AUTHOR
X:75
Y:20
Align:Left
Width:175
Height:20
WordWrap:True
Label@CURMAP_SIZE_LABEL:
Id:CURMAP_SIZE_LABEL
X:0
Y:40
Align:Right
Width:70
Height:20
Text:Size:
Font:Bold
Label@CURMAP_SIZE:
Id:CURMAP_SIZE
X:75
Y:40
Align:Left
Width:70
Height:20
Label@CURMAP_THEATER_LABEL:
Id:CURMAP_THEATER_LABEL
X:0
Y:60
Align:Right
Width:70
Height:20
Text:Theater:
Font:Bold
Label@CURMAP_THEATER:
Id:CURMAP_THEATER
X:75
Y:60
Align:Left
Width:70
Height:20
Label@CURMAP_PLAYERS_LABEL:
Id:CURMAP_PLAYERS_LABEL
X:0
Y:80
Align:Right
Width:70
Height:20
Text:Players:
Font:Bold
Label@CURMAP_PLAYERS:
Id:CURMAP_PLAYERS
X:75
Y:80
Align:Left
Width:70
Height:20
Label@CURMAP_DESC_LABEL:
Id:CURMAP_DESC_LABEL
X:0
Y:100
Align:Right
Width:70
Height:20
Text:Desc:
Font:Bold
Label@CURMAP_DESC:
Id:CURMAP_DESC
X:75
Y:100
Align:Left
Width:117
Height:20
WordWrap:True
Button@BUTTON_CANCEL: Button@BUTTON_CANCEL:
Id:BUTTON_CANCEL Id:BUTTON_CANCEL
Key:escape Key:escape
@@ -200,7 +73,7 @@ Container@MAPCHOOSER_PANEL:
Button@BUTTON_OK: Button@BUTTON_OK:
Id:BUTTON_OK Id:BUTTON_OK
Key:return Key:return
X:600 X:790 - WIDTH
Y:499 Y:499
Width:140 Width:140
Height:35 Height:35