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,7 +49,8 @@ namespace OpenRA.Mods.Common.Widgets
if (TooltipContainer == null) if (TooltipContainer == null)
return; return;
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText } }); if (GetTooltipText != null)
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText } });
} }
public override void MouseExited() public override void MouseExited()

View File

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

View File

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

View File

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

View File

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

View File

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