diff --git a/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs index 8bc91f836f..9ff1d019ca 100644 --- a/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs @@ -34,7 +34,7 @@ namespace OpenRA.Widgets.Delegates var r = Chrome.rootWidget; var bg = r.GetWidget("MAP_CHOOSER"); bg.SpecialOneArg = (map) => RefreshMapList(map); - var ml = bg.GetWidget("MAP_LIST"); + var ml = bg.GetWidget("MAP_LIST"); bg.GetWidget("MAPCHOOSER_MAP_PREVIEW").Map = () => {return Map;}; bg.GetWidget("CURMAP_TITLE").GetText = () => {return Map.Title;}; @@ -53,7 +53,7 @@ namespace OpenRA.Widgets.Delegates return true; }; - var itemTemplate = ml.GetWidget("MAP_TEMPLATE"); + var itemTemplate = ml.GetWidget("MAP_TEMPLATE"); int offset = itemTemplate.Bounds.Y; foreach (var kv in Game.AvailableMaps) { @@ -61,10 +61,11 @@ namespace OpenRA.Widgets.Delegates if (!map.Selectable) continue; - var template = itemTemplate.Clone() as ButtonWidget; + var template = itemTemplate.Clone() as LabelWidget; template.Id = "MAP_{0}".F(map.Uid); - template.GetText = () => map.Title; - template.OnMouseUp = mi => {Map = map; return true;}; + template.GetText = () => " "+map.Title; + template.GetBackground = () => ((Map == map) ? "dialog2" : null); + template.OnMouseDown = mi => {Map = map; return true;}; template.Parent = ml; template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height); @@ -72,6 +73,7 @@ namespace OpenRA.Widgets.Delegates ml.AddChild(template); offset += template.Bounds.Height; + ml.ContentHeight += template.Bounds.Height; } } diff --git a/OpenRA.Game/Widgets/LabelWidget.cs b/OpenRA.Game/Widgets/LabelWidget.cs index a22c148a2a..e8661e303d 100644 --- a/OpenRA.Game/Widgets/LabelWidget.cs +++ b/OpenRA.Game/Widgets/LabelWidget.cs @@ -32,15 +32,18 @@ namespace OpenRA.Widgets Right } - public string Text = ""; + public string Text = null; + public string Background = null; public TextAlign Align = TextAlign.Left; public bool Bold = false; public Func GetText; - + public Func GetBackground; + public LabelWidget() : base() { GetText = () => { return Text; }; + GetBackground = () => { return Background; }; } public LabelWidget(Widget other) @@ -50,10 +53,16 @@ namespace OpenRA.Widgets Align = (other as LabelWidget).Align; Bold = (other as LabelWidget).Bold; GetText = (other as LabelWidget).GetText; + GetBackground = (other as LabelWidget).GetBackground; } public override void DrawInner(World world) { + var bg = GetBackground(); + + if (bg != null) + WidgetUtils.DrawPanel(bg, RenderBounds ); + var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont; var text = GetText(); if (text == null) diff --git a/OpenRA.Game/Widgets/ListBoxWidget.cs b/OpenRA.Game/Widgets/ListBoxWidget.cs index c658226059..961f4acd6f 100644 --- a/OpenRA.Game/Widgets/ListBoxWidget.cs +++ b/OpenRA.Game/Widgets/ListBoxWidget.cs @@ -28,6 +28,8 @@ namespace OpenRA.Widgets public readonly float ScrollVelocity = 4f; public readonly int HeaderHeight = 25; + + public int ContentHeight = 0; float ListOffset = 0; bool UpPressed = false; bool DownPressed = false; diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 217dbbf541..589ade7b94 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -36,7 +36,7 @@ namespace OpenRA.Widgets public string Width = "0"; public string Height = "0"; public string Delegate = null; - public bool ClickThrough = false; + public bool ClickThrough = true; public bool Visible = true; public readonly List Children = new List(); @@ -173,7 +173,7 @@ namespace OpenRA.Widgets return true; } - public virtual bool HandleInput(MouseInput mi) { return false; } + public virtual bool HandleInput(MouseInput mi) { return !ClickThrough; } public bool HandleMouseInputOuter(MouseInput mi) { // Are we able to handle this event? diff --git a/mods/cnc/menus.yaml b/mods/cnc/menus.yaml index d0d8bf3243..09edf36a1c 100644 --- a/mods/cnc/menus.yaml +++ b/mods/cnc/menus.yaml @@ -1,14 +1,5 @@ Container: - ClickThrough:true Children: - PostGame@POSTGAME_TEXT: - Id:POSTGAME_TEXT - X:0 - Y:0 - Width: WINDOW_RIGHT - Height: WINDOW_BOTTOM - ClickThrough: true - Visible: true Background@MAINMENU_BG: Id:MAINMENU_BG X:(WINDOW_RIGHT - WIDTH)/2 @@ -776,10 +767,11 @@ Container: Width:500 Height:480 Children: - Button@MAP_TEMPLATE: + Label@MAP_TEMPLATE: Id:MAP_TEMPLATE Width:PARENT_RIGHT-28 Height:25 + ClickThrough:false X:2 Y:25 Visible:false @@ -881,6 +873,12 @@ Container: Delegate:IngameChromeDelegate Visible:false Children: + PostGame@POSTGAME_TEXT: + Id:POSTGAME_TEXT + X:0 + Y:0 + Width: WINDOW_RIGHT + Height: WINDOW_BOTTOM SpecialPowerBin@INGAME_POWERS_BIN: Id:INGAME_POWERS_BIN X:0 @@ -1006,14 +1004,12 @@ Container: Height: 250 Children: PerfGraph@GRAPH: - ClickThrough:true Id:GRAPH X:5 Y:5 Width:200 Height:200 Label@TEXT: - ClickThrough:true Id:TEXT Bold: false X:20 diff --git a/mods/ra/menus.yaml b/mods/ra/menus.yaml index 2a780442a0..cee56275db 100644 --- a/mods/ra/menus.yaml +++ b/mods/ra/menus.yaml @@ -1,14 +1,5 @@ Container: - ClickThrough:true Children: - PostGame@POSTGAME_TEXT: - Id:POSTGAME_TEXT - X:0 - Y:0 - Width: WINDOW_RIGHT - Height: WINDOW_BOTTOM - ClickThrough: true - Visible: true Background@MAINMENU_BG: Id:MAINMENU_BG X:(WINDOW_RIGHT - WIDTH)/2 @@ -776,10 +767,11 @@ Container: Width:500 Height:480 Children: - Button@MAP_TEMPLATE: + Label@MAP_TEMPLATE: Id:MAP_TEMPLATE Width:PARENT_RIGHT-28 Height:25 + ClickThrough:false X:2 Y:25 Visible:false @@ -881,6 +873,12 @@ Container: Delegate:IngameChromeDelegate Visible:false Children: + PostGame@POSTGAME_TEXT: + Id:POSTGAME_TEXT + X:0 + Y:0 + Width: WINDOW_RIGHT + Height: WINDOW_BOTTOM SpecialPowerBin@INGAME_POWERS_BIN: Id:INGAME_POWERS_BIN X:0 @@ -1006,14 +1004,12 @@ Container: Height: 250 Children: PerfGraph@GRAPH: - ClickThrough:true Id:GRAPH X:5 Y:5 Width:200 Height:200 Label@TEXT: - ClickThrough:true Id:TEXT Bold: false X:20 @@ -1104,4 +1100,6 @@ Container: Width:25 Height:25 ImageCollection:music - ImageName:prev \ No newline at end of file + ImageName:prev + +