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

size of hotbar background textures #9580

Open
kyubi-no-kitsune opened this issue Apr 2, 2020 · 12 comments
Open

size of hotbar background textures #9580

kyubi-no-kitsune opened this issue Apr 2, 2020 · 12 comments

Comments

@kyubi-no-kitsune
Copy link

kyubi-no-kitsune commented Apr 2, 2020

Problem

There is no documentation about the size of the hotbar (or the recommended size for custom hotbar textures).
Not that those are needed to play the game, but it is an essential feature for Texture Packs and Games, and since there is support for custom textures, it should be documented somewhere.

I tried to make a template for custom textures using the sizes I read from the hotbar textures provided in Minetest Game, but even those "official" textures are not of the correct size.

The 'gui_hotbar_selected.png' image gets cut off on the right side, and the item item slots in 'gui_hotbar.png' are gradually misplaced as the selection frame moves towards the right side.

these are the templates i made based on the textures from Minetest Game:
gui_hotbar
gui_hotbar_selected

Solutions

Someone decided the design on the hotbar; and even if that person is no longer around, someone must be able read that code and tell what size the hotbar textures are scaled to.

Furthermore, the textures used in Minetest Game should be updated accordingly, but that's an MTG issue i guess...

Additional context

While we are at it, i would also like to know the same stuff for the formspec textures 'gui_formbg.png' and 'gui_hb_bg.png'.
They don't concern my project yet, but eventually they will. (for the same reason)

@kyubi-no-kitsune kyubi-no-kitsune added the Feature request Issues that request the addition or enhancement of a feature label Apr 2, 2020
@sfan5
Copy link
Member

sfan5 commented Apr 2, 2020

The relevant source file: https://github.com/minetest/minetest/blob/master/src/client/hud.cpp
Hotbar textures do not seem to be scaled at all, while padding is dependent on display density on the client (what?).

@paramat paramat added Documentation missing / error Textures and removed Feature request Issues that request the addition or enhancement of a feature labels Apr 2, 2020
@paramat
Copy link
Contributor

paramat commented Apr 2, 2020

I am using a default game window size 1024x600 on a desktop PC.

The 'gui_hotbar_selected.png' image gets cut off on the right side

the item item slots in 'gui_hotbar.png' are gradually misplaced as the selection frame moves towards the right side.

I cannot see either of these happening.
I spent many hours adjusting these 2 textures to optimise the appearence.
Please can you post screenshots to show the problems?
What device are you using, Android?

I do not think you can state that the textures in MTGame are incorrect, they are fine for me, and it seems that sfan5 suggests this may depend on device.

@kyubi-no-kitsune
Copy link
Author

I am using a default game window size 1024x600 on a desktop PC.

i use a notebook with a 1366x768 screen.
according to what i found in the settings, the in-game screen is 1358x707.

I cannot see either of these happening.
I spent many hours adjusting these 2 textures to optimise the appearence.
Please can you post screenshots to show the problems?

both custom textures:
screenshot_20200402_213424
screenshot_20200402_213458

just custom background, no texture for the selection frame:
screenshot_20200402_213618
screenshot_20200402_213624
screenshot_20200402_213633

just the selection frame, no background texture:
screenshot_20200402_213710

although less visible, this also happens with the textures from MTG.
just in case, i also reset to the default settings. the window size becomes 1024x707 then.
the hotbar issue remains unchanged.
holding a ruler over my screen, it appears that the 8th slot is slightly wider than the others.

this may depend on device.

the hotbar textures are the only thing affected by this.
inventory formspecs and menus look fine. when not setting custom textures, the default red frame and stuff also look fine.
if this is caused by my screen, shouldn't all things be affected then?

@ghost
Copy link

ghost commented Apr 2, 2020

While we are at it, i would also like to know the same stuff for the formspec textures 'gui_formbg.png' and 'gui_hb_bg.png'.

On newer versions of Minetest (5.1.x and above, I believe), gui_formbg.png is a 9-slice texture with a border width of 10 pixels. If you don't intend to support older clients, then you can use whatever resolution you want as long as you design your texture with that border width in mind. And honestly, you probably won't be able to make a background that scales scales properly in all cases on older clients because the size and aspect ratio of prepended formspecs are arbitrary. This is why we use 9-slice textures now.

I don't think gui_hb_bg.png has a set size... It's a 1x1 formspec image, so it's the size of an inventory slot. The size will vary by device, so I'd pick something consistent with other formspec images of that size. If you're making a TP, that means probably the size of icons like the furnace arrow. If you're making a game, you'll want to pick a number that looks good and stick to it.

@sfan5
Copy link
Member

sfan5 commented Apr 2, 2020

Here are two textures that are pixel-perfect on my system:
gui_hotbar
gui_hotbar_selected

All these sizes change with the DPI(*), but textures are always scaled to the sizes the HUD expects:

  • black: 48x48 square for item
  • yellow/dark red: border of 4px on each side (=48/12)
  • blue: border of 2px around entire image (=4/2)
  • light red: border of 4px around entire image (=4)

(*) The size of the black square is calculated as round(48 * (DPI / 96))

  • on Windows the DPI is 72 unless screen_dpi is changed in the .conf (this means the black square is 36x36)
  • on Linux/BSD the DPI is retrieved from X11, with screen_dpi as fallback value
  • on Android (DPI / 96) is replaced with the density returned from here

The window size is irrelevant by the way

@kyubi-no-kitsune
Copy link
Author

Here are two textures that are pixel-perfect on my system:

the background looks flawless, but the selection frame is odd on the left border.
the light red line is thicker while the dark red line is thinner.
according to the in-game settings, minetest's DPI is set to 72.

but now i noticed something else:
it's not only in minetest but also on the desktop. the thickness of the lines in the preview image is mismatched, but everything is correct when i open it with Gimp.
it also happens in Firefox and others. changing the screen resolution doesn't fix this.

looking for alternate screens for comparison, i viewed it on my phone and it happens there too. although in different places and less noticeable (my phone has a much higher screen resolution than my notebook).
i guess this concludes that this is a screen issue and i'm just too sensitive about it...
thank you for your support.

but i still need to know something:
it's not like the size of textures doesn't matter at all, as the hotbar background does get streched into a certain shape.
is there a formula to calculate the distance between item slots and the border size?
based on sfan5's textures i would assume that the distance (and selection frame) is 1/6 of the slot size and the border is 1/8 of the slot size.
is this correct and can be applied to any resolution?

@sfan5
Copy link
Member

sfan5 commented Apr 3, 2020

I explained the exact sizes of the borders in my post, no idea how you arrive at 1/6 or 1/8.

@paramat
Copy link
Contributor

paramat commented Apr 3, 2020

The 'gui_hotbar_selected.png' image gets cut off on the right side

Do you mean that the right side of the frame is compressed slightly in size? If so, yes that is visible in MTGame for me, but is due to what appears to be texture scaling, it is not 'cut off'.
For me the right and lower frame edges appear on screen 7 pixels wide, the upper and left frame edges appear on screen 8 pixels wide. In the texture the frame edges are 10 pixels wide.

the item item slots in 'gui_hotbar.png' are gradually misplaced as the selection frame moves towards the right side.

Ok i see what you mean. This is not noticeable in MTGame when i use it.
This is all part of the 'weirdness of scaling and offsetting' i discovered when making those textures. I designed the textures to hide the weirdness. They were very carefully adjusted to be optimum, if one thing is adjusted to fix one problem, another worse problem occurs. But of course this is display-dependent, so the MTGame dimensions may not be optimum for everyone.

I am not sure these textures deserve dimension documentation, as everyone will want different appearences anyway, and they can analyse the MTgame textures if they want some guidance. So 'low priority' i think.

@paramat paramat added Low priority Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature. and removed @ Client / Audiovisuals Documentation missing / error labels Apr 3, 2020
@kyubi-no-kitsune
Copy link
Author

kyubi-no-kitsune commented Apr 4, 2020

I explained the exact sizes of the borders in my post, no idea how you arrive at 1/6 or 1/8.

i calculated it based on your sizes.
the textures i want to use are of lower resolution.
the HUD doesn't change in size or form, instead the textures are re-sized to fit into the defined shape.
that's why i was looking for the hotbar texture scale.
if possible i want to go with a slot size of 16x16, since my source texture pack is made of this.

@kyubi-no-kitsune
Copy link
Author

kyubi-no-kitsune commented Apr 13, 2020

i was able to scale it down to half size, with slots being 24 pixels.
this seems to be the smallest possible size wit the 1/6 1/8 border ratio. anything smaller would get deformed textures again.

it is possible to get a few other sizes by thinning the borders, but none of those are compatible with 16x textures.
this means that minecraft texture packs are generally incompatible with minetest's hotbar size, so custom hotbar textures have to be newly created.

while 24x slot size is the smallest possible, i found the 48x slot size more fitting with 16x textures, as the smaller one doesn't allow enough detail on the borders.
depending on the style, a slot size of 96x might be even better.

they can analyse the MTgame textures if they want some guidance

since the MTG hotbar is just grey lines, the smaller scale with 24x slot size would be enough, it's easier to analyze.
i might draw something up when i feel motivated.

@paramat
Copy link
Contributor

paramat commented Apr 14, 2020

this means that minecraft texture packs are generally incompatible with minetest's hotbar size

Not a problem =)

@paramat paramat added Documentation missing / error and removed Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature. labels May 21, 2020
@kyubi-no-kitsune
Copy link
Author

kyubi-no-kitsune commented Jun 8, 2020

gui_hotbar(24-thin)
gui_hotbar_selected(48)

i remade the default textures with the scale mentioned above.
they look (almost) identical in-game, and are easier to analyse.
i might make a mod of this, with templates and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants