Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room editor grid width/height fixes. #1014

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -42,9 +42,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