Skip to content

ActorMoveBrush for Editor - #21255

Merged
PunkPun merged 1 commit into
OpenRA:bleedfrom
CDVoidwalker:editor-move-actors
Mar 3, 2024
Merged

ActorMoveBrush for Editor#21255
PunkPun merged 1 commit into
OpenRA:bleedfrom
CDVoidwalker:editor-move-actors

Conversation

@CDVoidwalker

@CDVoidwalker CDVoidwalker commented Dec 14, 2023

Copy link
Copy Markdown
Contributor

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

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

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.

Comment thread OpenRA.Mods.Common/EditorBrushes/EditorActorMoveBrush.cs Outdated
@abcdefg30

Copy link
Copy Markdown
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

PunkPun commented Dec 20, 2023

Copy link
Copy Markdown
Member

actor edit brush should be handling the inputs

@abcdefg30

abcdefg30 commented Dec 20, 2023

Copy link
Copy Markdown
Member

We don't have a brush for editing actors.

@Porenutak

Copy link
Copy Markdown
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

PunkPun commented Dec 20, 2023

Copy link
Copy Markdown
Member

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

Comment thread OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

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
Copy Markdown
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
Copy Markdown
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
drogoganor force-pushed the editor-move-actors branch from 352c05d to 8fc0ad1 Compare March 3, 2024 10:48
@drogoganor

Copy link
Copy Markdown
Contributor

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

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

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
drogoganor force-pushed the editor-move-actors branch from 8fc0ad1 to 1ccf805 Compare March 3, 2024 12:16
@drogoganor

Copy link
Copy Markdown
Contributor

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


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

Copy link
Copy Markdown
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
Copy Markdown
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

@drogoganor
drogoganor force-pushed the editor-move-actors branch from 1ccf805 to fb36e99 Compare March 3, 2024 12:24
@PunkPun
PunkPun merged commit 7b82d85 into OpenRA:bleed Mar 3, 2024
@PunkPun

PunkPun commented Mar 3, 2024

Copy link
Copy Markdown
Member

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