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

Editor: enhance coordinates hint when moving Objects and Characters around the room #2229

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Nov 14, 2023

Fix #984, addresses a minor problem mentioned in #614.

  • Display coordinates hint when Characters or Objects are moved with keys too.
  • Fixed hint's position was only constrained by top-left border; made sure it is always visible even if a moved object is out of visible bounds (e.g. if user zoomed into a different part of room).
  • Allow to move Objects outside of room bg, similar to Characters.
  • Brought Characters and Objects moving code to more consistency (although imo they should get a base class, but that's for separate task).

On a side note, the coordinates may be difficult to see sometimes, depending on background.
For a moment I've been thinking about letting user choose a color in Editor prefs, but even a custom color will still be fixed and have same problem. So this is an open issue.
EDIT: added a black shade under the text.

There is ALOT of code duplication in these two classes, so I opened #2230 as a separate task, don't have spare time for that right now.

@ivan-mogilko ivan-mogilko added type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor context: ui/ux labels Nov 14, 2023
@ericoporto
Copy link
Member

ericoporto commented Nov 14, 2023

the coordinates may be difficult to see sometimes

I think I would collect the code that draws it around like here:

graphics.DrawString(toDraw, font, pen.Brush, scaledx, scaledy);

And then make an alternative to System.Drawing graphics DrawString that puts an outline around it - like say a black outline around the yellow text. I looked around and there isn't an easy way to do this, so it would require some amount of fiddling. But if this is acceptable approach l can figure somewhere to add a utility method for this and then PR this change later.

@ivan-mogilko
Copy link
Contributor Author

I just added a black shade under whole text for now.

@ericoporto
Copy link
Member

using_keyboard_keys.mp4

The PR does what it says. I noticed when tapping keys that the coordinate is only briefly shown, not sure if this is an issue or not.

@ivan-mogilko
Copy link
Contributor Author

Yes, that's a problem, because with mouse user may keep button down and have the hint for as long as necessary, but with keys you cannot do that. So this solution does not work.

Options:

  • make coordinates display all the time so long as object is selected;
  • make coordinates display after it's been moved by keys until it's moved by mouse or deselected.
  • hide hint by a timer (but then users may argue that timeout is not enough)

@ericoporto
Copy link
Member

ericoporto commented Nov 14, 2023

From the options above

make coordinates display all the time so long as object is selected

It appears this is the simplest rule.

Maybe just making a function for the drawing of the coordinates and then when drawing the selection rectangle it would just call such function.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Nov 14, 2023

Maybe just making a function for the drawing of the coordinates and then when drawing the selection rectangle it would just call such function.

All this is already in the same function, everything is drawn in OnPaint event.

@ericoporto
Copy link
Member

I think it's best to merge this PR as is.

I played a bit with the mentioned alternatives and the "hide hint by a timer" is actually the one that felt best but there isn't a way to make the code for this super short, so this is best left to test it out later, probably after #2230 .

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Nov 15, 2023

I think i will ask on forums for more opinions.

From the code's perspective the easiest is to draw coordinates always (while the object is selected). But I don't know if people will be okay with that.

The way it works right now won't let to find coordinates comfortably enough with key moving, which will defeat the purpose of pr.

@ericoporto
Copy link
Member

if the zoom is one that makes the room really small, the coordinates occupy all of the room, and it's not possible to see what is selected, but by using the timer approach it's still useable. By showing when the object is selected, it becomes weird in this specific edge case, but the timer approach works alright.

* Timer starts when user releases all moving keys.
* Timer stops whenever an object begins to move again.
* Hint state is cleared whenever selection changes or room filter looses focus.
@ivan-mogilko
Copy link
Contributor Author

Okay, I added the timer to remove the hint. It ended up with pretty small amount of code.

@ericoporto
Copy link
Member

I tested and the timer works great!!! This is a nice addition! Nudging with the arrow keys works nicely now, no more flickering when tapping the keys. :)

@ivan-mogilko ivan-mogilko merged commit be02cdd into adventuregamestudio:master Nov 18, 2023
20 checks passed
@ivan-mogilko ivan-mogilko deleted the 361--editorobjectmovement branch November 18, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: ui/ux type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

show coordinates when moving object with arrowkeys
2 participants