Skip to content

Commit

Permalink
Fix annoying mirror bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantornRU committed Oct 3, 2024
1 parent c654745 commit d5a6b2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
22 changes: 5 additions & 17 deletions Controllers/DrawController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public static void SetStoragePoints()
foreach (var stateDirection in stateDirections)
{
if (pointsStorage.ContainsKey(stateDirection) == false) continue;
Point[] points = GetStoragePoints(stateDirection);

WriteableBitmap bitmapPreview = EnvironmentController.GetPreviewBMP(stateDirection, StateImageSideType.Left);
WriteableBitmap bitmapOverlayPreview = EnvironmentController.GetOverlayBMP(stateDirection, StateImageSideType.Left);
Expand All @@ -148,18 +147,14 @@ public static void SetStoragePoints()

foreach (var point in pointsStorage[stateDirection])
{
//var tempPoint = CorrectMousePositionPoint(stateDirection, point.Key, cellsSize);
//var storagePoint = point.Value;

// Pixel Shift
Point tempPoint = CorrectMousePositionPoint(stateDirection, point.Key, cellsSize);

// Storage Pixel
Point selectedPoint = new Point(tempPoint.X + pointOffset.X, tempPoint.Y + pointOffset.Y);
selectedPoint = CorrectMousePositionPoint(stateDirection, selectedPoint, cellsSize);

Point storagePoint = pointsStorage[stateDirection][point.Key];
storagePoint = CorrectMousePositionPoint(stateDirection, storagePoint, cellsSize);
Point storagePoint = point.Value;

// Update Data Pixel Storage
if (StatesController.isLandmarkEditable)
Expand All @@ -180,20 +175,17 @@ public static void UpdateStoragePoints(Point[] points)
{
var stateDirections = StatesController.GetStateDirections();
var cellsSize = EnvironmentController.dataImageState.imageCellsSize;

pointsStorage = pointsStorage ?? new Dictionary<StateDirection, Dictionary<Point, Point>>();

foreach (var stateDirection in stateDirections)
{
pointsStorage[stateDirection] = new Dictionary<Point, Point>();
foreach (var point in points)
{
Point tempPoint = CorrectMousePositionPoint(stateDirection, point, cellsSize);
Point storagePoint = EnvironmentController.dataPixelStorage.GetPointStorage(stateDirection, point);
pointsStorage[stateDirection][tempPoint] = storagePoint;
Point newPoint = CorrectMousePositionPoint(stateDirection, point, cellsSize);
Point storagePoint = EnvironmentController.dataPixelStorage.GetPointStorage(stateDirection, newPoint);
pointsStorage[stateDirection][newPoint] = storagePoint;
}
//string pointStoragePoints = string.Join(", ", GetStoragePoints(stateDirection));
//Debug.WriteLine($"StoragePoints: {stateDirection}: {pointStoragePoints}");
}
}

Expand Down Expand Up @@ -231,10 +223,6 @@ public static void ViewSelectedPoints(Point[] points)
Point selectedPoint = new Point(point.X - pointOffset.X, point.Y - pointOffset.Y);
selectedPoint = CorrectMousePositionPoint(stateDirection, selectedPoint, cellsSize);
Point storagePoint = pointsStorage[stateDirection][selectedPoint];
storagePoint = CorrectMousePositionPoint(stateDirection, storagePoint, cellsSize);

//Point curPos = MouseController.currentMousePosition;
//Debug.WriteLine($"curPos: {curPos}, point: {point}, temp: {tempPoint}, selected: {selectedPoint}, storage: {storagePoint}, --- offset: {pointOffset}");

// Pixel Color
Color color = GetPointColor(bitmapOverlayPreview, storagePoint);
Expand Down Expand Up @@ -773,7 +761,7 @@ public static void UpdatePointOffsetBounds(Point point1, Point point2)
pointOffsetMax.X = Math.Max(point1.X, point2.X);
pointOffsetMax.Y = Math.Max(point1.Y, point2.Y);

Debug.WriteLine($"Update Point Offset Bounds, min: {pointOffsetMin}, max: {pointOffsetMax}. pointOffset: {pointOffset}, Down: {pointOffsetDown}, Last: {pointOffsetLast}");
//Debug.WriteLine($"Update Point Offset Bounds, min: {pointOffsetMin}, max: {pointOffsetMax}. pointOffset: {pointOffset}, Down: {pointOffsetDown}, Last: {pointOffsetLast}");
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Helpers/UndoSaves.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void SaveStorage(ConcurrentDictionary<StateDirection, ConcurrentDi

//Similarly: Push(tempPixelStorage);
pixelsStorages.AddLast(tempPixelStorage);
Debug.WriteLine($"UndoStack PUSH: {pixelsStorages.Count}");
//Debug.WriteLine($"UndoStack PUSH: {pixelsStorages.Count}");
}

}
Expand Down
4 changes: 4 additions & 0 deletions Resources/DataPixelStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public DataPixelStorage(string path, int width, int height, bool isNeedDraw = fa

public void ChangePoint(StateDirection direction, (int x, int y) point, (int x, int y) pointMod)
{
//Debug.WriteLine($"ChangePoint {direction} -- {point} - {pointMod}");
//string textWas = $"\tWas: {point} - Storage: {pixelStorages[direction][point]}";
pixelStorages[direction][point] = pointMod;
//string textNow = $"\tNow: {point} - Storage: {pixelStorages[direction][point]}";
//Debug.WriteLine($"{textWas} \n{textNow}");
wasUpdated = true;
}

Expand Down

0 comments on commit d5a6b2b

Please sign in to comment.