Add automatic screen output and formatting to Consoles.

This commit is contained in:
2025-02-13 00:50:11 -05:00
parent b1d12bad28
commit b7fa9cb2cd
2 changed files with 29 additions and 5 deletions

View File

@ -2,9 +2,11 @@
// Provides a Print() function that will both call MyGridProgram.Echo()
// and also output to the Programmable Block's LCD.
using Sandbox.Common.ObjectBuilders;
using Sandbox.ModAPI.Ingame;
using System.Collections.Generic;
using System.Text;
using VRage.Game.GUI.TextPanel;
using VRage.Game.ModAPI.Ingame.Utilities;
namespace IngameScript
@ -41,7 +43,7 @@ namespace IngameScript
private int _tickCount = 0;
private Program _program;
private string _programName;
private int _maxLines;
private int _maxLines = 10;
private const int DefaultMaxLines = 10;
@ -51,8 +53,32 @@ namespace IngameScript
_programName = programName;
// Check the PB's custom data for a maxlines directive.
// TODO: can we check for which block we are and adjust accordingly? Using screen size perhaps...
_program.Ini.TryParse(program.Me.CustomData);
_maxLines = _program.Ini.Get("console", "maxLines").ToInt32(DefaultMaxLines);
// Setup the block's screens
_program.Me.GetSurface(0).ContentType = ContentType.TEXT_AND_IMAGE;
_program.Me.GetSurface(0).WriteText("Initializing...");
_program.Me.GetSurface(1).ContentType = ContentType.TEXT_AND_IMAGE;
_program.Me.GetSurface(1).FontSize = 3.5f;
_program.Me.GetSurface(1).TextPadding = 22.5f;
_program.Me.GetSurface(1).Alignment = TextAlignment.CENTER;
_program.Me.GetSurface(1).WriteText("Initializing...");
switch ((int)_program.Me.GetSurface(1).SurfaceSize.X)
{
case 512:
_maxLines = 10;
break;
case 256:
_maxLines = 17;
break;
default:
Print("Warning: unknown Programmable Block size.");
break;
}
}
public void Print(string text)