public MeterText(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData) { sm.PostionInterpreter(def); this.def = def; this.shipData = shipData; if (def.min == 0 && def.max == 0) { UseDataMinMax = true; } else { total = def.max - def.min; } if (def.size.X == 0) { def.size.X = 1; } def.position += sm.Center; def.position.Y -= sm.TextHeight(def.size.X) * 0.5f; sprite = MySprite.CreateText(def.textData, "Debug", def.color, def.size.X); sprite.Position = def.position; switch (def.anchor) { case Anchor.Left: sprite.Alignment = TextAlignment.LEFT; break; case Anchor.Right: sprite.Alignment = TextAlignment.RIGHT; break; case Anchor.Center: default: sprite.Alignment = TextAlignment.CENTER; break; } }
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); MySprite sprite; sprite = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: pbSquare); //This cannot be reused? sprite.Size = new Vector2(pbSM.Size.X, pbSM.Size.Y * 0.333f); sprite.Position = headerPos; frame.Add(sprite); sprite = new MySprite(SpriteType.TEXTURE, "Grid", color: pbSurface.ScriptForegroundColor); sprite.Size = pbSM.BGSize * 2; frame.Add(sprite); string status = ""; string problems = ""; if (Initialized < 2) { status = "Initializing...\nPlease wait."; } else { if (InitProblemBlockNames.Count > 0) { status = "Problem(s) with:"; for (int i = 0; i < InitProblemBlockNames.Count; i++) { problems += InitProblemBlockNames[i] + "\n"; } pbSurface.ScriptBackgroundColor = problemBG; } else { status = "Running"; pbSurface.ScriptBackgroundColor = defaultBG; heartBeatIndex++; sprite = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: pbSquare); sprite.Size = Vector2.One * (pbSM.SmallestSize * 0.15f) * heartBeat[heartBeatIndex % heartBeat.Length]; sprite.Position = new Vector2(pbSM.Center.X, pbSM.Center.Y + pbSM.Size.Y * 0.165f); frame.Add(sprite); } } //Add text MySprite textSprite; //This can be reused after running frame.Add textSprite = MySprite.CreateText("Blargmode's\nFancy Flight Info", "Debug", pbSurface.ScriptForegroundColor, 1f, TextAlignment.CENTER); textSprite.Position = new Vector2(headerPos.X, headerPos.Y - pbSM.TextHeight(1, 2) * 0.5f); frame.Add(textSprite); textSprite = MySprite.CreateText(status, "Debug", pbSurface.ScriptForegroundColor, 1f, TextAlignment.CENTER); textSprite.Position = new Vector2(headerPos.X, headerPos.Y + pbSM.Size.Y * 0.165f); frame.Add(textSprite); textSprite = MySprite.CreateText(problems, "Debug", pbSurface.ScriptForegroundColor, 0.7f, TextAlignment.CENTER); textSprite.Position = new Vector2(headerPos.X, headerPos.Y + pbSM.Size.Y * 0.165f + pbSM.TextHeight(1, 1)); frame.Add(textSprite); } }
public void Draw(Data dataChanged) { if (Meters.Count == 0) { //No meters, show a helpful placeholder using (var frame = Surface.DrawFrame()) { // Fill background with background color MySprite sprite; sprite = new MySprite(SpriteType.TEXTURE, "UVChecker", color: Color.White); sprite.Size = SM.BGSize; sprite.Position = SM.Center; frame.Add(sprite); sprite = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: Color.Red); //This cannot be reused? sprite.Size = new Vector2(110, 110); sprite.Position = SM.Center; frame.Add(sprite); //Add text MySprite textSprite; //This can be reused after running frame.Add textSprite = MySprite.CreateText($"{SkinDef.screenId+1}", "Debug", Color.White, 3f, TextAlignment.CENTER); Vector2 center = SM.Center; center.Y -= SM.TextHeight(3f) * 0.5f; center.Y += 12f; textSprite.Position = center; frame.Add(textSprite); textSprite = MySprite.CreateText("Screen", "Debug", Color.White, 1f, TextAlignment.CENTER); center = SM.Center; center.Y -= SM.TextHeight(4f) * 0.5f; center.Y += 12f; textSprite.Position = center; frame.Add(textSprite); textSprite = MySprite.CreateText(Surface.SurfaceSize.X.ToString("#.#") + " x " + Surface.SurfaceSize.Y.ToString("#.#"), "Debug", Color.White, 1f, TextAlignment.LEFT); textSprite.Position = SM.TopLeft; frame.Add(textSprite); } return; } if (true || (DataInUse & dataChanged) != 0) // DataInUse == Data.None //Option for drawing without data. Need to run profiler on multiple displays. { using (var frame = Surface.DrawFrame()) { if (SkinDef.background != null) { // Fill background with sprite color MySprite sprite; sprite = new MySprite(SpriteType.TEXTURE, SkinDef.background); if (SkinDef.colorSet) { sprite.Color = SkinDef.color; } else { sprite.Color = Surface.ScriptForegroundColor; } sprite.Size = SM.BGSize; sprite.Position = SM.Center; frame.Add(sprite); } //Idea: Send 'dataChanged' to the meters and let them return either a new sprite or the same as before. foreach (var meter in Meters) { meter.Draw(frame, dataChanged); } } } }