Add owner token to TooltipContainer
This commit is contained in:
committed by
Matthias Mailänder
parent
7e72cd262c
commit
cffe5e3d9d
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public Action BeforeRender = Nothing;
|
public Action BeforeRender = Nothing;
|
||||||
public int TooltipDelayMilliseconds = 200;
|
public int TooltipDelayMilliseconds = 200;
|
||||||
Widget tooltip;
|
Widget tooltip;
|
||||||
|
int nextToken = 1;
|
||||||
|
int currentToken;
|
||||||
|
|
||||||
public TooltipContainerWidget()
|
public TooltipContainerWidget()
|
||||||
{
|
{
|
||||||
@@ -34,16 +36,29 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
IsVisible = () => Game.RunTime > Viewport.LastMoveRunTime + TooltipDelayMilliseconds;
|
IsVisible = () => Game.RunTime > Viewport.LastMoveRunTime + TooltipDelayMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTooltip(string id, WidgetArgs args)
|
public int SetTooltip(string id, WidgetArgs args)
|
||||||
{
|
{
|
||||||
RemoveTooltip();
|
RemoveTooltip();
|
||||||
|
currentToken = nextToken++;
|
||||||
|
|
||||||
tooltip = Ui.LoadWidget(id, this, new WidgetArgs(args) { { "tooltipContainer", this } });
|
tooltip = Ui.LoadWidget(id, this, new WidgetArgs(args) { { "tooltipContainer", this } });
|
||||||
|
|
||||||
|
return currentToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveTooltip(int token)
|
||||||
|
{
|
||||||
|
if (currentToken != token)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RemoveChildren();
|
||||||
|
BeforeRender = Nothing;
|
||||||
|
currentToken = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveTooltip()
|
public void RemoveTooltip()
|
||||||
{
|
{
|
||||||
RemoveChildren();
|
RemoveTooltip(currentToken);
|
||||||
BeforeRender = Nothing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw() { BeforeRender(); }
|
public override void Draw() { BeforeRender(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user