コード例 #1
0
 public ControlWithDescription(StringBuilder boundButtons, StringBuilder description, MyFontEnum leftFont = MyFontEnum.Red, MyFontEnum rightFont = MyFontEnum.White)
 {
     BoundButtons = new StringBuilder(boundButtons.Length).AppendStringBuilder(boundButtons);
     Description = new StringBuilder(description.Length).AppendStringBuilder(description);
     LeftFont = leftFont;
     RightFont = rightFont;
 }
コード例 #2
0
        // admin deletearea x y z radius
        public override bool HandleCommand(ulong userId, string[] words)
        {
            if (words.Length != 3)
            {
                Communication.SendPrivateInformation(userId, GetHelp());
                return(true);
            }

            string     colour = words[0];
            MyFontEnum font   = MyFontEnum.White;

            if (!Enum.TryParse <MyFontEnum>(colour, out font))
            {
                Communication.SendPrivateInformation(userId, string.Format("Invalid colour value entered.  {0} is nto a valid value.  Please enter one of the following: {1}", colour, GetFontList()));
                return(true);
            }

            int timeInSeconds = 2;

            if (!int.TryParse(words[1], out timeInSeconds) || timeInSeconds < 1)
            {
                Communication.SendPrivateInformation(userId, string.Format("Invalid time value entered.  {0} is not a valid value.  Please enter a value above 0"));
                return(true);
            }

            string message = string.Join(" ", words.Skip(2).ToArray());

            Communication.Notification(0, font, (timeInSeconds * 1000), message);
            return(true);
        }
コード例 #3
0
 public MyRichLabelText()
 {
     m_text  = new StringBuilder(512);
     m_font  = MyFontEnum.Blue;
     m_scale = 0;
     m_color = Vector4.Zero;
 }
コード例 #4
0
 public MyRichLabelText()
 {
     m_text = new StringBuilder(512);
     m_font = MyFontEnum.Blue;
     m_scale = 0;
     m_color = Vector4.Zero;
 }
コード例 #5
0
        void IMyUtilities.ShowNotification(string message, int disappearTimeMs, MyFontEnum font)
        {
            var not = new MyHudNotification(MyCommonTexts.CustomText, disappearTimeMs, font);

            not.SetTextFormatArguments(message);
            MyHud.Notifications.Add(not);
        }
コード例 #6
0
 public ControlWithDescription(StringBuilder boundButtons, StringBuilder description, MyFontEnum leftFont = MyFontEnum.Red, MyFontEnum rightFont = MyFontEnum.White)
 {
     BoundButtons = new StringBuilder(boundButtons.Length).AppendStringBuilder(boundButtons);
     Description  = new StringBuilder(description.Length).AppendStringBuilder(description);
     LeftFont     = leftFont;
     RightFont    = rightFont;
 }
コード例 #7
0
        internal static int ComputeNumCharsThatFit(MyFontEnum font, StringBuilder text, float scale, float maxTextWidth)
        {
            float fixedScale     = scale * m_safeScreenScale;
            float screenMaxWidth = GetScreenSizeFromNormalizedSize(new Vector2(maxTextWidth, 0f)).X;

            return(m_fontsById[(int)font].ComputeCharsThatFit(text, fixedScale, screenMaxWidth));
        }
コード例 #8
0
        private void RefreshInternals()
        {
            if (HasHighlight)
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureHighlight;
                m_selectedItemFont = m_styleDef.ItemFontHighlight;
            }
            else
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureNormal;
                m_selectedItemFont = m_styleDef.ItemFontNormal;
            }
            MinSize = BackgroundTexture.MinSizeGui;
            MaxSize = BackgroundTexture.MaxSizeGui;

            m_scrollbarTexture = (HasHighlight)
                ? MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB_HIGHLIGHT
                : MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB;

            m_selectedItemArea.Position = m_styleDef.SelectedItemOffset;
            m_selectedItemArea.Size = new Vector2(Size.X - (m_scrollbarTexture.MinSizeGui.X + m_styleDef.ScrollbarMargin.HorizontalSum + m_styleDef.SelectedItemOffset.X), ITEM_HEIGHT);

            var openedArea = GetOpenedArea();
            m_openedArea.Position = openedArea.LeftTop;
            m_openedArea.Size = openedArea.Size;

            m_openedItemArea.Position = m_openedArea.Position + new Vector2(m_styleDef.SelectedItemOffset.X, m_styleDef.DropDownTexture.LeftTop.SizeGui.Y);
            m_openedItemArea.Size = new Vector2(m_selectedItemArea.Size.X,
                (m_showScrollBar ? m_openAreaItemsCount : m_items.Count) * m_selectedItemArea.Size.Y);

            m_textScaleWithLanguage = m_styleDef.TextScale * MyGuiManager.LanguageTextScale;
        }
コード例 #9
0
ファイル: MyToolTips.cs プロジェクト: fluxit/SpaceEngineers
 public void AddToolTip(String toolTip,
     float textScale = MyGuiConstants.TOOL_TIP_TEXT_SCALE,
     MyFontEnum font = MyFontEnum.Blue)
 {
     if (toolTip != null)
         ToolTips.Add(new MyColoredText(toolTip, Color.White, font: font, textScale: textScale));
 }
コード例 #10
0
        public int AllocateMarkerStyle(MyFontEnum font, MyHudTexturesEnum directionIcon, MyHudTexturesEnum targetIcon, Color color)
        {
            int newHandle = m_markerStyles.Count;

            m_markerStyles.Add(new MyMarkerStyle(font, directionIcon, targetIcon, color));
            return(newHandle);
        }
コード例 #11
0
        //  Draws string (string builder) at specified position
        //  normalizedPosition -> X and Y are within interval <0..1>
        //  scale -> scale for original texture, it's not in pixel/texels, but multiply of original size. E.g. 1 means unchanged size, 2 means double size. Scale is uniform, preserves aspect ratio.
        //  RETURN: Method returns size of the string in normalized coordinates.
        public static void DrawString(
            MyFontEnum font,
            StringBuilder text,
            Vector2 normalizedCoord,
            float scale,
            Color?colorMask = null,
            MyGuiDrawAlignEnum drawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            bool fullscreen    = false,
            float maxTextWidth = float.PositiveInfinity)
        {
            var size = MeasureString(font, text, scale);

            size.X = Math.Min(maxTextWidth, size.X);
            var     topLeft        = MyUtils.GetCoordTopLeftFromAligned(normalizedCoord, size, drawAlign);
            Vector2 screenCoord    = GetScreenCoordinateFromNormalizedCoordinate(topLeft, fullscreen);
            float   screenScale    = scale * m_safeScreenScale;
            float   screenMaxWidth = GetScreenSizeFromNormalizedSize(new Vector2(maxTextWidth, 0f)).X;

            VRageRender.MyRenderProxy.DrawString(
                (int)font,
                screenCoord,
                colorMask ?? new Color(MyGuiConstants.LABEL_TEXT_COLOR),
                text,
                screenScale,
                screenMaxWidth);
        }
コード例 #12
0
 public void Init(string text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text.Append(text);
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
コード例 #13
0
 public MyRichLabelText(StringBuilder text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text = text;
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
コード例 #14
0
        public static Vector2 MeasureString(MyFontEnum font, StringBuilder text, float scale)
        {
            //  Fix the scale for screen resolution
            float   fixedScale         = scale * m_safeScreenScale;
            Vector2 sizeInPixelsScaled = m_fontsById[(int)font].MeasureString(text, fixedScale);

            return(GetNormalizedSizeFromScreenSize(sizeInPixelsScaled));
        }
コード例 #15
0
        public static float GetFontHeight(MyFontEnum font, float scale)
        {
            //  Fix the scale for screen resolution
            float   fixedScale         = scale * m_safeScreenScale * MyRenderGuiConstants.FONT_SCALE;
            Vector2 sizeInPixelsScaled = new Vector2(0.0f, fixedScale * m_fontsById[(int)font].LineHeight);

            return(GetNormalizedSizeFromScreenSize(sizeInPixelsScaled).Y);
        }
コード例 #16
0
 public MyRichLabelText(StringBuilder text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text  = text;
     m_font  = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
コード例 #17
0
 public void Init(string text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text.Append(text);
     m_font  = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
コード例 #18
0
        public override void deserialize(VRage.ByteStream stream)
        {
            base.deserialize(stream);

            NotificationText = stream.getString();
            Time             = stream.getUShort();
            Font             = (MyFontEnum)stream.getUShort();
        }
コード例 #19
0
 MyGuiControlLabel MakeLabel(float scale, MyFontEnum font)
 {
     return(new MyGuiControlLabel(
                text: String.Empty,
                colorMask: ColorMask,
                textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * scale,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                font: font));
 }
コード例 #20
0
 public void AddToolTip(String toolTip,
                        float textScale = MyGuiConstants.TOOL_TIP_TEXT_SCALE,
                        MyFontEnum font = MyFontEnum.Blue)
 {
     if (toolTip != null)
     {
         ToolTips.Add(new MyColoredText(toolTip, Color.White, font: font, textScale: textScale));
     }
 }
コード例 #21
0
 public MyMarkerStyle(MyFontEnum font, MyHudTexturesEnum textureDirectionIndicator, MyHudTexturesEnum textureTarget, Color color, float textureTargetRotationSpeed = 0f, float textureTargetScale = 1f)
 {
     Font = font;
     TextureDirectionIndicator = textureDirectionIndicator;
     TextureTarget             = textureTarget;
     this.Color = color;
     TextureTargetRotationSpeed = textureTargetRotationSpeed;
     TextureTargetScale         = textureTargetScale;
 }
コード例 #22
0
 public ControlWithDescription(MyStringId control)
 {
     MyControl c = MyInput.Static.GetGameControl(control);
     BoundButtons = null;
     c.AppendBoundButtonNames(ref BoundButtons, unassignedText: MyInput.Static.GetUnassignedName());
     Description = MyTexts.Get(c.GetControlDescription() ?? c.GetControlName());
     LeftFont = MyFontEnum.Red;
     RightFont = MyFontEnum.White;
 }
コード例 #23
0
            public ControlWithDescription(MyStringId control)
            {
                MyControl c = MyInput.Static.GetGameControl(control);

                BoundButtons = null;
                c.AppendBoundButtonNames(ref BoundButtons, unassignedText: MyInput.Static.GetUnassignedName());
                Description = MyTexts.Get(c.GetControlDescription() ?? c.GetControlName());
                LeftFont    = MyFontEnum.Red;
                RightFont   = MyFontEnum.White;
            }
コード例 #24
0
 public MyHudNotificationDebug(string text,
                               int disapearTimeMs           = 2500,
                               MyFontEnum font              = MyFontEnum.White,
                               MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                               int priority = 0,
                               MyNotificationLevel level = MyNotificationLevel.Debug) :
     base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
コード例 #25
0
 public MyHudMissingComponentNotification(MyStringId text,
                                          int disapearTimeMs           = 2500,
                                          MyFontEnum font              = MyFontEnum.White,
                                          MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                          int priority = 0,
                                          MyNotificationLevel level = MyNotificationLevel.Normal) :
     base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
コード例 #26
0
        public void ShowMessage(string sender, string messageText, MyFontEnum font = MyFontEnum.Blue)
        {
            MessagesQueue.Enqueue(new Tuple <string, string, MyFontEnum>(sender, messageText, font));

            if (MessagesQueue.Count > MAX_MESSAGES_IN_CHAT)
            {
                MessagesQueue.Dequeue();
            }

            UpdateTimestamp();
        }
コード例 #27
0
 public void Add(MyDefinitionId id, double val1, double val2, MyFontEnum font)
 {
     var control = new ComponentControl(id);
     control.Size            = new Vector2(Size.X - m_padding.HorizontalSum, control.Size.Y);
     m_currentOffsetFromTop += control.Size.Y;
     control.Position        = -0.5f * Size + new Vector2(m_padding.Left, m_currentOffsetFromTop);
     control.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     control.ValuesFont      = font;
     control.SetValues(val1, val2);
     Elements.Add(control);
 }
コード例 #28
0
 public void notifyPlayers(String msg, List <long> playerIDs, MyFontEnum color)
 {
     m_MailMan.send(new NotificationResponse()
     {
         NotificationText = msg,
         Time             = Constants.NotificationMillis,
         Font             = color,
         Destination      = playerIDs,
         DestType         = BaseResponse.DEST_TYPE.PLAYER
     });
 }
コード例 #29
0
        //  IMPORTANT: This class isn't initialized by constructor, but by Start() because it's supposed to be used in memory pool
        public MyHudText Start(MyFontEnum font, Vector2 position, Color color, float scale, MyGuiDrawAlignEnum alignement)
        {
            Font       = font;
            Position   = position;
            Color      = color;
            Scale      = scale;
            Alignement = alignement;

            m_text.Clear();
            return(this);
        }
コード例 #30
0
 public void Add(MyDefinitionId id, double val1, double val2, MyFontEnum font)
 {
     var control = new ComponentControl(id);
     control.Size            = new Vector2(Size.X - m_padding.HorizontalSum, control.Size.Y);
     m_currentOffsetFromTop += control.Size.Y;
     control.Position        = -0.5f * Size + new Vector2(m_padding.Left, m_currentOffsetFromTop);
     control.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     control.ValuesFont      = font;
     control.SetValues(val1, val2);
     Elements.Add(control);
 }
コード例 #31
0
 MyGuiControlSlider MakeSlider(MyFontEnum font, byte defaultVal)
 {
     return(new MyGuiControlSlider(
                position: Vector2.Zero,
                width: 121f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                minValue: 0,
                maxValue: 255,
                color: ColorMask,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                labelFont: font,
                defaultValue: (int)defaultVal));
 }
コード例 #32
0
        public MyGuiControlMultilineText(
            Vector2?position                = null,
            Vector2?size                    = null,
            Vector4?backgroundColor         = null,
            MyFontEnum font                 = MyFontEnum.Blue,
            float textScale                 = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlign    = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            StringBuilder contents          = null,
            bool drawScrollbar              = true,
            MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            bool selectable                 = false)
            : base(position: position,
                   size: size,
                   colorMask: backgroundColor,
                   toolTip: null)
        {
            Font            = font;
            TextScale       = textScale;
            m_drawScrollbar = drawScrollbar;
            TextColor       = new Color(Vector4.One);
            TextBoxAlign    = textBoxAlign;
            m_selectable    = selectable;

            m_scrollbar     = new MyVScrollbar(this);
            m_scrollbarSize = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(Font, m_lineHeightMeasure, TextScaleWithLanguage).Y;

            m_label           = new MyRichLabel(ComputeRichLabelWidth(), minLineHeight);
            m_label.TextAlign = textAlign;
            m_text            = new StringBuilder();
            m_selection       = new MyGuiControlMultilineSelection();

            if (contents != null && contents.Length > 0)
            {
                Text = contents;
            }

            m_keys = new MyMultilineKeyTimeController[11];
            m_keys[(int)MyMultilineTextKeys.UP]    = new MyMultilineKeyTimeController(Keys.Up);
            m_keys[(int)MyMultilineTextKeys.DOWN]  = new MyMultilineKeyTimeController(Keys.Down);
            m_keys[(int)MyMultilineTextKeys.LEFT]  = new MyMultilineKeyTimeController(Keys.Left);
            m_keys[(int)MyMultilineTextKeys.RIGHT] = new MyMultilineKeyTimeController(Keys.Right);

            m_keys[(int)MyMultilineTextKeys.C]      = new MyMultilineKeyTimeController(Keys.C);
            m_keys[(int)MyMultilineTextKeys.A]      = new MyMultilineKeyTimeController(Keys.A);
            m_keys[(int)MyMultilineTextKeys.V]      = new MyMultilineKeyTimeController(Keys.V);
            m_keys[(int)MyMultilineTextKeys.X]      = new MyMultilineKeyTimeController(Keys.X);
            m_keys[(int)MyMultilineTextKeys.HOME]   = new MyMultilineKeyTimeController(Keys.Home);
            m_keys[(int)MyMultilineTextKeys.END]    = new MyMultilineKeyTimeController(Keys.End);
            m_keys[(int)MyMultilineTextKeys.DELETE] = new MyMultilineKeyTimeController(Keys.Delete);
        }
コード例 #33
0
        public void Append(string text, MyFontEnum font, float scale, Vector4 color)
        {
            string[] paragraphs = text.Split(m_lineSeparators, StringSplitOptions.None);

            for (int i = 0; i < paragraphs.Length; i++)
            {
                AppendParagraph(paragraphs[i], font, scale, color);
                if (i < paragraphs.Length - 1)
                {
                    AppendLine();
                }
            }
        }
コード例 #34
0
ファイル: Logger.cs プロジェクト: borrel/Autopilot
        /// <summary>
        /// For a safe way to display a message as a notification, not conditional. Logs a warning iff message cannot be displayed.
        /// </summary>
        /// <param name="message">the notification message</param>
        /// <param name="disappearTimeMs">time on screen, in milliseconds</param>
        /// <param name="level">severity level</param>
        /// <returns>true iff the message was displayed</returns>
        public void notify(string message, int disappearTimeMs = 2000, severity level = severity.TRACE)
        {
            MyFontEnum font = fontForSeverity(level);

            if (MyAPIGateway.Utilities != null)
            {
                MyAPIGateway.Utilities.ShowNotification(message, disappearTimeMs, font);
            }
            else
            {
                log(severity.WARNING, "ShowNotificationDebug()", "MyAPIGateway.Utilities == null");
            }
        }
コード例 #35
0
        public MyGuiControlMultilineText(
            Vector2?position                        = null,
            Vector2?size                            = null,
            Vector4?backgroundColor                 = null,
            MyFontEnum font                         = MyFontEnum.Blue,
            float textScale                         = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlign            = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            StringBuilder contents                  = null,
            bool drawScrollbar                      = true,
            MyGuiDrawAlignEnum textBoxAlign         = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            int?visibleLinesCount                   = null,
            bool selectable                         = false,
            bool showTextShadow                     = false,
            MyGuiCompositeTexture backgroundTexture = null,
            MyGuiBorderThickness?textPadding        = null
            )
            : base(position: position,
                   size: size,
                   colorMask: backgroundColor,
                   toolTip: null,
                   backgroundTexture: backgroundTexture)
        {
            Font            = font;
            TextScale       = textScale;
            m_drawScrollbar = drawScrollbar;
            TextColor       = new Color(Vector4.One);
            TextBoxAlign    = textBoxAlign;
            m_selectable    = selectable;

            m_textPadding   = textPadding ?? new MyGuiBorderThickness(0, 0, 0, 0);
            m_scrollbar     = new MyVScrollbar(this);
            m_scrollbarSize = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(Font, m_lineHeightMeasure, TextScaleWithLanguage).Y;

            m_label = new MyRichLabel(this, ComputeRichLabelWidth(), minLineHeight, visibleLinesCount)
            {
                ShowTextShadow = showTextShadow
            };
            m_label.AdjustingScissorRectangle += AdjustScissorRectangleLabel;
            m_label.TextAlign = textAlign;
            m_text            = new StringBuilder();
            m_selection       = new MyGuiControlMultilineSelection();

            if (contents != null && contents.Length > 0)
            {
                Text = contents;
            }

            m_keyThrottler = new MyKeyThrottler();
        }
コード例 #36
0
        private void ShowNotification(string text, MyFontEnum color)
        {
            if (mNotify == null)
            {
                mNotify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
            }
            else
            {
                mNotify.Text = text;
                mNotify.ResetAliveTime();
            }

            mNotify.Show();
        }
コード例 #37
0
 public MyHudNameValueData(int itemCount,
     MyFontEnum defaultNameFont = MyFontEnum.Blue,
     MyFontEnum defaultValueFont = MyFontEnum.White,
     float lineSpacing      = MyGuiConstants.HUD_LINE_SPACING,
     bool showBackgroundFog = false)
 {
     DefaultNameFont   = defaultNameFont;
     DefaultValueFont  = defaultValueFont;
     LineSpacing       = lineSpacing;
     m_count           = itemCount;
     m_items           = new List<Data>(itemCount);
     ShowBackgroundFog = showBackgroundFog;
     EnsureItemsExist();
 }
コード例 #38
0
 public MyHudNameValueData(int itemCount,
                           MyFontEnum defaultNameFont  = MyFontEnum.Blue,
                           MyFontEnum defaultValueFont = MyFontEnum.White,
                           float lineSpacing           = MyGuiConstants.HUD_LINE_SPACING,
                           bool showBackgroundFog      = false)
 {
     DefaultNameFont   = defaultNameFont;
     DefaultValueFont  = defaultValueFont;
     LineSpacing       = lineSpacing;
     m_count           = itemCount;
     m_items           = new List <Data>(itemCount);
     ShowBackgroundFog = showBackgroundFog;
     EnsureItemsExist();
 }
コード例 #39
0
 public MyGuiControlMultilineEditableText(
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     MyFontEnum font = MyFontEnum.Blue,
     float textScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
     StringBuilder contents = null,
     bool drawScrollbar = true,
     MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
     : base(position, size, backgroundColor, font, textScale, textAlign, contents, drawScrollbar, textBoxAlign, true)
 {
     m_fontHeight = MyGuiManager.GetFontHeight(Font, TextScaleWithLanguage);
     this.AllowFocusingElements = false;
 }
コード例 #40
0
 public MyColoredText(
     String text,
     Color? normalColor    = null,
     Color? highlightColor = null,
     MyFontEnum font       = MyFontEnum.White,
     float textScale       = MyGuiConstants.COLORED_TEXT_DEFAULT_TEXT_SCALE,
     Vector2? offset       = null)
 {
     Text           = new StringBuilder(text.Length).Append(text);
     NormalColor    = normalColor ?? MyGuiConstants.COLORED_TEXT_DEFAULT_COLOR;
     HighlightColor = highlightColor ?? MyGuiConstants.COLORED_TEXT_DEFAULT_HIGHLIGHT_COLOR;
     Font           = font;
     Scale          = textScale;
     Offset         = offset ?? Vector2.Zero;
 }
コード例 #41
0
 public MyHudControlChat(
     MyHudChat chat,
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     MyFontEnum font = MyFontEnum.White,
     float textScale = 0.7f,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     StringBuilder contents = null,
     bool drawScrollbar = false,
     MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     bool selectable = false)
     : base (position, size, backgroundColor, font, textScale, textAlign, contents, drawScrollbar, textBoxAlign, selectable)
 {
     m_forceUpdate = true;
     m_chat = chat;
     OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     base.VisibleChanged += MyHudControlChat_VisibleChanged;
 }
コード例 #42
0
        public MyHudNotificationBase(
            int disapearTimeMs,
            MyFontEnum font              = MyFontEnum.White,
            MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            int priority                 = 0,
            MyNotificationLevel level    = MyNotificationLevel.Normal)
        {
            Font = font;
            Priority = priority;
            m_isTextDirty = true;

            m_actualTextAlign = textAlign;
            AssignFormatArgs(null);
            Level = level;

            // timing:
            m_lifespanMs = disapearTimeMs;
            m_aliveTime = 0;
            RefreshAlive();
        }
コード例 #43
0
        private void DrawNetgraphScaleForAverageScale(Vector2 position, int optimalLengthOfBarInPx, float maximumValueOfScale, int stepCount, bool alignToRight = true, float textScale = 0.7f, MyFontEnum fontType = MyFontEnum.White)
        {
            int step = optimalLengthOfBarInPx / stepCount;
            float stepValue = (maximumValueOfScale) / stepCount;
            float totalStepValue = 0;
            Vector2 vecStep = new Vector2(0, step);
            vecStep = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(vecStep);
            vecStep.X = 0;

            MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            if (alignToRight)
                align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_helperSB.Clear();
            for (int i = 0; i < stepCount; i++)
            {
                position -= vecStep;
                totalStepValue += stepValue;
                m_helperSB.Clear();
                m_helperSB.Append(totalStepValue);
                MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
            }

            m_helperSB.Clear().Append("[kB]");
            position.Y -= 0.02f;
            MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
        }
コード例 #44
0
        private void RefreshInternals()
        {
            if (HasHighlight)
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureHighlight;
                m_selectedItemFont = m_styleDef.ItemFontHighlight;
            }
            else
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureNormal;
                m_selectedItemFont = m_styleDef.ItemFontNormal;
            }
            MinSize = BackgroundTexture.MinSizeGui;
            MaxSize = BackgroundTexture.MaxSizeGui;

            m_scrollbarTexture = (HasHighlight)
                ? MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB_HIGHLIGHT
                : MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB;

            m_selectedItemArea.Position = m_styleDef.SelectedItemOffset;
            m_selectedItemArea.Size = new Vector2(Size.X - (m_scrollbarTexture.MinSizeGui.X + m_styleDef.ScrollbarMargin.HorizontalSum + m_styleDef.SelectedItemOffset.X), ITEM_HEIGHT);

            var openedArea = GetOpenedArea();
            m_openedArea.Position = openedArea.LeftTop;
            m_openedArea.Size = openedArea.Size;

            m_openedItemArea.Position = m_openedArea.Position + new Vector2(m_styleDef.SelectedItemOffset.X, m_styleDef.DropDownTexture.LeftTop.SizeGui.Y);
            m_openedItemArea.Size = new Vector2(m_selectedItemArea.Size.X,
                (m_showScrollBar ? m_openAreaItemsCount : m_items.Count) * m_selectedItemArea.Size.Y);

            m_textScaleWithLanguage = m_styleDef.TextScale * MyGuiManager.LanguageTextScale;
        }
コード例 #45
0
 //same as above, but designed to have realtime updates of text inside. So no copy of text :-)
 public Item(ref StringBuilder text, String toolTip = null, string icon = null, object userData = null, MyFontEnum? fontOverride = null)
 {
     Text = text;
     ToolTip = (toolTip != null) ? new MyToolTips(toolTip) : null;
     Icon = icon;
     UserData = userData;
     FontOverride = fontOverride;
     Visible = true;
 }
コード例 #46
0
 public MyHudNotificationDebug(string text,
     int disapearTimeMs           = 2500,
     MyFontEnum font              = MyFontEnum.White,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
     int priority                 = 0,
     MyNotificationLevel level    =  MyNotificationLevel.Debug):
     base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
コード例 #47
0
 public MyHudMissingComponentNotification(MyStringId text,
     int disapearTimeMs           = 2500,
     MyFontEnum font              = MyFontEnum.White,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
     int priority                 = 0,
     MyNotificationLevel level    = MyNotificationLevel.Normal) :
     base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
コード例 #48
0
ファイル: Core_Server.cs プロジェクト: Devlah/GardenConquest
 public void notifyPlayers(String msg, List<long> playerIDs, MyFontEnum color)
 {
     m_MailMan.send(new NotificationResponse() {
         NotificationText = msg,
         Time = Constants.NotificationMillis,
         Font = color,
         Destination = playerIDs,
         DestType = BaseResponse.DEST_TYPE.PLAYER
     });
 }
コード例 #49
0
 MyGuiControlLabel MakeLabel(float scale, MyFontEnum font)
 {
     return new MyGuiControlLabel(
         text: String.Empty,
         colorMask: ColorMask,
         textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * scale,
         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
         font: font);
 }
コード例 #50
0
        private void DrawNetgraphScaleForPacketScale(Vector2 position, int optimalLengthOfBarInPx, float optimalDataSizeOfBarInBytes, int stepCount, StringBuilder unitForScale, bool showIntervals, bool alignToRight = true, float textScale = 0.7f, MyFontEnum fontType = MyFontEnum.White)
        {
            int step = optimalLengthOfBarInPx / stepCount;
            float stepValue = (float)(Math.Truncate((optimalDataSizeOfBarInBytes / stepCount) * 100.0) * 0.01f);
            float totalStepValue = 0;
            Vector2 vecStep = new Vector2(0, step);
            vecStep = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(vecStep);
            vecStep.X = 0;

            MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            if (alignToRight)
                align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_helperSB.Clear();
            for (int i = 0; i < stepCount; i++)
            {
                Vector2 oldPosition = position;
                position -= vecStep;

                // small intervals next to the scale
                //if (showIntervals)
                //{
                //float intervalOffset = vecStep.Y / MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT;
                //for (int j = 1; j <= MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT; j++)
                //{
                //    Vector2 intervalMarkPosition = new Vector2(oldPosition.X + 0.005f, oldPosition.Y - j * intervalOffset);
                //    bool isLast = j == MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT;
                //    Vector2 intervalMarkEndPosition;
                //    Color intervalColor;
                //    if (isLast)
                //    {
                //        intervalMarkEndPosition = new Vector2(0.008f, 0.002f);
                //        intervalColor = MyGuiConstants.NETGRAPH_PACKET_SCALE_INTERVAL_POINT_COLOR;
                //    }
                //    else
                //    {
                //        intervalMarkEndPosition = new Vector2(0.005f, 0.002f);
                //        intervalColor = MyGuiConstants.NETGRAPH_PACKET_SCALE_SMALL_INTERVAL_COLOR;
                //    }
                //    MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, intervalMarkPosition, intervalMarkEndPosition, MyGuiConstants.NETGRAPH_PACKET_SCALE_SMALL_INTERVAL_COLOR, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                //}
                //}

                totalStepValue += stepValue;
                m_helperSB.Clear();
                m_helperSB.Append(totalStepValue);
                MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
            }

            if (unitForScale.Length != 0)
            {
                position.Y -= 0.02f;
                MyGuiManager.DrawString(fontType, unitForScale, position, textScale, null, align);
            }
        }
コード例 #51
0
 public static void Notification(ulong steamId, MyFontEnum color, int timeInSeconds, string message)
 {
     SendClientMessage(steamId, string.Format("/notification {0} {1} {2}", color, timeInSeconds, message));
 }
コード例 #52
0
        private void RefreshInternals()
        {
            ColorMask = m_styleDef.BackgroundColor;
            if (HasHighlight || Checked)
            {
                BackgroundTexture = m_styleDef.HighlightTexture;
                TextFont          = m_styleDef.HighlightFont;
            }
            else
            {
                BackgroundTexture = m_styleDef.NormalTexture;
                TextFont          = m_styleDef.NormalFont;
            }
            var size = Size;
            if (BackgroundTexture != null)
            {
                MinSize = BackgroundTexture.MinSizeGui;
                MaxSize = BackgroundTexture.MaxSizeGui;
                if (ButtonScale == 1.0f)
                    size = m_styleDef.SizeOverride ?? size;
            }
            else
            {
                MinSize = Vector2.Zero;
                MaxSize = Vector2.PositiveInfinity;
                size = m_styleDef.SizeOverride ?? Vector2.Zero;
            }

            // No size specified, but we have string and font ... probably its a clickable text so let's use that as size.
            if (size == Vector2.Zero && m_drawText != null)
            {
                size = MyGuiManager.MeasureString(TextFont, m_drawText, TextScaleWithLanguage);
            }

            var padding = m_styleDef.Padding;
            m_internalArea.Position = padding.TopLeftOffset;
            m_internalArea.Size = Size - padding.SizeChange;
            Size = size;
        }
コード例 #53
0
		public static void Notification( ulong steamId, MyFontEnum color, int timeInSeconds, string message )
		{
            ServerNotificationItem MessageItem = new ServerNotificationItem( );
                MessageItem.color = color;
                MessageItem.time = timeInSeconds;
                MessageItem.message= message;

            string messageString = MyAPIGateway.Utilities.SerializeToXML( MessageItem );
            byte[ ] data = Encoding.Unicode.GetBytes( messageString );

            if ( steamId != 0 )
                SendDataMessage( steamId, DataMessageType.Notification, data );
            else
                BroadcastDataMessage( DataMessageType.Notification, data );
        }		
コード例 #54
0
 MyGuiControlSlider MakeSlider(MyFontEnum font, byte defaultVal)
 {
     return new MyGuiControlSlider(
         position: Vector2.Zero,
         width: 121f/MyGuiConstants.GUI_OPTIMAL_SIZE.X,
         minValue: 0,
         maxValue: 255,
         color: ColorMask,
         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
         labelFont: font,
         defaultValue: (int)defaultVal);
 }
コード例 #55
0
 public void AppendText(string text, MyFontEnum font, float scale, Vector4 color)
 {
     m_label.Append(text, font, scale, color);
     RecalculateScrollBar();
 }
コード例 #56
0
 /// <summary>
 /// Do not construct directly. Use AddItem on listbox for that.
 /// </summary>
 public Item(StringBuilder text = null, String toolTip = null, string icon = null, object userData = null, MyFontEnum? fontOverride = null)
 {
     Text         = new StringBuilder((text != null) ? text.ToString() : "");
     ToolTip      = (toolTip != null) ? new MyToolTips(toolTip) : null;
     Icon         = icon;
     UserData     = userData;
     FontOverride = fontOverride;
     Visible      = true;
 }
コード例 #57
0
 public MyGuiControlLabel(
     Vector2? position = null,
     Vector2? size = null,
     String text = null,
     Vector4? colorMask = null,
     float textScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
     MyFontEnum font = MyFontEnum.Blue,
     MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)
     : base(position: position,
            size: size,
            colorMask: colorMask,
            isActiveControl: false)
 {
     Name = "Label";
     Font = font;
     if (text != null)
     {
         //  Create COPY of the text (Don't just point to one string builder!!! This was my original mistake!)
         m_text = text;
         TextToDraw = new StringBuilder(text);
     }
     OriginAlign = originAlign;
     TextScale = textScale;
 }
コード例 #58
0
        public MyGuiControlColor(
            StringBuilder text,
            float textScale,
            Vector2 position,
            Color color,
            Color defaultColor,
            bool placeSlidersVertically = false,
            MyFontEnum font = MyFontEnum.Blue)
            : base(position: position,
                   toolTip: null,
                   isActiveControl: false)
        {
            m_color = color;
            m_placeSlidersVertically = placeSlidersVertically;
            m_textLabel = MakeLabel(textScale, font);
            m_textLabel.Text = text.ToString();

            m_RSlider = MakeSlider(font, defaultColor.R);
            m_GSlider = MakeSlider(font, defaultColor.G);
            m_BSlider = MakeSlider(font, defaultColor.B);

            m_RSlider.ValueChanged += delegate(MyGuiControlSlider sender)
            {
                if (m_canChangeColor)
                {
                    m_color.R = (byte)sender.Value;
                    UpdateTexts();
                    if (OnChange != null)
                        OnChange(this);
                }
            };
            m_GSlider.ValueChanged += delegate(MyGuiControlSlider sender)
            {
                if (m_canChangeColor)
                {
                    m_color.G = (byte)sender.Value;
                    UpdateTexts();
                    if (OnChange != null)
                        OnChange(this);
                }
            };
            m_BSlider.ValueChanged += delegate(MyGuiControlSlider sender)
            {
                if (m_canChangeColor)
                {
                    m_color.B = (byte)sender.Value;
                    UpdateTexts();
                    if (OnChange != null)
                        OnChange(this);
                }
            };

            m_RLabel = MakeLabel(textScale, font);
            m_GLabel = MakeLabel(textScale, font);
            m_BLabel = MakeLabel(textScale, font);

            m_RSlider.Value = m_color.R;
            m_GSlider.Value = m_color.G;
            m_BSlider.Value = m_color.B;

            Elements.Add(m_textLabel);

            Elements.Add(m_RSlider);
            Elements.Add(m_GSlider);
            Elements.Add(m_BSlider);

            Elements.Add(m_RLabel);
            Elements.Add(m_GLabel);
            Elements.Add(m_BLabel);

            UpdateTexts();
            RefreshInternals();
            Size = m_minSize;
        }
コード例 #59
0
        public MyGuiControlMultilineText(
            Vector2? position = null,
            Vector2? size = null,
            Vector4? backgroundColor = null,
            MyFontEnum font = MyFontEnum.Blue,
            float textScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            StringBuilder contents = null,
            bool drawScrollbar = true,
            MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            bool selectable = false)
            : base( position: position,
                    size: size,
                    colorMask: backgroundColor,
                    toolTip: null)
        {
            Font = font;
            TextScale = textScale;
            m_drawScrollbar = drawScrollbar;
            TextColor = new Color(Vector4.One);
            TextBoxAlign = textBoxAlign;
            m_selectable = selectable;

            m_scrollbar = new MyVScrollbar(this);
            m_scrollbarSize = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(Font, m_lineHeightMeasure, TextScaleWithLanguage).Y;
            m_label = new MyRichLabel(ComputeRichLabelWidth(), minLineHeight);
            m_label.TextAlign = textAlign;
            m_text = new StringBuilder();
            m_selection = new MyGuiControlMultilineSelection();

            if (contents != null && contents.Length > 0)
                Text = contents;

            m_keys = new MyMultilineKeyTimeController[11];
            m_keys[(int)MyMultilineTextKeys.UP] = new MyMultilineKeyTimeController(Keys.Up);
            m_keys[(int)MyMultilineTextKeys.DOWN] = new MyMultilineKeyTimeController(Keys.Down);
            m_keys[(int)MyMultilineTextKeys.LEFT] = new MyMultilineKeyTimeController(Keys.Left);
            m_keys[(int)MyMultilineTextKeys.RIGHT] = new MyMultilineKeyTimeController(Keys.Right);
            
            m_keys[(int)MyMultilineTextKeys.C] = new MyMultilineKeyTimeController(Keys.C);
            m_keys[(int)MyMultilineTextKeys.A] = new MyMultilineKeyTimeController(Keys.A);
            m_keys[(int)MyMultilineTextKeys.V] = new MyMultilineKeyTimeController(Keys.V);
            m_keys[(int)MyMultilineTextKeys.X] = new MyMultilineKeyTimeController(Keys.X);
            m_keys[(int)MyMultilineTextKeys.HOME] = new MyMultilineKeyTimeController(Keys.Home);
            m_keys[(int)MyMultilineTextKeys.END] = new MyMultilineKeyTimeController(Keys.End);
            m_keys[(int)MyMultilineTextKeys.DELETE] = new MyMultilineKeyTimeController(Keys.Delete);
        }
コード例 #60
0
 public ControlWithDescription(string boundButtons, string description, MyFontEnum leftFont = MyFontEnum.Red, MyFontEnum rightFont = MyFontEnum.White)
     : this(new StringBuilder(boundButtons), new StringBuilder(description), leftFont, rightFont)
 { }