From 3e8864c1a271a6f0e0ac72a49ae9bc6fe86f5c8a Mon Sep 17 00:00:00 2001 From: Aristeas <94058548+Jnick-24@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:14:24 -0600 Subject: [PATCH] Add limits to GUI --- .../UserInterface/ReloadIndicators/ReloadWindow.cs | 6 ++++++ .../UserInterface/TurretBarrelIndicator.cs | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/ReloadIndicators/ReloadWindow.cs b/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/ReloadIndicators/ReloadWindow.cs index bd67f1f4..db0c4961 100644 --- a/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/ReloadIndicators/ReloadWindow.cs +++ b/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/ReloadIndicators/ReloadWindow.cs @@ -125,8 +125,14 @@ public void UpdateWeaponText(List weapons) weaponStatus.Remove(weaponTextId); } + int i = 0; foreach (var weapon in weapons) + { + if (i > 14) + break; UpdateWeaponText(weapon); + i++; + } } public void ClearWeaponText() diff --git a/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/TurretBarrelIndicator.cs b/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/TurretBarrelIndicator.cs index e1589849..941c3383 100644 --- a/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/TurretBarrelIndicator.cs +++ b/Orrery Combat Framework - Heart Module/Data/Scripts/HeartModule/UserInterface/TurretBarrelIndicator.cs @@ -14,20 +14,31 @@ namespace Heart_Module.Data.Scripts.HeartModule.UserInterface internal class TurretBarrelIndicator : GridBasedIndicator_Base { // TODO: Add global setting for indicator visibility + const int MaxVisibleIndicators = 100; readonly MyStringId FixedMaterial = MyStringId.GetOrCompute("WhiteDot"); readonly Vector4 FixedColor = new Vector4(1, 0.48f, 0, 0.5f); readonly MyStringId TurretMaterial = MyStringId.GetOrCompute("SquareFullColor"); readonly Vector4 TurretColor = new Vector4(1 * 2, 0.48f * 2, 0, 1f); float viewDist = 10000; + int numVisible = 0; public override void LoadData() { viewDist = MyAPIGateway.Multiplayer.MultiplayerActive ? MyAPIGateway.Session.SessionSettings.SyncDistance : MyAPIGateway.Session.SessionSettings.ViewDistance; } + public override void UpdateAfterSimulation() + { + base.UpdateAfterSimulation(); + numVisible = 0; + } + public override void PerWeaponUpdate(SorterWeaponLogic weapon) { + if (numVisible > MaxVisibleIndicators) + return; + try // TODO: Fix error that occurs here { if (!weapon.SorterWep.IsWorking) @@ -58,6 +69,8 @@ public override void PerWeaponUpdate(SorterWeaponLogic weapon) float adjSymbolHeight = (float)dist / (40f / 70f * MyAPIGateway.Session.Camera.FieldOfViewAngle); var progradeTop = progradeCtr + MyAPIGateway.Session.Camera.WorldMatrix.Up * adjSymbolHeight; MySimpleObjectDraw.DrawLine(progradeTop, progradeTop - MyAPIGateway.Session.Camera.WorldMatrix.Up * adjSymbolHeight * 2, texture, ref color, adjSymbolHeight, MyBillboard.BlendTypeEnum.AdditiveTop); // Based on BDCarrillo's Flight Vector mod + + numVisible++; } catch { } }