public void Init() { if (widget_ == null) { widget_ = new HudAPIv2.BillBoardHUDMessage( Material: MyStringId.GetOrCompute("Square"), Origin: location_, BillBoardColor: Color.Red, Height: 0.05f ); } }
private BillboardInfo InitHUDFatigue() { StringBuilder fatigueStringBuilder = new StringBuilder(); var fatigueHudMessage = new HudAPIv2.HUDMessage(fatigueStringBuilder, new Vector2D(-0.766f, -0.505f), Scale: 1.2d); var fatigueIconBillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.FatigueIcon, new Vector2D(-0.941, -0.515), Color.White) { Height = 1.55f, Scale = 0.02d, Rotation = 0f }; var fatigueBar25BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.TwentyFivePercentHudIconFull, new Vector2D(-0.906f, -0.52), Color.White) { Height = 2.0f, Rotation = 0f, Scale = 0.07f }; var fatigueBar50BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.FiftyPercentHudIconHudIconFull, new Vector2D(-0.868f, -0.52), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var fatigueBar75BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.SeventyFivePercentHudIconFull, new Vector2D(-0.8295f, -0.52), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var fatigueBar100BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.OneHundredPercentHudIconFull, new Vector2D(-0.791f, -0.52), Color.White) { Height = 1.85f, Rotation = 0f, Scale = 0.07f }; return(new BillboardInfo { Message = fatigueHudMessage, StringBuilder = fatigueStringBuilder, Icon = fatigueIconBillboardMessage, TwentyFive = fatigueBar25BillboardMessage, Fifty = fatigueBar50BillboardMessage, SeventyFive = fatigueBar75BillboardMessage, OneHundred = fatigueBar100BillboardMessage }); }
private BillboardInfo InitHUDHunger() { StringBuilder hungerStringBuilder = new StringBuilder(); var hungerHudMessage = new HudAPIv2.HUDMessage(hungerStringBuilder, new Vector2D(-0.766f, -0.4f), Scale: 1.2d); var hungerIconBillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.HungerIcon, new Vector2D(-0.941, -0.405), Color.White) { Height = 1.65f, Scale = 0.02d, Rotation = 0f }; var hungerBar25BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.TwentyFivePercentHudIconFull, new Vector2D(-0.906f, -0.41), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var hungerBar50BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.FiftyPercentHudIconHudIconFull, new Vector2D(-0.868f, -0.41), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var hungerBar75BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.SeventyFivePercentHudIconFull, new Vector2D(-0.8295f, -0.41), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var hungerBar100BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.OneHundredPercentHudIconFull, new Vector2D(-0.791f, -0.41), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; return(new BillboardInfo { Message = hungerHudMessage, StringBuilder = hungerStringBuilder, Icon = hungerIconBillboardMessage, TwentyFive = hungerBar25BillboardMessage, Fifty = hungerBar50BillboardMessage, SeventyFive = hungerBar75BillboardMessage, OneHundred = hungerBar100BillboardMessage }); }
private BillboardInfo InitHUDThirst() { StringBuilder thirstStringBuilder = new StringBuilder(); var thirstHudMessage = new HudAPIv2.HUDMessage(thirstStringBuilder, new Vector2D(-0.766f, -0.445f), Scale: 1.2d); var thirstIconBillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.ThirstIcon, new Vector2D(-0.941, -0.460), Color.White) { Height = 1.55f, Rotation = 0f, Scale = 0.02d }; var thirstBar25BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.TwentyFivePercentHudIconFull, new Vector2D(-0.906f, -0.465), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var thirstBar50BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.FiftyPercentHudIconHudIconFull, new Vector2D(-0.868f, -0.465), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var thirstBar75BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.SeventyFivePercentHudIconFull, new Vector2D(-0.8295f, -0.465), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; var thirstBar100BillboardMessage = new HudAPIv2.BillBoardHUDMessage( IconStringRefs.OneHundredPercentHudIconFull, new Vector2D(-0.791f, -0.465), Color.White) { Height = 1.85f, Scale = 0.07f, Rotation = 0f }; return(new BillboardInfo { Message = thirstHudMessage, StringBuilder = thirstStringBuilder, Icon = thirstIconBillboardMessage, TwentyFive = thirstBar25BillboardMessage, Fifty = thirstBar50BillboardMessage, SeventyFive = thirstBar75BillboardMessage, OneHundred = thirstBar100BillboardMessage }); }
public void Init() { fill_lvl_lbl_.Init(); fill_lvl_icon_ = new HudAPIv2.BillBoardHUDMessage( BillBoardColor: Color.White, Origin: FILL_LVL_LOCATION, Material: FILL_LEVEL_100, Scale: 0.2, Width: 0.8f ); fill_lvl_icon_.Visible = false; fill_mulitplier_lbl_.Init(); fill_mulitplier_lbl_.Scale = 1.2; }
private void CleanupHUD() { if (Background != null) { Background.TimeToLive = 0; Background = null; } if (Message != null) { text.Clear(); Message.TimeToLive = 0; Message = null; } textCache = defaultTextCache; needsUpdate = false; }
void SetUIOption(HudAPIv2.Options flag, bool set) { if (uiTitle == null) { return; } for (int i = 0; i < ui.Length; ++i) { HudAPIv2.MessageBase msgBase = ui[i]; // just in case this issue comes back I wanna know if it's it specifically if (msgBase.BackingObject == null) { Log.Error($"{msgBase.GetType().Name} (ui{i}) has BackingObject = null!!!"); continue; } HudAPIv2.HUDMessage hudMessage = msgBase as HudAPIv2.HUDMessage; if (hudMessage != null) { if (set) { hudMessage.Options |= flag; } else { hudMessage.Options &= ~flag; } continue; } HudAPIv2.BillBoardHUDMessage hudBillboard = msgBase as HudAPIv2.BillBoardHUDMessage; if (hudBillboard != null) { if (set) { hudBillboard.Options |= flag; } else { hudBillboard.Options &= ~flag; } continue; } } }
public void Close(bool deregister = true) { active = false; text.Clear(); textCache = defaultTextCache; if (Message != null) { Message.TimeToLive = 0; Message = null; } if (Background != null) { Background.TimeToLive = 0; Background = null; } if (deregister) { HudRenderer.Instance.UnregisterSurface(this); } }
private void UpdateLCD() { if (Background == null) { Background = new HudAPIv2.BillBoardHUDMessage( MyStringId.GetOrCompute("SquareIgnoreDepth"), Position, BackgroundColorObject, Scale: 1.05, // .05 is for padding HideHud: !NoHideHud, Blend: BlendTypeEnum.PostPP); } if (Message == null) { Message = new HudAPIv2.HUDMessage( text, Position, Scale: Scale, HideHud: !NoHideHud, Blend: BlendTypeEnum.PostPP, Font: Font); } needsUpdate = false; textCache = surface.GetText(); text.Clear(); text.Append(ColorObject); text.Append(textCache); Background.Visible = HasBackground; if (HasBackground) { var ln = Message.GetTextLength(); Background.Offset = ln / 2d; Background.Width = (float)ln.X; Background.Height = (float)ln.Y; } }
private void InitHudElements() { if (TextAPI == null) { return; } if (!TextAPI.Heartbeat) { return; } if (HudInit) { return; } if (Instructions == null) { Instructions = new HudAPIv2.HUDMessage(); Instructions.Scale = 1.5d; Instructions.Visible = false; } if (Notification == null) { Notification = new HudAPIv2.HUDMessage(); Notification.Visible = false; Notification.Scale = 1.5d; Notification.Origin = new Vector2D(-0.2, 1.0); Notification.Message = CanActivateHud; V_CanActivateHud = Notification.GetTextLength(); Notification.Message = HudActivated; V_HudActivated = Notification.GetTextLength(); Instructions.Origin = Notification.Origin; Instructions.Offset = new Vector2D(0, V_CanActivateHud.Y); } if (Distance == null) { Distance = new HudAPIv2.HUDMessage(); Distance.Visible = false; } if (CenterDot == null) { CenterDot = new HudAPIv2.BillBoardHUDMessage(WHITEDOT, Vector2D.Zero, Color.Blue); CenterDot.Options |= HudAPIv2.Options.Shadowing | HudAPIv2.Options.Fixed; CenterDot.Scale = 0.0012d; CenterDot.Visible = false; } if (TargetDot == null) { TargetDot = new HudAPIv2.BillBoardHUDMessage(WHITEDOT, Vector2D.Zero, Color.Orange); TargetDot.Options |= HudAPIv2.Options.Shadowing | HudAPIv2.Options.Fixed; TargetDot.Scale = 0.0012d; TargetDot.Visible = false; } if (TrackingDot == null) { TrackingDot = new HudAPIv2.BillBoardHUDMessage(WHITEDOT, Vector2D.Zero, Color.White); TrackingDot.Options |= HudAPIv2.Options.Shadowing | HudAPIv2.Options.Fixed; TrackingDot.Scale = 0.0008d; TrackingDot.Visible = false; } if (AlignmentDot == null) { AlignmentDot = new HudAPIv2.BillBoardHUDMessage(WHITEDOT, Vector2D.Zero, Color.Red); AlignmentDot.Options |= HudAPIv2.Options.Shadowing | HudAPIv2.Options.Fixed; AlignmentDot.Scale = 0.0012d; AlignmentDot.Visible = false; } HudInit = true; }
public override void UpdateBeforeSimulation() { try { if (MyAPIGateway.Session == null) { return; } if (!_initialized) { Init(); _initialized = true; } if (hudApIv2.Heartbeat == false && _tick >= 600) { MyAPIGateway.Utilities.ShowNotification("HUDAPI MOD MISSING - PLEASE ENABLE", 5000, "Red"); _logging.WriteLine("Text HUD API was not detected!"); } if (hudApIv2.Heartbeat && !_hudInit) { crosshairIcon_Billboard_Message = new HudAPIv2.BillBoardHUDMessage(CrossHairIcon, new Vector2D(0, 0), Color.White, null, -1, 1D, 1F, 1F, 0F, true, true, BlendTypeEnum.PostPP); crosshairIcon_Billboard_Message.Height = 1.80f; crosshairIcon_Billboard_Message.Scale = 0.35d; crosshairIcon_Billboard_Message.Rotation = 0f; crosshairIcon_Billboard_Message.Material = CrossHairIcon; _hudInit = true; _logging.WriteLine("HUD initialised and heart beat active"); } if (hudApIv2.Heartbeat && _hudInit) { const int keyPressTimer = 1; const MyKeys keyBind = MyKeys.F2; var equippedItem = MyAPIGateway.Session?.Player?.Character?.Components?.Get <MyCharacterWeaponPositionComponent>(); var equippedTool = MyAPIGateway.Session?.Player?.Character?.EquippedTool; var inCockpit = MyAPIGateway.Session?.Player?.Controller?.ControlledEntity?.Entity is IMyCockpit; if ((equippedTool is IMyAngleGrinder || (equippedTool is IMyWelder)) && _hightlightBlocks) { var toolCast = equippedTool.Components?.Get <MyCasterComponent>(); var hitBlock = (IMySlimBlock)toolCast?.HitBlock; if (hitBlock != null) { var cubeBlockDefinition = hitBlock.BlockDefinition as MyCubeBlockDefinition; Matrix result; hitBlock.Orientation.GetMatrix(out result); var matrixD = (MatrixD)result; var worldMatrix1 = hitBlock.CubeGrid.Physics.GetWorldMatrix(); var worldMatrix2 = matrixD * Matrix.CreateTranslation((Vector3)hitBlock.Position) * Matrix.CreateScale(hitBlock.CubeGrid.GridSize) * worldMatrix1; var lineWidth = hitBlock.CubeGrid.GridSizeEnum == MyCubeSize.Large ? 0.06f : 0.03f; var vector1 = new Vector3(0.5f, 0.5f, 0.5f); var vector2 = new Vector3(0.05f); var localbox = new BoundingBoxD((Vector3D)((Vector3)(-cubeBlockDefinition.Center) - vector1 - vector2), (Vector3D)((Vector3)(cubeBlockDefinition.Size - cubeBlockDefinition.Center) - vector1 + vector2)); var highlightColor = Color.White; var highlightMaterial = MyStringId.GetOrCompute(""); if (equippedTool is IMyAngleGrinder) { highlightColor = Color.Red * 0.3f; highlightMaterial = MyStringId.GetOrCompute("GizmoDrawLineRed"); } if (equippedTool is IMyWelder) { highlightColor = Color.Green * 0.75f; highlightMaterial = MyStringId.GetOrCompute("GizmoDrawLine"); } MySimpleObjectDraw.DrawTransparentBox(ref worldMatrix2, ref localbox, ref highlightColor, MySimpleObjectRasterizer.Wireframe, 1, lineWidth, new MyStringId?(), highlightMaterial); } } if (MyAPIGateway.Gui.ChatEntryVisible) { return; } if (MyAPIGateway.Input.IsNewGameControlPressed(MyControlsSpace.TOGGLE_HUD)) { _hudHidden = MyAPIGateway.Session?.Config?.MinimalHud ?? false; } // When HUD is displayed if (MyVisualScriptLogicProvider.IsNewKeyPressed(keyBind) && _crosshairDisplayedPlayer && _keypressWait == 0 && !_viewDisabledByUser && !_hudHidden) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = false; _viewDisabledByUser = true; _crosshairDisplayedPlayer = false; } if (MyVisualScriptLogicProvider.IsNewKeyPressed(keyBind) && !_crosshairDisplayedPlayer && _keypressWait == 0 && _viewDisabledByUser && !_hudHidden) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = true; _viewDisabledByUser = false; _crosshairDisplayedPlayer = true; } // When HUD is NOT displayed if (MyVisualScriptLogicProvider.IsNewKeyPressed(keyBind) && !_crosshairDisplayOnHudHidden && _keypressWait == 0 && _hudHidden) { _keypressWait = keyPressTimer; //MyVisualScriptLogicProvider.ShowNotification("Hide CrossHair on No HUD", 2000, "Red"); crosshairIcon_Billboard_Message.Visible = true; crosshairIcon_Billboard_Message.Options |= HudAPIv2.Options.HideHud; _crosshairDisplayOnHudHidden = true; } if (MyVisualScriptLogicProvider.IsNewKeyPressed(keyBind) && _crosshairDisplayOnHudHidden && _keypressWait == 0 && _hudHidden) { _keypressWait = keyPressTimer; //MyVisualScriptLogicProvider.ShowNotification("Show CrossHair on No HUD", 2000, "Green"); crosshairIcon_Billboard_Message.Visible = true; crosshairIcon_Billboard_Message.Options &= ~HudAPIv2.Options.HideHud; _crosshairDisplayOnHudHidden = false; } // When player is in first view if (MyAPIGateway.Session.Player.Character != null && MyAPIGateway.Session.Player.Character.IsInFirstPersonView && !_crosshairDisplayedPlayer && _keypressWait == 0 && !_viewDisabledByUser && !equippedItem.IsInIronSight) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = true; _crosshairDisplayedPlayer = true; } // When player charecter is in 3rd person view if (MyAPIGateway.Session.Player.Character != null && !MyAPIGateway.Session.Player.Character.IsInFirstPersonView && _crosshairDisplayedPlayer && _keypressWait == 0 && !equippedItem.IsInIronSight && !inCockpit) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = false; _crosshairDisplayedPlayer = false; } // When player looking down weapon sights if (equippedItem.IsInIronSight && _crosshairDisplayedPlayer && _keypressWait == 0 && !_viewDisabledByUser) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = false; _crosshairDisplayedPlayer = false; } if (!equippedItem.IsInIronSight && !_crosshairDisplayedPlayer && _keypressWait == 0 && !_viewDisabledByUser && MyAPIGateway.Session.Player.Character.IsInFirstPersonView && !inCockpit) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = true; _crosshairDisplayedPlayer = true; } // When player in menus if (!MyAPIGateway.Gui.IsCursorVisible && _crosshairDisplayedPlayer && _keypressWait == 0) { crosshairIcon_Billboard_Message.Visible = true; } if (MyAPIGateway.Gui.IsCursorVisible && _crosshairDisplayedPlayer && _keypressWait == 0 && !_viewDisabledByUser) { crosshairIcon_Billboard_Message.Visible = false; } // When player in Cockpit third person if (inCockpit && !((IMyCockpit)MyAPIGateway.Session?.Player?.Controller?.ControlledEntity?.Entity) .IsInFirstPersonView && _crosshairDisplayedCockpit && _keypressWait == 0 && !equippedItem.IsInIronSight) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = false; _crosshairDisplayedCockpit = true; } // When player in Cockpit first person if (inCockpit && ((IMyCockpit)MyAPIGateway.Session?.Player?.Controller?.ControlledEntity?.Entity) .IsInFirstPersonView && !_crosshairDisplayedCockpit && _keypressWait == 0 && !_viewDisabledByUser && !equippedItem.IsInIronSight) { _keypressWait = keyPressTimer; crosshairIcon_Billboard_Message.Visible = true; _crosshairDisplayedCockpit = true; } } if (_keypressWait > 0) { _keypressWait--; } _tick++; } catch (Exception e) { _logging.WriteLine("Crosshair MOD Error" + e.ToString()); } }
/// <summary> /// Refresh the stats display using latest data. /// </summary> public void Refresh() { // quality quarantined if (!HudApi.Heartbeat) { return; } // Check if HUD elements have been initialised. If not, do. // TODO: Init once, don't check. if (hudStaminaReadout == null) { hudStaminaReadout = new HudAPIv2.HUDMessage( Message: new StringBuilder(COLOR_STRING_Y.Length + "100".Length), Origin: new Vector2D(-0.925d, 0.95d), Blend: BlendTypeEnum.PostPP ); } if (hudStaminaIcon == null) { // TODO: Refresh on "exit from any menu", like Digi does in PaintGun (or better!). var viewportSize = MyAPIGateway.Session.Camera.ViewportSize; float aspectRatio = viewportSize.X / viewportSize.Y; hudStaminaIcon = new HudAPIv2.BillBoardHUDMessage( Material: MyStringId.GetOrCompute("StaminaIconMale"), Origin: new Vector2D(-0.95d, 0.935d), BillBoardColor: Color.White, Width: 0.0325f / aspectRatio, Height: 0.0325f, Blend: BlendTypeEnum.PostPP ); } if (hudStaminaLowOverlay == null) { hudStaminaLowOverlay = new HudAPIv2.BillBoardHUDMessage( Material: MyStringId.GetOrCompute("StaminaLowOverlay"), Origin: new Vector2D(0.0d, 0.0d), BillBoardColor: noColor, Width: 2.0f, Height: 2.0f, Blend: BlendTypeEnum.Standard ); } if (stamina < 0.25f) { // Sigmoid - so it reaches near-full saturation earlier than stamina gets to zero. // See WolframAlpha: 1 - 1/(1+e^(-50x + 6.25)) from -0.25 to 0.25 // https://www.wolframalpha.com/input/?i=1+-+1%2F%281%2Be%5E%28-50x+%2B+6.25%29%29+from+-0.25+to+0.25 float alpha = 1.0f - 1.0f / (1.0f + (float)Math.Exp(-50.0f * stamina + 6.25f)); // Clamp to below 1 so it's never fully opaque. alpha = Math.Min(0.95f, Math.Max(0.0f, alpha)); hudStaminaLowOverlay.BillBoardColor = new Color(new Vector4(1.0f, 1.0f, 1.0f, alpha)); } else { hudStaminaLowOverlay.BillBoardColor = noColor; } hudStaminaReadout.Message.Clear(); if (stamina > 0.75f) { colorString = COLOR_STRING_W; } else if (stamina < 0.25f) { colorString = COLOR_STRING_R; } else { colorString = COLOR_STRING_Y; } hudStaminaReadout.Message.AppendFormat($"{colorString}{Convert.ToInt32(stamina * 100.0f)}"); refreshNeeded = false; }
public void UpdateUISettings() { if (uiTitle == null) { return; } SetUIOption(HudAPIv2.Options.HideHud, Main.Settings.hidePaletteWithHUD); float alpha = (Main.Settings.aimInfoBackgroundOpacity < 0 ? Main.GameConfig.HudBackgroundOpacity : Main.Settings.aimInfoBackgroundOpacity); uiTitleBg.BillBoardColor = Utils.HUDColorAlpha(UI_TITLE_BG_COLOR, alpha); uiTextBg.BillBoardColor = Utils.HUDColorAlpha(UI_TEXT_BG_COLOR, alpha); uiProgressBarBg.BillBoardColor = Utils.HUDColorAlpha(UI_PROGRESSBAR_BG_COLOR, MathHelper.Clamp(alpha * 2, 0.1f, 0.9f)); float aspectRatioMod = (float)(1d / Main.GameConfig.AspectRatio); float boxBgWidth = UI_BOX_WIDTH * aspectRatioMod; float colorWidth = UI_COLORBOX_WIDTH * aspectRatioMod; float progressBarWidth = UI_PROGRESSBAR_WIDTH * aspectRatioMod; for (int i = 0; i < ui.Length; ++i) { HudAPIv2.MessageBase msgBase = ui[i]; if (msgBase is HudAPIv2.HUDMessage) { HudAPIv2.HUDMessage obj = (HudAPIv2.HUDMessage)msgBase; obj.Origin = uiPosition; } else if (msgBase is HudAPIv2.BillBoardHUDMessage) { HudAPIv2.BillBoardHUDMessage obj = (HudAPIv2.BillBoardHUDMessage)msgBase; obj.Origin = uiPosition; } } //float scale = settings.aimInfoScale; const float scale = 1f; // TODO: make it scaleable? uiTitleBg.Width = boxBgWidth * scale; uiTextBg.Width = boxBgWidth * scale; uiPaintColor.Width = colorWidth * scale; uiTargetColor.Width = colorWidth * scale; uiProgressBar.Width = progressBarWidth * scale; uiProgressBarBg.Width = progressBarWidth * scale; uiTitle.Offset = new Vector2D(0.012, -0.018) * scale; uiTitleBg.Offset = new Vector2D(uiTitleBg.Width * 0.5, uiTitleBg.Height * -0.5); uiText.Offset = new Vector2D(0.07 * aspectRatioMod, -0.09) * scale; uiTextBg.Offset = new Vector2D(uiTextBg.Width * 0.5, uiTextBg.Height * -0.5) + (uiTextBgPosition * scale); uiTargetColor.Offset = new Vector2D(0.09 * aspectRatioMod, -0.195) * scale; uiPaintColor.Offset = new Vector2D(0.09 * aspectRatioMod, -0.295) * scale; uiProgressBar.Offset = new Vector2D(uiProgressBar.Width * 0.5, uiProgressBar.Height * -0.5) + (uiProgressBarPosition * scale); uiProgressBarBg.Offset = new Vector2D(uiProgressBarBg.Width * 0.5, uiProgressBarBg.Height * -0.5) + (uiProgressBarPosition * scale); uiTitle.Scale = UI_TITLE_SCALE * scale; uiTitleBg.Scale = scale; uiText.Scale = UI_TEXT_SCALE * scale; uiTextBg.Scale = scale; uiTargetColor.Scale = scale; uiPaintColor.Scale = scale; uiProgressBar.Scale = scale; uiProgressBarBg.Scale = scale; }
void UpdateGUI() { if (!Main.TextAPI.IsEnabled || !Main.CheckPlayerField.Ready) { return; } if (uiTitle == null) { const int MAX_EXPECTED_CHARACTERS_TITLE = 64; const int MAX_EXPECTED_CHARACTERS_TEXT = 512; // NOTE: this creation order is needed to have background elements stay in background when everything uses PostPP (or SDR) at once. int i = 0; ui[i++] = uiTextBg = new HudAPIv2.BillBoardHUDMessage(Main.PaletteHUD.MATERIAL_PALETTE_BACKGROUND, uiPosition, UI_TEXT_BG_COLOR, Width: UI_BOX_WIDTH, Height: UI_TEXT_BG_HEIGHT, Blend: UI_BG_BLENDTYPE); ui[i++] = uiTitleBg = new HudAPIv2.BillBoardHUDMessage(Main.PaletteHUD.MATERIAL_PALETTE_BACKGROUND, uiPosition, UI_TITLE_BG_COLOR, Width: UI_BOX_WIDTH, Height: UI_TITLE_BG_HEIGHT, Blend: UI_BG_BLENDTYPE); ui[i++] = uiTitle = new HudAPIv2.HUDMessage(new StringBuilder(MAX_EXPECTED_CHARACTERS_TITLE), uiPosition, Scale: UI_TITLE_SCALE, Blend: UI_FG_BLENDTYPE); ui[i++] = uiText = new HudAPIv2.HUDMessage(new StringBuilder(MAX_EXPECTED_CHARACTERS_TEXT), uiPosition, Scale: UI_TEXT_SCALE, Blend: UI_FG_BLENDTYPE); ui[i++] = uiTargetColor = new HudAPIv2.BillBoardHUDMessage(MATERIAL_ICON_GENERIC_BLOCK, uiPosition, Color.White, Width: UI_COLORBOX_WIDTH, Height: UI_COLORBOX_HEIGHT, Blend: UI_FG_BLENDTYPE); ui[i++] = uiPaintColor = new HudAPIv2.BillBoardHUDMessage(MATERIAL_ICON_PAINT_AMMO, uiPosition, Color.White, Width: UI_COLORBOX_WIDTH, Height: UI_COLORBOX_HEIGHT, Blend: UI_FG_BLENDTYPE); ui[i++] = uiProgressBarBg = new HudAPIv2.BillBoardHUDMessage(Main.PaletteHUD.MATERIAL_PALETTE_BACKGROUND, uiPosition, UI_PROGRESSBAR_BG_COLOR, Width: UI_PROGRESSBAR_WIDTH, Height: UI_PROGRESSBAR_HEIGHT, Blend: UI_BG_BLENDTYPE); ui[i++] = uiProgressBar = new HudAPIv2.BillBoardHUDMessage(Main.PaletteHUD.MATERIAL_PALETTE_BACKGROUND, uiPosition, UI_PROGRESSBAR_COLOR, Width: UI_PROGRESSBAR_WIDTH, Height: UI_PROGRESSBAR_HEIGHT, Blend: UI_FG_BLENDTYPE); UpdateUISettings(); } bool targetCharacter = (Main.Palette.ColorPickMode && Main.LocalToolHandler.AimedPlayer != null); bool visible = (!MyAPIGateway.Gui.IsCursorVisible && Main.Palette.LocalInfo != null && (targetCharacter || Main.LocalToolHandler.AimedBlock != null)); SetGUIVisible(visible); if (!visible) { return; } PaintMaterial targetMaterial; PaintMaterial paint = Main.Palette.GetLocalPaintMaterial(); int ammo = (Main.LocalToolHandler.LocalTool != null ? Main.LocalToolHandler.LocalTool.Ammo : 0); StringBuilder title = uiTitle.Message.Clear().Append("<color=220,244,252>"); float progress = 0f; if (targetCharacter) { uiTargetColor.Material = MATERIAL_ICON_GENERIC_CHARACTER; targetMaterial = Main.LocalToolHandler.AimedPlayersPaint; uiTargetColor.BillBoardColor = (targetMaterial.ColorMask.HasValue ? Utils.ColorMaskToRGB(targetMaterial.ColorMask.Value) : Color.Gray); title.AppendLimitedChars(Main.LocalToolHandler.AimedPlayer.DisplayName, GUI_TITLE_MAX_CHARS); } else { uiTargetColor.Material = MATERIAL_ICON_GENERIC_BLOCK; IMySlimBlock block = Main.LocalToolHandler.AimedBlock; targetMaterial = new PaintMaterial(block.ColorMaskHSV, block.SkinSubtypeId); uiTargetColor.BillBoardColor = Utils.ColorMaskToRGB(targetMaterial.ColorMask.Value); if (paint.ColorMask.HasValue) { progress = Utils.ColorScalar(targetMaterial.ColorMask.Value, paint.ColorMask.Value); } else { progress = 1f; } progress *= 0.75f; if (paint.Skin.HasValue && targetMaterial.Skin == paint.Skin.Value) { progress += 0.25f; } progress = MathHelper.Clamp(progress, 0, 1f); MyCubeBlockDefinition selectedDef = (MyCubeBlockDefinition)block.BlockDefinition; title.AppendLimitedChars(selectedDef.DisplayNameText, GUI_TITLE_MAX_CHARS); } uiPaintColor.BillBoardColor = (paint.ColorMask.HasValue ? Utils.ColorMaskToRGB(paint.ColorMask.Value) : Color.Gray); float height = UI_PROGRESSBAR_HEIGHT * progress; uiProgressBar.Height = height; uiProgressBar.Offset = new Vector2D(uiProgressBar.Width * 0.5, -UI_PROGRESSBAR_HEIGHT + uiProgressBar.Height * 0.5) + uiProgressBarPosition; StringBuilder text = uiText.Message; text.Clear().Append(blockInfoStatus[0]); text.Append('\n'); text.Append('\n'); { text.Append("<color=220,244,252>"); if (Main.Palette.ColorPickMode && Main.LocalToolHandler.AimedPlayer != null) { text.Append("Engineer's selected paint:"); } else { text.Append("Block's material:"); } text.Append('\n').Append(" HSV: "); if (targetMaterial.ColorMask.HasValue) { if (Main.Palette.IsColorMaskInPalette(targetMaterial.ColorMask.Value)) { text.Append("<color=55,255,55>"); } else { text.Append("<color=255,200,25>"); } text.Append(Utils.ColorMaskToString(targetMaterial.ColorMask.Value)); } else { text.Append("(N/A)"); } text.Append('\n'); text.Append("<color=white> Skin: "); if (targetMaterial.Skin.HasValue) { SkinInfo targetSkin = Main.Palette.GetSkinInfo(targetMaterial.Skin.Value); if (targetSkin != null) { if (!targetSkin.LocallyOwned) { text.Append("<color=red>"); } else if (targetSkin.SubtypeId == MyStringHash.NullOrEmpty) { text.Append("<color=gray>"); } text.Append(targetSkin.Name); } else { text.Append("<color=gray>").Append(targetMaterial.Skin.Value.ToString()).Append(" <color=red>(uninstalled)"); } } else { text.Append("(N/A)"); } text.Append('\n'); } text.Append('\n'); { text.Append("<color=220,244,252>"); if (Main.Palette.ColorPickMode) { text.Append("Replace slot: ").Append(Main.Palette.LocalInfo.SelectedColorSlot + 1); } else { text.Append("Paint: "); if (Main.IgnoreAmmoConsumption) { text.Append("Inf."); } else { text.Append(ammo); } } text.Append('\n'); } { text.Append(" "); if (paint.ColorMask.HasValue) { text.Append("<color=white>HSV: ").Append(Utils.ColorMaskToString(paint.ColorMask.Value)).Append('\n'); } else { text.Append('\n'); } } { if (paint.Skin.HasValue) { text.Append(" <color=white>Skin: "); SkinInfo skin = Main.Palette.GetSkinInfo(paint.Skin.Value); if (skin != null) { if (skin.SubtypeId == MyStringHash.NullOrEmpty) { text.Append("<color=gray>"); } text.Append(skin.Name); } else { text.Append("<color=gray>").Append(paint.Skin.Value.ToString()).Append(" <color=red>(uninstalled)"); } } text.Append('\n'); } text.Append("<color=white>"); if (blockInfoStatus[1] != null) { text.Append('\n').Append(blockInfoStatus[1]); } if (blockInfoStatus[2] != null) { text.Append('\n').Append(blockInfoStatus[2]); } }