public void Fill(IConsole data)
{
if (data.UsePixelPositioning)
{
WorldLocation.X = ScreenLocation.X - data.Position.X;
WorldLocation.Y = ScreenLocation.Y - data.Position.Y;
ConsoleLocation = WorldLocation.WorldLocationToConsole(data.TextSurface.Font.Size.X, data.TextSurface.Font.Size.Y);
if (WorldLocation.X < 0)
ConsoleLocation.X -= 1;
if (WorldLocation.Y < 0)
ConsoleLocation.Y -= 1;
}
else
{
WorldLocation = ScreenLocation.WorldLocationToConsole(data.TextSurface.Font.Size.X, data.TextSurface.Font.Size.Y);
ConsoleLocation = new Point(WorldLocation.X - data.Position.X, WorldLocation.Y - data.Position.Y);
}
//TODO: Need to translate mouse coords by the render transform used by the console!!
// If the mouse is on a console, then we need to fill out the mouse information with the console information.
if (ConsoleLocation.X >= 0 && ConsoleLocation.X <= data.TextSurface.RenderArea.Width - 1 &&
ConsoleLocation.Y >= 0 && ConsoleLocation.Y <= data.TextSurface.RenderArea.Height - 1)
{
ConsoleLocation = new Point(ConsoleLocation.X + data.TextSurface.RenderArea.Left, ConsoleLocation.Y + data.TextSurface.RenderArea.Top);
Cell = data.TextSurface.Cells[ConsoleLocation.Y * data.TextSurface.RenderArea.Width + ConsoleLocation.X];
Console = data;
// Other console previously had mouse, we'll properly tell it that it has loss it.
if (Engine.LastMouseConsole != data)
{
if (Engine.LastMouseConsole != null)
{
var info = this.Clone();
var oldConsole = Engine.LastMouseConsole;
Engine.LastMouseConsole = data;
if (oldConsole is Console)
{
((Console)oldConsole).SkipMouseDataFill = true;
oldConsole.ProcessMouse(info);
((Console)oldConsole).SkipMouseDataFill = false;
}
else
oldConsole.ProcessMouse(info);
}
else
Engine.LastMouseConsole = data;
}
}
}