Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
While currently the existing window handling code is technically correct, on Android opertating sytem certain devices (or SDL on them) behave weirdly. In the engine we have two types of coordinates, screen and script: - Screen coordinates are coordinates the game window runs in (needed to translate e.g. mouse pointer hover area). - Script coordinates are coordinates the game runs in (always 1080p). So, for a 2400x1080 screen, as found in Redmi Note9 Pro in landscape mode, the following values are set: - script_width / script_height = 1920 / 1080 (game resolution) - screen_width / screen_height = 1920 / 1080 (windowed game resolution, unused in fullscreen really) - screen_ratio1 / screen_ratio2 = 1080 / 1080 (native screen height / game script height) - fullscript_width / fullscript_height = 2400 / 1080 (screen resolution in game coordinates) - fullscreen_width / fullscreen_height = 1920 / 1080 (game resolution in screen coordinates) - fullscript_offset_x / fullscript_offset_y = 240 / 0 (offset to game on device screen in game coordinates) What we actually observe on the device is padding of 420 pixels to the left and 210 pixels to the right with the game width cut to 1770 pixels wide. If fullscript_offset_x becomes 0 on a normal device that would have meant the game would run in the top left corner, but it is absolutely not what happens on Redmi Note9 Pro. What we observe after the change is left padding of 180 pixels and right padding of 300 pixels with the game width being 1920 as normal. I guess, neither is correct, but the latter is at least useable. What we concluded from these values is that on this device the game always runs at 180 pixel offset to the right (420 - 240 = 180) enforced by some system software (or maybe SDL). This is horrifying but not much we can do about it. To handle the issue as such and get a perfectly centred image fullscript_offset_x should be 60 as calculated from (2400 - 1920) / 2 - 180. Here 180 is so called system_offset_x. This patch introduces such a variable and makes it user-configurable via engine arguments or ons.cfg.
- Loading branch information