CreativeMD / CreativeCore

Required by AmbientSounds, ItemPhysic, LittleTiles, ...
GNU Lesser General Public License v3.0
67 stars 36 forks source link

Scalable Text using labels #230

Closed SrRapero720 closed 4 months ago

SrRapero720 commented 4 months ago

scalling is possible using PoseStack#scale(0.75F, 0.75F, 0.75F) whoever, this carries one issue, widgets dimensions is still keeped, so no the dimensions applied are still the same (wasting space)

this works on decorative/label texts just to enhance readability this propotype shows the capability of scaling image image image

SrRapero720 commented 4 months ago

this can be applied on any kind of text, again it needs some precision and control over the position and the scaled dimensions

image image

CreativeMD commented 4 months ago

Is this something I should add? Do you want to scale all text by 0.75 by default? Or do you mean it should be an option. It is actually quite easy to make it work with the dimensions as well.

SrRapero720 commented 4 months ago

i mean it should be an option (method) last time we talk about you said needs a better way to implement something like that (because 1.20.1 rewrites how font rendering works)

CreativeMD commented 4 months ago

What you can do is the scale the parent. That always works and will respect the dimensions as well. The question is do you want a scale config for labels for example?

SrRapero720 commented 4 months ago

I tried scaling parents but seems like is not working? I didn't dig much in scaling parents.

And yes, a scale config for labels is a good addition.

CreativeMD commented 4 months ago

Create a parent, add the controls you want to scale. Do parent.setScale(0.75); and that's it.

CreativeMD commented 4 months ago

Released a new version which does fixes a few things about scaling and adds it to label and compiled text. Hope that works for you.

SrRapero720 commented 4 months ago

scaling for some reason get texts cropped into a new line, i assume is caused by the missing ceiling method https://github.com/CreativeMD/CreativeCore/blob/4c619b2c487608961f4101cff8175ecf48c23233/src/main/java/team/creative/creativecore/client/render/text/CompiledText.java#L450 image

GuiParents scaling on the other hands works perfectly fine

image

But clarifying, scaling is more like a feature for all widgets using text. In Labels, what you want (normally) is scale the text and also get a responsive width and height based on the scaled text size

Buttons on the other hand extends Label, but what i want when i scale GuiButtons i want to get scaled only the text and no the GuiButton dimensions. To make this more clear, if i set a dimension of... lets say... 30 and i scale the Button 0.5f, it will also scale the dimensions, making that 30 into a 15

CreativeMD commented 4 months ago

If you use GuiLabel.setScale(scale) it will not effect the dimensions of the button if it has fixed ones. Will also release a fix for the missing ceil.

SrRapero720 commented 4 months ago

about that, can be also implemented on GuiSliders and GuiTextFields?

CreativeMD commented 3 months ago

about that, can be also implemented on GuiSliders and GuiTextFields?

Actually that is a little bit more complicated. I think in that case it is better to wrap it inside a parent and scale that one.