Add automatic screen output and formatting to Consoles.
This commit is contained in:
parent
b1d12bad28
commit
b7fa9cb2cd
|
@ -2,9 +2,11 @@
|
||||||
// Provides a Print() function that will both call MyGridProgram.Echo()
|
// Provides a Print() function that will both call MyGridProgram.Echo()
|
||||||
// and also output to the Programmable Block's LCD.
|
// and also output to the Programmable Block's LCD.
|
||||||
|
|
||||||
|
using Sandbox.Common.ObjectBuilders;
|
||||||
using Sandbox.ModAPI.Ingame;
|
using Sandbox.ModAPI.Ingame;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using VRage.Game.GUI.TextPanel;
|
||||||
using VRage.Game.ModAPI.Ingame.Utilities;
|
using VRage.Game.ModAPI.Ingame.Utilities;
|
||||||
|
|
||||||
namespace IngameScript
|
namespace IngameScript
|
||||||
|
@ -41,7 +43,7 @@ namespace IngameScript
|
||||||
private int _tickCount = 0;
|
private int _tickCount = 0;
|
||||||
private Program _program;
|
private Program _program;
|
||||||
private string _programName;
|
private string _programName;
|
||||||
private int _maxLines;
|
private int _maxLines = 10;
|
||||||
|
|
||||||
private const int DefaultMaxLines = 10;
|
private const int DefaultMaxLines = 10;
|
||||||
|
|
||||||
|
@ -51,8 +53,32 @@ namespace IngameScript
|
||||||
_programName = programName;
|
_programName = programName;
|
||||||
|
|
||||||
// Check the PB's custom data for a maxlines directive.
|
// 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);
|
_program.Ini.TryParse(program.Me.CustomData);
|
||||||
_maxLines = _program.Ini.Get("console", "maxLines").ToInt32(DefaultMaxLines);
|
_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)
|
public void Print(string text)
|
||||||
|
|
|
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirMonitor", "AirMonitor\Ai
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8a3cdcc5-4b55-4d87-a415-698a0e1ff06f}") = "Sequencer", "Mixins\Sequencer\Sequencer.shproj", "{722a2146-2e38-477c-9587-55075b8fa0e6}"
|
Project("{8a3cdcc5-4b55-4d87-a415-698a0e1ff06f}") = "Sequencer", "Mixins\Sequencer\Sequencer.shproj", "{722a2146-2e38-477c-9587-55075b8fa0e6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8a3cdcc5-4b55-4d87-a415-698a0e1ff06f}") = "Console", "Mixins\Console\Console.shproj", "{323e8400-84c2-46a0-b2e9-fcd3b31681da}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -38,9 +40,5 @@ Global
|
||||||
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Debug|Any CPU.Build.0 = Debug|x64
|
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Release|Any CPU.ActiveCfg = Release|x64
|
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Release|Any CPU.Build.0 = Release|x64
|
{40B352CD-100E-4F87-A7A0-FF00F4B8846C}.Release|Any CPU.Build.0 = Release|x64
|
||||||
# {722a2146-2e38-477c-9587-55075b8fa0e6}.Debug|Any CPU.ActiveCfg = Debug|x64
|
|
||||||
# {722a2146-2e38-477c-9587-55075b8fa0e6}.Debug|Any CPU.Build.0 = Debug|x64
|
|
||||||
# {722a2146-2e38-477c-9587-55075b8fa0e6}.Release|Any CPU.ActiveCfg = Release|x64
|
|
||||||
# {722a2146-2e38-477c-9587-55075b8fa0e6}.Release|Any CPU.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user