Console singleton, dpi fixes, no linespacing

This commit is contained in:
GoaLitiuM
2021-04-03 03:17:25 +03:00
parent dc7fc99b03
commit ae8983a90e
5 changed files with 133 additions and 135 deletions

View File

@@ -48,7 +48,7 @@ namespace Cabrito
set
{
heightMultiplier = value;
Height = Screen.Size.Y * HeightMultiplier;
UpdateHeight();
}
}
@@ -97,7 +97,9 @@ namespace Cabrito
if (font == null)
return (int)Height;
return (int)Mathf.Round(LineSpacing * (font.Height / Platform.DpiScale) * Scale.Y);
int h = (int)Mathf.Round(LineSpacing * (font.Height / Platform.DpiScale) * Scale.Y);
Console.Print("height: " + LineSpacing.ToString());
return h;
}
private int GetHeightInLines()
@@ -108,14 +110,26 @@ namespace Cabrito
return (int)(Height / (font.Height / Platform.DpiScale)); // number of fully visible lines
}
protected override void OnParentChangedInternal()
{
base.OnParentChangedInternal();
if (Parent != null)
OnParentResized();
}
public override void OnParentResized()
{
if (HeightMultiplier > 0)
Height = Screen.Size.Y * HeightMultiplier;
UpdateHeight();
base.OnParentResized();
}
private void UpdateHeight()
{
if (Parent != null && Parent.Parent != null)
Height = (Parent.Parent.Size.Y * HeightMultiplier) - GetFontHeight();
}
private void CalculateVisibleLines(IReadOnlyCollection<ConsoleLine> lines, out int firstVisibleLine, out int lastVisibleLine, out LineInfo[] wrappedLines)
{