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

ActorMoveBrush for Editor #21255

Merged
merged 1 commit into from Mar 3, 2024
Merged

Conversation

CDVoidwalker
Copy link
Contributor

@CDVoidwalker CDVoidwalker commented Dec 14, 2023

This PR adds a new brush that can move singular actors by drag and drop. It includes Ctrl + M hotkey as well as translation strings. It is expected to wait for #20226 to be merged first and this adjusted to changes, currently my goal is to get feedback whether this is the right approach. Example of tool in action:

Fixes #5241

2023-12-14.11-23-57.mp4

Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

Crash

Exception of type `System.NullReferenceException`: Object reference not set to an instance of an object.
   at OpenRA.Mods.Common.Widgets.EditorActorMoveBrush.HandleMouseInput(MouseInput mi) in /OpenRA/OpenRA.Mods.Common/EditorBrushes/EditorActorMoveBrush.cs:line 49
   at OpenRA.Mods.Common.Widgets.EditorViewportControllerWidget.HandleMouseInput(MouseInput mi) in /OpenRA/OpenRA.Mods.Common/Widgets/EditorViewportControllerWidget.cs:line 94

Generally we do atomic and self-contained commits, that is each commit is a feature or change that doesn't break bleed. We do make exceptions to that rule sometimes when splitting a feature makes reviewing much simpler.

When it comes to this feature I feel like it would be much more intuitive to just allow moving actors while having them selected. I feel a new brush isn't necessary as it really only interacts with actors anyway.

OpenRA.Mods.Common/EditorBrushes/EditorActorMoveBrush.cs Outdated Show resolved Hide resolved
@abcdefg30
Copy link
Member

I feel a new brush isn't necessary as it really only interacts with actors anyway.

Even if we move actors while they are selected we would still need a new brush that handles the mouse inputs etc.

@PunkPun
Copy link
Member

PunkPun commented Dec 20, 2023

actor edit brush should be handling the inputs

@abcdefg30
Copy link
Member

abcdefg30 commented Dec 20, 2023

We don't have a brush for editing actors.

@Porenutak
Copy link
Contributor

From workflow perspective new brush just for move is bad idea. default brush should handle this just fine. If you really wanna use modifier, not button.

@PunkPun
Copy link
Member

PunkPun commented Dec 20, 2023

if #20226 were to be merged then drag selection will conflict with actor moving, a lot of tools separate out move cursor specifically for this purpose. But I still believe that actor edit cursor should be capable of moving actors

@@ -189,6 +189,22 @@ public int SetActor(WorldRenderer wr, ActorInfo actor, PlayerReference owner)
return ++CurrentToken;
}

public void MoveActor(EditorActorPreview preview, CPos location)
{
editorLayer.Remove(preview);
Copy link
Member

Choose a reason for hiding this comment

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

I think removing is wrong. We should instead add an update function to EditorActorLayer

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm giving this a go but it is proving to be a bit difficult. It makes a lot of sense to remove and recreate because lots of items like the footprint, LocationInit, and RuntimeNeighbourInit need to be removed and recreated, too. A dedicated Update function essentially recreates a lot of stuff that the Remove/Add functions are already doing and only really increases future maintenance burden.
However, I am recovering from Covid as I write this and might not be in my right state of mind.

Copy link
Member

Choose a reason for hiding this comment

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

We also remove and add actors to the world instead of updating them, so this could be fine.

var r = previews.SelectMany(p => p.ScreenBounds(worldRenderer, CenterPosition));

Bounds = r.Union();

SelectionBox = new SelectionBoxAnnotationRenderable(new WPos(CenterPosition.X, CenterPosition.Y, 8192),
selectionBox = new SelectionBoxAnnotationRenderable(new WPos(CenterPosition.X, CenterPosition.Y, 8192),
new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height), Color.White);

// TODO: updating all actors on the map is not very efficient.
onCellEntryChanged = _ => GeneratePreviews();
Copy link
Member

Choose a reason for hiding this comment

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

this should also trigger a visual update. When map height changes so should the actors position. Easiest way to test is placing cliffs and having terrain overlay turned on

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes, I see - also pasting terrain of a different height with the actor filter turned off

@drogoganor
Copy link
Contributor

That should all be fixed up now - actor previews and selection box will be updated when the terrain changes.

Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM, just one last bug

When you are dragging around an unselected actor you can still delete it, however if you had never stopped dragging the actor gets recreated. Once you're done dragging, if you move trough action history the map editor will crash

@drogoganor
Copy link
Contributor

Cool - I disallowed the right click to delete actor if shift is held.

@@ -211,7 +243,7 @@ public bool HandleMouseInput(MouseInput mi)
editorWidget.SetTooltip(null);

// Delete actor.
if (underCursor != null && underCursor != Selection.Actor)
if (underCursor != null && underCursor != Selection.Actor && !mi.Modifiers.HasModifier(Modifiers.Shift))
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't fix the bug. Holding shift is only necessary to start dragging, but once you start it can be released

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh hell, you're right

@PunkPun PunkPun merged commit 7b82d85 into OpenRA:bleed Mar 3, 2024
3 checks passed
@PunkPun
Copy link
Member

PunkPun commented Mar 3, 2024

changelog

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.

Ingame Map Editor: Movable actors
6 participants