protected override void Layout() { Offset = HudMain.GetPixelVector(_absolutePosition) / HudMain.ResScale - Origin - alignment; base.Layout(); _absolutePosition = HudMain.GetAbsoluteVector((Position + alignment) * HudMain.ResScale); _absolutePosition.X = (float)Math.Round(_absolutePosition.X, 4); _absolutePosition.Y = (float)Math.Round(_absolutePosition.Y, 4); UpdateAlignment(); }
public override void Draw() { pageCategory.Enabled = EnableDebug; if (EnableDebug && (statsText.Element.Visible || enableOverlay) && updateTimer.ElapsedMilliseconds > 100) { IReadOnlyList <RichHudMaster.ModClient> modClients = RichHudMaster.Clients; IReadOnlyList <IFont> fonts = FontManager.Fonts; HudMain.TreeClient masterHud = HudMain.TreeManager.MainClient; BindManager.Client masterInput = BindManager.MainClient; stats.Update(); statsBuilder.Clear(); var vID = RichHudMaster.versionID; statsBuilder.Append($"Rich HUD Master (v {vID.X}.{vID.Y}.{vID.Z}.{vID.W})\n"); statsBuilder.Append($"Summary:\n"); statsBuilder.Append($"\tSE Input Blacklist: {BindManager.CurrentBlacklistMode}\n"); statsBuilder.Append($"\tInput Mode: {HudMain.InputMode}\n"); statsBuilder.Append($"\tCursor Visible: {HudMain.Cursor.Visible}\n"); statsBuilder.Append($"\tClient Mods: {modClients.Count}\n"); foreach (RichHudMaster.ModClient client in modClients) { statsBuilder.Append($"\t\t{client.name}\t\t|\tVersion: {client.VersionString}\t\t|\tSubtype: {client.ClientSubtype}\n"); } statsBuilder.Append($"\n\tHudMain:\n"); statsBuilder.Append($"\t\tHUD Spaces Updating: {HudMain.TreeManager.HudSpacesRegistered}\n"); statsBuilder.Append($"\t\tElements Updating: {HudMain.TreeManager.ElementRegistered}\n"); statsBuilder.Append($"\t\tClients Registered: {HudMain.TreeManager.Clients.Count}\n"); statsBuilder.Append($"\t\tUpdate Timers (IsHighResolution: {Stopwatch.IsHighResolution}):\n"); AddGrid(statsBuilder, new string[, ] { { "Name", "Avg", "50th", "99th" }, { "Draw", $"{stats.AvgDrawTime:F2}ms", $"{stats.Draw50th:F2}ms", $"{stats.Draw99th:F2}ms" }, { "Input", $"{stats.AvgInputTime:F2}ms", $"{stats.Input50th:F2}ms", $"{stats.Input99th:F2}ms" }, { "Total", $"{stats.AvgTotalTime:F2}ms", $"{stats.Total50th:F2}ms", $"{stats.Total99th:F2}ms" }, { "Tree*", $"{stats.AvgTreeTime:F2}ms", $"{stats.Tree50th:F2}ms", $"{stats.Tree99th:F2}ms" }, }, 3, 4); overlay.SetText(statsBuilder); if (statsText.Element.Visible) { var cursor = HudMain.Cursor as HudMain.HudCursor; statsBuilder.Append($"\n\tCursor:\n"); statsBuilder.Append($"\t\tVisible: {cursor.Visible}\n"); statsBuilder.Append($"\t\tCaptured: {cursor.IsCaptured}\n"); if (cursor.IsCaptured) { statsBuilder.Append($"\t\tPosition: {cursor.ScreenPos}\n"); var modName = cursor.CapturedElement(null, (int)HudElementAccessors.ModName) as string ?? "None"; var type = cursor.CapturedElement(null, (int)HudElementAccessors.GetType) as Type; var ZOffset = (sbyte)cursor.CapturedElement(null, (int)HudElementAccessors.ZOffset); var fullZOffset = (ushort)cursor.CapturedElement(null, (int)HudElementAccessors.FullZOffset); var pos = (Vector2)cursor.CapturedElement(null, (int)HudElementAccessors.Position); var size = (Vector2)cursor.CapturedElement(null, (int)HudElementAccessors.Size); statsBuilder.Append($"\t\t\tMod: {modName}\n"); statsBuilder.Append($"\t\t\tType: {type}\n"); statsBuilder.Append($"\t\t\tZOffset: {ZOffset}\n"); statsBuilder.Append($"\t\t\tFullZOffset: {fullZOffset}\n"); statsBuilder.Append($"\t\t\tPosition: {pos}\n"); statsBuilder.Append($"\t\t\tSize: {size}\n"); } statsBuilder.Append($"\n\tBindManager:\n"); statsBuilder.Append($"\t\tControls Registered: {BindManager.Controls.Count}\n"); statsBuilder.Append($"\t\tClients Registered: {BindManager.Clients.Count}\n"); statsBuilder.Append($"\t\tCandidate Bind: "); int i = 0, bindLength = BindManager.CandidateBindSet.Count; foreach (int conIndex in BindManager.CandidateBindSet) { statsBuilder.Append(BindManager.Controls[conIndex].DisplayName); i++; if (i != bindLength) { statsBuilder.Append(", "); } } statsBuilder.Append($"\n\n\tFontManager:\n"); statsBuilder.Append($"\t\tFonts Registered: {fonts.Count}\n\n"); foreach (IFont font in fonts) { FontStyles supportedStyles = FontStyles.Italic | FontStyles.Underline; if (font.IsStyleDefined(FontStyles.Bold)) { supportedStyles |= FontStyles.Bold; } statsBuilder.Append($"\t\t{font.Name}\n"); statsBuilder.Append($"\t\t\tAtlas PtSize: {font.PtSize}\n"); statsBuilder.Append($"\t\t\tStyles: Regular, {supportedStyles}\n\n"); } statsBuilder.Append($"Details:\n"); statsBuilder.Append($"\tMaster:\n"); GetHudStats(masterHud, statsBuilder); GetBindStats(masterInput, statsBuilder); foreach (RichHudMaster.ModClient modClient in modClients) { statsBuilder.Append($"\n\t{modClient.name}:\n"); GetHudStats(modClient.hudClient, statsBuilder); GetBindStats(modClient.bindClient, statsBuilder); } statsText.Text = statsBuilder; } updateTimer.Restart(); } if (EnableDebug && enableOverlay) { var offset = HudMain.GetPixelVector(overlayPos) / HudMain.ResScale; if (offset.X < 0f) { offset.X += overlay.Size.X * .5f; } else { offset.X -= overlay.Size.X * .5f; } if (offset.Y < 0f) { offset.Y += overlay.Size.Y * .5f; } else { offset.Y -= overlay.Size.Y * .5f; } overlay.Draw(offset, MatrixD.CreateScale(HudMain.ResScale, HudMain.ResScale, 1d) * HudMain.PixelToWorld); } }
protected override void Layout() { var specCon = MyAPIGateway.Session.CameraController as MySpectator; float scale = BvConfig.Current.genUI.hudScale; if (BvConfig.Current.genUI.resolutionScaling) { scale *= HudMain.ResScale; } if (Target.TBlock != null && Open) { Vector3D targetWorldPos, targetScreenPos; Vector2 screenBounds = new Vector2(HudMain.ScreenWidth, HudMain.ScreenHeight) * HudMain.ResScale * .5f, menuPos; if (!BvConfig.Current.genUI.useCustomPos) { if (LocalPlayer.IsLookingInBlockDir(Target.TBlock)) { targetWorldPos = Target.Position + Target.ModelOffset * .75d; targetScreenPos = LocalPlayer.GetWorldToScreenPos(targetWorldPos) / 2d; menuPos = new Vector2((float)targetScreenPos.X, (float)targetScreenPos.Y); menuPos = HudMain.GetPixelVector(menuPos) / scale; } else { menuPos = lastPos; } } else { menuPos = BvConfig.Current.genUI.hudPos; menuPos = HudMain.GetPixelVector(menuPos) / scale; if (menuPos.X < 0) { menuPos.X += .5f * quickActionMenu.Width; } else { menuPos.X -= .5f * quickActionMenu.Width; } if (menuPos.Y < 0) { menuPos.Y += .5f * quickActionMenu.Height; } else { menuPos.Y -= .5f * quickActionMenu.Height; } } if (BvConfig.Current.genUI.clampHudPos || BvConfig.Current.genUI.useCustomPos) { screenBounds -= .5f * quickActionMenu.Size; menuPos.X = MathHelper.Clamp(menuPos.X, -screenBounds.X, screenBounds.X); menuPos.Y = MathHelper.Clamp(menuPos.Y, -screenBounds.Y, screenBounds.Y); } if ((lastPos - menuPos).LengthSquared() > 1f && !(HudMain.EnableCursor && SharedBinds.LeftButton.IsPressed)) { posLerpFactor = 0f; lastPos = menuPos; } if (BvConfig.Current.genUI.useCustomPos) { posLerpFactor = 1f; } lerpScale = frameTimer.ElapsedMilliseconds / 16.6667f; posLerpFactor = Math.Min(posLerpFactor + .4f * lerpScale, 1f); quickActionMenu.Offset = Vector2.Lerp(quickActionMenu.Offset, lastPos, posLerpFactor); quickActionMenu.Visible = bpTick > 30; if (specCon != null && lastSpecSpeeds != null) { specCon.SpeedModeAngular = lastSpecSpeeds.Value.X; specCon.SpeedModeLinear = lastSpecSpeeds.Value.Y; } } else if (specCon != null) { lastSpecSpeeds = new Vector2(specCon.SpeedModeAngular, specCon.SpeedModeLinear); } // Rescale draw matrix based on config PlaneToWorldRef[0] = MatrixD.CreateScale(scale, scale, 1d) * HudMain.PixelToWorld; base.Layout(); frameTimer.Restart(); }