Пример #1
0
 public void Init()
 {
     if (widget_ == null)
     {
         widget_ = new HudAPIv2.HUDMessage(new StringBuilder(), Origin: location_, Blend: BlendTypeEnum.PostPP);
     }
 }
Пример #2
0
        internal void InitHudMesages(bool bForce = false)
        {
            if (TextAPI == null)
            {
                ModLog.Error("Text HUD API not loaded");
                return;
            }
            if (TextAPI.Heartbeat)
            {
//                ModLog.Info("Have Heartbeat");

                if (hackInterruptedV2 == null || bForce)
                {
//                    ModLog.Info("Creating Interrupted HUD");
                    sbInterruptedMessage = new StringBuilder(SeTextColor + "CONNECTION LOST");
                    hackInterruptedV2    = new HudAPIv2.HUDMessage(sbInterruptedMessage, new Vector2D(-0.5, 0.5));
                    if (hackInterruptedV2 != null)
                    {
                        hackInterruptedV2.Message  = sbInterruptedMessage;
                        hackInterruptedV2.Scale    = 2;
                        hackInterruptedV2.Options  = HudAPIv2.Options.Shadowing;
                        hackInterruptedV2.Options |= HudAPIv2.Options.HideHud;
                        //                        hackInterruptedV2.TimeToLive = 45;
                        hackInterruptedV2.Visible = false;
                    }
                    else
                    {
                        ModLog.Info("Could not create Interrupted HUD");
                    }
                }
                if (hackBarV2 == null || bForce)
                {
//                    ModLog.Info("Creating Hacking HUD");
                    if (sbHackBarMessage == null)
                    {
                        sbHackBarMessage = new StringBuilder("Initial Research Bar");
                    }
                    hackBarV2 = new HudAPIv2.HUDMessage(sbHackBarMessage, new Vector2D(-0.5, 0.5));
                    if (hackBarV2 != null)
                    {
                        hackBarV2.Message  = sbHackBarMessage;
                        hackBarV2.Scale    = 2;
                        hackBarV2.Options  = HudAPIv2.Options.Shadowing;
                        hackBarV2.Options |= HudAPIv2.Options.HideHud;
                        hackBarV2.Visible  = false;
//                        hackBarV2.TimeToLive = 45;
                    }
                    else
                    {
                        ModLog.Info("Could not create Research HUD");
                    }
                }
            }
            else
            {
                ModLog.Info("NO TextHud HEARTBEAT");
            }
        }
Пример #3
0
        void DrawSkinNameText(SkinInfo selectedSkin)
        {
            if (!Main.TextAPI.IsEnabled)
            {
                return;
            }

            PlayerInfo localInfo = Main.Palette.LocalInfo;

            float    scale    = Main.Settings.paletteScale;
            Vector2D labelPos = Main.Settings.paletteScreenPos + new Vector2D(0, 0.06 * 2 * scale); // TODO FIX: needs to move relatively with the scale of the elements below it, but it doesn't...

            if (localInfo.ApplyColor)
            {
                labelPos += new Vector2D(0, 0.08); // this needs fixing too
            }
            const double TextScaleOffset = 1.8;

            if (skinLabel == null)
            {
                skinLabelSB = new StringBuilder(64).Append(selectedSkin.Name);

                skinLabelShadow = new HudAPIv2.HUDMessage(skinLabelSB, labelPos, Scale: TextScaleOffset, HideHud: true, Blend: BlendTypeEnum.PostPP);
                skinLabel       = new HudAPIv2.HUDMessage(skinLabelSB, labelPos, Scale: TextScaleOffset, HideHud: true, Blend: BlendTypeEnum.PostPP);

                skinLabelShadow.InitialColor = Color.Black;
                skinLabel.InitialColor       = Color.White;

                skinLabelUpdate = true;
            }

            if (skinLabelUpdate)
            {
                skinLabelUpdate = false;

                skinLabelSB.Clear().Append(selectedSkin.Name);

                skinLabel.Origin       = labelPos;
                skinLabelShadow.Origin = labelPos;

                skinLabel.Scale       = scale * TextScaleOffset;
                skinLabelShadow.Scale = scale * TextScaleOffset;

                Vector2D textLen = skinLabel.GetTextLength();
                skinLabel.Offset       = new Vector2D(textLen.X * -0.5, 0);                // centered
                skinLabelShadow.Offset = skinLabel.Offset + new Vector2D(0.0015, -0.0015); // centered + small offset
            }

            if (!skinLabelVisible)
            {
                skinLabelVisible        = true;
                skinLabel.Visible       = true;
                skinLabelShadow.Visible = true;
            }

            drawSkinLabel = true;
        }
Пример #4
0
        void textHudCallback()
        {
            StringBuilder sb = new StringBuilder(SeTextColor + "CONNECTION LOST");

            hackInterruptedV2 = new HudAPIv2.HUDMessage(sb, new Vector2D(-0.5, 0.5));

            sb.Clear();
            hackBarV2 = new HudAPIv2.HUDMessage(sb, new Vector2D(-0.5, 0.5));
        }
Пример #5
0
 private void init()
 {
     if (inited || !HudAPI.Heartbeat)
     {
         return;
     }
     HUDPanel = new HudAPIv2.HUDMessage(Display, DefaultOrigin, Blend: BlendTypeEnum.SDR);
     //HUDPanelBackground = new HudAPIv2.BillBoardHUDMessage(MATERIAL_VANILLA_SQUARE, DefaultOrigin, VRageMath.Color.DeepSkyBlue);
     HUDPanel.Scale = 1.4;
     inited         = true;
 }
Пример #6
0
        //		private void SendToHud(HUDTextAPI.HUDMessage hudMessage)
        private void SendToHud(HudAPIv2.HUDMessage hudMessage)
        {
            if (TextAPI.Heartbeat)
// V1			if (hudTextApi.Heartbeat)
            {
//				hudTextApi.Send(hudMessage);
            }
            else
            {
                MyAPIGateway.Utilities.ShowNotification("Error: You need to install the Text HUD API Mod!", 300, MyFontEnum.Red);
            }
        }
Пример #7
0
        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
            });
        }
Пример #8
0
        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
            });
        }
Пример #9
0
        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
            });
        }
Пример #10
0
        void HideText(bool permanent = false)
        {
            if (text != null)
            {
                text.Visible = false;

                if (permanent)
                {
                    text.DeleteMessage();
                    text = null;
                }
            }

            SetUpdateMethods(UpdateFlags.UPDATE_INPUT, false);
        }
Пример #11
0
 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;
 }
Пример #12
0
        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;
                }
            }
        }
Пример #13
0
        void DrawText()
        {
            if (hidden || !Main.TextAPI.IsEnabled)
            {
                return;
            }

            if (text == null)
            {
                text = new HudAPIv2.HUDMessage(new StringBuilder(MyTexts.GetString(Text)), TextPosition, Scale: TextScale, Shadowing: true, Blend: BlendTypeEnum.PostPP);

                Vector2D textSize = text.GetTextLength();
                text.Offset = new Vector2D(-textSize.X, textSize.Y); // pivot top-right
            }

            text.Visible = true;

            // enable input reading for hiding the text
            SetUpdateMethods(UpdateFlags.UPDATE_INPUT, true);
        }
Пример #14
0
            /// <summary>
            /// Updates settings of underlying Text HUD API type.
            /// </summary>
            protected override void Draw()
            {
                if (hudMessage == null)
                {
                    hudMessage = new HudAPIv2.HUDMessage
                    {
                        Blend   = BlendTypeEnum.LDR,
                        Scale   = Scale,
                        Options = HudAPIv2.Options.Fixed,
                        Visible = false,
                    };

                    UpdateMessage();
                }

                if (Visible)
                {
                    hudMessage.Origin = Instance.GetScaledPos(Origin + Offset + alignmentOffset);
                    hudMessage.Draw();
                }
            }
Пример #15
0
        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);
            }
        }
Пример #16
0
        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;
            }
        }
Пример #17
0
        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]);
            }
        }
Пример #18
0
        /// <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;
        }
Пример #19
0
        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;
        }
Пример #20
0
 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;
 }
Пример #21
0
 public void Init()
 {
     lbl_ = new HudAPIv2.HUDMessage(Message: lbl_txt_, Origin: DRAW_POS);
 }