Esempio n. 1
0
 private void UpdateHeight()
 {
     if (this.d.Lines.Count > 0)
     {
         DeviceChunkLine line = this.d.Lines[this.d.Lines.Count - 1];
         this.CompiledHeight = line.Y + line.Height;
     }
     else
     {
         this.CompiledHeight = 0;
     }
 }
Esempio n. 2
0
 public void Draw(float deltaTime)
 {
     if (this.d != null)
     {
         for (int lineIndex = 0; lineIndex < this.d.Lines.Count; lineIndex++)
         {
             DeviceChunkLine line = this.d.Lines[lineIndex];
             for (int chunkIndex = 0; chunkIndex < line.Chunks.Count; chunkIndex++)
             {
                 DeviceChunk chunk = line.Chunks[chunkIndex];
                 chunk.Draw(deltaTime);
             }
         }
     }
 }
Esempio n. 3
0
 public void Offset(int dx, int dy)
 {
     if (this.d != null)
     {
         for (int lineIndex = 0; lineIndex < this.d.Lines.Count; lineIndex++)
         {
             DeviceChunkLine line = this.d.Lines[lineIndex];
             for (int chunkIndex = 0; chunkIndex < line.Chunks.Count; chunkIndex++)
             {
                 DeviceChunk chunk = line.Chunks[chunkIndex];
                 chunk.Rect.X += dx;
                 chunk.Rect.Y += dy;
             }
         }
     }
 }
Esempio n. 4
0
 public void Draw(float deltaTime, object userData = null)
 {
     if (this.d != null)
     {
         for (int lineIndex = 0; lineIndex < this.d.Lines.Count; lineIndex++)
         {
             DeviceChunkLine line = this.d.Lines[lineIndex];
             for (int chunkIndex = 0; chunkIndex < line.Chunks.Count; chunkIndex++)
             {
                 DeviceChunk chunk = line.Chunks[chunkIndex];
                 string      linkText;
                 if (this.d.Links.TryGetValue(chunk, out linkText))
                 {
                     chunk.Draw(deltaTime, linkText, userData);
                 }
                 else
                 {
                     chunk.Draw(deltaTime, null, userData);
                 }
             }
         }
     }
 }
Esempio n. 5
0
 private void MergeSameTextChunks()
 {
     if (this.d != null)
     {
         for (int lineIndex = 0; lineIndex < this.d.Lines.Count; lineIndex++)
         {
             DeviceChunkLine line      = this.d.Lines[lineIndex];
             DeviceChunk     currChunk = null;
             for (int chunkIndex = 0; chunkIndex < line.Chunks.Count;)
             {
                 DeviceChunk chunk = line.Chunks[chunkIndex];
                 if (currChunk == null)
                 {
                     currChunk = chunk;
                     chunkIndex++;
                 }
                 else
                 {
                     string linkText1;
                     this.d.Links.TryGetValue(currChunk, out linkText1);
                     string linkText2;
                     this.d.Links.TryGetValue(chunk, out linkText2);
                     if (string.Equals(linkText1, linkText2))
                     {
                         var textEffectChunk1 = currChunk as DeviceChunkDrawTextEffect;
                         var textEffectChunk2 = chunk as DeviceChunkDrawTextEffect;
                         if (textEffectChunk1 != null && textEffectChunk2 != null)
                         {
                             // try to merge text effect chunk.
                             if (textEffectChunk1.Font.Equals(textEffectChunk2.Font) &&
                                 textEffectChunk1.Deco == textEffectChunk2.Deco &&
                                 textEffectChunk1.Color.R == textEffectChunk2.Color.R &&
                                 textEffectChunk1.Color.G == textEffectChunk2.Color.G &&
                                 textEffectChunk1.Color.B == textEffectChunk2.Color.B &&
                                 textEffectChunk1.Color.A == textEffectChunk2.Color.A &&
                                 (textEffectChunk1.DecoStop == true || (textEffectChunk1.DecoStop == false && textEffectChunk2.DecoStop == false)) &&
                                 textEffectChunk1.Effect == textEffectChunk2.Effect &&
                                 textEffectChunk1.EffectColor.R == textEffectChunk2.EffectColor.R &&
                                 textEffectChunk1.EffectColor.G == textEffectChunk2.EffectColor.G &&
                                 textEffectChunk1.EffectColor.B == textEffectChunk2.EffectColor.B &&
                                 textEffectChunk1.EffectColor.A == textEffectChunk2.EffectColor.A &&
                                 textEffectChunk1.EffectAmount == textEffectChunk2.EffectAmount)
                             {
                                 if (textEffectChunk2.PrevIsWord)
                                 {
                                     textEffectChunk1.Text        = textEffectChunk1 + " " + textEffectChunk2.Text;
                                     textEffectChunk1.Rect.Width += textEffectChunk1.Font.WhiteSize + textEffectChunk2.Rect.Width;
                                 }
                                 else
                                 {
                                     textEffectChunk1.Text        = textEffectChunk1 + textEffectChunk2.Text;
                                     textEffectChunk1.Rect.Width += textEffectChunk2.Rect.Width;
                                 }
                                 line.Chunks.RemoveAt(chunkIndex);
                                 textEffectChunk2.Dispose();
                                 textEffectChunk2 = null;
                                 continue;
                             }
                         }
                         else if (textEffectChunk1 == null && textEffectChunk2 == null)
                         {
                             var textChunk1 = currChunk as DeviceChunkDrawText;
                             var textChunk2 = chunk as DeviceChunkDrawText;
                             if (textChunk1 != null && textChunk2 != null)
                             {
                                 // try to merge text chunk.
                                 if (textChunk1.Font.Equals(textChunk2.Font) &&
                                     textChunk1.Deco == textChunk2.Deco &&
                                     textChunk1.Color.R == textChunk2.Color.R &&
                                     textChunk1.Color.G == textChunk2.Color.G &&
                                     textChunk1.Color.B == textChunk2.Color.B &&
                                     textChunk1.Color.A == textChunk2.Color.A &&
                                     (textChunk1.DecoStop == true || (textChunk1.DecoStop == false && textChunk2.DecoStop == false)))
                                 {
                                     if (textChunk2.PrevIsWord)
                                     {
                                         textChunk1.Text        = textChunk1 + " " + textChunk2.Text;
                                         textChunk1.Rect.Width += textChunk1.Font.WhiteSize + textChunk2.Rect.Width;
                                     }
                                     else
                                     {
                                         textChunk1.Text        = textChunk1 + textChunk2.Text;
                                         textChunk1.Rect.Width += textChunk2.Rect.Width;
                                     }
                                     line.Chunks.RemoveAt(chunkIndex);
                                     textChunk2.Dispose();
                                     textChunk2 = null;
                                     continue;
                                 }
                             }
                         }
                     }
                     currChunk = chunk;
                     chunkIndex++;
                 }
             }
         }
     }
 }