Skip to content

Commit

Permalink
Add limits to GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-steas committed Feb 3, 2024
1 parent da35e20 commit 3e8864c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ public void UpdateWeaponText(List<SorterWeaponLogic> weapons)
weaponStatus.Remove(weaponTextId);
}

int i = 0;
foreach (var weapon in weapons)
{
if (i > 14)
break;
UpdateWeaponText(weapon);
i++;
}
}

public void ClearWeaponText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 { }
}
Expand Down

0 comments on commit 3e8864c

Please sign in to comment.