Fixed, Classic modes, UDMF: grid size didn't go below 1 mu. when zooming in when "Dynamic grid size" option was enabled.

Internal: restored GridSetup DB2 compatibility.
Updated ZDoom_ACS.cfg (SetFogDensity, SetSectorGlow).
This commit is contained in:
MaxED 2017-01-06 13:01:59 +03:00
parent bd74d1d35e
commit cd854779e8
17 changed files with 66 additions and 61 deletions

View file

@ -367,6 +367,7 @@ keywords
SetCVar = "bool SetCVar(str cvar, int value)\nSets the value of a particular console variable.\nOnly mod-defined console variables through CVARINFO can be changed by using this function.\nReturns FALSE if cvar is invalid, or it is not writable.";
SetCVarString = "bool SetCVarString(str cvar, str value)\nSets the value of a particular console variable.\nOnly mod-defined console variables through CVARINFO can be changed by using this function.\nReturns FALSE if cvar is invalid, or it is not writable.";
SetFloorTrigger = "SetFloorTrigger(tag, height, special, arg1, arg2, arg3, arg4, arg5)";
SetFogDensity = "void SetFogDensity(int tag, int density)";
SetFont = "void SetFont(str fontlump)\nSets the current font (only within the script) to fontlump";
SetGlobalFogParameter = "SetGlobalFogParameter(property, value)";
SetGravity = "void SetGravity(fixed amount)\nThis function sets the global gravity of an entire level.\nDefault is 800.0";
@ -387,6 +388,7 @@ keywords
SetPointer = "bool SetPointer(int assign_slot, int tid[, int pointer_selector[, int flags]])\nSet the value of one of the caller's stored pointers.";
SetResultValue = "void SetResultValue(int value)";
SetSectorDamage = "fixed SetSectorDamage(int tag, int amount, str damagetype, int interval, int leaky)";
SetSectorGlow = "void SetSectorGlow(int tag, int ceiling, int r, int g, int b, int height)";
SetSectorTerrain = "fixed SetSectorTerrain(int tag, int plane, str terraintype)";
SetSkyScrollSpeed = "void SetSkyScrollSpeed(int sky, fixed skyspeed)\nChanges the scrolling speed of a sky.\nThis is useful in conjunction with ChangeSky.\nsky: either 1 or 2.\nskyspeed: the desired scrolling speed.";
SetThingSpecial = "void SetThingSpecial(int tid, int special[, int arg0[, int arg1[, int arg2[, int arg3[, int arg4]]]]])\nSets the special for any things with the same TID.\nThis is similar to Thing_SetSpecial, except it can only be used from ACS,\nand it can set all of a thing's special arguments.\nIf tid is 0, then the activator is used.";

View file

@ -304,7 +304,9 @@ 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) * 8;
// Aim for 32 grid lines on screen, multiplied by 8 to support integer representation of 0.125 grid size (clientscale / 32 * 8)
int targetsize = (int)Math.Ceiling(Math.Min(clientscale.x, clientscale.y) / 4);
// Convert to nearest power of 2
targetsize--;

View file

@ -46,9 +46,9 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Grid
private int gridsizei;
private float gridsize;
private float gridsizeinv;
private int gridsize;
private float gridsizef;
private float gridsizefinv;
// Background
private string background = "";
@ -64,8 +64,8 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
public int GridSizeI { get { return gridsizei; } } //mxd
public float GridSize { get { return gridsize; } }
public int GridSize { get { return gridsize; } } //mxd
public float GridSizeF { get { return gridsizef; } }
internal string BackgroundName { get { return background; } }
internal int BackgroundSource { get { return backsource; } }
internal ImageData Background { get { return backimage; } }
@ -127,7 +127,7 @@ namespace CodeImp.DoomBuilder.Editing
cfg.WriteSetting(path + ".backoffsety", backoffsety);
cfg.WriteSetting(path + ".backscalex", (int)(backscalex * 100.0f));
cfg.WriteSetting(path + ".backscaley", (int)(backscaley * 100.0f));
cfg.WriteSetting(path + ".gridsize", gridsize);
cfg.WriteSetting(path + ".gridsize", gridsizef);
}
// Read settings from configuration
@ -140,10 +140,10 @@ namespace CodeImp.DoomBuilder.Editing
backoffsety = cfg.ReadSetting(path + ".backoffsety", 0);
backscalex = cfg.ReadSetting(path + ".backscalex", 100) / 100.0f;
backscaley = cfg.ReadSetting(path + ".backscaley", 100) / 100.0f;
gridsize = cfg.ReadSetting(path + ".gridsize", DEFAULT_GRID_SIZE);
gridsizef = cfg.ReadSetting(path + ".gridsize", DEFAULT_GRID_SIZE);
// Setup
SetGridSize(gridsize);
SetGridSize(gridsizef);
LinkBackground();
}
@ -154,12 +154,12 @@ namespace CodeImp.DoomBuilder.Editing
size = Math.Max(size, ((General.Map != null && General.Map.UDMF) ? MINIMUM_GRID_SIZE_UDMF : MINIMUM_GRID_SIZE));
// Change grid
gridsize = size;
gridsizei = (int)Math.Max(1, Math.Round(gridsize)); //mxd
gridsizeinv = 1f / gridsize;
gridsizef = size;
gridsize = (int)Math.Max(1, Math.Round(gridsizef)); //mxd
gridsizefinv = 1f / gridsizef;
// Update in main window
General.MainWindow.UpdateGrid(gridsize);
General.MainWindow.UpdateGrid(gridsizef);
}
// This sets the background
@ -214,19 +214,19 @@ namespace CodeImp.DoomBuilder.Editing
// This returns the next higher coordinate
public float GetHigher(float offset)
{
return (float)Math.Round((offset + (gridsize * 0.5f)) * gridsizeinv) * gridsize;
return (float)Math.Round((offset + (gridsizef * 0.5f)) * gridsizefinv) * gridsizef;
}
// This returns the next lower coordinate
public float GetLower(float offset)
{
return (float)Math.Round((offset - (gridsize * 0.5f)) * gridsizeinv) * gridsize;
return (float)Math.Round((offset - (gridsizef * 0.5f)) * gridsizefinv) * gridsizef;
}
// This snaps to the nearest grid coordinate
public Vector2D SnappedToGrid(Vector2D v)
{
return SnappedToGrid(v, gridsize, gridsizeinv);
return SnappedToGrid(v, gridsizef, gridsizefinv);
}
// This snaps to the nearest grid coordinate
@ -270,13 +270,13 @@ namespace CodeImp.DoomBuilder.Editing
{
//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)
if(gridsizef >= preminsize)
{
//mxd. Disable automatic grid resizing
General.MainWindow.DisableDynamicGridResize();
// Change grid
SetGridSize(gridsize / 2);
SetGridSize(gridsizef / 2);
// Redraw display
General.MainWindow.RedrawDisplay();
@ -289,13 +289,13 @@ namespace CodeImp.DoomBuilder.Editing
internal void IncreaseGrid()
{
// Not higher than 1024
if(gridsize <= 512)
if(gridsizef <= 512)
{
//mxd. Disable automatic grid resizing
General.MainWindow.DisableDynamicGridResize();
// Change grid
SetGridSize(gridsize * 2);
SetGridSize(gridsizef * 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.GridSize)
for(; gx < maxx; gx += General.Map.Grid.GridSizeF)
{
// 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.GridSize)
for(; gy < maxy; gy += General.Map.Grid.GridSizeF)
{
// Add intersection point at this y coordinate
float u = (gy - miny) / (maxy - miny);

View file

@ -813,7 +813,7 @@ namespace CodeImp.DoomBuilder.Rendering
private unsafe void RenderBackgroundGrid()
{
// Do we need to redraw grid?
if(lastgridsize != General.Map.Grid.GridSize || lastgridscale != scale ||
if(lastgridsize != General.Map.Grid.GridSizeF || lastgridscale != scale ||
lastgridx != offsetx || lastgridy != offsety || drawmapcenter != lastdrawmapcenter)
{
// Lock background rendertarget memory
@ -826,10 +826,10 @@ namespace CodeImp.DoomBuilder.Rendering
if(General.Settings.RenderGrid) //mxd
{
// Render normal grid
RenderGrid(General.Map.Grid.GridSize, General.Colors.Grid, gridplotter);
RenderGrid(General.Map.Grid.GridSizeF, General.Colors.Grid, gridplotter);
// Render 64 grid
if(General.Map.Grid.GridSize <= 64) RenderGrid(64f, General.Colors.Grid64, gridplotter);
if(General.Map.Grid.GridSizeF <= 64) RenderGrid(64f, General.Colors.Grid64, gridplotter);
}
else
{
@ -858,7 +858,7 @@ namespace CodeImp.DoomBuilder.Rendering
backtex.UnlockRectangle(0);
lockedrect.Data.Dispose();
lastgridscale = scale;
lastgridsize = General.Map.Grid.GridSize;
lastgridsize = General.Map.Grid.GridSizeF;
lastgridx = offsetx;
lastgridy = offsety;
lastdrawmapcenter = drawmapcenter; //mxd

View file

@ -438,25 +438,25 @@ namespace CodeImp.DoomBuilder.VisualModes
[BeginAction("movethingleft", BaseAction = true)]
protected void MoveSelectedThingsLeft()
{
MoveSelectedThings(new Vector2D(0f, -General.Map.Grid.GridSize), false);
MoveSelectedThings(new Vector2D(0f, -General.Map.Grid.GridSizeF), false);
}
//mxd
[BeginAction("movethingright", BaseAction = true)]
protected void MoveSelectedThingsRight()
{
MoveSelectedThings(new Vector2D(0f, General.Map.Grid.GridSize), false);
MoveSelectedThings(new Vector2D(0f, General.Map.Grid.GridSizeF), false);
}
//mxd
[BeginAction("movethingfwd", BaseAction = true)]
protected void MoveSelectedThingsForward()
{
MoveSelectedThings(new Vector2D(-General.Map.Grid.GridSize, 0f), false);
MoveSelectedThings(new Vector2D(-General.Map.Grid.GridSizeF, 0f), false);
}
//mxd
[BeginAction("movethingback", BaseAction = true)]
protected void MoveSelectedThingsBackward()
{
MoveSelectedThings(new Vector2D(General.Map.Grid.GridSize, 0f), false);
MoveSelectedThings(new Vector2D(General.Map.Grid.GridSizeF, 0f), false);
}
//mxd

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.Windows
InitializeComponent();
// Show grid size
gridsize.Text = General.Map.Grid.GridSize.ToString();
gridsize.Text = General.Map.Grid.GridSizeF.ToString();
// Background image?
if((General.Map.Grid.Background != null) &&
@ -141,8 +141,8 @@ namespace CodeImp.DoomBuilder.Windows
private void apply_Click(object sender, EventArgs e)
{
//mxd. Apply
float newgridsize = gridsize.GetResultFloat(General.Map.Grid.GridSize);
if(newgridsize != General.Map.Grid.GridSize)
float newgridsize = gridsize.GetResultFloat(General.Map.Grid.GridSizeF);
if(newgridsize != General.Map.Grid.GridSizeF)
{
//Disable automatic grid resizing
General.MainWindow.DisableDynamicGridResize();

View file

@ -753,7 +753,7 @@ namespace CodeImp.DoomBuilder.Windows
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)
if(!General.Map.UDMF && General.Map.Grid.GridSizeF < GridSetup.MINIMUM_GRID_SIZE)
General.Map.Grid.SetGridSize(GridSetup.MINIMUM_GRID_SIZE);
}
else

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.GridSizeI;
posY.ButtonStep = General.Map.Grid.GridSizeI;
posZ.ButtonStep = General.Map.Grid.GridSizeI;
posX.ButtonStep = General.Map.Grid.GridSize;
posY.ButtonStep = General.Map.Grid.GridSize;
posZ.ButtonStep = General.Map.Grid.GridSize;
//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.GridSizeI;
posY.ButtonStep = General.Map.Grid.GridSizeI;
posZ.ButtonStep = General.Map.Grid.GridSizeI;
posX.ButtonStep = General.Map.Grid.GridSize;
posY.ButtonStep = General.Map.Grid.GridSize;
posZ.ButtonStep = General.Map.Grid.GridSize;
//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.GridSizeI, panel.MaxSpikiness);
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSize, 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.GridSizeI, panel.MinSpikiness);
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSize, 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.GridSizeI;
slicesH = width / General.Map.Grid.GridSize;
slicesV = verticalslices;
break;
case GridLockMode.VERTICAL:
slicesH = horizontalslices;
slicesV = height / General.Map.Grid.GridSizeI;
slicesV = height / General.Map.Grid.GridSize;
break;
case GridLockMode.BOTH:
slicesH = width / General.Map.Grid.GridSizeI;
slicesV = height / General.Map.Grid.GridSizeI;
slicesH = width / General.Map.Grid.GridSize;
slicesV = height / General.Map.Grid.GridSize;
break;
}
@ -444,7 +444,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Triangulate?
if(triangulate)
{
bool startflip = ((int)Math.Round(((s.x + e.y) / General.Map.Grid.GridSize) % 2) == 0);
bool startflip = ((int)Math.Round(((s.x + e.y) / General.Map.Grid.GridSizeF) % 2) == 0);
bool flip = startflip;
for(int w = 0; w < slicesH; w++)

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.GridSizeI, panel.MaxBevelWidth);
bevelwidth = Math.Min(bevelwidth + General.Map.Grid.GridSize, 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.GridSizeI, panel.MinBevelWidth);
bevelwidth = Math.Max(bevelwidth - General.Map.Grid.GridSize, 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.GridSizeI)
if(Math.Abs(deltax) >= General.Map.Grid.GridSize)
{
deltax = General.Map.Grid.GridSizeI * Math.Sign(deltax);
deltax = General.Map.Grid.GridSize * Math.Sign(deltax);
prevoffsetx = newoffsetx;
}
else
@ -201,9 +201,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
deltax = 0;
}
if(Math.Abs(deltay) >= General.Map.Grid.GridSizeI)
if(Math.Abs(deltay) >= General.Map.Grid.GridSize)
{
deltay = General.Map.Grid.GridSizeI * Math.Sign(deltay);
deltay = General.Map.Grid.GridSize * 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.GridSizeI)
if(Math.Abs(dx) >= General.Map.Grid.GridSize)
{
dx = General.Map.Grid.GridSizeI * Math.Sign(dx);
dx = General.Map.Grid.GridSize * Math.Sign(dx);
prevoffsetx = newoffsetx;
}
else
@ -1369,9 +1369,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
dx = 0;
}
if(Math.Abs(dy) >= General.Map.Grid.GridSizeI)
if(Math.Abs(dy) >= General.Map.Grid.GridSize)
{
dy = General.Map.Grid.GridSizeI * Math.Sign(dy);
dy = General.Map.Grid.GridSize * 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.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
[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
//mxd
private void MoveTextureByOffset(int ox, int oy)

View file

@ -145,6 +145,7 @@
<None Include="Resources\LinesMode.png" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
<None Include="Resources\SectorsMode.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />