diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index f15001e27a..e63198e24f 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -183,6 +183,7 @@ + diff --git a/OpenRA.Game/Widgets/ScrollItem.cs b/OpenRA.Game/Widgets/ScrollItem.cs new file mode 100644 index 0000000000..e77594b898 --- /dev/null +++ b/OpenRA.Game/Widgets/ScrollItem.cs @@ -0,0 +1,54 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Drawing; +using OpenRA.Graphics; + +namespace OpenRA.Widgets +{ + public class ScrollItemWidget : ButtonWidget + { + public ScrollItemWidget() + : base() + { + IsVisible = () => false; + } + + protected ScrollItemWidget(ScrollItemWidget other) + : base(other) + { + IsVisible = () => false; + } + + public Func IsSelected = () => false; + + public override void DrawInner() + { + var state = IsSelected() ? "scrollitem-selected" : + RenderBounds.Contains(Viewport.LastMousePos) ? "scrollitem-hover" : + null; + + if (state != null) + WidgetUtils.DrawPanel(state, RenderBounds); + } + + public override Widget Clone() { return new ScrollItemWidget(this); } + + public static ScrollItemWidget Setup(ScrollItemWidget template, Func isSelected, Action onClick) + { + var w = template.Clone() as ScrollItemWidget; + w.IsVisible = () => true; + w.IsSelected = isSelected; + w.OnClick = onClick; + return w; + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs b/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs index 0e8f8e7fe3..10e09bde21 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs @@ -226,43 +226,5 @@ namespace OpenRA.Mods.Cnc.Widgets ShowDropPanel(w, dropDown, dismissAfter, () => true); } } - - public class ScrollItemWidget : ButtonWidget - { - public ScrollItemWidget() - : base() - { - IsVisible = () => false; - } - - protected ScrollItemWidget(ScrollItemWidget other) - : base(other) - { - IsVisible = () => false; - } - - public Func IsSelected = () => false; - - public override void DrawInner() - { - var state = IsSelected() ? "button-pressed" : - RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : - null; - - if (state != null) - WidgetUtils.DrawPanel(state, RenderBounds); - } - - public override Widget Clone() { return new ScrollItemWidget(this); } - - public static ScrollItemWidget Setup(ScrollItemWidget template, Func isSelected, Action onClick) - { - var w = template.Clone() as ScrollItemWidget; - w.IsVisible = () => true; - w.IsSelected = isSelected; - w.OnClick = onClick; - return w; - } - } } diff --git a/mods/cnc/chrome.yaml b/mods/cnc/chrome.yaml index aea19ff095..21aa860a90 100644 --- a/mods/cnc/chrome.yaml +++ b/mods/cnc/chrome.yaml @@ -120,6 +120,31 @@ progressbar-thumb: chrome.png corner-bl: 0,190,2,2 corner-br: 62,190,2,2 + +# A copy of button-hover +scrollitem-hover: chrome.png + background: 2,130,60,60 + border-r: 62,132,2,60 + border-l: 0,130,2,60 + border-b: 2,190,60,2 + border-t: 2,128,60,2 + corner-tl: 0,128,2,2 + corner-tr: 62,128,2,2 + corner-bl: 0,190,2,2 + corner-br: 62,190,2,2 + +# A copy of button-pressed +scrollitem-selected: chrome.png + background: 66,194,60,60 + border-r: 126,194,2,60 + border-l: 64,194,2,60 + border-b: 66,254,60,2 + border-t: 66,192,60,2 + corner-tl: 64,192,2,2 + corner-tr: 126,192,2,2 + corner-bl: 64,254,2,2 + corner-br: 126,254,2,2 + panel-black: chrome.png background: 66,2,60,60 border-r: 126,2,2,60