diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 4fc4e832cb..4bc60a33b3 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -23,8 +23,10 @@ namespace OpenRA.Widgets public int VisualHeight = ChromeMetrics.Get("ButtonDepth"); public string Font = ChromeMetrics.Get("ButtonFont"); public bool Disabled = false; + public bool Highlighted = false; public Func GetText; public Func IsDisabled; + public Func IsHighlighted; public Action OnMouseDown = _ => {}; public Action OnMouseUp = _ => {}; @@ -39,6 +41,7 @@ namespace OpenRA.Widgets OnMouseUp = _ => OnClick(); OnKeyPress = _ => OnClick(); IsDisabled = () => Disabled; + IsHighlighted = () => Highlighted; } protected ButtonWidget(ButtonWidget widget) @@ -52,6 +55,8 @@ namespace OpenRA.Widgets OnMouseDown = widget.OnMouseDown; Disabled = widget.Disabled; IsDisabled = widget.IsDisabled; + Highlighted = widget.Highlighted; + IsHighlighted = widget.IsHighlighted; OnMouseUp = mi => OnClick(); OnKeyPress = _ => OnClick(); @@ -124,13 +129,14 @@ namespace OpenRA.Widgets { var rb = RenderBounds; var disabled = IsDisabled(); + var highlighted = IsHighlighted(); var font = Game.Renderer.Fonts[Font]; var text = GetText(); var s = font.Measure(text); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); - DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this); + DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this, highlighted); font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, disabled ? Color.Gray : Color.White); } @@ -138,17 +144,19 @@ namespace OpenRA.Widgets public override Widget Clone() { return new ButtonWidget(this); } public virtual int UsableWidth { get { return Bounds.Width; } } - public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover) + public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted) { - ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover); + ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover, highlighted); } - public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover) + public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted) { var state = disabled ? "-disabled" : pressed ? "-pressed" : hover ? "-hover" : ""; + if (highlighted) + state += "-highlighted"; WidgetUtils.DrawPanel(baseName + state, rect); } diff --git a/OpenRA.Game/Widgets/ScrollPanelWidget.cs b/OpenRA.Game/Widgets/ScrollPanelWidget.cs index c896775306..365670a007 100644 --- a/OpenRA.Game/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Game/Widgets/ScrollPanelWidget.cs @@ -79,11 +79,11 @@ namespace OpenRA.Widgets var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos); WidgetUtils.DrawPanel(Background, backgroundRect); WidgetUtils.DrawPanel("scrollpanel-bg", scrollbarRect); - ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover); - ButtonWidget.DrawBackground("button", downButtonRect, downDisabled, DownPressed, downHover); + ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover, false); + ButtonWidget.DrawBackground("button", downButtonRect, downDisabled, DownPressed, downHover, false); if (thumbHeight > 0) - ButtonWidget.DrawBackground("scrollthumb", thumbRect, false, Focused && thumbHover, thumbHover); + ButtonWidget.DrawBackground("scrollthumb", thumbRect, false, Focused && thumbHover, thumbHover, false); var upOffset = !UpPressed || upDisabled ? 4 : 4 + ButtonDepth; var downOffset = !DownPressed || downDisabled ? 4 : 4 + ButtonDepth; diff --git a/OpenRA.Game/Widgets/SliderWidget.cs b/OpenRA.Game/Widgets/SliderWidget.cs index e94a04f00a..a1cf26e6be 100755 --- a/OpenRA.Game/Widgets/SliderWidget.cs +++ b/OpenRA.Game/Widgets/SliderWidget.cs @@ -118,7 +118,7 @@ namespace OpenRA.Widgets // Thumb var thumbHover = Ui.MouseOverWidget == this && tr.Contains(Viewport.LastMousePos); - ButtonWidget.DrawBackground("scrollthumb", tr, IsDisabled(), isMoving, thumbHover); + ButtonWidget.DrawBackground("scrollthumb", tr, IsDisabled(), isMoving, thumbHover, false); } } } diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs index 3e585f4fe5..95f31484ba 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs @@ -138,8 +138,8 @@ namespace OpenRA.Mods.Cnc.Widgets var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos); WidgetUtils.DrawPanel("panel-black", rb); - ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover); - ButtonWidget.DrawBackground("button", rightButtonRect, rightDisabled, rightPressed, rightHover); + ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover, false); + ButtonWidget.DrawBackground("button", rightButtonRect, rightDisabled, rightPressed, rightHover, false); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", leftPressed || leftDisabled ? "left_pressed" : "left_arrow"), new float2(leftButtonRect.Left + 2, leftButtonRect.Top + 2)); @@ -157,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets var rect = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height); var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos); var baseName = tab.Queue == CurrentQueue ? "button-toggled" : "button"; - ButtonWidget.DrawBackground(baseName, rect, false, false, hover); + ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false); ContentWidth += TabWidth - 1; int2 textSize = font.Measure(tab.Name); diff --git a/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs b/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs index 4b46a67956..a55a807814 100644 --- a/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs @@ -53,10 +53,10 @@ namespace OpenRA.Mods.Cnc.Widgets tooltipContainer.Value.RemoveTooltip(); } - public override void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover) + public override void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted) { var baseName = IsToggled() ? "button-toggled" : "button"; - ButtonWidget.DrawBackground(baseName, rect, disabled, pressed, hover); + ButtonWidget.DrawBackground(baseName, rect, disabled, pressed, hover, highlighted); } } -} \ No newline at end of file +} diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs index 5a91a546de..4f1cd7a0c2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs @@ -45,10 +45,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var objectivesButton = gameRoot.Get("OBJECTIVES_BUTTON"); var objectivesWidget = Game.LoadWidget(world, iop.ObjectivesPanel, Ui.Root, new WidgetArgs()); objectivesWidget.Visible = false; - objectivesButton.OnClick = () => - { - objectivesWidget.Visible = !objectivesWidget.Visible; - }; + objectivesButton.OnClick += () => objectivesWidget.Visible = !objectivesWidget.Visible; objectivesButton.IsVisible = () => world.LocalPlayer != null; } diff --git a/OpenRA.Mods.RA/Widgets/Logic/MissionObjectivesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MissionObjectivesLogic.cs index 391d63a6d9..21de67faf2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MissionObjectivesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MissionObjectivesLogic.cs @@ -11,7 +11,6 @@ using System.Linq; using OpenRA.Mods.RA.Missions; using OpenRA.Network; -using OpenRA.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.RA.Widgets.Logic @@ -23,18 +22,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic Widget secondaryPanel; Widget primaryTemplate; Widget secondaryTemplate; + ButtonWidget objectivesButton; [ObjectCreator.UseCtor] public MissionObjectivesLogic(World world, Widget widget) { + var gameRoot = Ui.Root.Get("INGAME_ROOT"); primaryPanel = widget.Get("PRIMARY_OBJECTIVES"); secondaryPanel = widget.Get("SECONDARY_OBJECTIVES"); primaryTemplate = primaryPanel.Get("PRIMARY_OBJECTIVE_TEMPLATE"); secondaryTemplate = secondaryPanel.Get("SECONDARY_OBJECTIVE_TEMPLATE"); + objectives = world.WorldActor.TraitsImplementing().First(); - Game.ConnectionStateChanged += RemoveHandlers; + + objectivesButton = gameRoot.Get("OBJECTIVES_BUTTON"); + objectivesButton.IsHighlighted = () => Game.LocalTick % 60 <= 30 && objectivesButton.Highlighted; + objectivesButton.OnClick += () => objectivesButton.Highlighted = false; + objectives.ObjectivesUpdated += UpdateObjectives; UpdateObjectives(); + Game.ConnectionStateChanged += RemoveHandlers; } public void RemoveHandlers(OrderManager orderManager) @@ -48,6 +55,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic public void UpdateObjectives() { + objectivesButton.Highlighted = true; primaryPanel.RemoveChildren(); secondaryPanel.RemoveChildren(); foreach (var o in objectives.Objectives.Where(o => o.Status != ObjectiveStatus.Inactive)) diff --git a/mods/ra/chrome.yaml b/mods/ra/chrome.yaml index 2bd7854ad6..91be2c8e9a 100644 --- a/mods/ra/chrome.yaml +++ b/mods/ra/chrome.yaml @@ -249,6 +249,17 @@ button: dialog.png corner-bl: 512,82,1,1 corner-br: 594,82,1,1 +button-highlighted: dialog.png + background: 513,145,126,126 + border-r: 639,145,1,126 + border-l: 512,145,1,126 + border-b: 513,271,126,1 + border-t: 513,144,126,1 + corner-tl: 512,144,1,1 + corner-tr: 594,144,1,1 + corner-bl: 512,271,1,1 + corner-br: 594,271,1,1 + # A copy of dialog2 button-hover: dialog.png background: 513,1,126,126 @@ -261,6 +272,17 @@ button-hover: dialog.png corner-bl: 512,82,1,1 corner-br: 594,82,1,1 +button-hover-highlighted: dialog.png + background: 513,145,126,126 + border-r: 639,145,1,126 + border-l: 512,145,1,126 + border-b: 513,271,126,1 + border-t: 513,144,126,1 + corner-tl: 512,144,1,1 + corner-tr: 594,144,1,1 + corner-bl: 512,271,1,1 + corner-br: 594,271,1,1 + # A copy of dialog2 button-disabled: dialog.png background: 513,1,126,126 @@ -273,6 +295,17 @@ button-disabled: dialog.png corner-bl: 512,82,1,1 corner-br: 594,82,1,1 +button-disabled-highlighted: dialog.png + background: 513,145,126,126 + border-r: 639,145,1,126 + border-l: 512,145,1,126 + border-b: 513,271,126,1 + border-t: 513,144,126,1 + corner-tl: 512,144,1,1 + corner-tr: 594,144,1,1 + corner-bl: 512,271,1,1 + corner-br: 594,271,1,1 + # A copy of dialog3 button-pressed: dialog.png background: 641,1,126,126 @@ -284,7 +317,18 @@ button-pressed: dialog.png corner-tr: 722,0,1,1 corner-bl: 640,82,1,1 corner-br: 722,82,1,1 - + +button-pressed-highlighted: dialog.png + background: 641,145,126,126 + border-r: 767,145,1,126 + border-l: 640,145,1,126 + border-b: 641,271,126,1 + border-t: 641,144,126,1 + corner-tl: 640,144,1,1 + corner-tr: 722,144,1,1 + corner-bl: 640,271,1,1 + corner-br: 722,271,1,1 + scrollthumb: dialog.png background: 513,1,126,126 border-r: 639,1,1,126 diff --git a/mods/ra/uibits/dialog.png b/mods/ra/uibits/dialog.png index b7047caefa..a5f2cc0411 100644 Binary files a/mods/ra/uibits/dialog.png and b/mods/ra/uibits/dialog.png differ