Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryMarkle committed Jun 17, 2024
1 parent bbbc716 commit b6611d5
Show file tree
Hide file tree
Showing 15 changed files with 413 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v0.9.93-2
release_name: Release v0.9.93-3
body: ${{ steps.read_release_notes.outputs.notes }}
draft: false
prerelease: false
Expand Down
2 changes: 1 addition & 1 deletion Leditor/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ internal static string AssetsDirectory {

internal static System.Timers.Timer AutoSaveTimer = new(30_000);

internal const string Version = "Henry's Leditor v0.9.93-2";
internal const string Version = "Henry's Leditor v0.9.93-3";
internal const string RaylibVersion = "Raylib v5.0.0";
internal static string BuildConfiguration { get; set; } = "Build Configuration: Unknown";
internal static string OperatingSystem { get; set; } = "Operating System: Unknown";
Expand Down
12 changes: 6 additions & 6 deletions Leditor/Gram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class GeoGram(int limit)
{
public interface IAction;

public record CellAction(Coords Position, RunCell Previous, RunCell Next) : IAction;
public record CellAction(Coords Position, GeoCell Previous, GeoCell Next) : IAction;

public record RectAction(Coords Position, RunCell[,] Previous, RunCell[,] Next, bool FillAir = true) : IAction;
public record RectAction(Coords Position, GeoCell[,] Previous, GeoCell[,] Next, bool FillAir = true) : IAction;

public record GroupAction(CellAction[] CellActions) : IAction
{
Expand All @@ -42,7 +42,7 @@ public record GroupAction(CellAction[] CellActions) : IAction

public IAction? Current => _currentNode?.Value;

public void Proceed(Coords position, RunCell previous, RunCell current)
public void Proceed(Coords position, GeoCell previous, GeoCell current)
{
if (_currentNode?.Next is not null)
{
Expand All @@ -59,7 +59,7 @@ public void Proceed(Coords position, RunCell previous, RunCell current)
if (Actions.Count == limit) Actions.RemoveFirst();
}

public void Proceed(Coords position, RunCell[,] previous, RunCell[,] current, bool fillAir = true)
public void Proceed(Coords position, GeoCell[,] previous, GeoCell[,] current, bool fillAir = true)
{
if (_currentNode?.Next is not null)
{
Expand Down Expand Up @@ -176,8 +176,8 @@ public void Undo()

public record struct TileAction(Coords Position, TileCell Old, TileCell New) : ISingleMatrixAction<TileCell>;

public record struct TileGeoAction(Coords Position, (TileCell, RunCell) Old, (TileCell, RunCell) New)
: ISingleMatrixAction<(TileCell, RunCell)>;
public record struct TileGeoAction(Coords Position, (TileCell, GeoCell) Old, (TileCell, GeoCell) New)
: ISingleMatrixAction<(TileCell, GeoCell)>;
public record struct GroupAction<TG>(IEnumerable<ISingleAction<TG>> Actions) : IGroupAction<TG>;

}
Expand Down
198 changes: 128 additions & 70 deletions Leditor/Pages/Dimensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public override void Dispose()
private Vector2 _bottomSideLeft = Vector2.Zero;
private Vector2 _bottomSideRight = Vector2.Zero;

private Vector2 _prevFirst;
private Vector2 _prevSecond;

private void ResetSides() {
var size = new Vector2(GLOBALS.Level.Width, GLOBALS.Level.Height) * 20;

Expand Down Expand Up @@ -171,58 +174,81 @@ public override void Draw()

const int colThres = 5;

// Left Side
if (CheckCollisionPointLine(
worldMouse,
_leftSideTop,
_leftSideBottom,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeEw);
_resizing = Resizing.Left;

if (IsMouseButtonDown(MouseButton.Left)) _resizeLock = 1;
}
// Top Side
else if (CheckCollisionPointLine(
worldMouse,
_topSideLeft,
_topSideRight,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeNs);
_resizing = Resizing.Top;
if (_resizeLock == 0) {

if (IsMouseButtonDown(MouseButton.Left)) _resizeLock = 2;
}
// Right Side
else if (CheckCollisionPointLine(
worldMouse,
_rightSideTop,
_rightSideBottom,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeEw);
_resizing = Resizing.Right;

if (IsMouseButtonDown(MouseButton.Left)) _resizeLock = 3;
}
// Bottom Side
else if (CheckCollisionPointLine(
worldMouse,
_bottomSideLeft,
_bottomSideRight,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeNs);
_resizing = Resizing.Bottom;

if (IsMouseButtonDown(MouseButton.Left)) _resizeLock = 4;
}
// Else
else if (_resizeLock == 0) {
SetMouseCursor(MouseCursor.Default);
_resizing = Resizing.None;
// Left Side
if (CheckCollisionPointLine(
worldMouse,
_leftSideTop,
_leftSideBottom,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeEw);
_resizing = Resizing.Left;

if (IsMouseButtonDown(MouseButton.Left)) {
_resizeLock = 1;

_prevFirst = _leftSideTop;
_prevSecond = _leftSideBottom;
}
}
// Top Side
else if (CheckCollisionPointLine(
worldMouse,
_topSideLeft,
_topSideRight,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeNs);
_resizing = Resizing.Top;

if (IsMouseButtonDown(MouseButton.Left)) {
_resizeLock = 2;

_prevFirst = _topSideLeft;
_prevSecond = _topSideRight;
}
}
// Right Side
else if (CheckCollisionPointLine(
worldMouse,
_rightSideTop,
_rightSideBottom,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeEw);
_resizing = Resizing.Right;

if (IsMouseButtonDown(MouseButton.Left)) {
_resizeLock = 3;

_prevFirst = _rightSideTop;
_prevSecond = _rightSideBottom;
}
}
// Bottom Side
else if (CheckCollisionPointLine(
worldMouse,
_bottomSideLeft,
_bottomSideRight,
colThres
)) {
SetMouseCursor(MouseCursor.ResizeNs);
_resizing = Resizing.Bottom;

if (IsMouseButtonDown(MouseButton.Left)) {
_resizeLock = 4;

_prevFirst = _bottomSideLeft;
_prevSecond = _bottomSideRight;
}
}
// Else
else {
SetMouseCursor(MouseCursor.Default);
_resizing = Resizing.None;
}
}

// Resizing
Expand Down Expand Up @@ -252,31 +278,63 @@ public override void Draw()

// Apply Resize
if (IsMouseButtonReleased(MouseButton.Left) && _resizeLock != 0) {
_resizeLock = 0;
var left = (int)(_levelOrigin.X -_leftSideTop.X)/20;
var top = (int)(_levelOrigin.Y - _topSideLeft.Y)/20;
var right = (int)_rightSideTop.X/20 - (int)(_levelOrigin.X/20 + GLOBALS.Level.Width);
var bottom = (int)_bottomSideRight.Y/20 - (int)(_levelOrigin.Y/20 + GLOBALS.Level.Height);

if (_leftSideTop.X == _rightSideTop.X || _topSideLeft.Y == _bottomSideLeft.Y) {

switch (_resizeLock) {
case 1: // Left
_leftSideTop = _prevFirst;
_leftSideBottom = _prevSecond;
break;

case 2: // Top
_topSideLeft = _prevFirst;
_topSideRight = _prevSecond;
break;

case 3: // Right
_rightSideTop = _prevFirst;
_rightSideBottom = _prevSecond;
break;

case 4: // Bottom
_bottomSideLeft = _prevFirst;
_bottomSideRight = _prevSecond;
break;
}

} else {

GLOBALS.Level.Resize(
(int)(_levelOrigin.X -_leftSideTop.X)/20,
(int)(_levelOrigin.Y - _topSideLeft.Y)/20,
(int)_rightSideTop.X/20 - (int)(_levelOrigin.X/20 + GLOBALS.Level.Width),
(int)_bottomSideRight.Y/20 - (int)(_levelOrigin.Y/20 + GLOBALS.Level.Height),
_fillLayer1 ? new RunCell(1) : new RunCell(0),
_fillLayer2 ? new RunCell(1) : new RunCell(0),
_fillLayer3 ? new RunCell(1) : new RunCell(0)
);
GLOBALS.Level.Resize(
left,
top,
right,
bottom,
_fillLayer1 ? new GeoCell(1) : new GeoCell(0),
_fillLayer2 ? new GeoCell(1) : new GeoCell(0),
_fillLayer3 ? new GeoCell(1) : new GeoCell(0)
);

ResizeLightMap(
_levelOrigin - new Vector2(_leftSideTop.X, _topSideLeft.Y),
GLOBALS.Level.Width,
GLOBALS.Level.Height
);
ResizeLightMap(
_levelOrigin - new Vector2(_leftSideTop.X, _topSideLeft.Y),
GLOBALS.Level.Width,
GLOBALS.Level.Height
);

_levelOrigin = _leftSideTop;
_levelOrigin = _leftSideTop;

UnloadRenderTexture(GLOBALS.Textures.GeneralLevel);
GLOBALS.Textures.GeneralLevel =
LoadRenderTexture(GLOBALS.Level.Width * 20, GLOBALS.Level.Height * 20);
UnloadRenderTexture(GLOBALS.Textures.GeneralLevel);

GLOBALS.Textures.GeneralLevel = LoadRenderTexture(GLOBALS.Level.Width * 20, GLOBALS.Level.Height * 20);
}

_shouldRedrawLevel = true;

_resizeLock = 0;
}
}
#endregion
Expand Down
Loading

0 comments on commit b6611d5

Please sign in to comment.