Added: minimum grid size is now 0.125 instead of 1.

This commit is contained in:
MaxED 2016-12-27 16:59:20 +03:00
parent e12130744d
commit be7ba0a05d
17 changed files with 115 additions and 68 deletions

View file

@ -1,16 +1,16 @@
**System requirements:**
- 2.4 GHz CPU or faster (multi-core recommended).
- Windows XP, Vista, 7, 8 or 10.
- Graphics card with Pixel Shader model 2.0 support.
- 2.4 GHz CPU or faster (multi-core recommended)
- Windows XP, Vista, 7, 8 or 10
- Graphics card with Pixel Shader model 2.0 support
**Required software:**
- Microsoft .Net Framework 3.5 (http://www.microsoft.com/download/en/details.aspx?id=25150).
- DirectX 9.0 Runtime (https://www.microsoft.com/en-us/download/details.aspx?id=35&44F86079-8679-400C-BFF2-9CA5F2BCBDFC=1).
- [Microsoft .Net Framework 3.5](http://www.microsoft.com/download/en/details.aspx?id=25150)
- [DirectX 9.0 Runtime](https://www.microsoft.com/en-us/download/details.aspx?id=35&44F86079-8679-400C-BFF2-9CA5F2BCBDFC=1)
**Links:**
- [Official thread at ZDoom.org](http://forum.zdoom.org/viewtopic.php?f=3&t=32392)
- [Unofficial thread at iddqd.ru (in russian)](http://i.iddqd.ru/viewtopic.php?t=522)
- [Unofficial thread at iddqd.ru](http://i.iddqd.ru/viewtopic.php?t=522) (in russian)
- [Git builds at DRDTeam.org](http://devbuilds.drdteam.org/doombuilder2-gzdb/)
More detailed info can be found in the **editor documentation** (Refmanual.chm).
More detailed info can be found in the **editor documentation** (Refmanual.chm)

View file

@ -304,7 +304,7 @@ namespace CodeImp.DoomBuilder.Editing
General.Map.Graphics.RenderTarget.ClientSize.Height);
Vector2D clientscale = clientsize / renderer2d.Scale;
int targetsize = (int)Math.Ceiling(Math.Min(clientscale.x, clientscale.y) / 32);
int targetsize = (int)Math.Ceiling(Math.Min(clientscale.x, clientscale.y) / 32) * 8;
// Convert to nearest power of 2
targetsize--;
@ -316,7 +316,7 @@ namespace CodeImp.DoomBuilder.Editing
targetsize++;
// Apply changes
General.Map.Grid.SetGridSize(targetsize);
General.Map.Grid.SetGridSize(targetsize / 8f);
}
// This zooms to a specific level

View file

@ -33,8 +33,9 @@ namespace CodeImp.DoomBuilder.Editing
{
#region ================== Constants
private const int DEFAULT_GRID_SIZE = 32;
private const int MINIMUM_GRID_SIZE = 1; //mxd
private const float DEFAULT_GRID_SIZE = 32f;
internal const float MINIMUM_GRID_SIZE_UDMF = 0.125f; //mxd
internal const float MINIMUM_GRID_SIZE = 1.0f; //mxd
public const int SOURCE_TEXTURES = 0;
public const int SOURCE_FLATS = 1;
@ -45,9 +46,9 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Grid
private int gridsize;
private float gridsizef;
private float gridsizefinv;
private int gridsizei;
private float gridsize;
private float gridsizeinv;
// Background
private string background = "";
@ -63,8 +64,8 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
public int GridSize { get { return gridsize; } }
public float GridSizeF { get { return gridsizef; } }
public int GridSizeI { get { return gridsizei; } } //mxd
public float GridSize { get { return gridsize; } }
internal string BackgroundName { get { return background; } }
internal int BackgroundSource { get { return backsource; } }
internal ImageData Background { get { return backimage; } }
@ -147,15 +148,15 @@ namespace CodeImp.DoomBuilder.Editing
}
// This sets the grid size
internal void SetGridSize(int size)
internal void SetGridSize(float size)
{
//mxd. Bad things happen when size <= 0
size = Math.Max(size, MINIMUM_GRID_SIZE);
size = Math.Max(size, ((General.Map != null && General.Map.UDMF) ? MINIMUM_GRID_SIZE_UDMF : MINIMUM_GRID_SIZE));
// Change grid
this.gridsize = size;
this.gridsizef = gridsize;
this.gridsizefinv = 1f / gridsizef;
gridsize = size;
gridsizei = (int)Math.Max(1, Math.Round(gridsize)); //mxd
gridsizeinv = 1f / gridsize;
// Update in main window
General.MainWindow.UpdateGrid(gridsize);
@ -213,19 +214,19 @@ namespace CodeImp.DoomBuilder.Editing
// This returns the next higher coordinate
public float GetHigher(float offset)
{
return (float)Math.Round((offset + (gridsizef * 0.5f)) * gridsizefinv) * gridsizef;
return (float)Math.Round((offset + (gridsize * 0.5f)) * gridsizeinv) * gridsize;
}
// This returns the next lower coordinate
public float GetLower(float offset)
{
return (float)Math.Round((offset - (gridsizef * 0.5f)) * gridsizefinv) * gridsizef;
return (float)Math.Round((offset - (gridsize * 0.5f)) * gridsizeinv) * gridsize;
}
// This snaps to the nearest grid coordinate
public Vector2D SnappedToGrid(Vector2D v)
{
return SnappedToGrid(v, gridsizef, gridsizefinv);
return SnappedToGrid(v, gridsize, gridsizeinv);
}
// This snaps to the nearest grid coordinate
@ -267,14 +268,15 @@ namespace CodeImp.DoomBuilder.Editing
[BeginAction("gridinc")]
internal void DecreaseGrid()
{
// Not lower than 1
if(gridsize >= 2)
//mxd. Not lower than 0.125 in UDMF or 1 otherwise
float preminsize = (General.Map.UDMF ? MINIMUM_GRID_SIZE_UDMF * 2 : MINIMUM_GRID_SIZE * 2);
if(gridsize >= preminsize)
{
//mxd. Disable automatic grid resizing
General.MainWindow.DisableDynamicGridResize();
// Change grid
SetGridSize(gridsize >> 1);
SetGridSize(gridsize / 2);
// Redraw display
General.MainWindow.RedrawDisplay();
@ -293,7 +295,7 @@ namespace CodeImp.DoomBuilder.Editing
General.MainWindow.DisableDynamicGridResize();
// Change grid
SetGridSize(gridsize << 1);
SetGridSize(gridsize * 2);
// Redraw display
General.MainWindow.RedrawDisplay();

View file

@ -936,7 +936,7 @@ namespace CodeImp.DoomBuilder.Map
float gx = General.Map.Grid.GetHigher(minx) + gridoffset.x;
if(gx < maxx)
{
for(; gx < maxx; gx += General.Map.Grid.GridSizeF)
for(; gx < maxx; gx += General.Map.Grid.GridSize)
{
// Add intersection point at this x coordinate
float u = (gx - minx) / (maxx - minx);
@ -951,7 +951,7 @@ namespace CodeImp.DoomBuilder.Map
float gy = General.Map.Grid.GetHigher(miny) + gridoffset.y;
if(gy < maxy)
{
for(; gy < maxy; gy += General.Map.Grid.GridSizeF)
for(; gy < maxy; gy += General.Map.Grid.GridSize)
{
// Add intersection point at this y coordinate
float u = (gy - miny) / (maxy - miny);

View file

@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.Rendering
private bool drawmapcenter = true; //mxd
private bool lastdrawmapcenter = true; //mxd
private float lastgridscale = -1f;
private int lastgridsize;
private float lastgridsize;
private float lastgridx;
private float lastgridy;
private RectangleF viewport;
@ -357,7 +357,7 @@ namespace CodeImp.DoomBuilder.Rendering
if(thingsvertices != null) thingsvertices.Dispose();
thingsvertices = null;
lastgridscale = -1f;
lastgridsize = 0;
lastgridsize = 0.0f;
}
// Allocates new image memory to render on
@ -413,7 +413,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Force update of view
lastgridscale = -1f;
lastgridsize = 0;
lastgridsize = 0.0f;
lastgridx = 0.0f;
lastgridy = 0.0f;
UpdateTransformations();

View file

@ -68,13 +68,14 @@ namespace CodeImp.DoomBuilder.Windows
//
// gridsize
//
this.gridsize.AllowDecimal = false;
this.gridsize.AllowDecimal = true;
this.gridsize.AllowExpressions = false;
this.gridsize.AllowNegative = false;
this.gridsize.AllowRelative = true;
this.gridsize.AllowRelative = false;
this.gridsize.ButtonStep = 8;
this.gridsize.ButtonStepBig = 10F;
this.gridsize.ButtonStepFloat = 1F;
this.gridsize.ButtonStepSmall = 0.1F;
this.gridsize.ButtonStepSmall = 0.25F;
this.gridsize.ButtonStepsUseModifierKeys = false;
this.gridsize.ButtonStepsWrapAround = false;
this.gridsize.Location = new System.Drawing.Point(146, 26);
@ -117,6 +118,7 @@ namespace CodeImp.DoomBuilder.Windows
// backscaley
//
this.backscaley.AllowDecimal = false;
this.backscaley.AllowExpressions = false;
this.backscaley.AllowNegative = false;
this.backscaley.AllowRelative = true;
this.backscaley.ButtonStep = 1;
@ -135,6 +137,7 @@ namespace CodeImp.DoomBuilder.Windows
// backscalex
//
this.backscalex.AllowDecimal = false;
this.backscalex.AllowExpressions = false;
this.backscalex.AllowNegative = false;
this.backscalex.AllowRelative = true;
this.backscalex.ButtonStep = 1;
@ -153,6 +156,7 @@ namespace CodeImp.DoomBuilder.Windows
// backoffsety
//
this.backoffsety.AllowDecimal = false;
this.backoffsety.AllowExpressions = false;
this.backoffsety.AllowNegative = true;
this.backoffsety.AllowRelative = true;
this.backoffsety.ButtonStep = 1;
@ -171,6 +175,7 @@ namespace CodeImp.DoomBuilder.Windows
// backoffsetx
//
this.backoffsetx.AllowDecimal = false;
this.backoffsetx.AllowExpressions = false;
this.backoffsetx.AllowNegative = true;
this.backoffsetx.AllowRelative = true;
this.backoffsetx.ButtonStep = 1;

View file

@ -141,7 +141,7 @@ namespace CodeImp.DoomBuilder.Windows
private void apply_Click(object sender, EventArgs e)
{
//mxd. Apply
int newgridsize = gridsize.GetResult(General.Map.Grid.GridSize);
float newgridsize = gridsize.GetResultFloat(General.Map.Grid.GridSize);
if(newgridsize != General.Map.Grid.GridSize)
{
//Disable automatic grid resizing

View file

@ -243,6 +243,9 @@ namespace CodeImp.DoomBuilder.Windows
this.itemgrid8 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgrid4 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgrid1 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgrid05 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgrid025 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgrid0125 = new System.Windows.Forms.ToolStripMenuItem();
this.itemgridcustom = new System.Windows.Forms.ToolStripMenuItem();
this.zoomlabel = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonzoom = new System.Windows.Forms.ToolStripDropDownButton();
@ -2228,7 +2231,7 @@ namespace CodeImp.DoomBuilder.Windows
this.gridlabel.AutoSize = false;
this.gridlabel.AutoToolTip = true;
this.gridlabel.Name = "gridlabel";
this.gridlabel.Size = new System.Drawing.Size(62, 18);
this.gridlabel.Size = new System.Drawing.Size(64, 18);
this.gridlabel.Text = "32 mp";
this.gridlabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.gridlabel.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
@ -2249,6 +2252,9 @@ namespace CodeImp.DoomBuilder.Windows
this.itemgrid8,
this.itemgrid4,
this.itemgrid1,
this.itemgrid05,
this.itemgrid025,
this.itemgrid0125,
toolStripMenuItem4,
this.itemgridcustom});
this.buttongrid.Image = global::CodeImp.DoomBuilder.Properties.Resources.Grid2_arrowup;
@ -2339,6 +2345,30 @@ namespace CodeImp.DoomBuilder.Windows
this.itemgrid1.Text = "1 mp";
this.itemgrid1.Click += new System.EventHandler(this.itemgridsize_Click);
//
// itemgrid05
//
this.itemgrid05.Name = "itemgrid05";
this.itemgrid05.Size = new System.Drawing.Size(153, 22);
this.itemgrid05.Tag = "0.5";
this.itemgrid05.Text = "0.5 mp";
this.itemgrid05.Click += new System.EventHandler(this.itemgridsize_Click);
//
// itemgrid025
//
this.itemgrid025.Name = "itemgrid025";
this.itemgrid025.Size = new System.Drawing.Size(153, 22);
this.itemgrid025.Tag = "0.25";
this.itemgrid025.Text = "0.25 mp";
this.itemgrid025.Click += new System.EventHandler(this.itemgridsize_Click);
//
// itemgrid0125
//
this.itemgrid0125.Name = "itemgrid0125";
this.itemgrid0125.Size = new System.Drawing.Size(153, 22);
this.itemgrid0125.Tag = "0.125";
this.itemgrid0125.Text = "0.125 mp";
this.itemgrid0125.Click += new System.EventHandler(this.itemgridsize_Click);
//
// itemgridcustom
//
this.itemgridcustom.Name = "itemgridcustom";
@ -2977,6 +3007,9 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.ToolStripMenuItem itemopenconfigfolder;
private System.Windows.Forms.ToolStripMenuItem itemopenmapincurwad;
private System.Windows.Forms.ToolStripMenuItem itemgrid1;
private System.Windows.Forms.ToolStripMenuItem itemgrid05;
private System.Windows.Forms.ToolStripMenuItem itemgrid025;
private System.Windows.Forms.ToolStripMenuItem itemgrid0125;
private System.Windows.Forms.ToolStripMenuItem itemzoom400;
private System.Windows.Forms.Label modename;
private System.Windows.Forms.ToolStripMenuItem itemautoclearsidetextures;

View file

@ -746,8 +746,15 @@ namespace CodeImp.DoomBuilder.Windows
zoomlabel.Enabled = true;
buttonzoom.Enabled = true;
gridlabel.Enabled = true;
itemgrid05.Visible = General.Map.UDMF; //mxd
itemgrid025.Visible = General.Map.UDMF; //mxd
itemgrid0125.Visible = General.Map.UDMF; //mxd
buttongrid.Enabled = true;
configlabel.Text = General.Map.Config.Name;
//mxd. Raise grid size to 1 if it was lower and the map isn't in UDMF
if(!General.Map.UDMF && General.Map.Grid.GridSize < GridSetup.MINIMUM_GRID_SIZE)
General.Map.Grid.SetGridSize(GridSetup.MINIMUM_GRID_SIZE);
}
else
{
@ -933,10 +940,10 @@ namespace CodeImp.DoomBuilder.Windows
}
// This changes grid display
internal void UpdateGrid(int gridsize)
internal void UpdateGrid(float gridsize)
{
// Update grid label
gridlabel.Text = (gridsize == 0 ? "--" : gridsize.ToString("###0") + " mp");
gridlabel.Text = (gridsize == 0 ? "--" : gridsize + " mp");
}
// Set grid to a specified size
@ -951,8 +958,8 @@ namespace CodeImp.DoomBuilder.Windows
ToolStripMenuItem item = sender as ToolStripMenuItem;
if(item != null)
{
// Get integral zoom level
int size = int.Parse(item.Tag.ToString(), CultureInfo.InvariantCulture);
//mxd. Get decimal zoom level
float size = float.Parse(item.Tag.ToString(), CultureInfo.InvariantCulture);
//mxd. Disable automatic grid resizing
DisableDynamicGridResize();

View file

@ -173,9 +173,9 @@ namespace CodeImp.DoomBuilder.Windows
posX.Text = ((int)ft.Position.x).ToString();
posY.Text = ((int)ft.Position.y).ToString();
posZ.Text = (useabsoluteheight ? ((int)Math.Round(ft.Position.z + floorheight)).ToString() : ((int)ft.Position.z).ToString());
posX.ButtonStep = General.Map.Grid.GridSize;
posY.ButtonStep = General.Map.Grid.GridSize;
posZ.ButtonStep = General.Map.Grid.GridSize;
posX.ButtonStep = General.Map.Grid.GridSizeI;
posY.ButtonStep = General.Map.Grid.GridSizeI;
posZ.ButtonStep = General.Map.Grid.GridSizeI;
//mxd
thinginfo = General.Map.Data.GetThingInfoEx(ft.Type);

View file

@ -197,9 +197,9 @@ namespace CodeImp.DoomBuilder.Windows
posX.Text = (ft.Position.x).ToString();
posY.Text = (ft.Position.y).ToString();
posZ.Text = (useabsoluteheight ? ((float)Math.Round(ft.Position.z + floorheight, General.Map.FormatInterface.VertexDecimals)).ToString() : (ft.Position.z).ToString());
posX.ButtonStep = General.Map.Grid.GridSize;
posY.ButtonStep = General.Map.Grid.GridSize;
posZ.ButtonStep = General.Map.Grid.GridSize;
posX.ButtonStep = General.Map.Grid.GridSizeI;
posY.ButtonStep = General.Map.Grid.GridSizeI;
posZ.ButtonStep = General.Map.Grid.GridSizeI;
//mxd. User vars. Should be done before adding regular fields
ThingTypeInfo fti = General.Map.Data.GetThingInfoEx(ft.Type);

View file

@ -282,7 +282,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(points.Count < 2 || currentbevelwidth == bevelwidth || bevelwidth < 0)
{
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSize, panel.MaxSpikiness);
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSizeI, panel.MaxSpikiness);
panel.Spikiness = bevelwidth;
Update();
}
@ -292,7 +292,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(bevelwidth > 0 || currentbevelwidth <= bevelwidth + 1)
{
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSize, panel.MinSpikiness);
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSizeI, panel.MinSpikiness);
panel.Spikiness = bevelwidth;
Update();
}

View file

@ -353,18 +353,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
break;
case GridLockMode.HORIZONTAL:
slicesH = width / General.Map.Grid.GridSize;
slicesH = width / General.Map.Grid.GridSizeI;
slicesV = verticalslices;
break;
case GridLockMode.VERTICAL:
slicesH = horizontalslices;
slicesV = height / General.Map.Grid.GridSize;
slicesV = height / General.Map.Grid.GridSizeI;
break;
case GridLockMode.BOTH:
slicesH = width / General.Map.Grid.GridSize;
slicesV = height / General.Map.Grid.GridSize;
slicesH = width / General.Map.Grid.GridSizeI;
slicesV = height / General.Map.Grid.GridSizeI;
break;
}

View file

@ -515,7 +515,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(points.Count < 2 || currentbevelwidth == bevelwidth || bevelwidth < 0)
{
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSize, panel.MaxBevelWidth);
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSizeI, panel.MaxBevelWidth);
panel.BevelWidth = bevelwidth;
Update();
}
@ -526,7 +526,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(currentbevelwidth == bevelwidth || bevelwidth > 0)
{
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSize, panel.MinBevelWidth);
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSizeI, panel.MinBevelWidth);
panel.BevelWidth = bevelwidth;
Update();
}

View file

@ -191,9 +191,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
deltax = prevoffsetx - newoffsetx;
deltay = prevoffsety - newoffsety;
if(Math.Abs(deltax) >= General.Map.Grid.GridSize)
if(Math.Abs(deltax) >= General.Map.Grid.GridSizeI)
{
deltax = General.Map.Grid.GridSize * Math.Sign(deltax);
deltax = General.Map.Grid.GridSizeI * Math.Sign(deltax);
prevoffsetx = newoffsetx;
}
else
@ -201,9 +201,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
deltax = 0;
}
if(Math.Abs(deltay) >= General.Map.Grid.GridSize)
if(Math.Abs(deltay) >= General.Map.Grid.GridSizeI)
{
deltay = General.Map.Grid.GridSize * Math.Sign(deltay);
deltay = General.Map.Grid.GridSizeI * Math.Sign(deltay);
prevoffsety = newoffsety;
}
else

View file

@ -1359,9 +1359,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
int dx = prevoffsetx - newoffsetx;
int dy = prevoffsety - newoffsety;
if(Math.Abs(dx) >= General.Map.Grid.GridSize)
if(Math.Abs(dx) >= General.Map.Grid.GridSizeI)
{
dx = General.Map.Grid.GridSize * Math.Sign(dx);
dx = General.Map.Grid.GridSizeI * Math.Sign(dx);
prevoffsetx = newoffsetx;
}
else
@ -1369,9 +1369,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
dx = 0;
}
if(Math.Abs(dy) >= General.Map.Grid.GridSize)
if(Math.Abs(dy) >= General.Map.Grid.GridSizeI)
{
dy = General.Map.Grid.GridSize * Math.Sign(dy);
dy = General.Map.Grid.GridSizeI * Math.Sign(dy);
prevoffsety = newoffsety;
}
else

View file

@ -2665,10 +2665,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
[BeginAction("movetextureright8")] public void MoveTextureRight8() { MoveTextureByOffset(8, 0); }
[BeginAction("movetextureup8")] public void MoveTextureUp8() { MoveTextureByOffset(0, -8); }
[BeginAction("movetexturedown8")] public void MoveTextureDown8() { MoveTextureByOffset(0, 8); }
[BeginAction("movetextureleftgs")] public void MoveTextureLeftGrid() { MoveTextureByOffset(-General.Map.Grid.GridSize, 0); } //mxd
[BeginAction("movetexturerightgs")] public void MoveTextureRightGrid() { MoveTextureByOffset(General.Map.Grid.GridSize, 0); } //mxd
[BeginAction("movetextureupgs")] public void MoveTextureUpGrid() { MoveTextureByOffset(0, -General.Map.Grid.GridSize); } //mxd
[BeginAction("movetexturedowngs")] public void MoveTextureDownGrid() { MoveTextureByOffset(0, General.Map.Grid.GridSize); } //mxd
[BeginAction("movetextureleftgs")] public void MoveTextureLeftGrid() { MoveTextureByOffset(-General.Map.Grid.GridSizeI, 0); } //mxd
[BeginAction("movetexturerightgs")] public void MoveTextureRightGrid() { MoveTextureByOffset(General.Map.Grid.GridSizeI, 0); } //mxd
[BeginAction("movetextureupgs")] public void MoveTextureUpGrid() { MoveTextureByOffset(0, -General.Map.Grid.GridSizeI); } //mxd
[BeginAction("movetexturedowngs")] public void MoveTextureDownGrid() { MoveTextureByOffset(0, General.Map.Grid.GridSizeI); } //mxd
//mxd
private void MoveTextureByOffset(int ox, int oy)