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