Ejemplo n.º 1
0
 private void DrawMessage(GLEx g)
 {
     if (mesFont == null)
     {
         return;
     }
     lock (mesFont) {
         if (isDirty)
         {
             char[] chars = message.ToCharArray();
             int    len = message.Length;
             int    i, j = 0;
             char   ch;
             mesFont.StartChar();
             if (isHch)
             {
                 for (i = 0; i < len; i++)
                 {
                     ch = chars[i];
                     if (ch != '\n')
                     {
                         mesFont.AddChar(ch, offsetY + message_y[j], offsetX
                                         + message_x[j], fontColor);
                         j++;
                     }
                 }
             }
             else
             {
                 for (i = 0; i < len; i++)
                 {
                     ch = chars[i];
                     if (ch != '\n')
                     {
                         mesFont.AddChar(ch, offsetX + message_x[j], offsetY
                                         + message_y[j], fontColor);
                         j++;
                     }
                 }
             }
             mesFont.StopChar();
             mesFont.SaveCharCache();
             this.isDirty = false;
         }
         else
         {
             mesFont.PostCharCache();
         }
     }
 }
Ejemplo n.º 2
0
        private void DrawMessage(GLEx gl, LColor old)
        {
            if (!visible)
            {
                return;
            }
            if (strings == null)
            {
                return;
            }
            lock (showMessages)
            {
                this.size     = showMessages.Length;
                this.fontSize = (isEnglish) ? strings.GetSize() / 2 : gl.GetFont()
                                .GetSize();
                this.fontHeight = strings.GetHeight();
                this.tmp_left   = isLeft ? 0 : (width - (fontSize * messageLength))
                                  / 2 - (int)(fontSize * 1.5);
                this.left           = tmp_left;
                this.index          = offset = font = tmp_font = 0;
                this.fontSizeDouble = fontSize * 2;

                int hashCode = 1;
                hashCode = LSystem.Unite(hashCode, size);
                hashCode = LSystem.Unite(hashCode, left);
                hashCode = LSystem.Unite(hashCode, fontSize);
                hashCode = LSystem.Unite(hashCode, fontHeight);

                if (strings == null)
                {
                    return;
                }

                if (hashCode == lazyHashCade)
                {
                    strings.PostCharCache();
                    if (iconX != 0 && iconY != 0)
                    {
                        gl.DrawTexture(creeseIcon, iconX, iconY);
                    }
                    return;
                }

                strings.StartChar();
                fontColor = old;

                for (int i = 0; i < size; i++)
                {
                    text = showMessages[i];
                    if (text == '\0')
                    {
                        continue;
                    }
                    if (interceptCount < interceptMaxString)
                    {
                        interceptCount++;
                        continue;
                    }
                    else
                    {
                        interceptMaxString = 0;
                        interceptCount     = 0;
                    }
                    if (showMessages[i] == 'n' &&
                        showMessages[(i > 0) ? i - 1 : 0] == '\\')
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        continue;
                    }
                    else if (text == '\n')
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        continue;
                    }
                    else if (text == '<')
                    {
                        LColor color = GetColor(showMessages[(i < size - 1) ? i + 1
                                : i]);
                        if (color != null)
                        {
                            interceptMaxString = 1;
                            fontColor          = color;
                        }
                        continue;
                    }
                    else if (showMessages[(i > 0) ? i - 1 : i] == '<' &&
                             GetColor(text) != null)
                    {
                        continue;
                    }
                    else if (text == '/')
                    {
                        if (showMessages[(i < size - 1) ? i + 1 : i] == '>')
                        {
                            interceptMaxString = 1;
                            fontColor          = old;
                        }
                        continue;
                    }
                    else if (index > messageLength)
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        newLine = false;
                    }
                    else if (text == '\\')
                    {
                        continue;
                    }
                    tmp_font = strings.CharWidth(text);
                    if (System.Char.IsLetter(text))
                    {
                        if (tmp_font < fontSize)
                        {
                            font = fontSize;
                        }
                        else
                        {
                            font = tmp_font;
                        }
                    }
                    else
                    {
                        font = fontSize;
                    }
                    left += font;

                    if (i != size - 1)
                    {
                        strings.AddChar(text, vector.x + left + leftOffset,
                                        (offset * fontHeight) + vector.y + fontSizeDouble
                                        + topOffset - font - 2, fontColor);
                    }
                    else if (!newLine && !onComplete)
                    {
                        iconX = vector.x + left + leftOffset + iconWidth;
                        iconY = (offset * fontHeight) + vector.y + fontSize
                                + topOffset + strings.GetAscent();
                        if (iconX != 0 && iconY != 0)
                        {
                            gl.DrawTexture(creeseIcon, iconX, iconY);
                        }
                    }
                    index++;
                }

                strings.StopChar();
                strings.SaveCharCache();

                lazyHashCade = hashCode;

                if (messageCount == next)
                {
                    onComplete = true;
                }
            }
        }