public void flush() { if (renderTarget_ != null && newMesssages_ == true) { float offset = (messages_.Count * lineHeight_ + lineCorrection_) - (renderTarget_.Size.Y + renderTarget_.Position.Y); int lineCount = 0; newMesssages_ = false; using (MySpriteDrawFrame frame = renderTarget_.getRenderFrame()) { // Workaround to fix the MP Sprite issue if (drawEmpty_) { frame.Add(new MySprite()); } drawEmpty_ = !drawEmpty_; // background renderTarget_.clearDrawArea(sprite => frame.Add(sprite)); // flush message lines foreach (var message in messages_) { MySprite line = MySprite.CreateText(message.Value, font_, getFontColor(message.Key), fontSize_, TextAlignment.LEFT); line.Position = new Vector2(renderTarget_.Position.X, lineCount++ *lineHeight_ - offset); frame.Add(line); } } } }
public void Main(string argument, UpdateType updateSource) { Dictionary <string, object> inputs = Me.GetProperty("ControlModule.Inputs")?.As <Dictionary <string, object> >()?.GetValue(Me); if (inputs != null) { blocks.Clear(); foreach (long key in spritesPreviewers.Keys) { missingSpritePreviewers.Add(key); } GridTerminalSystem.GetBlocks(blocks); foreach (IMyTerminalBlock block in blocks) { if (block is IMyTextPanel) { IMyTextPanel text_panel = (IMyTextPanel)block; if (text_panel.CustomData.Trim() == "previewSprites") { if (!(spritesPreviewers.ContainsKey(text_panel.EntityId))) { List <string> sprites = new List <string>(); text_panel.GetSprites(sprites); spritesPreviewers.Add(text_panel.EntityId, new SpritesPreviewer(text_panel, sprites)); } missingSpritePreviewers.Remove(text_panel.EntityId); } } } foreach (long key in missingSpritePreviewers) { spritesPreviewers.Remove(key); } missingSpritePreviewers.Clear(); foreach (string input in inputs.Keys) { if (spritesPreviewersKeyInputActions.ContainsKey(input)) { SpritesPreviewerKeyInputActionDelegate sprites_previewers_key_input_action = spritesPreviewersKeyInputActions[input]; foreach (SpritesPreviewer sprite_previewer in spritesPreviewers.Values) { sprites_previewers_key_input_action(sprite_previewer); } } } foreach (SpritesPreviewer sprite_previewer in spritesPreviewers.Values) { string selected_sprite = sprite_previewer.SelectedSprite; if (selected_sprite != null) { sprite_previewer.TextPanel.ContentType = ContentType.SCRIPT; using (MySpriteDrawFrame sprite_draw_frame = sprite_previewer.TextPanel.DrawFrame()) { sprite_draw_frame.Add(MySprite.CreateSprite(selected_sprite, sprite_previewer.TextPanel.SurfaceSize * 0.5f, sprite_previewer.TextPanel.SurfaceSize * sprite_previewer.ZoomFactor)); sprite_draw_frame.Add(MySprite.CreateText(selected_sprite, "DEBUG", Color.White, 1.0f, TextAlignment.CENTER)); } } } } }
public void DrawSprites(ref MySpriteDrawFrame frame, RectangleF _viewport) { var background = MySprite.CreateSprite("SquareSimple", _viewport.Center, _viewport.Size); background.Color = new Color(26, 28, 32); frame.Add(background); Vector2 ocSize = percentageSize(80, _viewport); var outerCircle = MySprite.CreateSprite("Circle", _viewport.Center, ocSize); outerCircle.Color = new Color(29, 229, 128); frame.Add(outerCircle); Vector2 icSize = percentageSize(60, _viewport); var innerCircle = MySprite.CreateSprite("Circle", _viewport.Center, icSize); innerCircle.Color = new Color(37, 39, 45); frame.Add(innerCircle); float size = TextSize(40, _viewport); float offset = TextSizeOffset(size); var platformCode = MySprite.CreateText("01", "White", Color.White, size, TextAlignment.CENTER); // Vector2 pcPos = new Vector2(_viewport.Center.X, _viewport.Center.Y - 100); Vector2 pcPos = new Vector2(_viewport.Size.X / 2, _viewport.Size.Y / 2 - offset) + _viewport.Position; platformCode.Position = pcPos; frame.Add(platformCode); }
public void Draw() { if (program.Me.CubeGrid.GridSizeEnum == MyCubeSize.Small) { return; } using (MySpriteDrawFrame frame = textSurface.DrawFrame()) { frame.Add(new MySprite(SpriteType.TEXT, "SolarMap v0.9.1", new Vector2(10, 100), null, Color.White, null, TextAlignment.LEFT, 0.7f)); frame.Add(new MySprite(SpriteType.TEXT, "Average instructions:\nInstruction peak:\nAverage runtime:\nRuntime:\nUpdates:", new Vector2(10, 125), null, Color.White, null, TextAlignment.LEFT, 0.6f)); // Calculate various. runTimes[tick] = program.Runtime.LastRunTimeMs; instructionCounts[tick] = program.Runtime.CurrentInstructionCount; time += program.Runtime.TimeSinceLastRun; tick = tick > 8 ? 0 : ++tick; frame.Add(new MySprite(SpriteType.TEXT, AverageInstructions + "/" + program.Runtime.MaxInstructionCount + "\n" + HighestInstruction + "\n" + AverageRunTime + " ms\n" + time.ToString(@"dd\.hh\:mm\:ss") + "\n" + program.terminalManager.ShipController.UpdateCount, new Vector2(200, 125), null, Color.White, null, TextAlignment.LEFT, 0.6f)); if (!program.terminalManager.ShipController.HasController) { frame.Add(new MySprite(SpriteType.TEXT, "Status", new Vector2(10, 250), null, Color.White, null, TextAlignment.LEFT, 0.7f)); frame.Add(new MySprite(SpriteType.TEXT, "- Controller does not exist.", new Vector2(10, 275), null, Color.White, null, TextAlignment.LEFT, 0.6f)); } } }
public override void Refresh(MySpriteDrawFrame?spriteDrawFrame) { spriteDrawFrame?.Add(topBorderSprite); spriteDrawFrame?.Add(bottomBorderSprite); spriteDrawFrame?.Add(leftBorderSprite); spriteDrawFrame?.Add(rightBorderSprite); base.Refresh(spriteDrawFrame); }
public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame) { if (Tracker.Updating) { return; } var categories = window.GetData <CategoryStorage>(); if (categories == null) { return; } JobInventory.ItemTypeDescriptor.ItemCategory cat = categories.Categories; Buffer.Clear(); ValueStrings.Clear(); int name_w = 0; int val_w = 0; string val; foreach (var item in Tracker.Stock) { if ((cat & item.Value.Category) == item.Value.Category) { val = item.Value.FormatAmount(); ValueStrings[item.Value.Name] = val; name_w = Math.Max(name_w, item.Value.Name.Length); val_w = Math.Max(val_w, val.Length); } } string catname = cat.ToString(); int titlepad = name_w + 1 + val_w - catname.Length; if (titlepad < 0) { name_w += -titlepad; titlepad = 0; } Buffer.Append('-', titlepad / 2); Buffer.Append(catname); Buffer.Append('-', titlepad - titlepad / 2); Buffer.Append('\n'); foreach (var item in ValueStrings) { Buffer.Append(item.Key); Buffer.Append(' ', (name_w - item.Key.Length) + 1 + (val_w - item.Value.Length)); Buffer.Append(item.Value); Buffer.Append('\n'); } if (BgColor != Color.Transparent) { frame.Add(window.Surface.FitSprite("SquareSimple", window.Area, BgColor)); } frame.Add(window.Surface.FitText(Buffer.ToString(), window.Area, "Monospace", window.Surface.ScriptForegroundColor)); Buffer.Clear(); ValueStrings.Clear(); }
void drawInitScreen() { using (MySpriteDrawFrame frame = getRenderFrame()) { MySprite textInit = MySprite.CreateText("Initilize screen", "debug", Color.LawnGreen, 1f, TextAlignment.LEFT); textInit.Position = new Vector2(5f, Default.CharHeight) + Position; clearDrawArea(sprite => frame.Add(sprite)); frame.Add(textInit); } }
public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame) { text.Append('\n').Append(Buffer).Append('\n'); if (BgColor != Color.Transparent) { frame.Add(window.Surface.FitSprite("SquareSimple", window.Area, BgColor)); } Color textcolor = FontColor == Color.Transparent ? window.Surface.ScriptForegroundColor : FontColor; frame.Add(window.Surface.FitText(Buffer.ToString(), window.Area, "Monospace", textcolor, TextAlignment.LEFT)); }
private static void DrawCross(ref MySpriteDrawFrame Frame) { MySprite CrossDiagonal1 = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, 100 * UnitY)); CrossDiagonal1.RotationOrScale = ToRadian(45); CrossDiagonal1.Color = Color.Tomato; Frame.Add(CrossDiagonal1); MySprite CrossDiagonal2 = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, 100 * UnitY)); CrossDiagonal2.RotationOrScale = ToRadian(-45); CrossDiagonal2.Color = Color.Tomato; Frame.Add(CrossDiagonal2); }
public void Draw(MySpriteDrawFrame frame, Data dataChanged) { if (UseDataMinMax) { def.min = shipData[def.data].Min; def.max = shipData[def.data].Max; total = def.max - def.min; } val = Ini.AdjustToUnit(def, shipData, total, UseDataMinMax); //Check for hide condition. if (Ini.MeetsConditions(def.conditions, val, def.condVals)) { return; } if ((dataChanged & def.data) != 0) { semi.RotationOrScale = MathHelper.ToRadians(MathHelper.Clamp((float)(shipData[def.data].Value / total * 180f), 0, 180)) + def.rotation; frame.Add(full); frame.Add(semi); frame.Add(inner); frame.Add(box); } else { frame.Add(full); frame.Add(semi); frame.Add(inner); frame.Add(box); } }
public static void DrawText(Vector2 position, Color color, string text, float fontSize = 1.0f, TextAlignment textAlignment = TextAlignment.CENTER) { MySprite sprite; sprite = MySprite.CreateText(text, paint.Font, color, fontSize, textAlignment); sprite.Position = position + paint.Offset; frame.Add(sprite); }
private static void DrawDataScreenVORSection(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData) { float PositionYFactor = 5f; float PosistionX = Center.X + 12 * UnitX; if (CombinedData.VORData.Rotation == null) { Frame.Add(new MySprite() { Type = SpriteType.TEXT, Data = "No VOR\nConnection!", Position = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position, RotationOrScale = DataScreenFontSize + 0.2f, Color = Color.Tomato, Alignment = TextAlignment.LEFT, FontId = "White" }); return; } string[] _lines = { "VOR: " + CombinedData.VORData.Name, "DME: " + Math.Round(CombinedData.VORData.Distance / 1000, 1).ToString(), "Radial: " + Math.Round(CombinedData.VORData.Radial, 0).ToString(), "OBS: " + Math.Round(CombinedData.VORData.OBS, 0).ToString(), "HDG: " + Math.Round(CombinedData.VORData.Heading, 0).ToString(), "DEV: " + Math.Round(CombinedData.VORData.Deviation, 0).ToString() }; List <string> Lines = new List <string>(_lines); foreach (string line in Lines) { Frame.Add(new MySprite() { Type = SpriteType.TEXT, Data = line, Position = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position, RotationOrScale = DataScreenFontSize, Color = CockpitFGColor.Alpha(1f), Alignment = TextAlignment.LEFT, FontId = "White" }); PositionYFactor += 35; } }
void Draw(Canvas can) { MySpriteDrawFrame _frame = _textSurface.DrawFrame(); if (can == null) { return; } foreach (BasePanel item in can.GetListChildrens()) { if (item == null) { return; } foreach (BaseCompo baseCompo in item.Content) { foreach (var sprite in baseCompo.content.Sprites) { _frame.Add(sprite); } } } _frame.Dispose(); }
public void DrawBar(ref MySpriteDrawFrame frame, Vector2 position, float value) { // Display 10 lines of text by 20 columns int bar_width = 21; var filled_blocks = (int)(bar_width * value); var empty_blocks = Math.Max(bar_width - filled_blocks, 0); var bar_top = new string('═', bar_width); var bar_mid = new string(' ', bar_width); var bar_bot = new string('═', bar_width); var bar_filled = new string('▓', filled_blocks); var bar_empty = new string(' ', empty_blocks); var line1 = $"╔{bar_top}╗\n"; var line2 = $"║{bar_filled}{bar_empty}║ {value:P}\n"; var line3 = $"╚{bar_top}╝"; // Create our first bar var bar_outline = new MySprite() { Type = SpriteType.TEXT, Data = $"{line1}{line2}{line3}", Position = position, RotationOrScale = 0.8f /* 80 % of the font's default size */, Color = Color.Red, Alignment = TextAlignment.LEFT /* Center the text on the position */, FontId = "Monospace" }; // Add the sprite to the frame frame.Add(bar_outline); }
public override void Run() { using (MySpriteDrawFrame frame = m_surface.DrawFrame()) { AddBackground(frame, new Color?(new Color(m_foregroundColor, 0.66f))); num1 = num1 + 1; string str = "HELLO\n" + "MOD BY FROSTY\n" + num1.ToString(); Vector2 vector2 = m_surface.MeasureStringInPixels(new StringBuilder(str), m_fontId, m_fontScale); MySprite sprite = new MySprite() { Position = new Vector2?(new Vector2(m_halfSize.X, m_halfSize.Y - vector2.Y * 0.5f)), Size = new Vector2?(new Vector2(m_innerSize.X, m_innerSize.Y)), Type = SpriteType.TEXT, FontId = m_fontId, Alignment = TextAlignment.CENTER, Color = new Color?(m_foregroundColor), RotationOrScale = m_fontScale, Data = str }; frame.Add(sprite); float scale = (float)(m_innerSize.Y / 256.0 * 0.899999976158142); //AddBrackets(frame, new Vector2(64f, 256f), scale); } }
public override void Run() { using (MySpriteDrawFrame frame = m_surface.DrawFrame()) { AddBackground(frame, new Color?(new Color(m_foregroundColor, 0.66f))); string str = "No file found"; if (MyAPIGateway.Utilities.FileExistsInGlobalStorage("OutputHere.txt")) { var read = MyAPIGateway.Utilities.ReadFileInGlobalStorage("OutputHere.txt"); str = read.ReadToEnd(); read.Dispose(); } Vector2 vector2 = m_surface.MeasureStringInPixels(new StringBuilder(str), m_fontId, m_fontScale); MySprite sprite = new MySprite() { Position = new Vector2?(new Vector2(0, m_halfSize.Y * 2f - vector2.Y)), Size = new Vector2?(new Vector2(m_innerSize.X, m_innerSize.Y)), Type = SpriteType.TEXT, FontId = m_fontId, Alignment = TextAlignment.LEFT, Color = new Color?(m_foregroundColor), RotationOrScale = m_fontScale, Data = str }; frame.Add(sprite); float scale = (float)(m_innerSize.Y / 256.0 * 0.899999976158142); //AddBrackets(frame, new Vector2(64f, 256f), scale); } }
private void DisplayPerformance(Surface surface) { /* * display the last run times on the surface */ MySpriteDrawFrame frame = surface.TextSurface.DrawFrame(); RectangleF viewRect = surface.ViewRect; Color color = surface.TextSurface.ScriptForegroundColor; spritePosition = viewRect.Center; spritePosition.Y -= 20; sprite = new MySprite() { Type = SpriteType.TEXT, Data = $"last run: {parent.LastRunTime}ms ({parent.LastRunType})" + $"\nlast average: {parent.LastAverage}ms ({parent.RunsPerAverage} runs)", Position = spritePosition, RotationOrScale = 0.6f, Color = color, Alignment = TextAlignment.CENTER, FontId = "Monospace" }; frame.Add(sprite); frame.Dispose(); }
private static void DrawDataScreenILSSection(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData) { float PositionYFactor = 5f; float PosistionX = 12 * UnitX; if (CombinedData.ILSData.Rotation == null) { Frame.Add(new MySprite() { Type = SpriteType.TEXT, Data = "No ILS\nConnection!", Position = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position, RotationOrScale = DataScreenFontSize + 0.2f, Color = Color.Tomato, Alignment = TextAlignment.LEFT, FontId = "White" }); return; } string[] _lines = { "RWY: " + CombinedData.ILSData.RunwayNumber.ToString(), "DME: " + Math.Round(CombinedData.ILSData.Distance / 1000, 1).ToString(), "Bearing: " + Math.Round(CombinedData.ILSData.Bearing, 0).ToString(), "Rel. Bearing: " + Math.Round(CombinedData.ILSData.RelativeBearing, 0).ToString(), "Track: " + Math.Round(CombinedData.ILSData.Track, 0).ToString(), }; List <string> Lines = new List <string>(_lines); foreach (string line in Lines) { Frame.Add(new MySprite() { Type = SpriteType.TEXT, Data = line, Position = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position, RotationOrScale = DataScreenFontSize, Color = CockpitFGColor.Alpha(1f), Alignment = TextAlignment.LEFT, FontId = "White" }); PositionYFactor += 35; } }
public override void OnCycle(IMyTextPanel lcd, TextPanelSetting setting) { this.lcd = lcd; this.setting = setting; // Setting error. if (setting.HasError) { SetError(setting.Status.ToString()); return; } // LCD dimension error. if (lcd.SurfaceSize.Y != 512) { SetError("Solar map cannot be displayed on 5:3 text panel."); return; } // Update propreties. spriteManager.Update(lcd, setting); // Paint. PaintMap(); PaintInfoPanel(); // Add paint. Must be added in the correct order. using (frame = lcd.DrawFrame()) { // Used to force the texture surface cache to refresh. // See Whiplash141's original post: https://support.keenswh.com/spaceengineers/pc/topic/1-192-021-lcd-scripts-using-sprites-dont-work-in-mp // See Georgik's original code: https://discordapp.com/channels/125011928711036928/216219467959500800/721065427140083832 if (isOdd) { frame.Add(new MySprite()); } frame.AddRange(orbitSprites); frame.AddRange(planetSprites); frame.Add(grid); frame.AddRange(infoSprites); } // Force texture cache to change every odd and even interval. isOdd = !isOdd; }
private MySpriteDrawFrame prepareScreen(IMyTextPanel scr) { scr.ContentType = ContentType.SCRIPT; MySpriteDrawFrame frame = scr.DrawFrame(); frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", size: screenSize, color: Color.Black)); return(frame); }
public override void DrawFrame(MySpriteDrawFrame frame) { using (frame) { sprite.Size = Viewport.Size; sprite.Position = Viewport.Center; frame.Add(sprite); } }
private void drawBox(MySpriteDrawFrame frame, float f, Color c, float limit) { f = Math.Min(f, limit); float h = f * 512; Vector2 box = new Vector2(barSize2.X, h); Vector2 ctr = new Vector2(256, 512 - h / 2); MySprite sprite = new MySprite(SpriteType.TEXTURE, "SquareSimple", size: box, color: c); sprite.Position = ctr; frame.Add(sprite); }
private void setScreenContent(IMyTextPanel scr, float f) { scr.ContentType = ContentType.SCRIPT; MySpriteDrawFrame frame = scr.DrawFrame(); frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", size: screenSize, color: BLACK)); frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", size: barSize1, color: GRAY1)); frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", size: barSize2, color: GRAY2)); drawBox(frame, f, BLUE_COLOR, 1); drawBox(frame, f, GREEN_COLOR, BLUE_THRESH); drawBox(frame, f, YELLOW_COLOR, GREEN_THRESH); drawBox(frame, f, ORANGE_COLOR, YELLOW_THRESH); drawBox(frame, f, RED_COLOR, ORANGE_THRESH); drawBox(frame, f, DARKRED_COLOR, RED_THRESH); frame.Add(MySprite.CreateText(String.Format("{0:0.000}", (f * 100)) + "%", "monospace", WHITE, 3)); frame.Dispose(); }
public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame) { int max = _Airlocks.Keys.Max((g) => g.Name.Length); foreach (var kv in _Airlocks) { Buffer.Append(kv.Key.Name).Append(' ', max - kv.Key.Name.Length) .Append(" : ").Append(kv.Value.CurrentState).Append('\n'); } frame.Add(window.Surface.FitText(Buffer.ToString(), window.Area, "Monospace", window.Surface.ScriptForegroundColor)); }
private static void DrawNDB(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, NDBDataSet NDBData) { if (NDBData.Rotation == null) { DrawCross(ref Frame); return; } // Vars float CircleSize = Size.Y * 0.95f; float ArrowLength = Size.Y * 0.8f; float ArrowRotation = (float)NDBData.Rotation; // Circle MySprite Circle1 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize)); Circle1.Color = CockpitFGColor.Alpha(1f); Frame.Add(Circle1); MySprite Circle2 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.95f); Circle2.Color = CockpitBGColor.Alpha(1f); Frame.Add(Circle2); // Arrow MySprite ArrowBody = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength)); ArrowBody.Color = Color.LawnGreen.Alpha(1f); ArrowBody.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(ArrowBody); float AConstant = ArrowLength / 2.1f; float Ax = (float)Math.Sin(ToRadian(ArrowRotation)) * AConstant; float Ay = (float)Math.Cos(ToRadian(ArrowRotation)) * AConstant * -1; MySprite ArrowHead = MySprite.CreateSprite("Triangle", Center + new Vector2(Ax, Ay), Size * 0.2f); ArrowHead.Color = Color.LawnGreen.Alpha(1f); ArrowHead.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(ArrowHead); }
private void AddEntry(ref MySpriteDrawFrame frame, int bars, string name) { /* * currently unused * adds entry for category info */ Color color = bars == 10 ? Color.Yellow : Color.White; // this does not spark joy string barString = $"[{new String('|', bars)}{new String('-', 10 - bars)}]"; spritePosition.Y -= 12; // getting this offset perfect probably depends on the size of the letters sprite = new MySprite() { Type = SpriteType.TEXT, Data = $"{barString}", Position = spritePosition, RotationOrScale = 0.4f, Color = color, Alignment = TextAlignment.CENTER, FontId = "Monospace" }; frame.Add(sprite); spritePosition.Y += 12; sprite = new MySprite() { Type = SpriteType.TEXT, Data = $"{name}", Position = spritePosition, RotationOrScale = 0.4f, Color = Color.White, Alignment = TextAlignment.CENTER, FontId = "Monospace" }; frame.Add(sprite); }
public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame) { if (Updating) { return; } Buffer.Clear(); if (BgColor != Color.Transparent) { frame.Add(window.Surface.FitSprite("SquareSimple", window.Area, BgColor)); } if (window.GetData <string>() == "compact") { int maxlen = ByCategory.Keys.Max((k) => k.Length); foreach (var kv in ByCategory) { Buffer.Append(kv.Key).Append(' ', maxlen - kv.Key.Length + 1) .AppendFormat("x{0,-3} {1,6:P1}", kv.Value.Count, kv.Value.GetRatio(0)).Append('\n'); } } else { int maxlen = Inventories.Max((i) => i.Block.CustomName.Length); maxlen = Math.Max(maxlen, Tanks.Max((t) => t.Target.CustomName.Length)); foreach (var inv in Inventories) { var name = inv.Block.CustomName; Buffer.Append(name).Append(' ', maxlen - name.Length + 1) .AppendFormat("{0,6:P1}", inv.GetRatio(0)).Append('\n'); } foreach (var tank in Tanks) { var name = tank.Target.CustomName; Buffer.Append(name).Append(' ', maxlen - name.Length + 1) .AppendFormat("{0,6:P1}", tank.GetRatio(0)).Append('\n'); } } frame.Add(window.Surface.FitText(Buffer.ToString(), window.Area, "Monospace", window.Surface.ScriptForegroundColor, TextAlignment.CENTER)); }
// Drawing Sprites public void DrawSprites(ref MySpriteDrawFrame frame) { Vector2 size = new Vector2(_viewport.Width / 2, _viewport.Height / 10); Vector2 pos = new Vector2(size.X / 2 + 10, size.Y / 2 + 10); // Create background sprite var sprite = new MySprite() { Type = SpriteType.TEXTURE, Data = "SquareSimple", //Position = _viewport.Center, //Size = _viewport.Size, Position = pos, Size = size, Color = _drawingSurface.ScriptForegroundColor.Alpha(0.66f), Alignment = TextAlignment.CENTER }; // Add the sprite to the frame frame.Add(sprite); // Set up the initial position - and remember to add our viewport offset var position = new Vector2(256, 20) + _viewport.Position; // Create our first line sprite = new MySprite() { Type = SpriteType.TEXT, Data = "Line 1", Position = position, RotationOrScale = 0.8f /* 80 % of the font's default size */, Color = Color.Red, Alignment = TextAlignment.CENTER /* Center the text on the position */, FontId = "White" }; // Add the sprite to the frame frame.Add(sprite); }
public void Draw(MySpriteDrawFrame frame, Data dataChanged) { if (UseDataMinMax) { def.min = shipData[def.data].Min; def.max = shipData[def.data].Max; total = def.max - def.min; } val = Ini.AdjustToUnit(def, shipData, total, UseDataMinMax); //Check for hide condition. if (Ini.MeetsConditions(def.conditions, val, def.condVals)) { return; } if ((dataChanged & def.data) != 0) { spriteSize.X = (float)Math.Abs(MathHelper.Clamp(shipData[def.data].Value, def.min, def.max) / total * def.size.X); //_sprite.Position = sm.AdjustToAnchor(def.anchor, def.position, spriteSize); sprite.Position = sm.AdjustToRotation(sm.AdjustToAnchor(def.anchor, def.position, spriteSize), def.position, def.rotation); sprite.Size = spriteSize; if (def.backgroundSet) { frame.Add(background); } frame.Add(sprite); } else { sprite.Size = spriteSize; if (def.backgroundSet) { frame.Add(background); } frame.Add(sprite); } }
private static void DrawDataScreen(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData) { // ILS Data DrawDataScreenILSSection(ref Frame, Surface, CombinedData); // VOR DrawDataScreenVORSection(ref Frame, Surface, CombinedData); // Line between the two columns MySprite SeparationLine = MySprite.CreateSprite("SquareSimple", Center, new Vector2(3 * UnitX, 200 * UnitY)); SeparationLine.Color = CockpitFGColor.Alpha(1f); Frame.Add(SeparationLine); }