Ejemplo n.º 1
0
    private void CachedLabel()
    {
      string v;


      if (_containsProperty)
      {
        v = GUIPropertyManager.Parse(_labelText) ?? String.Empty;
      }
      else
      {
        v = _labelText;
      }
      if (v != _cachedTextLabel)
      {
        _textwidth = 0;
        _textheight = 0;
        _reCalculate = true;
        _cachedTextLabel = v;
        _context = null;
      }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Optimized version of "Draw some text on the screen".
    /// </summary>
    /// <param name="xpos">The X position.</param>
    /// <param name="ypos">The Y position.</param>
    /// <param name="color">The font color.</param>
    /// <param name="text">The actual text.</param>
    /// <param name="context">Cached context.</param>
    /// <param name="maxWidth">Maximum width of text</param>
    public void DrawTextEx(float xpos, float ypos, long color, string text, ref FontRenderContext context, int maxWidth)
    {
      lock (GUIFontManager.Renderlock)
      {
        if (context == null)
        {
          if (string.IsNullOrEmpty(text))
            return;

          context = new FontRenderContext(this, text);
        }

        if (xpos <= 0 || ypos <= 0)
          return;


        if (context.charOutOfBounds)
        {
          int alpha = (int)((color >> 24) & 0xff);
          int red = (int)((color >> 16) & 0xff);
          int green = (int)((color >> 8) & 0xff);
          int blue = (int)(color & 0xff);
          GUIFontManager.DrawText(_d3dxFont, xpos, ypos, Color.FromArgb(alpha, red, green, blue), text, maxWidth,
                                  _fontHeight);
          return;
        }

        unsafe
        {
          float[,] matrix = GUIGraphicsContext.GetFinalMatrix();

          DXNative.FontEngineDrawText3D(ID, (void*)(context.ptr.ToPointer()), (int)xpos, (int)ypos, (uint)color, maxWidth,
                                               matrix);
          return;
        }
      }
    }