private void UpdateTextPosition() { if (_Text == String.Empty) { return; } CFonts.SetFont(Fon); CFonts.Style = Style; float h = Height; float y = Y; RectangleF bounds = CFonts.GetTextBounds(this); while (bounds.Width > Bounds.W) { h -= 0.2f; y += 0.1f; bounds = CFonts.GetTextBounds(this, h); } float x = X; switch (Align) { case EAlignment.Center: x = X - bounds.Width / 2; break; case EAlignment.Right: x = X - bounds.Width; break; default: break; } _DrawPosition.X = x; _DrawPosition.Y = y; _DrawPosition.tH = h; _DrawPosition.Width = bounds.Width; _DrawPosition.Height = bounds.Height; _PositionNeedsUpdate = false; }
public void DrawRelative(float rx, float ry, bool reflection, float reflectionSpace, float reflectionHeight, float rectHeight) { // Update Text Text = Text; float h = Height; float x = X + rx; float y = Y + ry; RectangleF bounds = CDraw.GetTextBounds(this); if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) { float factor = Bounds.W / bounds.Width; float step = h * (1 - factor); h *= factor; switch (HAlign) { case EHAlignment.Top: y += step * 0.25f; break; case EHAlignment.Center: y += step * 0.50f; break; case EHAlignment.Bottom: y += step * 0.75f; break; default: break; } bounds = CFonts.GetTextBounds(this, h); } switch (Align) { case EAlignment.Center: x = x - bounds.Width / 2; break; case EAlignment.Right: x = x - bounds.Width; break; default: break; } SColorF CurrentColor = new SColorF(Color); if (Selected) { CurrentColor = new SColorF(SColor); } SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha); CFonts.SetFont(Fon); CFonts.Style = Style; if (!EditMode) { CFonts.DrawText(_Text, h, x, y, Z, color); } else { CFonts.DrawText(_Text + "|", h, x, y, Z, color); } if (reflection) { float space = (rectHeight - Y - bounds.Height) * 2f + reflectionSpace; float height = reflectionHeight - (rectHeight - Y) + bounds.Height; if (!EditMode) { CFonts.DrawTextReflection(_Text, h, x, y, Z, color, space, height); } else { CFonts.DrawTextReflection(_Text + "|", h, x, y, Z, color, space, height); } } if (Selected && (CSettings.GameState == EGameState.EditTheme)) { CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha), new SRectF(x, y, bounds.Width, bounds.Height, Z)); } }
private void UpdateTextPosition() { if (_Text == String.Empty) { return; } CFonts.SetFont(Fon); CFonts.Style = Style; float h = Height; float y = Y; RectangleF bounds = CFonts.GetTextBounds(this); if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) { float factor = Bounds.W / bounds.Width; float step = h * (1 - factor); h *= factor; switch (HAlign) { case EHAlignment.Top: y += step * 0.25f; break; case EHAlignment.Center: y += step * 0.50f; break; case EHAlignment.Bottom: y += step * 0.75f; break; default: break; } bounds = CFonts.GetTextBounds(this, h); } float x = X; switch (Align) { case EAlignment.Center: x = X - bounds.Width / 2; break; case EAlignment.Right: x = X - bounds.Width; break; default: break; } _DrawPosition.X = x; _DrawPosition.Y = y; _DrawPosition.tH = h; _DrawPosition.Width = bounds.Width; _DrawPosition.Height = bounds.Height; _PositionNeedsUpdate = false; }
public override void LoadTheme(string xmlPath) { bool ressourceOK = true; //Vocaluxe-Logo ressourceOK &= CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo); //Little stars for logo ressourceOK &= CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar); ressourceOK &= CDataBase.GetCreditsRessource("redDot.png", ref _TexRedDot); ressourceOK &= CDataBase.GetCreditsRessource("blueDot.png", ref _TexBlueDot); ressourceOK &= CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel); ressourceOK &= CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice); ressourceOK &= CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep); ressourceOK &= CDataBase.GetCreditsRessource("flamefire.png", ref _TexNameFlamefire); ressourceOK &= CDataBase.GetCreditsRessource("lukeIam.png", ref _TexNameLukeIam); ressourceOK &= CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning); ressourceOK &= CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand); ressourceOK &= CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03); if (!ressourceOK) { CLog.Fatal("Could not load all ressources!"); } //Prepare Text int lastY = 280; foreach (string[] paragraph in _Paragraphs) { string line = ""; for (int e = 0; e < paragraph.Length; e++) { if (paragraph[e] == null) { continue; } string newLine = " " + paragraph[e]; CText text = GetNewText(75, lastY, -2, 25, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); text.Visible = false; if (CFonts.GetTextBounds(text).Width < (CSettings.RenderW - 220)) { line += newLine; //Check if all words are used if ((e + 1) == paragraph.Length) { text.Text = line; _ParagraphTexts.Add(text); line = ""; lastY += 40; } } else { _ParagraphTexts.Add(text); line = newLine; lastY += 27; } _AddText(text); } } CBackground bg = new CBackground(_BGTheme, -1); bg.LoadSkin(); _AddBackground(bg); //Vocaluxe-Logo _Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2)); _AddStatic(_Logo); //Little stars for logo var numstars = (int)(_Logo.Rect.W * 0.25f / 2f); var partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1); _StarsRed = _GetStarParticles(numstars, true, partRect, true); _StarsBlue = _GetStarParticles(numstars, false, partRect, true); _AddParticleEffect(_StarsRed); _AddParticleEffect(_StarsBlue); //Credit names _CreditNames = new List <CCreditName>(); _AddNewCreditName(_TexNameBrunzel, 502, 29, true); _AddNewCreditName(_TexNameDarkice, 360, 55, true); _AddNewCreditName(_TexNameFlokuep, 214, 14, true); _AddNewCreditName(_TexNameFlamefire, 496, 46, true); _AddNewCreditName(_TexNameLukeIam, 411, 26, true); _AddNewCreditName(_TexNameBohning, 383, 54, false); _AddNewCreditName(_TexNameMesand, 525, 13, false); _AddNewCreditName(_TexNameBabene03, 33, 26, false); _AddTranslations(); }