Skip to content

Commit

Permalink
Fixed crash when used on PB without screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Blargmode committed Feb 29, 2020
1 parent 305d154 commit fe52121
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Fancy flight info/AAA_Description.cs
Expand Up @@ -20,7 +20,7 @@ namespace IngameScript
{
#region untouched
/*
Blargmode's Fancy Flight Info (FFI) (V4.0.3, 2019-05-09)
Blargmode's Fancy Flight Info (FFI) (V4.0.4, 2020-02-29)
This script gives you free hands in creating a fancy cockpit with data about your ship.
When this project started, I intended to replace the awful hud, then the hud got better. Now it's mostly for looks.
Expand All @@ -38,9 +38,9 @@ namespace IngameScript
This place is not good for describing this. Go to the workshop for detailed info.
Setup guide: https://steamcommunity.com/sharedfiles/filedetails/?id=907697156
Setup guide: http://blargmode.se/ffi-guide/
If you refuse or can't visit the workshop/watch the setup video, there is a way.
If you can't visit the guide, there is a way.
You can figure out a whole lot in-game as well if you're a bit crafty. Start by loading a preload like this:
1. Type the following 3 lines in Custom Data of a block with screens, e.g. an LCD panel.
[FFI 1]
Expand Down
14 changes: 9 additions & 5 deletions Fancy flight info/Main.cs
Expand Up @@ -60,11 +60,14 @@ public class Program : MyGridProgram

public Program()
{
pbSurface = Me.GetSurface(0);
pbSM = new SurfaceMath(pbSurface);
pbSurface.ContentType = ContentType.SCRIPT;
pbSurface.Script = "";
if (pbSurface.ScriptBackgroundColor != problemBG) defaultBG = pbSurface.ScriptBackgroundColor;
if(Me.SurfaceCount > 0)
{
pbSurface = Me.GetSurface(0);
pbSM = new SurfaceMath(pbSurface);
pbSurface.ContentType = ContentType.SCRIPT;
pbSurface.Script = "";
if (pbSurface.ScriptBackgroundColor != problemBG) defaultBG = pbSurface.ScriptBackgroundColor;
}

InitPreloads();

Expand Down Expand Up @@ -464,6 +467,7 @@ void PrintDetailedInfo()
int heartBeatIndex = 0;
void DrawOutsidePBLcd()
{
if (pbSurface == null) return;
using (var frame = pbSurface.DrawFrame())
{
Vector2 headerPos = new Vector2(pbSM.Center.X, pbSM.Center.Y - pbSM.Size.Y * 0.333f);
Expand Down

0 comments on commit fe52121

Please sign in to comment.