Package pu.web.client

Examples of pu.web.client.PU_Font


    long ticks = System.currentTimeMillis() - mLastTicks;
    mLastTicks = System.currentTimeMillis();
   
    if(mMessages.size() > 0)
    {
      PU_Font font = PUWeb.resources().getFont(Fonts.FONT_ARIALBLK_BOLD_14_OUTLINE);
     
      int drawCount = 0;
      for(PU_OnscreenChatMessage message : mMessages)
      {
        drawCount += message.getName().length() + 6;
        for(PU_OnscreenChatLine line :  message.getLines())
        {
          drawCount += line.getText().length();
        }
      }
     
      PUWeb.engine().beginTextureBatch(font.getImage().getTexture(), font.getImage().getWidth(), drawCount, 0, 162, 232, 255);
      for(int i = 0; i < mMessages.size();)
      {
        PU_OnscreenChatMessage message = mMessages.get(i);
        if(message != null)
        {
View Full Code Here


   
    int[] offset = PUWeb.game().getScreenOffset();
    int offsetX = offset[0];
    int offsetY = offset[1];
   
    PU_Font font = PUWeb.resources().getFont(Fonts.FONT_ARIALBLK_BOLD_14_OUTLINE);
   
    int lineHeight = font.getLineHeight();
    int height = lineHeight + (lineHeight * mLines.size());
   
    boolean center = false;
   
    int drawX = PU_Game.MID_X - (PUWeb.game().getSelf().getX() - mX);
    int drawY = PU_Game.MID_Y - (PUWeb.game().getSelf().getY() - mY);
   
    drawX = (drawX * PU_Tile.TILE_WIDTH) - PU_Tile.TILE_WIDTH - 22 + offsetX;
    drawY = (drawY * PU_Tile.TILE_HEIGHT) - PU_Tile.TILE_HEIGHT + offsetY;
   
    if(drawY-height < 0)
    {
      drawY = 0;
    }
    else if(drawY > PU_Engine.SCREEN_HEIGHT)
    {
      drawY = PU_Engine.SCREEN_HEIGHT - height;
    }
    else
    {
      drawY -= height;
      drawY += lineHeight;
    }
   
    String header = mName + " says:";
   
    int widest = font.getStringWidth(header);
   
    for(PU_OnscreenChatLine line : mLines)
    {
      if(line != null)
      {
        int len = font.getStringWidth(line.getText());
        if(len > widest)
        {
          widest = len;
        }
      }
    }
   
    if(drawX - (int)Math.ceil((float)widest/2.0f) < 0)
    {
      drawX = 0;
    }
    else if(drawX + (int)Math.ceil((float)widest/2.0f) > PU_Engine.SCREEN_WIDTH)
    {
      drawX = PU_Engine.SCREEN_WIDTH - widest;
    }
    else
    {
      center = true;
    }
   
    int posHalf = 0;
    if(!center)
    {
      posHalf = drawX + (int)Math.ceil((float)((drawX+widest)-drawX)/2);
    }
    else
    {
      posHalf = (drawX - ((int)Math.ceil((float)widest / 2.0))) + (int)(Math.ceil((float)((drawX+widest)-(drawX-((int)Math.ceil((float)widest/2.0))))/2));
    }
   
    int nameHalf = (int)(Math.floor((float)font.getStringWidth(header) / 2.0));
        int centerPos = posHalf - nameHalf;

        font.drawTextInBatch(header, centerPos, drawY);
       
        for(int i = 0; i < mLines.size(); i++)
        {
          PU_OnscreenChatLine line = mLines.get(i);
          if(line != null)
          {
            nameHalf = (int)Math.floor((float)font.getStringWidth(line.getText())/2.0);
            centerPos = posHalf - nameHalf;
           
            font.drawTextInBatch(line.getText(), centerPos, drawY+((i+1)*lineHeight));
          }
        }
       
        updateLines(ticks);
        if(mLines.size() <= 0)
View Full Code Here

    mLines.add(new PU_OnscreenChatLine(line));
  }
 
  public void addText(String textToAdd)
  {
    PU_Font font = PUWeb.resources().getFont(Fonts.FONT_ARIALBLK_BOLD_14_OUTLINE);
    int curSize = 2;
    String curText = "";
    int maxWidth = 160;
    int textWidth = font.getStringWidth(textToAdd) + 2;
   
    if(textWidth > maxWidth)
    {
      String text = textToAdd;
      int curPos = 0;

      while(curPos < text.length())
      {
        String word = nextWord(text, curPos);
        int wordSize = font.getStringWidth(word);
        if(curSize+wordSize < maxWidth)
        {
          curText += word;
          curSize += wordSize;
          curPos += word.length();
        }
        else
        {
          if(!curText.equals(""))
          {
            addLine(curText);
           
            curText = "";
            curSize = 2;
          }
          else
          {
            for(int i = 0; i < word.length(); i++)
            {
              int charWidth = font.getStringWidth("" + word.charAt(i));
              if(curSize+charWidth > maxWidth)
              {
                curText += "-";
               
                addLine(curText);
View Full Code Here

  public void updateSize()
  {
    int width = 0;
    int height = 0;
    PU_Font font = getFont();
    if(font != null)
    {
      width = font.getStringWidth(mText);
      height = font.getLineHeight()+2;
    }
   
    getRect().width = width;
    getRect().height = height;
  }
View Full Code Here

  public void draw(PU_Rect drawArea)
  {
    PU_Rect realRect = new PU_Rect(getRect().x + drawArea.x, getRect().y + drawArea.y, getRect().width, getRect().height);
    PU_Rect inRect = drawArea.intersection(realRect);
   
    PU_Font font = getFont();
    if(font != null)
    {
      font.setColor(getFontColor().r, getFontColor().g, getFontColor().b);
      font.drawTextInRect(mText, drawArea.x + getRect().x, drawArea.y + getRect().y, inRect);
   
  }
View Full Code Here

    if(mImage.getImage() != null)
    {
      mImage.getImage().drawRectInRect(getRect(), drawArea);
    }
   
    PU_Font font = getFont();
    int caretX = 0;
    int textX = getRect().x + font.getStringWidth(" ");
    int textY = getRect().y + ((getRect().height/2)-(font.getLineHeight()/2));
    if(!mText.equals(""))
    {
      String drawText = "";
      if(mPassword)
      {
        for(int i = 0; i < mText.length(); i++)
        {
          drawText += "*";
        }
      }
      else
      {
        drawText = mText;
      }
     
      font.setColor(getFontColor().r, getFontColor().g, getFontColor().b);
      font.drawTextInRect(drawText, drawArea.x + textX, drawArea.y + textY, inRect);
     
      caretX = font.getStringWidth(drawText);
    }
   
    //draw caret
    if(mCaret && !mReadOnly && hasFocus())
    {
      caretX += textX;
      if(inRect.contains(drawArea.x+caretX, drawArea.y+textY))
      {
        PUWeb.engine().setColor(getFontColor().r, getFontColor().g, getFontColor().b, 255);
        PUWeb.engine().renderLine(drawArea.x+caretX, drawArea.y+textY, drawArea.x+caretX, drawArea.y+textY+font.getLineHeight());
      }
    }
   
    if(System.currentTimeMillis()-mCaretLast >= CARET_TIME)
    {
View Full Code Here

    }
   
    PUWeb.engine().setColor(0, 0, 0, 255);
    PUWeb.engine().renderRect(realRect.x+2, realRect.y+2, realRect.width-4, realRect.height-4);
   
    PU_Font font = getFont();
    if(!mCaption.equals("") && font != null)
    {
      int captionX = getRect().x+((getRect().width/2)-(font.getStringWidth(mCaption)/2));
      int captionY = getRect().y+((getRect().height/2)-(font.getLineHeight()/2));
      font.setColor(getFontColor().r, getFontColor().g, getFontColor().b);
      font.drawTextInRect(mCaption, drawArea.x + captionX, drawArea.y + captionY, inRect);
    }
  }
View Full Code Here

TOP

Related Classes of pu.web.client.PU_Font

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.