Skip to content

Commit

Permalink
Merge pull request #1014 from VladiStep/roomGridFieldsLimit
Browse files Browse the repository at this point in the history
Room editor grid width/height fixes.
  • Loading branch information
Grossley committed Jun 28, 2022
2 parents f58f510 + 8eca21f commit 8b83639
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions UndertaleModLib/Models/UndertaleRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public enum RoomEntryFlags : uint
public uint Right { get; set; } = 1024;
public uint Bottom { get; set; } = 768;

private double _gridWidth = 16.0;
private double _gridHeight = 16.0;

/// <summary>
/// The gravity towards x axis using room physics in m/s.
/// </summary>
Expand All @@ -119,12 +122,12 @@ public enum RoomEntryFlags : uint
/// <summary>
/// The width of the room grid in pixels.
/// </summary>
public double GridWidth { get; set; } = 16d;
public double GridWidth { get => _gridWidth; set { if (value >= 0) _gridWidth = value; } }

/// <summary>
/// The height of the room grid in pixels.
/// </summary>
public double GridHeight { get; set; } = 16d;
public double GridHeight { get => _gridHeight; set { if (value >= 0) _gridHeight = value; } }

/// <summary>
/// The thickness of the room grid in pixels.
Expand Down Expand Up @@ -416,8 +419,10 @@ public void SetupRoom(bool calculateGridWidth = true, bool calculateGridHeight =

if (tileSizes.Count <= 0)
{
GridWidth = 16;
GridHeight = 16;
if (calculateGridWidth)
GridWidth = 16;
if (calculateGridHeight)
GridHeight = 16;
return;
}

Expand Down
6 changes: 4 additions & 2 deletions UndertaleModTool/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public class Settings
public bool DeleteOldProfileOnSave { get; set; } = false;
public bool WarnOnClose { get; set; } = true;

public double GlobalGridWidth { get; set; } = 20;
private double _globalGridWidth = 20;
private double _globalGridHeight = 20;
public double GlobalGridWidth { get => _globalGridWidth; set { if (value >= 0) _globalGridWidth = value; } }
public bool GridWidthEnabled { get; set; } = false;
public double GlobalGridHeight { get; set; } = 20;
public double GlobalGridHeight { get => _globalGridHeight; set { if (value >= 0) _globalGridHeight = value; } }
public bool GridHeightEnabled { get; set; } = false;

public double GlobalGridThickness { get; set; } = 1;
Expand Down

0 comments on commit 8b83639

Please sign in to comment.