Add faction specific tooltip backgrounds.
This commit is contained in:
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public Action<MouseInput> OnMouseDown = _ => { };
|
||||
public Action<MouseInput> OnMouseUp = _ => { };
|
||||
|
||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
protected Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
[Translate] public string TooltipText;
|
||||
public Func<string> GetTooltipText;
|
||||
[Translate] public string TooltipDesc;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public readonly string TooltipTemplate;
|
||||
public readonly string TooltipContainer;
|
||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
protected Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
|
||||
public Func<string> GetTooltipText = () => "";
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class MenuButtonWidget : ButtonWidget
|
||||
public class MenuButtonWidget : WorldButtonWidget
|
||||
{
|
||||
public readonly string MenuContainer = "INGAME_MENU";
|
||||
public readonly bool Pause = true;
|
||||
@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public readonly bool DisableWorldSounds = false;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MenuButtonWidget(ModData modData)
|
||||
: base(modData) { }
|
||||
public MenuButtonWidget(ModData modData, World world)
|
||||
: base(modData, world) { }
|
||||
|
||||
protected MenuButtonWidget(MenuButtonWidget other)
|
||||
: base(other)
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
if (TooltipContainer != null)
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
||||
new WidgetArgs() { { "player", World.LocalPlayer }, { "getTooltipIcon", GetTooltipIcon } });
|
||||
new WidgetArgs() { { "player", World.LocalPlayer }, { "getTooltipIcon", GetTooltipIcon }, { "world", World } });
|
||||
}
|
||||
|
||||
public override void MouseExited()
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class ProductionTypeButtonWidget : ButtonWidget
|
||||
public class ProductionTypeButtonWidget : WorldButtonWidget
|
||||
{
|
||||
public readonly string ProductionGroup;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ProductionTypeButtonWidget(ModData modData)
|
||||
: base(modData) { }
|
||||
public ProductionTypeButtonWidget(ModData modData, World world)
|
||||
: base(modData, world) { }
|
||||
|
||||
protected ProductionTypeButtonWidget(ProductionTypeButtonWidget other)
|
||||
: base(other)
|
||||
|
||||
@@ -33,10 +33,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public Func<Color> GetBarColor = () => Color.White;
|
||||
EWMA providedLerp = new EWMA(0.3f);
|
||||
EWMA usedLerp = new EWMA(0.3f);
|
||||
readonly World world;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ResourceBarWidget(World world)
|
||||
{
|
||||
this.world = world;
|
||||
tooltipContainer = Exts.Lazy(() =>
|
||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||
}
|
||||
@@ -47,7 +49,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
return;
|
||||
|
||||
Func<string> getText = () => TooltipFormat.F(GetUsed(), GetProvided());
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", getText } });
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", getText }, { "world", world } });
|
||||
}
|
||||
|
||||
public override void MouseExited()
|
||||
|
||||
44
OpenRA.Mods.Common/Widgets/WorldButtonWidget.cs
Normal file
44
OpenRA.Mods.Common/Widgets/WorldButtonWidget.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2019 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class WorldButtonWidget : ButtonWidget
|
||||
{
|
||||
readonly World world;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public WorldButtonWidget(ModData modData, World world)
|
||||
: base(modData)
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
protected WorldButtonWidget(WorldButtonWidget other)
|
||||
: base(other)
|
||||
{
|
||||
world = other.world;
|
||||
}
|
||||
|
||||
public override void MouseEntered()
|
||||
{
|
||||
if (TooltipContainer == null || GetTooltipText() == null)
|
||||
return;
|
||||
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
||||
new WidgetArgs { { "button", this }, { "getText", GetTooltipText }, { "getDesc", GetTooltipDesc }, { "world", world } });
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new WorldButtonWidget(this); }
|
||||
}
|
||||
}
|
||||
44
OpenRA.Mods.Common/Widgets/WorldLabelWithTooltipWidget.cs
Normal file
44
OpenRA.Mods.Common/Widgets/WorldLabelWithTooltipWidget.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2019 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class WorldLabelWithTooltipWidget : LabelWithTooltipWidget
|
||||
{
|
||||
readonly World world;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public WorldLabelWithTooltipWidget(World world)
|
||||
: base()
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
protected WorldLabelWithTooltipWidget(WorldLabelWithTooltipWidget other)
|
||||
: base(other)
|
||||
{
|
||||
world = other.world;
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new WorldLabelWithTooltipWidget(this); }
|
||||
|
||||
public override void MouseEntered()
|
||||
{
|
||||
if (TooltipContainer == null)
|
||||
return;
|
||||
|
||||
if (GetTooltipText != null)
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText }, { "world", world } });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user