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

Codechange: Disable pointer locking by default #9191

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

Conversation

@embeddedt
Copy link
Contributor

@embeddedt embeddedt commented May 4, 2021

Motivation / Problem

See #9150.

Description

This PR changes the default scroll mode so that pointer locking is not used by default, resolving the bad UX for the Emscripten port.

As this is a breaking change and needs further discussion, it's currently a draft.

Limitations

  • This is a breaking change.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')
@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented May 4, 2021

There are two kinds of "decorated" mouse cursors. The basic are single-sprite cursors, those are most of the construction tools. In the original graphics the construction tool is integrated in the cursor itself:

image

In OpenGFX the tool appears to be a separate sprite next to the cursor, but it's actually still a single sprite:

image

When you drag a vehicle in a depot, the vehicle graphics is used for the mouse cursor instead, the cursor is still only a single sprite then.

@PeterN
Copy link
Member

@PeterN PeterN commented May 4, 2021

How does that relate to whether the cursor is locked in position or not when scrolling?

@embeddedt
Copy link
Contributor Author

@embeddedt embeddedt commented May 4, 2021

@PeterN I think @nielsmh is referring to my comment under Limitations about the cursor being drawn incorrectly.

@nielsmh Hmm... I see what you mean. In that case, I think there will need to be an Emscripten-specific code path added for the cursor rendering, as the only way I know of to change the cursor appearance without having OpenTTD draw it itself is to use CSS.

@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented May 4, 2021

I think having an alternate cursor code path would be useful regardless, as there are some requests to support a high-contrast cursor style. In my mind that would be basically skipping the baseset for the cursor graphics and draw something custom instead.

@embeddedt
Copy link
Contributor Author

@embeddedt embeddedt commented May 4, 2021

I've discovered that adding cursor: none !important to the canvas CSS in os/emscripten/shell.html will actually override Emscripten's cursor logic and force the software-rendered OpenTTD cursors to always get drawn. That is probably a good enough compromise for now.

The side effect is that the cursor rendering will now be dependent on OpenTTD's frame rate, but that's also how it works on the normal ports. On my machine I don't see any noticeable lag while testing it.

@embeddedt
Copy link
Contributor Author

@embeddedt embeddedt commented May 11, 2021

I'm going to mark this as ready for review as I haven't noticed any bugs while testing it.

@embeddedt embeddedt marked this pull request as ready for review May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants