Game, set up a convention for managing half-pixels for centering elements #10308
Replies: 5 comments
-
|
This is an extremely difficult to follow as developers do not use hardcoded pixel values but rather rely on math. So, if a length is 9 then the first position is going to be 9 / 2 = 4 based on integer calculations. This is how the code looks right now: const int32_t posX = width / 2;Simple and easy to read. Now if we try to impose the proposed logic the code might look like this: int32_t posX = width / 2;
if ( posX * 2 != width ) {
posX += 2;
}As you can see the code is way longer and harder to read. Therefore, I don't see that any of developers is going to follow this. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @ihhub, So how is a value that is not entirely divisible handled mathematically? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, @LeHerosInconnu. Could you please point out where there currently is inconsistency in the buttons' centering regarding the leftover pixel? |
Beta Was this translation helpful? Give feedback.
-
|
Hello @zenseii,
I haven't checked the buttons recently, but I'll be sure to report a problem if I find one. :) The purpose of a convention would be to avoid having to check all the "centering", whether for text in buttons or other things. |
Beta Was this translation helpful? Give feedback.
-
|
I don't think such a solution even exists within reasonable development resources. We also handle some "special" cases here and there just to accommodate either the original game design or limitations of dialogs like placing some UI elements on a specific position. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Preliminary checks
Describe the problem requiring a solution
I suggest to set up a convention for managing half-pixels for centering elements.
Originally posted by @LeHerosInconnu in #9180 (comment)
Describe the possible solution
For horizontal and vertical centering of elements, text or graphics in a button, button in a window, window in a screen, in short any element in another element, make sure that pixels that cannot be split are added to the right for the horizontal dimension and to the bottom for the vertical dimension.
Additional info
No response
Beta Was this translation helpful? Give feedback.
All reactions