public override void Close() { InputMode = HudInputMode.NoInput; EnableCursor = false; instance = null; treeManager = null; }
private HudMain() : base(ApiModuleTypes.HudMain, false, true) { if (_instance != null) { throw new Exception("Only one instance of HudMain can exist at any give time!"); } _instance = this; var members = GetApiData(); cursor = new HudCursor(members.Item1); GetTextBoardDataFunc = members.Item2; GetOrSetMemberFunc = members.Item3; UnregisterAction = members.Item4; PixelToWorldRef = new MatrixD[1]; root = new HudClientRoot(); highDpiRoot = new ScaledSpaceNode(root) { UpdateScaleFunc = () => ResScale }; Action <List <HudUpdateAccessors>, byte> rootDelegate = root.GetUpdateAccessors, safeAccessor = (List <HudUpdateAccessors> list, byte depth) => { ExceptionHandler.Run(() => rootDelegate(list, depth)); }; // Register update delegate GetOrSetMemberFunc(safeAccessor, (int)HudMainAccessors.GetUpdateAccessors); root.CustomDrawAction = HudMasterDraw; root.CustomInputAction = HudMasterInput; UpdateCache(); }
public void Initialize() { OrdersPanelScript = GameObject.Find(goMonitor).transform.Find(goUIScreen).Find(goCompCanvas).Find(goApps).Find(goOrdersPanel).gameObject.GetComponent <OrderUI>(); hudScript = GameObject.Find("HudCanvas").GetComponent <HudMain>(); note = GameObject.Find("HudCanvas").transform.Find("Phone").gameObject.GetComponent <Notifications>(); achiev = GameObject.Find("NotificationCanvas").transform.Find("Acheivments").gameObject.GetComponent <AchievmentsUI>(); UIController = GameObject.Find("UiController").GetComponent <UIController>(); shopManager = GameObject.Find("Shop").transform.Find("ItemManager").GetComponent <ShopManagerClass> (); }
/// <summary> /// Gets input focus for keyboard controls. Input focus normally taken when an /// element with mouse input is clicked. /// </summary> public virtual void GetInputFocus() { if (!hasFocus) { hasFocus = true; HudMain.GetInputFocus(LoseFocusCallback); GainedInputFocus?.Invoke(_parent, EventArgs.Empty); } }
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(); }
protected override void AfterInit() { HudMain.Init(); RebindDialog.Init(); RichHudDebug.Init(); InitSettingsMenu(); RegisterClientHandler(); CheckClientQueue(); if (MenuUtilities.CanAddElements) { MenuUtilities.AddMenuElements(GetModMenuButton()); } }
private TreeManager() { HudMain.Init(); if (treeManager == null) { treeManager = this; } else { throw new Exception($"Only one instance of {GetType().Name} can exist at any given time."); } updateAccessors = new List <HudUpdateAccessors>(200); distMap = new Dictionary <Func <Vector3D>, ushort>(50); uniqueOriginFuncs = new HashSet <Func <Vector3D> >(); indexBuffer = new List <ulong>(200); depthTestActions = new List <Action>(200); depthTestActionBuffer = new List <Action>(200); inputActions = new List <Action>(200); inputActionBuffer = new List <Action>(200); drawActions = new List <Action>(200); drawActionBuffer = new List <Action>(200); layoutActions = new List <Action <bool> >(200); clients = new List <TreeClient>(); mainClient = new TreeClient() { GetUpdateAccessors = instance._root.GetUpdateAccessors }; drawTimer = new Stopwatch(); drawTimes = new long[tickResetInterval]; inputTimer = new Stopwatch(); inputTimes = new long[tickResetInterval]; treeTimer = new Stopwatch(); treeTimes = new long[tickResetInterval]; }
private HudMain() : base(false, true) { if (instance == null) { instance = this; } else { throw new Exception("Only one instance of HudMain can exist at any given time."); } _root = new HudRoot(); _highDpiRoot = new ScaledSpaceNode(_root) { UpdateScaleFunc = () => ResScale }; _cursor = new HudCursor(_root); UpdateScreenScaling(); TreeManager.Init(); }
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(); }
/// <summary> /// Brings the window into the foreground /// </summary> public virtual void GetFocus() { layerData.zOffsetInner = HudMain.GetFocusOffset(LoseFocusCallback); WindowActive = true; }
public override void Close() { UnregisterAction(); PixelToWorldRef = null; Instance = null; }
public override void Close() { UnregisterAction(); _instance = null; }