Merge tooltip support into Button and remove ToggleButton.
This commit is contained in:
@@ -15,7 +15,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
public class ButtonTooltipLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public ButtonTooltipLogic(Widget widget, ToggleButtonWidget button)
|
||||
public ButtonTooltipLogic(Widget widget, ButtonWidget button)
|
||||
{
|
||||
var label = widget.Get<LabelWidget>("LABEL");
|
||||
var hotkey = widget.Get<LabelWidget>("HOTKEY");
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
BindOrderButton<SellOrderGenerator>(world, sidebarRoot, "SELL_BUTTON", "sell");
|
||||
BindOrderButton<RepairOrderGenerator>(world, sidebarRoot, "REPAIR_BUTTON", "repair");
|
||||
|
||||
sidebarRoot.Get<ToggleButtonWidget>("SELL_BUTTON").Key = Game.Settings.Keys.SellKey;
|
||||
sidebarRoot.Get<ToggleButtonWidget>("REPAIR_BUTTON").Key = Game.Settings.Keys.RepairKey;
|
||||
sidebarRoot.Get<ButtonWidget>("SELL_BUTTON").Key = Game.Settings.Keys.SellKey;
|
||||
sidebarRoot.Get<ButtonWidget>("REPAIR_BUTTON").Key = Game.Settings.Keys.RepairKey;
|
||||
|
||||
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
|
||||
where T : IOrderGenerator, new()
|
||||
{
|
||||
var w = parent.Get<ToggleButtonWidget>(button);
|
||||
var w = parent.Get<ButtonWidget>(button);
|
||||
w.OnClick = () => world.ToggleInputMode<T>();
|
||||
w.IsHighlighted = () => world.OrderGenerator is T;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public class ProductionTypeButtonWidget : ToggleButtonWidget
|
||||
public class ProductionTypeButtonWidget : ButtonWidget
|
||||
{
|
||||
public readonly string ProductionGroup;
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#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.FileFormats;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public class ToggleButtonWidget : ButtonWidget
|
||||
{
|
||||
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
|
||||
public readonly string TooltipText;
|
||||
public readonly string TooltipContainer;
|
||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
|
||||
public ToggleButtonWidget()
|
||||
: base()
|
||||
{
|
||||
tooltipContainer = Lazy.New(() =>
|
||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||
}
|
||||
|
||||
protected ToggleButtonWidget(ToggleButtonWidget other)
|
||||
: base(other)
|
||||
{
|
||||
TooltipTemplate = other.TooltipTemplate;
|
||||
TooltipText = other.TooltipText;
|
||||
TooltipContainer = other.TooltipContainer;
|
||||
tooltipContainer = Lazy.New(() =>
|
||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||
}
|
||||
|
||||
public override void MouseEntered()
|
||||
{
|
||||
if (TooltipContainer == null) return;
|
||||
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
||||
new WidgetArgs() {{ "button", this }});
|
||||
}
|
||||
|
||||
public override void MouseExited()
|
||||
{
|
||||
if (TooltipContainer == null) return;
|
||||
tooltipContainer.Value.RemoveTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user