large worlds engine compat refactor, change vector -> float
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Game
|
||||
protected TextLayoutOptions _layout;
|
||||
|
||||
private bool doubleClicked;
|
||||
private Vector2 lastDoubleClickLocation = new Vector2(0, 0);
|
||||
private Float2 lastDoubleClickLocation = new Float2(0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the selection (Transparent if not used).
|
||||
@@ -121,7 +121,7 @@ namespace Game
|
||||
|
||||
public override void ResetViewOffset()
|
||||
{
|
||||
TargetViewOffset = new Vector2(0, 0);
|
||||
TargetViewOffset = new Float2(0, 0);
|
||||
}
|
||||
|
||||
/*public void ScrollToEnd()
|
||||
@@ -130,7 +130,7 @@ namespace Game
|
||||
float spacing = GetRealLineSpacing();
|
||||
maxY += spacing;
|
||||
|
||||
TargetViewOffset = new Vector2(0, Math.Max(0, maxY));
|
||||
TargetViewOffset = new Float2(0, Math.Max(0, maxY));
|
||||
}*/
|
||||
|
||||
public override void ScrollToCaret()
|
||||
@@ -142,13 +142,13 @@ namespace Game
|
||||
|
||||
float maxY = TextSize.Y - Height;
|
||||
|
||||
Vector2 newLocation = CaretBounds.Location;
|
||||
TargetViewOffset = Vector2.Clamp(newLocation, new Vector2(0, 0), new Vector2(_targetViewOffset.X, maxY));
|
||||
Float2 newLocation = CaretBounds.Location;
|
||||
TargetViewOffset = Float2.Clamp(newLocation, new Float2(0, 0), new Float2(_targetViewOffset.X, maxY));
|
||||
}
|
||||
|
||||
/*const bool smoothScrolling = false;
|
||||
|
||||
public override bool OnMouseWheel(Vector2 location, float delta)
|
||||
public override bool OnMouseWheel(Float2 location, float delta)
|
||||
{
|
||||
if (!IsMultiline || Text.Length == 0)
|
||||
return false;
|
||||
@@ -161,33 +161,33 @@ namespace Game
|
||||
float maxY = TextSize.Y - Height;
|
||||
float offset = GetRealLineSpacing();
|
||||
maxY += offset;
|
||||
TargetViewOffset = Vector2.Clamp(_targetViewOffset - new Vector2(0, delta), new Vector2(0, offset), new Vector2(_targetViewOffset.X, maxY));
|
||||
TargetViewOffset = Float2.Clamp(_targetViewOffset - new Float2(0, delta), new Float2(0, offset), new Float2(_targetViewOffset.X, maxY));
|
||||
return true;
|
||||
}*/
|
||||
|
||||
public override Vector2 GetTextSize()
|
||||
public override Float2 GetTextSize()
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
if (font == null)
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
|
||||
return font.MeasureText(Text, ref _layout);
|
||||
}
|
||||
|
||||
public override Vector2 GetCharPosition(int index, out float height)
|
||||
public override Float2 GetCharPosition(int index, out float height)
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
height = Height;
|
||||
return Vector2.Zero;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
height = GetFontHeight();
|
||||
return font.GetCharPosition(Text, index, ref _layout);
|
||||
}
|
||||
|
||||
public override int HitTestText(Vector2 location)
|
||||
public override int HitTestText(Float2 location)
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
if (font == null)
|
||||
@@ -195,7 +195,7 @@ namespace Game
|
||||
|
||||
if (TextPrefix != "")
|
||||
{
|
||||
Vector2 prefixSize = font.MeasureText(TextPrefix);
|
||||
Float2 prefixSize = font.MeasureText(TextPrefix);
|
||||
location.X -= prefixSize.X;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Game
|
||||
return base.OnKeyDown(key);
|
||||
}
|
||||
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (doubleClicked && lastDoubleClick.Elapsed.TotalSeconds < 0.5 &&
|
||||
location == lastDoubleClickLocation) // Windows defaults to 500ms window
|
||||
@@ -251,7 +251,7 @@ namespace Game
|
||||
}
|
||||
|
||||
|
||||
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
doubleClicked = true;
|
||||
lastDoubleClick.Restart();
|
||||
@@ -260,7 +260,7 @@ namespace Game
|
||||
return base.OnMouseDoubleClick(location, button);
|
||||
}
|
||||
|
||||
public bool OnMouseTripleClick(Vector2 location, MouseButton button)
|
||||
public bool OnMouseTripleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (!IsMultiline)
|
||||
SelectAll();
|
||||
@@ -281,7 +281,7 @@ namespace Game
|
||||
public override void Draw()
|
||||
{
|
||||
// Cache data
|
||||
Rectangle rect = new Rectangle(Vector2.Zero, Size);
|
||||
Rectangle rect = new Rectangle(Float2.Zero, Size);
|
||||
Font font = Font.GetFont();
|
||||
if (!font)
|
||||
return;
|
||||
@@ -312,8 +312,8 @@ namespace Game
|
||||
// Check if any text is selected to draw selection
|
||||
if (HasSelection)
|
||||
{
|
||||
Vector2 leftEdge = font.GetCharPosition(text, SelectionLeft + TextPrefix.Length, ref _layout);
|
||||
Vector2 rightEdge = font.GetCharPosition(text, SelectionRight + TextPrefix.Length, ref _layout);
|
||||
Float2 leftEdge = font.GetCharPosition(text, SelectionLeft + TextPrefix.Length, ref _layout);
|
||||
Float2 rightEdge = font.GetCharPosition(text, SelectionRight + TextPrefix.Length, ref _layout);
|
||||
float fontHeight = GetFontHeight();
|
||||
|
||||
// Draw selection background
|
||||
@@ -349,7 +349,7 @@ namespace Game
|
||||
|
||||
if (CaretPosition > -1)
|
||||
{
|
||||
Vector2 prefixSize = TextPrefix != "" ? font.MeasureText(TextPrefix) : new Vector2();
|
||||
Float2 prefixSize = TextPrefix != "" ? font.MeasureText(TextPrefix) : new Float2();
|
||||
Rectangle caretBounds = CaretBounds;
|
||||
caretBounds.X += prefixSize.X;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user