static void DrawTimelineWindow() { if (Multiplayer.Client == null) { return; } Rect rect = new Rect(0, 30f, UI.screenWidth - TimelineMargin * 2, TimelineHeight); Widgets.DrawBoxSolid(rect, new Color(0.6f, 0.6f, 0.6f, 0.8f)); int timerStart = Multiplayer.session.replayTimerStart >= 0 ? Multiplayer.session.replayTimerStart : OnMainThread.cachedAtTime; int timerEnd = Multiplayer.session.replayTimerEnd >= 0 ? Multiplayer.session.replayTimerEnd : TickPatch.tickUntil; int timeLen = timerEnd - timerStart; Widgets.DrawLine(new Vector2(rect.xMin + 2f, rect.yMin), new Vector2(rect.xMin + 2f, rect.yMax), Color.white, 4f); Widgets.DrawLine(new Vector2(rect.xMax - 2f, rect.yMin), new Vector2(rect.xMax - 2f, rect.yMax), Color.white, 4f); float progress = (TickPatch.Timer - timerStart) / (float)timeLen; float progressX = rect.xMin + progress * rect.width; Widgets.DrawLine(new Vector2(progressX, rect.yMin), new Vector2(progressX, rect.yMax), Color.green, 7f); float mouseX = Event.current.mousePosition.x; ReplayEvent mouseEvent = null; foreach (var ev in Multiplayer.session.events) { if (ev.time < timerStart || ev.time > timerEnd) { continue; } var pointX = rect.xMin + (ev.time - timerStart) / (float)timeLen * rect.width; //GUI.DrawTexture(new Rect(pointX - 12f, rect.yMin - 24f, 24f, 24f), texture); Widgets.DrawLine(new Vector2(pointX, rect.yMin), new Vector2(pointX, rect.yMax), ev.color, 5f); if (Mouse.IsOver(rect) && Math.Abs(mouseX - pointX) < 10) { mouseX = pointX; mouseEvent = ev; } } if (Mouse.IsOver(rect)) { float mouseProgress = (mouseX - rect.xMin) / rect.width; int mouseTimer = timerStart + (int)(timeLen * mouseProgress); Widgets.DrawLine(new Vector2(mouseX, rect.yMin), new Vector2(mouseX, rect.yMax), Color.blue, 3f); if (Event.current.type == EventType.MouseUp) { TickPatch.skipTo = mouseTimer; if (mouseTimer < TickPatch.Timer) { ClientJoiningState.ReloadGame(OnMainThread.cachedMapData.Keys.ToList(), false); } } if (Event.current.isMouse) { Event.current.Use(); } string tooltip = $"Tick {mouseTimer}"; if (mouseEvent != null) { tooltip = $"{mouseEvent.name}\n{tooltip}"; } TooltipHandler.TipRegion(rect, new TipSignal(tooltip, 215462143)); // No delay between the mouseover and showing if (TooltipHandler.activeTips.TryGetValue(215462143, out ActiveTip tip)) { tip.firstTriggerTime = 0; } } if (TickPatch.skipTo >= 0) { float pct = (TickPatch.skipTo - timerStart) / (float)timeLen; float skipToX = rect.xMin + rect.width * pct; Widgets.DrawLine(new Vector2(skipToX, rect.yMin), new Vector2(skipToX, rect.yMax), Color.yellow, 4f); } }
static void DrawTimelineWindow() { Rect rect = new Rect(0, 30f, UI.screenWidth - TimelineMargin * 2, TimelineHeight); Widgets.DrawBoxSolid(rect, new Color(0.6f, 0.6f, 0.6f, 0.8f)); int timerStart = Multiplayer.session.replayTimerStart >= 0 ? Multiplayer.session.replayTimerStart : Multiplayer.session.dataSnapshot.cachedAtTime; int timerEnd = Multiplayer.session.replayTimerEnd >= 0 ? Multiplayer.session.replayTimerEnd : TickPatch.tickUntil; int timeLen = timerEnd - timerStart; MpUI.DrawRotatedLine(new Vector2(rect.xMin + 2f, rect.center.y), TimelineHeight, 20f, 90f, Color.white); MpUI.DrawRotatedLine(new Vector2(rect.xMax - 2f, rect.center.y), TimelineHeight, 20f, 90f, Color.white); float progress = (TickPatch.Timer - timerStart) / (float)timeLen; float progressX = rect.xMin + progress * rect.width; MpUI.DrawRotatedLine(new Vector2((int)progressX, rect.center.y), TimelineHeight, 20f, 90f, Color.green); float mouseX = Event.current.mousePosition.x; ReplayEvent mouseEvent = null; foreach (var ev in Multiplayer.session.events) { if (ev.time < timerStart || ev.time > timerEnd) { continue; } var pointX = rect.xMin + (ev.time - timerStart) / (float)timeLen * rect.width; //GUI.DrawTexture(new Rect(pointX - 12f, rect.yMin - 24f, 24f, 24f), texture); MpUI.DrawRotatedLine(new Vector2(pointX, rect.center.y), TimelineHeight, 20f, 90f, ev.color); if (Mouse.IsOver(rect) && Math.Abs(mouseX - pointX) < 10) { mouseX = pointX; mouseEvent = ev; } } if (Mouse.IsOver(rect)) { float mouseProgress = (mouseX - rect.xMin) / rect.width; int mouseTimer = timerStart + (int)(timeLen * mouseProgress); MpUI.DrawRotatedLine(new Vector2(mouseX, rect.center.y), TimelineHeight, 15f, 90f, Color.blue); if (Event.current.type == EventType.MouseUp) { TickPatch.SetSimulation(mouseTimer, canESC: true); if (mouseTimer < TickPatch.Timer) { ClientJoiningState.ReloadGame(Multiplayer.session.dataSnapshot.mapData.Keys.ToList(), false, Multiplayer.GameComp.asyncTime); } } if (Event.current.isMouse) { Event.current.Use(); } string tooltip = $"Tick {mouseTimer}"; if (mouseEvent != null) { tooltip = $"{mouseEvent.name}\n{tooltip}"; } const int TickTipId = 215462143; TooltipHandler.TipRegion(rect, new TipSignal(tooltip, TickTipId)); // Remove delay between the mouseover and showing if (TooltipHandler.activeTips.TryGetValue(TickTipId, out ActiveTip tip)) { tip.firstTriggerTime = 0; } } if (TickPatch.Simulating) { float pct = (TickPatch.simulating.target.Value - timerStart) / (float)timeLen; float simulateToX = rect.xMin + rect.width * pct; MpUI.DrawRotatedLine(new Vector2(simulateToX, rect.center.y), TimelineHeight, 15f, 90f, Color.yellow); } }