Show replay percentage as a tooltip.

This commit is contained in:
Paul Chote
2016-09-24 14:58:52 +01:00
parent 39f2949e09
commit 10b5d8a06b
6 changed files with 51 additions and 51 deletions

View File

@@ -49,6 +49,7 @@ namespace OpenRA.Mods.Common.Widgets
if (TooltipContainer == null)
return;
if (GetTooltipText != null)
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText } });
}

View File

@@ -62,14 +62,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
status.GetText = statusText;
}
var percentage = widget.GetOrNull<LabelWidget>("GAME_TIMER_PERCENTAGE");
if (percentage != null)
var timerTooltip = timer as LabelWithTooltipWidget;
if (timerTooltip != null)
{
var connection = orderManager.Connection as ReplayConnection;
if (connection != null && connection.TickCount != 0)
percentage.GetText = () => "({0}%)".F(orderManager.NetFrameNumber * 100 / connection.TickCount);
else if (timer != null)
timer.Bounds.Width += percentage.Bounds.Width;
timerTooltip.GetTooltipText = () => "{0}% complete".F(orderManager.NetFrameNumber * 100 / connection.TickCount);
else
timerTooltip.GetTooltipText = null;
}
}
}

View File

@@ -10,24 +10,13 @@ Container@INGAME_ROOT:
Children:
LogicTicker@DISCONNECT_WATCHER:
Logic: DisconnectWatcherLogic
Container@GAME_TIMER_BLOCK:
Logic: GameTimerLogic
X: WINDOW_RIGHT/2 - WIDTH
Width: 100
Height: 55
Children:
Label@GAME_TIMER:
Width: PARENT_RIGHT
Height: 30
Align: Center
Font: Title
Contrast: true
Label@GAME_TIMER_STATUS:
Y: 35
Width: PARENT_RIGHT
Height: 15
Align: Center
Label@MISSION_TEXT:
X: WINDOW_RIGHT/2 - 256
Y: 22
Width: 512
Height: 25
Font: Bold
Align: Center
Contrast: true
StrategicProgress@STRATEGIC_PROGRESS:
X: WINDOW_RIGHT/2
@@ -43,17 +32,30 @@ Container@INGAME_ROOT:
WorldCommand:
Width: WINDOW_RIGHT
Height: WINDOW_BOTTOM
Container@GAME_TIMER_BLOCK:
Logic: GameTimerLogic
X: WINDOW_RIGHT/2 - WIDTH
Width: 100
Height: 55
Children:
LabelWithTooltip@GAME_TIMER:
Width: PARENT_RIGHT
Height: 30
Align: Center
Font: Title
Contrast: true
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Label@GAME_TIMER_STATUS:
Y: 35
Width: PARENT_RIGHT
Height: 15
Align: Center
Font: Bold
Contrast: true
Container@PLAYER_ROOT:
Container@MENU_ROOT:
TooltipContainer@TOOLTIP_CONTAINER:
Label@MISSION_TEXT:
X: WINDOW_RIGHT/2 - 256
Y: 22
Width: 512
Height: 25
Font: Bold
Align: Center
Contrast: true
Container@PERF_WIDGETS:
Logic: PerfDebugLogic

View File

@@ -24,12 +24,14 @@ Container@OBSERVER_WIDGETS:
Width: 100
Height: 55
Children:
Label@GAME_TIMER:
LabelWithTooltip@GAME_TIMER:
Width: PARENT_RIGHT
Height: 30
Align: Center
Font: Title
Contrast: true
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Label@GAME_TIMER_STATUS:
Y: 32
Width: PARENT_RIGHT

View File

@@ -21,19 +21,14 @@ Container@OBSERVER_WIDGETS:
Height: 22
Background: sidebar-button-observer
Children:
Label@GAME_TIMER:
LabelWithTooltip@GAME_TIMER:
Y: 0-1
Width: PARENT_RIGHT - 30
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Align: Center
Font: TinyBold
Label@GAME_TIMER_PERCENTAGE:
X: PARENT_RIGHT - 40
Y: 0-1
Width: 30
Height: PARENT_BOTTOM
Align: Right
Font: TinyBold
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Container@TOP_BUTTONS:
Logic: MenuButtonsChromeLogic
X: 9

View File

@@ -10,6 +10,14 @@ Container@INGAME_ROOT:
Children:
LogicTicker@DISCONNECT_WATCHER:
Logic: DisconnectWatcherLogic
Label@MISSION_TEXT:
X: WINDOW_RIGHT/2 - 256
Y: 22
Width: 512
Height: 25
Font: Bold
Align: Center
Contrast: true
WorldInteractionController@INTERACTION_CONTROLLER:
Width: WINDOW_RIGHT
Height: WINDOW_BOTTOM
@@ -27,11 +35,3 @@ Container@INGAME_ROOT:
Container@PERF_ROOT:
Container@MENU_ROOT:
TooltipContainer@TOOLTIP_CONTAINER:
Label@MISSION_TEXT:
X: WINDOW_RIGHT/2 - 256
Y: 22
Width: 512
Height: 25
Font: Bold
Align: Center
Contrast: true