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

Event system refactors. #3

Open
HexDecimal opened this issue Oct 28, 2022 · 1 comment
Open

Event system refactors. #3

HexDecimal opened this issue Oct 28, 2022 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@HexDecimal
Copy link
Contributor

Currently events are mainly handled by overriding UmbraModule::keyboard and UmbraModule::mouse. These are using libtcod's event system which has known issues. Mostly input lag or silently dropping events depending on how it's being used.

Several classes capture these events and handle them later in their update function. I think is a poor way of handing events and it makes it very hard to refactor them. Some of these might be replaceable with SDL_GetKeyboardState or SDL_GetMouseState.

The latest revision of Umbra adds UmbraModule::onEvent which handles SDL events, but due to how sensitive libtcod's event handing is combined with how the current code relies on several side effects, the event handing will be broken by updating to this version. Which means updating the code to use SDL for events will be a struggle.

Another thing is that SDL provides pixel coordinates which need to be converted by a libtcod function to tile coords for things like window management.

The plan is to remove all overrides of UmbraModule::keyboard and UmbraModule::mouse, and any other calls to libtcod's event system using whatever means possible.

@HexDecimal
Copy link
Contributor Author

I've updated the Umbra submodule so onEvent is now accessible. When adding new event handing always prefer adding to this method instead of update/mouse/keyboard.

I had to revert some Umbra input lag fixes so that the current code doesn't instantly break. Right now the lag can't be removed until all event code is moved over.

The next task is to steadily move pieces of event code into onEvent from other places.

@HexDecimal HexDecimal added bug Something isn't working enhancement New feature or request labels Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant