コード例 #1
0
ファイル: OTTextSprite.cs プロジェクト: rav3r/AdRally
    public List <OTTextLine> WordWrap(int wrapWidth, int dy)
    {
        List <OTTextLine> wLines = new List <OTTextLine>();

        if (words.Count > 0)
        {
            OTTextLine line = new OTTextLine(yPosition, false, lineHeight);
            wLines.Add(line);
            int ww = 0; int yp = yPosition;
            for (int w = 0; w < words.Count; w++)
            {
                line.words.Add(words[w]);
                if (w < words.Count - 1)
                {
                    ww += words[w].width;
                    if (ww >= wrapWidth || ww + words[w].space >= wrapWidth || ww + words[w + 1].width > wrapWidth)
                    {
                        // wrap
                        ww  = 0;
                        yp -= dy;
                        line.End();
                        line = new OTTextLine(yp, false, lineHeight);
                        wLines.Add(line);
                    }
                    else
                    {
                        ww += words[w].space;
                    }
                }
            }
            line.End();
        }
        return(wLines);
    }
コード例 #2
0
ファイル: OTTextSprite.cs プロジェクト: kimlavoie/DeadC0de
 public List<OTTextLine> WordWrap(int wrapWidth, int dy)
 {
     List<OTTextLine> wLines = new List<OTTextLine>();
     if (words.Count>0)
     {
         OTTextLine line = new OTTextLine(yPosition, false, lineHeight);
         wLines.Add(line);
         int ww = 0; int yp = yPosition;
         for (int w=0; w<words.Count; w++)
         {
             line.words.Add(words[w]);
             if (w < words.Count-1)
             {
                 ww += words[w].width;
                 if (ww >= wrapWidth || ww + words[w].space >= wrapWidth || ww + words[w+1].width > wrapWidth)
                 {
                     // wrap
                     ww = 0;
                     yp -= dy;
                     line.End();
                     line = new OTTextLine(yp, false, lineHeight);
                     wLines.Add(line);
                 }
                 else
                     ww += words[w].space;
             }
         }
         line.End();
     }
     return wLines;
 }