More bugfixes, and add failover code to InfoDisplays.

This commit is contained in:
Anna Rose 2025-03-01 00:23:42 -05:00
parent a786ee2720
commit 99ad625545
3 changed files with 17 additions and 7 deletions

View File

@ -24,4 +24,6 @@
<AdditionalFiles Include="thumb.png" />
</ItemGroup>
<Import Project="..\Mixins\Console\Console.projitems" Label="shared" />
<Import Project="..\Mixins\FailoverManager\FailoverManager.projitems" Label="shared" />
<Import Project="..\Mixins\ScaledGridDisplay\ScaledGridDisplay.projitems" Label="shared" />
</Project>

View File

@ -9,12 +9,14 @@ namespace IngameScript
public IConsole Console { get; private set; }
public MyIni Ini { get; private set; }
private FailoverManager _failover;
private ResourceReport _oreReport = null;
public Program()
{
Ini = new MyIni();
Console = new MainConsole(this, "Info Displays");
_failover = new FailoverManager(this, Console, Ini);
// find displays that are configured to show info, create the necessary objects.
// TODO: currently we only support one display per report, and we just use the first one
@ -67,6 +69,7 @@ namespace IngameScript
public void Main(string argument, UpdateType updateSource)
{
Console.UpdateTickCount();
if (_failover.ActiveCheck() == FailoverState.Standby) return;
if (_oreReport != null)
{

View File

@ -1,5 +1,7 @@
using Sandbox.ModAPI.Ingame;
using System.Collections.Generic;
using VRage.Game.GUI.TextPanel;
using VRageMath;
namespace IngameScript
{
@ -21,8 +23,11 @@ namespace IngameScript
private int _columns;
private float _columnWidth;
public ScaledGridDisplay(IMyTextSurface surface, int rows, int columns)
private IConsole _console;
public ScaledGridDisplay(IMyTextSurface surface, int rows, int columns, IConsole console)
{
_console = new PrefixedConsole(console, "ScaledGridDisplay");
// Setup draw surface
_surface = surface;
_surface.ScriptBackgroundColor = new Color(0, 0, 0, 255);
@ -39,8 +44,8 @@ namespace IngameScript
// Calculate grid geometry
_rows = rows;
_columns = columns;
_topPadding = (_viewport.Size.Y / rows) * 0.3;
_rowHeight = (_viewport.Size.Y - topPadding) / rows;
_topPadding = _viewport.Size.Y / rows * 0.3f;
_rowHeight = (_viewport.Size.Y - _topPadding) / rows;
_columnWidth = (_viewport.Size.X - LeftPadding) / columns;
}
@ -57,13 +62,13 @@ namespace IngameScript
switch (row)
{
case 0:
sprite.Scale = _scale * 1.2f;
sprite.RotationOrScale = _scale * 1.2f;
break;
case 1:
sprite.Scale = _scale * 1.1f;
sprite.RotationOrScale = _scale * 1.1f;
break;
default:
sprite.Scale = _scale;
sprite.RotationOrScale = _scale;
break;
}
break;
@ -81,7 +86,7 @@ namespace IngameScript
public void Draw()
{
MySpriteDrawFrame frame = _surface.DrawFrame();
foreach (MySprite sprite in _staticSprites.Values) frame.Add(sprite);
foreach (MySprite sprite in _sprites) frame.Add(sprite);
frame.Dispose();
}