Facepunch / sbox-issues

176 stars 12 forks source link

Css calculation does not do math operation, and rem not working at startup #6520

Open Tankonyako opened 1 month ago

Tankonyako commented 1 month ago

Describe the bug

Hello i found two bugs but i think it can be merged in one (because rem related to math too).

  1. Is all rem values are not settings property (corrupt math maybe) on start, but after reload it fixes.
    1. It happen with variables and static values too
  2. Calculation in css are not working with variables (using variables)
    1. Also found bug if put value without math calc(400px) it didnt compile

I encountered an issue while working with variables. I had a margin-step variable and created classes like .m-1, .m-2 (similar to Tailwind). I also made a universal multiplier for spacing.

i also think calculation maybe not working with dynamic values like width/height.

To Reproduce

  1. Use margin in rem margin: 4rem
  2. Use calc

Also you can check my media i just recorded all process of reproduce

Expected behavior

  1. Excepted behavior like after reload (all correct)
  2. I think it need calc (multiply, plus and etc)

Media/Files

  1. First startup rem bug - https://youtu.be/1I0cIg4dGac
  2. Bug with calc - https://youtu.be/ramYnVXuTYc

Additional context

No response

Nolankicks commented 1 month ago

Did you take a look at some of the errors within the console? I believe you are using some unsupported style properties

MrBrax commented 1 month ago

rem or any relative measurements have never worked for me, unless it has been fixed recently #5411

Tankonyako commented 1 month ago

Did you take a look at some of the errors within the console? I believe you are using some unsupported style properties

no i didnt receive any errors (only if i do calc(400px), if i put math errors gone and math didnt work only getting first value: example: calc(100px * 4) it gives 100px, not 400px) you can see this at video i using margin for demonstration calculation

Tankonyako commented 1 month ago

I just tested more, on client rem while connected also broken (hot reload help), also i found one, if i set all raw values to 1px for example (with code), it will change styles in game, but if i comment this code and restart scene, changes also persist, i think is s&box style cache algo (StyleSheet.Loaded is singletone , get styles only once and reload while file changes. maybe some broken in this part and losing information when game getting cached styles. i think file change fixing some variables and rem start work (freshing variables)

foreach (var item in Panel.Children)
{
    foreach (var style in item.AllStyleSheets)
    {
        foreach (var n in style.Nodes)
        {
            foreach(var i in n.GetRawValues())
            {
                n.SetRawValue(i.Name,"1px"); // some styles will keep, on next run also if comment (in editor, game not saving)
            }
        }
    }
}
xezno commented 1 month ago

Everything seems to be fine?

Image Image