October 16, 2019, 03:14:49 AMLatest Member: Tokisakyrlz

Author Topic: UI Scaling  (Read 4128 times)

0 Members and 1 Guest are viewing this topic.

Garog

  • Registered member
  • *
  • Posts: 5
    • View Profile
UI Scaling
« on: June 03, 2014, 06:19:01 AM »
Hello,

i played CorsixTH on my 47" TV at the weekend and now i need new glasses  ;D

because i don't want new glasses but want to play it on my tv, i started working on some ui scaling options
the lua stuff is easy to handel and most of it is allready done, i added a new option in the menu, updated the config(s/finder...) and so on...

attached are some first impressions
the font is not scaled atm, i hope i got this today or maybe tomorrow (just the real fonts, not the "spritefonts")

as i'm working on the lua stuff right now, i think i will got some problems with resizing the sprites
any suggestions where to start with that?

Garog

  • Registered member
  • *
  • Posts: 5
    • View Profile
Re: UI Scaling
« Reply #1 on: June 03, 2014, 02:00:23 PM »
So far.. so good... that was the easy part...
can someone pls tell me how to access config values from the config file in c++ ?
it's the first day with the corsix c code, somewhere i saw a lua_getglobal(L, "assert"); and so far i can see, is "assert" TheApp in Lua ?!
how ever... i'm not an c++ expert, i'm a noob  ;D
i don't know how to get the value "uiscale" from the configfile in FT_Error THFreeTypeFont::setPixelSize

atm uiscale is hardcoded in c for testing purposes

(the screenshot show's a scale of 2 and 1,6 with the font Arial)

Lego3

  • Project Owner
  • *****
  • Posts: 398
    • View Profile
Re: UI Scaling
« Reply #2 on: June 03, 2014, 03:48:26 PM »
Very good work indeed! :-)

Have you checked out the source code through Git so you can easily make a pull request?

I have mostly fiddled with Lua myself, so I'm not entirely sure, but from what I've seen so far all config options are read in lua and then passed to any C++ code that needs them. E.g. screen resolution and audio settings.
Therefore my solution would be to add some function like "setUIScale" in the C++ code that is interfaced to Lua. So when the user changes the value you first put it in the config and then calls that function. As a part of the startup in Lua you read the value from config and call that function. Have a look in th_lua_gfx.cpp for some examples of how to map functions between Lua and C++.

E.g. luaT_setfunction(l_surface_scale, "scale");
For the end of the world spell, press Control, Alt, Delete.

Garog

  • Registered member
  • *
  • Posts: 5
    • View Profile
Re: UI Scaling
« Reply #3 on: June 03, 2014, 05:08:18 PM »
Thanks, examples are always good :)

i used the sourcecode from git master, cloned it monday morning, so yes, when its finished, a pullrequest is possible :) but there is a lot of work to do
and i don't know much about git and "easy" ways to work with git.

the main menu and all submenues are working and looking good now, i have just a "problem" with the directorylists... but that's just something to make it perfect :)

atm i'm working on the ingame interface, menubar and the submenu are done so far, except the sprites (again^^)....
but i'm thinking about an png replacement of all UI sprites, with png's in all different scales, need to check that tomorrow how many work that could be :)
makes stuff like scaling a lot easier for me, and will look a lot better when scaled, but its just an idea atm

Garog

  • Registered member
  • *
  • Posts: 5
    • View Profile
Re: UI Scaling
« Reply #4 on: June 04, 2014, 04:34:09 PM »
damit it, i'm getting crazy...

that day i just tried SDL "resize utiles"... i got one working now.. it scales but the output is just black -.-*
the problem is, SDL 1.X doesn't support scaling -.-* there are a lot of libraries around in the internet, atm i'm using sprig libs
why didn't u finished SDL 2 support  ;D... there is a simple function for that  ... SDL_BlitScaled

cloning corsix sdl2 source now... :) lets take a look what's done so far :)
« Last Edit: June 04, 2014, 06:06:51 PM by Garog »

MarkL

  • Moderator
  • ***
  • Posts: 362
    • View Profile
Re: UI Scaling
« Reply #5 on: June 05, 2014, 08:53:52 AM »
hang in there, the team have been working on adding sdl2 for some time now.

Garog

  • Registered member
  • *
  • Posts: 5
    • View Profile
Re: UI Scaling
« Reply #6 on: June 05, 2014, 06:21:01 PM »
yeah i know, but the sources are buggy to me, i needed to get rid of all movie stuff before i could successfully compile it

so i continued my work with opengl...

atm i'm researching how the zoom in and out of the map is working to use this for the interface... its all so  new to me :)
the lua part is working, but c++ and sdl/opengl... thats a lot of new stuff :) but i will continue working on it :)