Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ezt hivja meg a DrawButton(), abban nincs hiba, ha torlom azt a sor amiben meghivja, nem jon elo a hiba
- internal void DrawText(string text, FontCi font, float x, float y, TextAlign align, TextBaseline baseline)
- {
- TextTexture t = GetTextTexture(text, font);
- int dx = 0;
- int dy = 0;
- if (align == TextAlign.Center)
- {
- dx -= t.textwidth / 2;
- }
- if (align == TextAlign.Right)
- {
- dx -= t.textwidth;
- }
- if (baseline == TextBaseline.Middle)
- {
- dy -= t.textheight / 2;
- }
- if (baseline == TextBaseline.Bottom)
- {
- dy -= t.textheight;
- }
- Draw2dQuad(t.texture, x + dx, y + dy, t.texturewidth, t.textureheight); //ha ezt a sort torlom ki, akkor sincs a hiba
- }
- // ... ami e sor alatt van, azt mar nem igazan ertem
- TextTexture GetTextTexture(string text, FontCi font)
- {
- for (int i = 0; i < textTexturesCount; i++)
- {
- TextTexture t = textTextures[i];
- if (t == null)
- {
- continue;
- }
- if (t.text == text
- && t.font.size == font.size
- && t.font.family == font.family
- && t.font.style == font.style)
- {
- return t;
- }
- }
- TextTexture textTexture = new TextTexture();
- Text_ text_ = new Text_();
- text_.text = text;
- text_.font = font;
- text_.color = Game.ColorFromArgb(255, 255, 255, 255);
- BitmapCi textBitmap = textColorRenderer.CreateTextTexture(text_);
- int texture = p.LoadTextureFromBitmap(textBitmap);
- IntRef textWidth = new IntRef();
- IntRef textHeight = new IntRef();
- p.TextSize(text, font, textWidth, textHeight);
- textTexture.texture = texture;
- textTexture.texturewidth = p.FloatToInt(p.BitmapGetWidth(textBitmap));
- textTexture.textureheight = p.FloatToInt(p.BitmapGetHeight(textBitmap));
- textTexture.text = text;
- textTexture.font = font;
- textTexture.textwidth = textWidth.value;
- textTexture.textheight = textHeight.value;
- p.BitmapDelete(textBitmap);
- textTextures[textTexturesCount++] = textTexture;
- return textTexture;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement