aiaf Posted May 14, 2018 Share Posted May 14, 2018 This is bad , didnt give much thought to resolution that the game need to support. To simplify i decided to support only 16:9 aspect size resolutions (1920x1080, 1600×900 etc). For the hud was simple i changed to have sizes depending on resolution: context->DrawImage(sentinelModuleLaserTex, context->GetWidth() / 30, context->GetHeight()/2, moduleDrawSize, moduleDrawSize); Text sizes are the problem , I have a complicated text ui , and have to somehow fix up all spaces between and resize fonts depending on resolution. mainMenuFont = Leadwerks::Font::Load("Fonts/arial.ttf", 16); context->SetFont(mainMenuFont); Question is theres another way to have text resize automatically depending on resolution ? Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
gamecreator Posted May 15, 2018 Share Posted May 15, 2018 I could be wrong but I think the Leadwerks GUI does this. Quote Link to comment Share on other sites More sharing options...
Rick Posted May 15, 2018 Share Posted May 15, 2018 I solved this by having the idea that everything is an "element" that has a bounding box area. That bounding box area (the size of the element) is the thing that's resized based on resolution so it looks the same between all resolutions. Then I have a label "widget" which is basically an element with just text. I can set the size of the text by setting it to be "x-small, small, medium, large, x-large, Fill". When the game starts it loads a bunch of fonts going up by 2 in size and stores them in a table. It then uses the font width and height functions to find the max font that fills the height and/or width (makes sure the font width/height isn't bigger than the bounding box of the element). Basically it starts at the biggest font loaded and goes down in size until the width and height fit into the element bounding box area. That's the fill font and all the other fonts are percentages of that. x-large = 80% of fill font, large = 70% etc (might not be exact numbers as I don't recall but you get the point). If the fill font size was 30 then x-large is 80% of 30 or 24. Since I only loaded fonts by multiples of 2 if the math works out to be an odd number (I truncate any decimals) then I subtract 1 to get the even number that is smaller so I know it'll fit. I mark the font as being used and assign that element that font object and any font in the table that isn't used is deleted from memory. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.