RocketStats icon indicating copy to clipboard operation
RocketStats copied to clipboard

Added ability for auto scale theme to screen size.

Open 3lack5ky opened this issue 1 year ago • 4 comments

The scale value accepts a string now, but is also fully compatible with any normal theme. If a string is entered it calculates the scale when the reset button is pressed. The scale can be adjusted by changing the scale value as a string.

Example for scale "1.0":

Y size = scale in menu 1600 = 1.110 1440 = 0.999 1200 = 0.833 1080 = 0.750

Example for Scale "0.9":

Y size = scale in menu 1600 = 0.999 1440 = 0.899 1200 = 0.749 1080 = 0.675

I also uploaded some _AutoScale themes on my fork of the RocketStats_themes as examples for testing.

3lack5ky avatar Feb 11 '25 09:02 3lack5ky

Hey @3lack5ky, thanks for your contribution

Can you explain how you get the value for the expression std::stof(std::string(theme_config["scale"])) * (0.500 + (display_size.y - 720) / 880 * 0.61); ?

Lyliya avatar Feb 11 '25 11:02 Lyliya

Hey Lyliya,

I took a theme as an example (Marker by Arubinu42), I changed the resolution to 2560x1600 and adjusted the scale manually to fit the theme perfectly to the clock. I noted down the Y value (1600) and the scale value (1.110). Then I changed the resolution to a very small one 1280x720 and adjusted the theme to fit there perfectly. Then I also noted down the Y value (720) and the scale value (0.500). Then I did some math:

The formula for linear interpolation between two points (x1,y1) and (x2,y2): y = y1 + (x - x1) * (y2 - y1) / (x2 - x1)

Substituting the values: (Scale in game) = (Scale from example config) * (0.500 + ((screen Y size) - 720) * (1.11 - 0.500) / (1600 - 720))

Simplyfied the formula: (Scale in game) = (Scale from example config) * (0.500 + ((screen Y size) - 720) / 880 * 0.61)

And finally with the variables from the code: rs_scale = std::stof(std::string(theme_config["scale"])) * (0.500 + (display_size.y - 720) / 880 * 0.61);

3lack5ky avatar Feb 11 '25 11:02 3lack5ky

@3lack5ky This make sense

I will try to check this soon, but it may be a good idea to apply this to all theme 🤔

Lyliya avatar Feb 13 '25 12:02 Lyliya

Yeah all themes could be changed to do auto scale. But we would have to determine the intended base scale for each one. On some like „Marker“ that’s pretty easy, but on some it‘s not so obvious, what is the intended scale by the author. But that would also not be a big deal, since the user can always change the scale manually, if he prefers to have a different scale.

3lack5ky avatar Feb 13 '25 13:02 3lack5ky