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

Implemented rectangle drag placing objects #8 #439

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Atria1234
Copy link
Collaborator

  • hold shift while starting placing single object to initiate

- hold shift while starting placing single object to initiate
@Atria1234
Copy link
Collaborator Author

obrazek

Works not just with farms. The buildings keep to the grid, avoiding places where would be collisions

@Atria1234 Atria1234 linked an issue Sep 16, 2022 that may be closed by this pull request
Copy link
Contributor

@StingMcRay StingMcRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Program Test it works like a Charm, Tree and Button wise
afbeelding

So it may be approved but code wise is for me still not a thing to do
@FroggieFrog if you would please do this :)

Copy link
Collaborator

@AgmasGold AgmasGold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good.

The main changes I'd like to see is to move the class GeneratePointsInsideRect, as it doesn't really fit inside IEnumerable extensions. Additionally, added some notes about hotkeys as well as some suggestions for if we should deal with all selected objects.

/// <param name="step">Increment between iterations.</param>
/// <param name="inclusiveTo">Returns value after last iteration if set to true.</param>
/// <returns>Sequence of doubles between provided bounds.</returns>
public static IEnumerable<double> Range(double from, double to, double step = 1, bool inclusiveTo = false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we only use this for the GeneratePointsInsideRect method, so we could probably just keep this private for now.

var objectToClone = CurrentObjects[0];
var start = ScreenPointToObjectGridPosition(_mouseDragStart, objectToClone);
var end = ScreenPointToObjectGridPosition(_mousePosition, objectToClone);
var clones = Core.Extensions.IEnumerableExtensions.GeneratePointsInsideRect(start, end, objectToClone.Size, true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only way we use this method, then it probably doesn't belong in the IEnumerableExtensions class.

We should probably make it some kind of helper, maybe something do with sequences, primitives, or shapes.

@@ -932,6 +934,24 @@ protected override void OnRender(DrawingContext drawingContext)
objectsChanged = true;
}

if (CurrentMode == MouseMode.RectPlaceObjects && CurrentObjects.Count == 1)
{
var objectToClone = CurrentObjects[0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion - do we only want this to work with one object?

Couldn't we technically figure out a bounding box and related to step size and clone entire groups of objects?

@@ -2106,8 +2120,17 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
}
else if (e.LeftButton == MouseButtonState.Pressed && CurrentObjects.Count != 0)
{
// place new object
TryPlaceCurrentObjects(isContinuousDrawing: false);
if (IsShiftPressed() && CurrentObjects.Count == 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be configurable, as other hotkeys are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

area-place for farm fields
4 participants