Ejemplo n.º 1
0
 public virtual void CreateUI(GLEx g)
 {
     if (visible)
     {
         LFont oldFont = g.GetFont();
         Color oldColor = g.GetColor();
         g.SetFont(font);
         g.SetColor(color);
         this.width = font.StringWidth(label);
         this.height = font.GetSize();
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
             g.DrawString(label, X(), Y() - font.GetAscent());
             g.SetAlpha(1.0F);
         }
         else
         {
             g.DrawString(label, X(), Y() - font.GetAscent());
         }
         g.SetFont(oldFont);
         g.SetColor(oldColor);
     }
 }
Ejemplo n.º 2
0
        private void DrawMessage(GLEx gl, LColor old)
        {
            if (!visible)
            {
                return;
            }
            if (!running)
            {
                return;
            }
            if (batch == null)
            {
                return;
            }
            if (strings.GetSize() > 25)
            {

                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.5f);
                    this.left = tmp_left;
                    this.index = offset = font = tmp_font = 0;
                    this.fontSizeDouble = fontSize * 2;

                    batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, gl.View);

                    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 (font <= 10 && StringUtils.IsSingle(text))
                        {
                            left += 12;
                        }
                        if (i != size - 1)
                        {
                            pos.X = vector.x + left + leftOffset;
                            pos.Y = (offset * fontHeight) + vector.y + fontSizeDouble
                                            + topOffset;
                            batch.DrawString(strings.Font, Convert.ToString(text), pos, fontColor.Color);
                        }
                        else if (!newLine)
                        {
                            pos.X = vector.x + left + leftOffset + iconWidth;
                            pos.Y = (offset * fontHeight) + vector.y + fontSize
                                    + topOffset + strings.GetAscent();
                            batch.Draw(creeseIcon.Texture, pos, Microsoft.Xna.Framework.Color.White);
                        }
                        index++;
                    }

                    batch.End();

                    if (messageCount == next)
                    {
                        onComplete = true;
                    }
                }
            }
            else
            {
                lock (showMessages)
                {
                    this.size = showMessages.Length;

                    this.fontSize = (isEnglish) ? ((int)(strings.GetSize() * 1.4f)) / 2 : (int)(gl.GetFont()
                            .GetSize() * 1.4f);
                    this.fontHeight = strings.GetHeight() + 10;
                    this.tmp_left = isLeft ? 0 : (int)(((width - (fontSize * messageLength))
                        / 2 + (int)(fontSize * 4)));
                    this.left = tmp_left;
                    this.index = offset = font = tmp_font = 0;
                    this.fontSizeDouble = (int)(fontSize * 2 * 1.2f);

                    batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

                    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);
                        font = tmp_font;
                        if (System.Char.IsLetter(text))
                        {
                            if (tmp_font < fontSize)
                            {
                                font = fontSize;
                            }
                            else
                            {
                                font = tmp_font;
                            }
                        }
                        else
                        {
                            font = fontSize;
                        }
                        left += font;
                        if (font <= 10 && StringUtils.IsSingle(text))
                        {
                            left += 12;
                        }
                        if (i != size - 1)
                        {
                            pos.X = vector.x + left + leftOffset;
                            pos.Y = ((offset * fontHeight) + vector.y + fontSizeDouble
                                            + topOffset + strings.GetAscent() * 2.2f);
                            batch.DrawString(strings.Font, Convert.ToString(text), pos, fontColor.Color);
                        }
                        else if (!newLine)
                        {
                            pos.X = vector.x + left + leftOffset + iconWidth;
                            pos.Y = (offset * fontHeight) + vector.y + fontSize
                                    + topOffset + (strings.GetAscent() * 2.2f) + iconWidth;
                            batch.Draw(creeseIcon.Texture, pos, Microsoft.Xna.Framework.Color.White);
                        }
                        index++;
                    }

                    batch.End();

                    if (messageCount == next)
                    {
                        onComplete = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public override void CreateUI(GLEx g, int x, int y, LComponent component,
         LTexture[] buttonImage)
 {
     LButton button = (LButton)component;
     if (buttonImage != null)
     {
         if (!button.IsEnabled())
         {
             g.DrawTexture(buttonImage[3], x, y);
         }
         else if (button.IsTouchPressed())
         {
             g.DrawTexture(buttonImage[2], x, y);
         }
         else if (button.IsTouchOver())
         {
             g.DrawTexture(buttonImage[1], x, y);
         }
         else
         {
             if (type == 1)
             {
                 g.DrawTexture(buttonImage[0], x, y, LColor.gray);
             }
             else
             {
                 g.DrawTexture(buttonImage[0], x, y);
             }
         }
     }
     if (text != null)
     {
         LFont old = g.GetFont();
         g.SetFont(font);
         g.SetColor(fontColor);
         g.DrawString(
                 text,
                 x + button.GetOffsetLeft()
                         + (button.GetWidth() - font.StringWidth(text)) / 2,
                 y + button.GetOffsetTop()
                         + (button.GetHeight() - font.GetLineHeight()) / 2
                         + font.GetLineHeight());
         g.SetFont(old);
         g.ResetColor();
     }
 }
Ejemplo n.º 4
0
 protected override void CreateCustomUI(GLEx g, int x, int y, int w,
         int h)
 {
     if (!visible)
     {
         return;
     }
     LFont oldFont = g.GetFont();
     g.SetFont(messageFont);
     print.Draw(g, fontColor);
     g.SetFont(oldFont);
     if (print.IsComplete() && animation != null)
     {
         if (animation.GetSpriteImage() != null)
         {
             g.SetAlpha(1.0F);
             UpdateIcon();
             g.DrawTexture(animation.GetSpriteImage(), dx, dy);
         }
     }
     g.ResetColor();
 }
Ejemplo n.º 5
0
 public virtual void CreateUI(GLEx g)
 {
     if (visible)
     {
         if (showValue)
         {
             hpString = "" + value_ren;
             g.SetColor(LColor.white);
             int current_0 = g.GetFont().StringWidth(hpString);
             int h = g.GetFont().GetSize();
             g.DrawString("" + value_ren, (X() + width / 2 - current_0 / 2) + 2,
                     (Y() + height / 2 + h / 2));
         }
         DrawBar(g, goal, current, width, GetX(), GetY());
     }
 }