-
Notifications
You must be signed in to change notification settings - Fork 92
Implement Root EM unit for UI components dimensions and render the game at full device's resolution #589
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
Draft
Reco1I
wants to merge
45
commits into
osudroid:master
Choose a base branch
from
Reco1I:engine-scalling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7f686d3 to
4c2f98b
Compare
-This will fix wrong clipping of components with non-zero translation of any axis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Color4, implementlightenanddarkenfunctions #581Introduction
This PR introduces two important changes that each goes in hand with the other:
Reason
The game was originally planned to run on 2010' devices or even older, due to that the render resolution was set to be at max 1280x720 which at that time was most of a standard.
Nowadays that resolution is not even closer to what most devices use as described in this article.
For devices with a screen with higher resolution than the render resolution the engine will just upscale the game to fill the screen viewport's width.
As an example if we ran the game on a device with a 1920x1080 screen resolution, the game will be upscaled by 1.5x. But 1920x1080 is 16:9 aspect ratio which is no longer the standard even for low-end devices if we try with a 20:9 resolution such as 2400x1080 the game will be scaled by 3.3x.
Example with a 2400x1080 device's screen, the old example uses Roboto font meanwhile the new uses Nunito
The
remunitAs a consequence of using 1280x720 as a fixed render resolution the game's UI was designed from the top to the bottom with absolute coordinates and dimensions for its UI components and screens.
Now if we want the game to look the same for every device I decided to implement the CSS's Root EM unit.
The implementation is similar to a regular Android WebView-based browser using DisplayMetrics.density property:
Now to use the
remunit we just have to use the extension function.remafter afloatnumber:myComponent { style = { width = 4f.rem } }The
stylepropertyIs important to set everything related to dimensions or colors inside the
styleproperty which is an evolution of the previousapplyTheme. It is most of a handler, it wraps properties that should be reapplied when some events are triggered such as a theme change or a UI scale change (which can eventually be available in the settings menu).There's an important utility for the
styleproperty which is theplusoperator. It will allow us to chain styles of UI components for cases when we want to add some style without overriding the component's current style:Important changes on UI components
colorVariantUI controls such as
UIButtonorUIBadgecan now vary betweenPrimary,SecondaryandTertiarycolor variants:Example missing Tertiary variant
sizeVariantUI controls such as
UIButtonorUIBadgecan now vary betweenSmall,MediumandLargesize variants:Removal of
relativeSizeAxesThe property
relativeSizeAxeswas removed and replaced by an extension function:Before:
component { relativeSizeAxes = Axes.X width = 0.5f }Now:
component { width = 0.5f.pct }UIText.wrapTextUITextnow supports text wrapping by word break method.UIText.fontSizeFont sizes will now be defined by constants of
FontSizeinremunits:What's left ?
As a consequence of using full resolution old UI elements and screens got outdated. So a full redesign of the following scenes is needed before any further step:
Components based on UI v2 are already updated to follow the new dimension rules.