Ejemplo n.º 1
0
        internal static int ComputeNumCharsThatFit(string font, StringBuilder text, float scale, float maxTextWidth)
        {
            float fixedScale     = scale * m_safeScreenScale;
            float screenMaxWidth = GetScreenSizeFromNormalizedSize(new Vector2(maxTextWidth, 0f)).X;

            return(m_fontsById[MyStringHash.Get(font)].ComputeCharsThatFit(text, fixedScale, screenMaxWidth));
        }
Ejemplo n.º 2
0
        /// <summary>Draws string (string builder) at specified position</summary>
        /// <param name="normalizedCoord">and Y are within interval [0,1]></param>
        /// <param name="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.</param>
        /// <param name="useFullClientArea">True uses full client rectangle. False limits to GUI rectangle</param>
        public static void DrawString(
            string font,
            StringBuilder text,
            Vector2 normalizedCoord,
            float scale,
            Color?colorMask = null,
            MyGuiDrawAlignEnum drawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            bool useFullClientArea       = 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, useFullClientArea);
            float   screenScale    = scale * m_safeScreenScale;
            float   screenMaxWidth = GetScreenSizeFromNormalizedSize(new Vector2(maxTextWidth, 0f)).X;

#if DEBUG_TEXT_SIZE
            DebugTextSize(text, ref size);
#endif

            VRageRender.MyRenderProxy.DrawString(
                (int)MyStringHash.Get(font),
                screenCoord,
                colorMask ?? new Color(MyGuiConstants.LABEL_TEXT_COLOR),
                text,
                screenScale,
                screenMaxWidth);
        }
Ejemplo n.º 3
0
        public static float GetFontHeight(string 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[MyStringHash.Get(font)].LineHeight);

            return(GetNormalizedSizeFromScreenSize(sizeInPixelsScaled).Y);
        }
Ejemplo n.º 4
0
        public static Vector2 MeasureString(string font, StringBuilder text, float scale)
        {
            //  Fix the scale for screen resolution
            float   fixedScale         = scale * m_safeScreenScale;
            Vector2 sizeInPixelsScaled = m_fontsById[MyStringHash.Get(font)].MeasureString(text, fixedScale);

            return(GetNormalizedSizeFromScreenSize(sizeInPixelsScaled));
        }
        private void SetPotentialStatChange(string id, float value)
        {
            var hashId = MyStringHash.Get(id);
            MyGuiControlStat statControl;

            if (m_statControls.TryGetValue(hashId, out statControl))
            {
                statControl.PotentialChange = value;
            }
        }
Ejemplo n.º 6
0
        public static void RunScript(string scriptName)
        {
            if (!Sync.IsServer && !MySession.Static.IsUserAdmin(Sync.MyId))
            {
                return;
            }
            var scriptId = MyStringHash.Get(scriptName);

            if (Sync.IsServer)
            {
                Static.RunScriptInternal(scriptId);
            }
            else
            {
                SendScriptRequest(scriptId);
            }
        }
Ejemplo n.º 7
0
        public static void RunScript(string scriptName)
        {
            if (!Sync.IsServer && !MyMultiplayer.Static.IsAdmin(MySteam.UserId))
            {
                return;
            }
            var scriptId = MyStringHash.Get(scriptName);

            if (Sync.IsServer)
            {
                Static.RunScriptInternal(scriptId);
            }
            else
            {
                SendScriptRequest(scriptId);
            }
        }