public void BuildSprites(List <MySprite> sprites, Vector2 center, Vector2 size, float frame = 0, Color?color = null, Color?bgColor = null) { Color fcolor = color ?? Color.White; Color bcolor = bgColor ?? Color.Black; MySprite sprite; foreach (SpriteData d in dlist) { if (d.Next == null) { Vector2 pos = d.Pos; pos.Rotate(d.PosRot); sprite = MySprite.CreateSprite(d.Id, pos * size + center, d.Size * size); sprite.Color = new Color(fcolor.ToVector3() * d.Alpha + bcolor.ToVector3() * (1.0f - d.Alpha)); sprite.RotationOrScale = d.Rotate; } else { Vector2 pos = Vector2.SmoothStep(d.Pos, d.Next.Pos, frame); pos.Rotate(d.PosRot + d.Next.PosRot * frame); sprite = MySprite.CreateSprite(d.Id, pos * size + center, d.Size * size); float alpha = d.Alpha + (d.Next.Alpha - d.Alpha) * frame; sprite.Color = new Color(fcolor.ToVector3() * alpha + bcolor.ToVector3() * (1.0f - alpha)); sprite.RotationOrScale = d.Rotate + d.Next.Rotate * frame; } sprites.Add(sprite); } }
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 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)); } } } } }
private void DrawProduction(List <MySprite> productionSpriteList, float screenOffset) { Vector2 b_pos = new Vector2(130.5f + screenOffset, 130); Vector2 b_size = new Vector2(241, 124); var background = MySprite.CreateSprite("SquareSimple", b_pos, b_size); background.Color = Constants.COLOR_BACKGROUND_MASK; Vector2 h_pos = new Vector2(130.5f + screenOffset, 78); Vector2 h_size = new Vector2(241, 20); var header = MySprite.CreateSprite("SquareSimple", h_pos, h_size); header.Color = Constants.COLOR_GREEN; var headerText = MySprite.CreateText("PRODUCTION INFO", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); headerText.Position = new Vector2(20 + screenOffset, 69); Vector2 gb_pos = new Vector2(130.5f + screenOffset, 116.5f); Vector2 gb_size = new Vector2(221, 37); var generatorsBackground = MySprite.CreateSprite("SquareSimple", gb_pos, gb_size); generatorsBackground.Color = Constants.COLOR_BACKGROUND_LIGHT; Vector2 ofb_pos = new Vector2(130.5f + screenOffset, 163.5f); Vector2 ofb_size = new Vector2(221, 37); var oxygenFarmBackground = MySprite.CreateSprite("SquareSimple", ofb_pos, ofb_size); oxygenFarmBackground.Color = Constants.COLOR_BACKGROUND_LIGHT; Vector2 gs_pos = new Vector2(30 + screenOffset, 116.5f); Vector2 gs_size = new Vector2(20, 37); var generatorsSwitch = MySprite.CreateSprite("SquareSimple", gs_pos, gs_size); generatorsSwitch.Color = myProgram.productionController.LifeSupportInfo.IsGeneratorsWorking ? Constants.COLOR_GREEN : Constants.COLOR_RED; Vector2 ofs_pos = new Vector2(30 + screenOffset, 163.5f); Vector2 ofs_size = new Vector2(20, 37); var oxygenFarmSwitch = MySprite.CreateSprite("SquareSimple", ofs_pos, ofs_size); oxygenFarmSwitch.Color = myProgram.productionController.LifeSupportInfo.IsOxygenFarmWorking ? Constants.COLOR_GREEN : Constants.COLOR_RED; var generatorsSwitchText = MySprite.CreateText($"H2/O2 GENERATORS\n{myProgram.productionController.WorkingGenerators}", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); generatorsSwitchText.Position = new Vector2(47 + screenOffset, 98.5f); var oxygenFarmSwitchText = MySprite.CreateText($"OXYGEN FARMS\n{myProgram.productionController.WorkingOxygenFarms}", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); oxygenFarmSwitchText.Position = new Vector2(47 + screenOffset, 145.5f); productionSpriteList.Add(background); productionSpriteList.Add(header); productionSpriteList.Add(headerText); productionSpriteList.Add(generatorsBackground); productionSpriteList.Add(oxygenFarmBackground); productionSpriteList.Add(generatorsSwitch); productionSpriteList.Add(oxygenFarmSwitch); productionSpriteList.Add(generatorsSwitchText); productionSpriteList.Add(oxygenFarmSwitchText); }
private void DrawSectionBackground(float posX, float posY, out MySprite sectionBackground) { Vector2 ib_pos = new Vector2(posX, posY); Vector2 ib_size = new Vector2(241, 66); sectionBackground = MySprite.CreateSprite("SquareSimple", ib_pos, ib_size); sectionBackground.Color = Constants.COLOR_BACKGROUND_MASK; }
public ProgressBar(Vector2 position, Vector2 size, Color backgroundColor, Color progressColor, Color borderColor, float borderSize, float value, IUIControl parent) : base(position, size, borderColor, borderSize, parent) { backgroundSprite = MySprite.CreateSprite(backgroundSpriteName, position, size); progressSprite = MySprite.CreateSprite(progressSpriteName, position, Vector2.Zero); BackgroundColor = backgroundColor; ForegroundColor = progressColor; Value = value; }
MySprite AddSprite(string spriteType, Vector2 wallPosition, Vector2 size, Color?color = null) { var sprite = MySprite.CreateSprite(spriteType, wallPosition, size); sprite.Color = color == null ? Color.White : color; SpriteScratchpad.Add(sprite); return(sprite); }
private void DrawOxygenInfo(Airlock airlock, List <MySprite> oxygenInfoSpriteList) { Vector2 orl_pos = new Vector2(112.5f, 390); Vector2 orl_size = new Vector2(205, 30); var outerRectLeft = MySprite.CreateSprite("SquareSimple", orl_pos, orl_size); outerRectLeft.Color = Constants.COLOR_WHITE; Vector2 orlm_pos = new Vector2(112.5f, 390); Vector2 orlm_size = new Vector2(201, 26); var outerRectLeftMask = MySprite.CreateSprite("SquareSimple", orlm_pos, orlm_size); outerRectLeftMask.Color = Constants.COLOR_BACKGROUND; Vector2 bfl_pos = new Vector2(112.5f, 390); Vector2 bfl_size = new Vector2((197 * float.Parse(airlock.OxygenLevelDecimals)), 22); var barFillLeft = MySprite.CreateSprite("SquareSimple", bfl_pos, bfl_size); barFillLeft.Color = Constants.COLOR_WHITE; var oxigenText = MySprite.CreateText("AIRLOCK OXYGEN", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER); oxigenText.Position = new Vector2(112.5f, 410); Vector2 orr_pos = new Vector2(399.5f, 390); Vector2 orr_size = new Vector2(205, 30); var outerRectRight = MySprite.CreateSprite("SquareSimple", orr_pos, orr_size); outerRectRight.Color = Constants.COLOR_WHITE; Vector2 orrm_pos = new Vector2(399.5f, 390); Vector2 orrm_size = new Vector2(201, 26); var outerRectRightMask = MySprite.CreateSprite("SquareSimple", orrm_pos, orrm_size); outerRectRightMask.Color = Constants.COLOR_BACKGROUND; Vector2 bfr_pos = new Vector2(399.5f, 390); Vector2 bfr_size = new Vector2((197 * float.Parse(airlock.OxygenTankFillDecimals)), 22); var barFillRight = MySprite.CreateSprite("SquareSimple", bfr_pos, bfr_size); barFillRight.Color = Constants.COLOR_WHITE; var tankText = MySprite.CreateText("02 TANKS STORAGE", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER); tankText.Position = new Vector2(399.5f, 410); oxygenInfoSpriteList.Add(outerRectLeft); oxygenInfoSpriteList.Add(outerRectLeftMask); oxygenInfoSpriteList.Add(barFillLeft); oxygenInfoSpriteList.Add(oxigenText); oxygenInfoSpriteList.Add(outerRectRight); oxygenInfoSpriteList.Add(outerRectRightMask); oxygenInfoSpriteList.Add(barFillRight); oxygenInfoSpriteList.Add(tankText); }
private void DrawBackground(List <MySprite> backgroundSpriteList) { Vector2 b_pos = new Vector2(256, 256); Vector2 b_size = new Vector2(512, 512); var background = MySprite.CreateSprite("SquareSimple", b_pos, b_size); background.Color = Constants.COLOR_BACKGROUND; backgroundSpriteList.Add(background); }
public Border(Vector2 position, Vector2 size, Color borderColor, float borderSize, IUIControl parent) : base(parent) { topBorderSprite = MySprite.CreateSprite(borderSideSpriteName, position, Vector2.Zero); bottomBorderSprite = MySprite.CreateSprite(borderSideSpriteName, position, Vector2.Zero); leftBorderSprite = MySprite.CreateSprite(borderSideSpriteName, position, Vector2.Zero); rightBorderSprite = MySprite.CreateSprite(borderSideSpriteName, position, Vector2.Zero); base.Position = position; base.Size = size; BorderColor = borderColor; base.BorderSize = borderSize; UpdateVisuals(); }
public Image(string texture, TextAlignment alignment, Vector2 position, Vector2 size, Color color, IUIControl parent) : base(parent) { if (texture == null) { throw new ArgumentNullException(nameof(texture)); } imageSprite = MySprite.CreateSprite(texture, position, size); base.Text = texture; Alignment = alignment; base.Position = position; base.Size = size; ForegroundColor = color; }
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); }
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); }
private void DrawFooter(Airlock airlock, List <MySprite> footerSpriteList) { Vector2 fb_pos = new Vector2(256, 457.5f); Vector2 fb_size = new Vector2(492, 5); var footerBar = MySprite.CreateSprite("SquareSimple", fb_pos, fb_size); footerBar.Color = Constants.COLOR_ORANGE; var airlockNameText = MySprite.CreateText(airlock.Name, "Debug", Constants.COLOR_ORANGE, 1.5f, TextAlignment.CENTER); airlockNameText.Position = new Vector2(256, 462f); footerSpriteList.Add(footerBar); footerSpriteList.Add(airlockNameText); }
private void DrawAirventIcon(float posX, float posY, Color stateColor, bool isWorking, out MySprite iconBorder, out MySprite iconBackground, out MySprite fanH, out MySprite fanV, out MySprite fanCenterBackground, out MySprite fanCenter) { Vector2 ib_pos = new Vector2(posX, posY); Vector2 ib_size = new Vector2(30, 30); iconBorder = MySprite.CreateSprite("SquareSimple", ib_pos, ib_size); iconBorder.Color = stateColor; Vector2 ibg_pos = new Vector2(posX, posY); Vector2 ibg_size = new Vector2(26, 26); iconBackground = MySprite.CreateSprite("Circle", ibg_pos, ibg_size); iconBackground.Color = Constants.COLOR_BACKGROUND; Vector2 fh_pos = new Vector2(posX, posY); Vector2 fh_size = new Vector2(20, 4); fanH = MySprite.CreateSprite("SquareSimple", fh_pos, fh_size); fanH.Color = stateColor; if (isWorking) { fanH.RotationOrScale = rotationRadiants; } Vector2 fv_pos = new Vector2(posX, posY); Vector2 fv_size = new Vector2(4, 20); fanV = MySprite.CreateSprite("SquareSimple", fv_pos, fv_size); fanV.Color = stateColor; if (isWorking) { fanV.RotationOrScale = rotationRadiants; } rotationRadiants += 0.05f; Vector2 fcb_pos = new Vector2(posX, posY); Vector2 fcb_size = new Vector2(10, 10); fanCenterBackground = MySprite.CreateSprite("Circle", fcb_pos, fcb_size); fanCenterBackground.Color = Constants.COLOR_BACKGROUND; Vector2 fc_pos = new Vector2(posX, posY); Vector2 fc_size = new Vector2(6, 6); fanCenter = MySprite.CreateSprite("Circle", fc_pos, fc_size); fanCenter.Color = stateColor; }
private void DrawFooter(int count, List <MySprite> footerSpriteList, int page) { Vector2 pf_pos = new Vector2(256, 405); Vector2 pf_size = new Vector2(492, 30); MySprite pageFrame = MySprite.CreateSprite("SquareSimple", pf_pos, pf_size); pageFrame.Color = Constants.COLOR_BACKGROUND_MASK; int numPages = 1; if (count % 10 == 0) { numPages = count / 10; } else { numPages = count / 10 + 1; } MySprite pageNumber = MySprite.CreateText($"Page {page} of {numPages}", "Debug", Constants.COLOR_WHITE, 0.8f, TextAlignment.CENTER); pageNumber.Position = new Vector2(256, 392); Vector2 ff_pos = new Vector2(256, 466); Vector2 ff_size = new Vector2(492, 72); MySprite footerFrame = MySprite.CreateSprite("SquareSimple", ff_pos, ff_size); string statusText = ""; if (myProgram.isLeakManagementOn) { footerFrame.Color = Constants.COLOR_GREEN; statusText = "ON"; } else { footerFrame.Color = Constants.COLOR_RED; statusText = "OFF"; } MySprite leakStatus = MySprite.CreateText($"Leak Prevention: {statusText}", "Debug", Constants.COLOR_WHITE, 1.5f, TextAlignment.CENTER); leakStatus.Position = new Vector2(256, 442); footerSpriteList.Add(pageFrame); footerSpriteList.Add(pageNumber); footerSpriteList.Add(footerFrame); footerSpriteList.Add(leakStatus); }
private void DrawScreenDebug(Platform platform) { foreach (IMyTextSurfaceProvider surfaceProvider in platform.Surfaces) { IMyTextSurface surface = surfaceProvider.GetSurface(0); surface.ContentType = ContentType.SCRIPT; RectangleF _viewport = new RectangleF((surface.TextureSize - surface.SurfaceSize) / 2f, surface.SurfaceSize); using (var frame = surface.DrawFrame()) { var background = MySprite.CreateSprite("SquareSimple", _viewport.Center, _viewport.Size); background.Color = Constants.COLOR_BACKGROUND; frame.Add(background); Vector2 ocSize = percentageSize(80, _viewport); var outerCircle = MySprite.CreateSprite("Circle", _viewport.Center, ocSize); if (platform.Status.Equals(Platform.PlatformStatus.Clear)) { outerCircle.Color = Constants.COLOR_WHITE; } else if (platform.Status.Equals(Platform.PlatformStatus.Requested)) { outerCircle.Color = Constants.COLOR_GREEN; } else if (platform.Status.Equals(Platform.PlatformStatus.Obstructed)) { outerCircle.Color = Constants.COLOR_YELLOW; } else if (platform.Status.Equals(Platform.PlatformStatus.Occupied)) { outerCircle.Color = Constants.COLOR_RED; } frame.Add(outerCircle); Vector2 icSize = percentageSize(60, _viewport); var innerCircle = MySprite.CreateSprite("Circle", _viewport.Center, icSize); innerCircle.Color = Constants.COLOR_BACKGROUND_MASK; frame.Add(innerCircle); float size = TextSize(40, _viewport); float offset = TextSizeOffset(size); var platformCode = MySprite.CreateText($"{platform.Code}", "White", Color.White, size, TextAlignment.CENTER); Vector2 pcPos = new Vector2(_viewport.Size.X / 2, _viewport.Size.Y / 2 - offset) + _viewport.Position; platformCode.Position = pcPos; frame.Add(platformCode); } } }
private void DrawHeader(List <MySprite> headerSpriteList, float screenOffset) { Color color = (myProgram.isProductionOn) ? Constants.COLOR_GREEN : Constants.COLOR_RED; Vector2 b_pos = new Vector2(256 + screenOffset, 34); Vector2 b_size = new Vector2(492, 48); var background = MySprite.CreateSprite("SquareSimple", b_pos, b_size); background.Color = color; string text = (myProgram.isProductionOn) ? "ON" : "OFF"; var headerText = MySprite.CreateText($"AUTO O2 PRODUCTION: {text}", "White", Constants.COLOR_WHITE, 1.5f, TextAlignment.CENTER); headerText.Position = new Vector2(256 + screenOffset, 10); headerSpriteList.Add(background); headerSpriteList.Add(headerText); }
private void UpdateScreen(MySpriteDrawFrame frame, IMyCameraBlock camera, MyDetectedEntityInfo info) { Vector2 size = new Vector2(); if (status.Equals(STATUS_SR)) { size = new Vector2(8, 8); } else if (status.Equals(STATUS_MR)) { size = new Vector2(32, 32); } else if (status.Equals(STATUS_LR)) { size = new Vector2(128, 128); } float xPos = (cameraYaw + 64) * 8; float yPos = 512 - (cameraPitch + 64) * 8; Vector2 pos = new Vector2(xPos, yPos); Echo("Position: " + xPos + "," + yPos); var dot = MySprite.CreateSprite("SquareSimple", pos, size); if (info.IsEmpty()) { Echo("Info Empty"); dot.Color = Color.Black; } else { Echo("Info: " + Vector3D.Distance(camera.GetPosition(), info.HitPosition.Value).ToString("0.00")); int color = (int)Vector3D.Distance(camera.GetPosition(), info.HitPosition.Value); color = 255 - (color * 3); Echo("color: " + color); dot.Color = new Color(color, color, color); } drawPoints.Add(dot); frame.AddRange(drawPoints); }
private void DrawPressureInfo(Airlock airlock, List <MySprite> pressureInfoSpriteList) { Color contrastColor = new Color(); if (airlock.RoomPressure.Equals("High Pressure")) { contrastColor = Constants.COLOR_GREEN; } else if (airlock.RoomPressure.Equals("Low Pressure")) { contrastColor = Constants.COLOR_YELLOW; } else { contrastColor = Constants.COLOR_RED; } Vector2 oc_pos = new Vector2(256, 150); Vector2 oc_size = new Vector2(240, 240); var outerCircle = MySprite.CreateSprite("Circle", oc_pos, oc_size); outerCircle.Color = contrastColor; Vector2 ocm_pos = new Vector2(256, 150); Vector2 ocm_size = new Vector2(230, 230); var outerCircleMask = MySprite.CreateSprite("Circle", ocm_pos, ocm_size); outerCircleMask.Color = Constants.COLOR_BACKGROUND_MASK; var pressureText = MySprite.CreateText(airlock.OxygenLevel, "Debug", Constants.COLOR_WHITE, 4f, TextAlignment.CENTER); pressureText.Position = new Vector2(256, 90); var barText = MySprite.CreateText("BAR", "Debug", contrastColor, 1f, TextAlignment.CENTER); barText.Position = new Vector2(256, 200); pressureInfoSpriteList.Add(outerCircle); pressureInfoSpriteList.Add(outerCircleMask); pressureInfoSpriteList.Add(pressureText); pressureInfoSpriteList.Add(barText); }
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 DrawBackground(Airlock airlock, List <MySprite> backgroundSpriteList) { Vector2 b_pos = new Vector2(256, 256); Vector2 b_size = new Vector2(512, 512); var background = MySprite.CreateSprite("SquareSimple", b_pos, b_size); background.Color = Constants.COLOR_BACKGROUND_MASK; Vector2 bc_pos = new Vector2(256, 150); Vector2 bc_size = new Vector2(280, 280); var backgroundCircle = MySprite.CreateSprite("Circle", bc_pos, bc_size); backgroundCircle.Color = Constants.COLOR_BACKGROUND; Vector2 bcr_pos = new Vector2(256, 150); Vector2 bcr_size = new Vector2(512, 170); var backgroundCircleRect = MySprite.CreateSprite("SquareSimple", bcr_pos, bcr_size); backgroundCircleRect.Color = Constants.COLOR_BACKGROUND; backgroundSpriteList.Add(background); backgroundSpriteList.Add(backgroundCircle); backgroundSpriteList.Add(backgroundCircleRect); }
private static void DrawVOR(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, VORDataSet VORData) { if (VORData.Rotation == null) { DrawCross(ref Frame); return; } // Vars float CircleSize = Size.Y * 0.95f; float ArrowLength = Size.Y * 0.8f; float ArrowRotation = (float)VORData.Rotation; float Deviation = (float)VORData.Deviation; // 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); // Deviation bar float DConstant = Deviation / (float)VORFullScaleDeflectionAngle * (Size.Y * 0.4f); float Dx = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DConstant * -1; float Dy = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DConstant; MySprite DeviationBarMask = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength / 2.7f)); DeviationBarMask.Color = CockpitBGColor.Alpha(1f); DeviationBarMask.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(DeviationBarMask); MySprite DeviationBar = MySprite.CreateSprite("SquareSimple", Center + new Vector2(Dx, Dy), new Vector2(12 * UnitX, ArrowLength / 3)); DeviationBar.Color = Color.LawnGreen.Alpha(1f); DeviationBar.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(DeviationBar); // VOR Deviation Scale float DSM4 = -1.0f * (Size.Y * 0.4f); float DSM3 = -0.75f * (Size.Y * 0.4f); float DSM2 = -0.5f * (Size.Y * 0.4f); float DSM1 = -0.25f * (Size.Y * 0.4f); float DSP1 = 0.25f * (Size.Y * 0.4f); float DSP2 = 0.5f * (Size.Y * 0.4f); float DSP3 = 0.75f * (Size.Y * 0.4f); float DSP4 = 1.0f * (Size.Y * 0.4f); float DSM4x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM4 * -1; float DSM4y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM4; float DSM3x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM3 * -1; float DSM3y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM3; float DSM2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM2 * -1; float DSM2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM2; float DSM1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM1 * -1; float DSM1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM1; float DSP1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP1 * -1; float DSP1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP1; float DSP2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP2 * -1; float DSP2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP2; float DSP3x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP3 * -1; float DSP3y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP3; float DSP4x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP4 * -1; float DSP4y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP4; MySprite DSM4Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM4x, DSM4y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSM3Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM3x, DSM3y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSM2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM2x, DSM2y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSM1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM1x, DSM1y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSCSprite = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite DSP1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP1x, DSP1y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSP2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP2x, DSP2y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSP3Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP3x, DSP3y), new Vector2(CircleSize, CircleSize) * 0.05f); MySprite DSP4Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP4x, DSP4y), new Vector2(CircleSize, CircleSize) * 0.05f); DSM4Sprite.Color = CockpitFGColor.Alpha(1f); DSM3Sprite.Color = CockpitFGColor.Alpha(1f); DSM2Sprite.Color = CockpitFGColor.Alpha(1f); DSM1Sprite.Color = CockpitFGColor.Alpha(1f); DSCSprite.Color = CockpitFGColor.Alpha(1f); DSP1Sprite.Color = CockpitFGColor.Alpha(1f); DSP2Sprite.Color = CockpitFGColor.Alpha(1f); DSP3Sprite.Color = CockpitFGColor.Alpha(1f); DSP4Sprite.Color = CockpitFGColor.Alpha(1f); Frame.Add(DSM4Sprite); Frame.Add(DSM3Sprite); Frame.Add(DSM2Sprite); Frame.Add(DSM1Sprite); Frame.Add(DSCSprite); Frame.Add(DSP1Sprite); Frame.Add(DSP2Sprite); Frame.Add(DSP3Sprite); Frame.Add(DSP4Sprite); }
private void DrawAirlocks(List <MySprite> airlocksSpriteList, float screenOffset) { Vector2 b_pos = new Vector2(381.5f + screenOffset, 285); Vector2 b_size = new Vector2(241, 434); var background = MySprite.CreateSprite("SquareSimple", b_pos, b_size); background.Color = Constants.COLOR_BACKGROUND_MASK; Vector2 h_pos = new Vector2(381.5f + screenOffset, 78); Vector2 h_size = new Vector2(241, 20); var header = MySprite.CreateSprite("SquareSimple", h_pos, h_size); header.Color = Constants.COLOR_GREEN; var headerText = MySprite.CreateText("AIRLOCKS STATUS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); headerText.Position = new Vector2(271 + screenOffset, 69); airlocksSpriteList.Add(background); airlocksSpriteList.Add(header); airlocksSpriteList.Add(headerText); float startY = 133; // 213 float offset = 80; int counter = 0; foreach (KeyValuePair <string, Airlock> _al in myProgram.airlockController.Airlocks) { Airlock airlock = _al.Value; myProgram.Echo($"Airlock: {airlock.Name}"); Color airlockStatusColor = new Color(256, 256, 256); if (airlock.PublicStatus.Equals(Constants.AP_IDLE) || airlock.PublicStatus.Equals(Constants.AP_CYCLE)) { airlockStatusColor = Constants.COLOR_YELLOW; } else if (airlock.PublicStatus.Equals(Constants.AP_PRESSURIZED)) { airlockStatusColor = Constants.COLOR_GREEN; } else if (airlock.PublicStatus.Equals(Constants.AP_DEPRESSURIZED)) { airlockStatusColor = Constants.COLOR_RED; } Vector2 ab_pos = new Vector2(381.5f + screenOffset, startY + (offset * counter)); Vector2 ab_size = new Vector2(221, 70); var airlockBackground = MySprite.CreateSprite("SquareSimple", ab_pos, ab_size); airlockBackground.Color = Constants.COLOR_BACKGROUND_LIGHT; Vector2 asi_pos = new Vector2(276f + screenOffset, startY + (offset * counter)); Vector2 asi_size = new Vector2(10, 70); var airlockStatusIndicator = MySprite.CreateSprite("SquareSimple", asi_pos, asi_size); airlockStatusIndicator.Color = airlockStatusColor; var airlockName = MySprite.CreateText(airlock.Name, "White", Constants.COLOR_WHITE, 1f, TextAlignment.LEFT); airlockName.Position = new Vector2(288f + screenOffset, 100 + (offset * counter)); var airlockStatusTitle = MySprite.CreateText("STATUS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); airlockStatusTitle.Position = new Vector2(288f + screenOffset, 128 + (offset * counter)); var airlockStatus = MySprite.CreateText(airlock.PublicStatus, "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.RIGHT); airlockStatus.Position = new Vector2(480f + screenOffset, 128 + (offset * counter)); var airlockDoorStatusTitle = MySprite.CreateText("DOORS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT); airlockDoorStatusTitle.Position = new Vector2(288.5f + screenOffset, 145 + (offset * counter)); var airlockDoorStatus = MySprite.CreateText(airlock.OpenDoors, "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.RIGHT); airlockDoorStatus.Position = new Vector2(480f + screenOffset, 145 + (offset * counter)); airlocksSpriteList.Add(airlockBackground); airlocksSpriteList.Add(airlockStatusIndicator); airlocksSpriteList.Add(airlockName); airlocksSpriteList.Add(airlockStatusTitle); airlocksSpriteList.Add(airlockStatus); airlocksSpriteList.Add(airlockDoorStatusTitle); airlocksSpriteList.Add(airlockDoorStatus); counter++; } }
private void DrawAirventInfos(float posX, float posY, Color stateColor, bool isWorking, IMyAirVent airvent, out MySprite airventText, out MySprite divider, out MySprite statusTitle, out MySprite statusInfo, out MySprite oxygenTitle, out MySprite oxygenInfo, out MySprite pressurizeTitle, out MySprite pressurizeInfo) { string name = airvent.CustomName; if (name.Length > 17) { name = name.Substring(0, 14); name += "..."; } airventText = MySprite.CreateText(name, "Debug", Constants.COLOR_WHITE, 0.8f, TextAlignment.LEFT); airventText.Position = new Vector2(posX - 83, posY - 25); Vector2 d_pos = new Vector2(posX + 17, posY); Vector2 d_size = new Vector2(199, 2); divider = MySprite.CreateSprite("SquareSimple", d_pos, d_size); divider.Color = Constants.COLOR_GREEN; statusTitle = MySprite.CreateText("Status", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.LEFT); statusTitle.Position = new Vector2(posX - 116, posY + 2); string airventStatus = ""; Color textColor = Constants.COLOR_WHITE; if (!airvent.IsFunctional) { airventStatus = "BROKEN"; textColor = Constants.COLOR_RED; } else if (!airvent.IsWorking) { airventStatus = "NOT WORKING"; textColor = Constants.COLOR_RED; } else if (!airvent.CanPressurize) { airventStatus = "LEAK"; textColor = Constants.COLOR_RED; } else { airventStatus = "OPTIMAL"; } statusInfo = MySprite.CreateText(airventStatus, "Debug", textColor, 0.5f, TextAlignment.LEFT); statusInfo.Position = new Vector2(posX - 116, posY + 16); oxygenTitle = MySprite.CreateText("Oxygen", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER); oxygenTitle.Position = new Vector2(posX, posY + 2); oxygenInfo = MySprite.CreateText((airvent.GetOxygenLevel() * 100).ToString("0.0"), "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER); oxygenInfo.Position = new Vector2(posX, posY + 16); pressurizeTitle = MySprite.CreateText("Action", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.RIGHT); pressurizeTitle.Position = new Vector2(posX + 116, posY + 2); string action = ""; if (airvent.Depressurize) { action = "Depressurizing"; } else { action = "Pressurizing"; } pressurizeInfo = MySprite.CreateText(action, "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.RIGHT); pressurizeInfo.Position = new Vector2(posX + 116, posY + 16); }
private void DrawDoorButtons(Airlock airlock, List <MySprite> doorButtonSpriteList) { Color internalColor = new Color(255, 255, 255); Color externalColor = new Color(255, 255, 255); if (airlock.OpenDoors.Equals("Both")) { internalColor = Constants.COLOR_GREEN; externalColor = Constants.COLOR_GREEN; } else if (airlock.OpenDoors.Equals("Internal")) { internalColor = Constants.COLOR_GREEN; externalColor = Constants.COLOR_RED; } else if (airlock.OpenDoors.Equals("External")) { internalColor = Constants.COLOR_RED; externalColor = Constants.COLOR_GREEN; } else { internalColor = Constants.COLOR_RED; externalColor = Constants.COLOR_RED; } Vector2 ldr_pos = new Vector2(70, 150); Vector2 ldr_size = new Vector2(60, 60); var leftDoorRect = MySprite.CreateSprite("SquareSimple", ldr_pos, ldr_size); leftDoorRect.Color = Constants.COLOR_WHITE; Vector2 ldrm_pos = new Vector2(70, 150); Vector2 ldrm_size = new Vector2(56, 56); var leftDoorRectMask = MySprite.CreateSprite("SquareSimple", ldrm_pos, ldrm_size); leftDoorRectMask.Color = Constants.COLOR_BACKGROUND; Vector2 lds_pos = new Vector2(70, 187); Vector2 lds_size = new Vector2(60, 10); var leftDoorSignal = MySprite.CreateSprite("SquareSimple", lds_pos, lds_size); leftDoorSignal.Color = internalColor; var innerDoorText = MySprite.CreateText("INNER\nDOOR", "Debug", internalColor, 0.6f, TextAlignment.CENTER); innerDoorText.Position = new Vector2(70, 133); Vector2 rdr_pos = new Vector2(437, 150); Vector2 rdr_size = new Vector2(60, 60); var rightDoorRect = MySprite.CreateSprite("SquareSimple", rdr_pos, rdr_size); rightDoorRect.Color = Constants.COLOR_WHITE; Vector2 rdrm_pos = new Vector2(437, 150); Vector2 rdrm_size = new Vector2(56, 56); var rightDoorRectMask = MySprite.CreateSprite("SquareSimple", rdrm_pos, rdrm_size); rightDoorRectMask.Color = Constants.COLOR_BACKGROUND; Vector2 rds_pos = new Vector2(437, 187); Vector2 rds_size = new Vector2(60, 10); var rightDoorSignal = MySprite.CreateSprite("SquareSimple", rds_pos, rds_size); rightDoorSignal.Color = externalColor; var outerDoorText = MySprite.CreateText("OUTER\nDOOR", "Debug", externalColor, 0.6f, TextAlignment.CENTER); outerDoorText.Position = new Vector2(437, 133); doorButtonSpriteList.Add(leftDoorRect); doorButtonSpriteList.Add(leftDoorRectMask); doorButtonSpriteList.Add(leftDoorSignal); doorButtonSpriteList.Add(innerDoorText); doorButtonSpriteList.Add(rightDoorRect); doorButtonSpriteList.Add(rightDoorRectMask); doorButtonSpriteList.Add(rightDoorSignal); doorButtonSpriteList.Add(outerDoorText); }
public Panel(Vector2 position, Vector2 size, Color borderColor, float borderSize, IUIControl parent) : base(position, size, borderColor, borderSize, parent) { backgroundSprite = MySprite.CreateSprite(panelBackgroundSpriteName, position, size); }
private void DrawPressureButton(Airlock airlock, List <MySprite> pressureButtonSpriteList) { Vector2 buttonSize = new Vector2(130, 50); //136 48 Vector2 frameSize = new Vector2(130, 50); //136 48 Vector2 frameMaskSize = new Vector2(126, 46); //132 44 Vector2 frameMaskSizeH = new Vector2(130, 30); // 136 28 Vector2 frameMaskSizeV = new Vector2(110, 50); // 116 48 // 130*50 Vector2 bbl_pos = new Vector2(75, 330); var buttonBgLeft = MySprite.CreateSprite("SquareSimple", bbl_pos, buttonSize); buttonBgLeft.Color = Constants.COLOR_NAVY_BLUE; Vector2 bbc_pos = new Vector2(256, 330); var buttonBgCenter = MySprite.CreateSprite("SquareSimple", bbc_pos, buttonSize); buttonBgCenter.Color = Constants.COLOR_NAVY_BLUE; Vector2 bbr_pos = new Vector2(437, 330); var buttonBgRight = MySprite.CreateSprite("SquareSimple", bbr_pos, buttonSize); buttonBgRight.Color = Constants.COLOR_NAVY_BLUE; var frameButton = MySprite.CreateSprite("SquareSimple", bbc_pos, frameSize); var frameButtonMask = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSize); frameButtonMask.Color = Constants.COLOR_NAVY_BLUE; var frameButtonMaskH = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSizeH); frameButtonMaskH.Color = Constants.COLOR_NAVY_BLUE; var frameButtonMaskV = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSizeV); frameButtonMaskV.Color = Constants.COLOR_NAVY_BLUE; if (airlock.PublicStatus.Equals(Constants.AP_PRESSURIZED)) { frameButton.Color = Constants.COLOR_GREEN; frameButtonMask.Color = Constants.COLOR_GREEN_DARK; frameButtonMaskH.Color = Constants.COLOR_GREEN_DARK; frameButtonMaskV.Color = Constants.COLOR_GREEN_DARK; frameButton.Position = bbl_pos; frameButtonMask.Position = bbl_pos; frameButtonMaskH.Position = bbl_pos; frameButtonMaskV.Position = bbl_pos; } else if (airlock.PublicStatus.Equals(Constants.AP_CYCLE)) { frameButton.Color = Constants.COLOR_YELLOW; frameButtonMask.Color = Constants.COLOR_YELLOW_DARK; frameButtonMaskH.Color = Constants.COLOR_YELLOW_DARK; frameButtonMaskV.Color = Constants.COLOR_YELLOW_DARK; frameButton.Position = bbc_pos; frameButtonMask.Position = bbc_pos; frameButtonMaskH.Position = bbc_pos; frameButtonMaskV.Position = bbc_pos; } else if (airlock.PublicStatus.Equals(Constants.AP_DEPRESSURIZED)) { frameButton.Color = Constants.COLOR_RED; frameButtonMask.Color = Constants.COLOR_RED_DARK; frameButtonMaskH.Color = Constants.COLOR_RED_DARK; frameButtonMaskV.Color = Constants.COLOR_RED_DARK; frameButton.Position = bbr_pos; frameButtonMask.Position = bbr_pos; frameButtonMaskH.Position = bbr_pos; frameButtonMaskV.Position = bbr_pos; } var bblText = MySprite.CreateText("PRESSURIZED", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER); bblText.Position = new Vector2(75, 320); var bbcText = MySprite.CreateText("CYCLING", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER); bbcText.Position = new Vector2(256, 320); var bbrText = MySprite.CreateText("DEPRESSURIZED", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER); bbrText.Position = new Vector2(437, 320); pressureButtonSpriteList.Add(buttonBgCenter); pressureButtonSpriteList.Add(buttonBgLeft); pressureButtonSpriteList.Add(buttonBgRight); pressureButtonSpriteList.Add(frameButton); pressureButtonSpriteList.Add(frameButtonMask); pressureButtonSpriteList.Add(frameButtonMaskH); pressureButtonSpriteList.Add(frameButtonMaskV); pressureButtonSpriteList.Add(bbcText); pressureButtonSpriteList.Add(bblText); pressureButtonSpriteList.Add(bbrText); }
private static void DrawILS(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, ILSDataSet ILSData) { if (ILSData.Rotation == null) { DrawCross(ref Frame); return; } // Vars float CircleSize = Size.Y * 0.95f; float ArrowLength = Size.Y * 0.8f; float ArrowRotation = (float)ILSData.Rotation; float Deviation = (float)ILSData.LocalizerDeviation; // between -12 and 12. // Re-position the Center position a bit offset in order to accomodate glideslope indicator. Center -= CenterSub; // 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)); // new Vector2(10 * UnitX, 60 * UnitY) 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); // Deviation bar float DConstant = Deviation / (float)LOCFullScaleDeflectionAngle * (Size.Y * 0.4f); float Dx = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DConstant * -1; float Dy = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DConstant; MySprite DeviationBarMask = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength / 2.7f)); DeviationBarMask.Color = CockpitBGColor.Alpha(1f); DeviationBarMask.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(DeviationBarMask); MySprite DeviationBar = MySprite.CreateSprite("SquareSimple", Center + new Vector2(Dx, Dy), new Vector2(12 * UnitX, ArrowLength / 3)); DeviationBar.Color = Color.LawnGreen.Alpha(1f); DeviationBar.RotationOrScale = ToRadian(ArrowRotation); Frame.Add(DeviationBar); // Localizer Deviation Scale float DSM2 = -1.0f * (Size.Y * 0.4f); float DSM1 = -0.5f * (Size.Y * 0.4f); float DSP1 = 0.5f * (Size.Y * 0.4f); float DSP2 = 1.0f * (Size.Y * 0.4f); float DSM2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM2 * -1; float DSM2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM2; float DSM1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM1 * -1; float DSM1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM1; float DSP1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP1 * -1; float DSP1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP1; float DSP2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP2 * -1; float DSP2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP2; MySprite DSM2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM2x, DSM2y), new Vector2(CircleSize, CircleSize) * 0.1f); MySprite DSM1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM1x, DSM1y), new Vector2(CircleSize, CircleSize) * 0.1f); MySprite DSCSprite = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite DSP1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP1x, DSP1y), new Vector2(CircleSize, CircleSize) * 0.1f); MySprite DSP2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP2x, DSP2y), new Vector2(CircleSize, CircleSize) * 0.1f); DSM2Sprite.Color = CockpitFGColor.Alpha(1f); DSM1Sprite.Color = CockpitFGColor.Alpha(1f); DSCSprite.Color = CockpitFGColor.Alpha(1f); DSP1Sprite.Color = CockpitFGColor.Alpha(1f); DSP2Sprite.Color = CockpitFGColor.Alpha(1f); Frame.Add(DSM2Sprite); Frame.Add(DSM1Sprite); Frame.Add(DSCSprite); Frame.Add(DSP1Sprite); Frame.Add(DSP2Sprite); // GlideSlope Vector2 GSCenter = new Vector2(Size.X * 1.3f, Center.Y); Vector2 GSM2 = new Vector2(GSCenter.X, GSCenter.Y - Size.Y * 0.4f); Vector2 GSM1 = new Vector2(GSCenter.X, GSCenter.Y - Size.Y * 0.2f); Vector2 GSP1 = new Vector2(GSCenter.X, GSCenter.Y + Size.Y * 0.2f); Vector2 GSP2 = new Vector2(GSCenter.X, GSCenter.Y + Size.Y * 0.4f); float DeviationUnits = (float)ILSData.GlideSlopeDeviation / (float)GSFullScaleDeflectionAngle * Size.Y * 0.4f; Vector2 GSDiamondPos = new Vector2(GSCenter.X, GSCenter.Y + DeviationUnits); MySprite GDSM2Sprite = MySprite.CreateSprite("Circle", GSM2, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite GDSM1Sprite = MySprite.CreateSprite("Circle", GSM1, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite GDSP1Sprite = MySprite.CreateSprite("Circle", GSP1, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite GDSP2Sprite = MySprite.CreateSprite("Circle", GSP2, new Vector2(CircleSize, CircleSize) * 0.1f); MySprite GDSCSprite = MySprite.CreateSprite("SquareSimple", GSCenter, new Vector2(CircleSize * 0.2f, UnitY * 6)); MySprite GSDiamond = MySprite.CreateSprite("SquareSimple", GSDiamondPos, new Vector2(UnitX * 25, UnitY * 25)); GDSCSprite.Color = CockpitFGColor.Alpha(1f); GSDiamond.Color = Color.LawnGreen.Alpha(1f); GSDiamond.RotationOrScale = ToRadian(45f); GDSM2Sprite.Color = CockpitFGColor.Alpha(1f); GDSM1Sprite.Color = CockpitFGColor.Alpha(1f); GDSP1Sprite.Color = CockpitFGColor.Alpha(1f); GDSP2Sprite.Color = CockpitFGColor.Alpha(1f); Frame.Add(GDSM2Sprite); Frame.Add(GDSM1Sprite); Frame.Add(GDSCSprite); Frame.Add(GDSP1Sprite); Frame.Add(GDSP2Sprite); Frame.Add(GSDiamond); // Re-center the center position. Center += CenterSub; }
public void HorizonalBarBox(BoxStyle style, float value, int separate = 8, bool discrete = false) { if (style.SizeRule == SizeRule.Auto) { style = new BoxStyle(style) { Size = new Vector2(100, 29) }; } Vector2 size = style.Size * Scale; BoundingBox2 box = new BoundingBox2(Cursor, Cursor + size); if (Sprites != null) { Vector2 innerSize = style.InnerSize * Scale; MySprite sprite; sprite = MySprite.CreateSprite(SpriteId.SquareHollow, new Vector2(), new Vector2(1.0f, 1.0f)); sprite.Color = Color; sprite.Position = sprite.Position * innerSize + box.Center; sprite.Size *= innerSize; Sprites.Add(sprite); //sprite = MySprite.CreateText($"value={value}", FontId, Color, 1.0f, TextAlignment.LEFT); //sprite.Position = new Vector2(-0.45f, -0.45f); //sprite.Position = sprite.Position * size + center; //sprites.Add(sprite); if (value > 1.0f) { value = 1.0f; } if (value < 0.0f) { value = 0.0f; } if (Single.IsNaN(value)) { value = 0.0f; } double len = value * separate; float delta = (float)(len - Math.Floor(len)); Vector2 deltaVec = new Vector2(delta, 1.0f); int top; if (discrete) { top = Convert.ToInt32(len); } else { top = Convert.ToInt32(Math.Floor(len)); } Vector2 cellPos = new Vector2(0, 0.0f); Vector2 cellSize = new Vector2(0.9f / separate, 0.9f); //Vector2 innerCellSize = new Vector2(cellSize.X * 0.8f, cellSize.Y * 0.8f); Vector2 innerCellSize = new Vector2(cellSize.X - 0.04f, cellSize.Y * 0.8f); for (int i = 0; i < separate; i++) { if (((discrete) && (i < top)) || ((!discrete) && (i <= top))) { //cellPos.X = 0.92f * (i - (int)((separate - 1)/2)) / separate; cellPos.X = (0.0f - (0.9f / 2)) + (cellSize.X / 2) + (i * cellSize.X); if (i == top) { cellPos.X += ((delta - 1) * innerCellSize.X) / 2.0f; sprite = MySprite.CreateSprite(SpriteId.SquareSimple, cellPos, innerCellSize * deltaVec); } else { sprite = MySprite.CreateSprite(SpriteId.SquareSimple, cellPos, innerCellSize); } //sprite.Color = new Color(0, 255, 255); sprite.Color = Color; sprite.Position = sprite.Position * innerSize + box.Center; sprite.Size *= innerSize; Sprites.Add(sprite); } } } MoveCursor(box.Width); MergeBox(box); }