mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
@ Renamed GetMapCoordinates function to DisplayToMap and added MapToDisplay function
@ Exposed the RenderTargetDisplay to plugins
This commit is contained in:
parent
5a6283c25d
commit
1d053a5e2b
6 changed files with 29 additions and 14 deletions
|
@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Controls
|
||||
{
|
||||
internal class RenderTargetControl : Panel
|
||||
public class RenderTargetControl : Panel
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public RenderTargetControl()
|
||||
internal RenderTargetControl()
|
||||
{
|
||||
// Initialize
|
||||
this.SetStyle(ControlStyles.FixedWidth, true);
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
General.MainWindow.RedrawDisplay();
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
||||
mousemappos = renderer2d.DisplayToMap(mousepos);
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
General.MainWindow.RedrawDisplay();
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
||||
mousemappos = renderer2d.DisplayToMap(mousepos);
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
mouseinside = true;
|
||||
mouselastpos = mousepos;
|
||||
mousepos = new Vector2D(e.X, e.Y);
|
||||
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
||||
mousemappos = renderer2d.DisplayToMap(mousepos);
|
||||
mousebuttons = e.Button;
|
||||
|
||||
// Update labels in main window
|
||||
|
@ -692,7 +692,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(mouseinside && !float.IsNaN(mouselastpos.x) && !float.IsNaN(mouselastpos.y))
|
||||
{
|
||||
// Get the map coordinates of the last mouse posision (before it moved)
|
||||
Vector2D lastmappos = renderer2d.GetMapCoordinates(mouselastpos);
|
||||
Vector2D lastmappos = renderer2d.DisplayToMap(mouselastpos);
|
||||
|
||||
// Do the scroll
|
||||
ScrollBy(lastmappos.x - mousemappos.x, lastmappos.y - mousemappos.y);
|
||||
|
|
|
@ -49,6 +49,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
int VertexSize { get; }
|
||||
ViewMode ViewMode { get; }
|
||||
|
||||
// View methods
|
||||
Vector2D DisplayToMap(Vector2D mousepos);
|
||||
Vector2D MapToDisplay(Vector2D mappos);
|
||||
|
||||
// Color methods
|
||||
PixelColor DetermineLinedefColor(Linedef l);
|
||||
PixelColor DetermineThingColor(Thing t);
|
||||
|
|
|
@ -546,12 +546,22 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
}
|
||||
|
||||
// This unprojects mouse coordinates into map coordinates
|
||||
public Vector2D GetMapCoordinates(Vector2D mousepos)
|
||||
/// <summary>
|
||||
/// This unprojects display coordinates (screen space) to map coordinates
|
||||
/// </summary>
|
||||
public Vector2D DisplayToMap(Vector2D mousepos)
|
||||
{
|
||||
return mousepos.GetInvTransformed(-translatex, -translatey, scaleinv, -scaleinv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This projects map coordinates to display coordinates (screen space)
|
||||
/// </summary>
|
||||
public Vector2D MapToDisplay(Vector2D mappos)
|
||||
{
|
||||
return mappos.GetTransformed(translatex, translatey, scale, -scale);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Colors
|
||||
|
@ -759,8 +769,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
backimageverts = CreateScreenVerts(windowsize);
|
||||
|
||||
// Determine map coordinates for view window
|
||||
ltpos = GetMapCoordinates(new Vector2D(0f, 0f));
|
||||
rbpos = GetMapCoordinates(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
ltpos = DisplayToMap(new Vector2D(0f, 0f));
|
||||
rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
|
||||
// Offset by given background offset
|
||||
ltpos -= backoffset;
|
||||
|
@ -828,8 +838,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if((size * scale) > 6f)
|
||||
{
|
||||
// Determine map coordinates for view window
|
||||
ltpos = GetMapCoordinates(new Vector2D(0, 0));
|
||||
rbpos = GetMapCoordinates(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
ltpos = DisplayToMap(new Vector2D(0, 0));
|
||||
rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
|
||||
// Clip to nearest grid
|
||||
ltpos = GridSetup.SnappedToGrid(ltpos, size, sizeinv);
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
bool MouseExclusive { get; }
|
||||
MouseButtons MouseButtons { get; }
|
||||
bool IsActiveWindow { get; }
|
||||
RenderTargetControl Display { get; }
|
||||
|
||||
// Methods
|
||||
void DisplayReady();
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
public bool AltState { get { return alt; } }
|
||||
public MouseButtons MouseButtons { get { return mousebuttons; } }
|
||||
public bool MouseInDisplay { get { return mouseinside; } }
|
||||
internal RenderTargetControl Display { get { return display; } }
|
||||
public RenderTargetControl Display { get { return display; } }
|
||||
public bool SnapToGrid { get { return buttonsnaptogrid.Checked; } }
|
||||
public bool AutoMerge { get { return buttonautomerge.Checked; } }
|
||||
public bool MouseExclusive { get { return mouseexclusive; } }
|
||||
|
|
Loading…
Reference in a new issue