Jump to content

FontSize management questions


Mud-H

Recommended Posts

I'm working on a new GUI system for my game and I have some questions that maybe you can help.


Is there a way to make the FontSize adapt to different screen ratio/size? From my knowledge, there's no way to do it with stock code but maybe there's a ressource about it somewhere.


Is there a way to manage different fontSizes for GuiTextCtrl instead of having to create parented profiles? Again, I know it's not possible with stock code but maybe someone know a ressource about it.


So maybe I should ask if there's any enhanced GUI ressources available somewhere. Last time I browse other developpers GitHub repositories I notice a lot of interesting branches, maybe there's one about GUI enhancements I missed.... (Would be nice to keep track of usefull branches somewhere...).

Link to comment
Share on other sites

"Out of the box?" Not really. You'll have to get the screen size yourself. The good news is that you can set the GUI profile of any control at runtime - allowing you to swap them on the fly as needed. So, make a collection of preset profiles sized as you wish and then swap them based on the scene dimensions or what not....


Actually, if I remember when I get home I have some script that will generate a profile with a font point size (it's a little hokey, the conversion is weird) and assign it to a GUI object on the fly - it was for the Three Step Studio editors, for customizing your game template fonts. It can also set font colors....

Link to comment
Share on other sites

Well, you don't really have to go that far.


I'll send myself an email to remind myself to grab that script - basically, you can create a GUI Profile on the fly and just assign it to a control. It's pretty simple, except that font sizes are weird and touchy - not simple to just convert point to pixel sizes, I used a "fudge factor" when doing this myself.

Link to comment
Share on other sites

I'll send myself an email to remind myself to grab that script - basically, you can create a GUI Profile on the fly and just assign it to a control. It's pretty simple, except that font sizes are weird and touchy - not simple to just convert point to pixel sizes, I used a "fudge factor" when doing this myself.

Interesting idea to generate new profiles on the fly. Might include it in my experiments. If you can that script, i'd like to have a look,


On my side, I start working on a new scripted Profile Manager system to deal with different profiles updating functions. I prefer to stay script-side for now and avoid C++ Modification but later I might have a look to enhance the GUI code for my needs.


For now I'm focusing on profile colors and I'm building a system that allow to change the colors of multiple profile from a color management GUI. I'm almost done with the initial script but I'm facing an issue that I don't know how to fix simply. I'd like to update the profiles color which link to updated profile (Like what it does when it exec the GuiControlProfile files on loading).


Here an example of one of my TextProfile:

//==============================================================================
singleton GuiControlProfile(GuiTextBaseA_C : GuiDefaultProfile) {
   fillColor = "238 236 240 255";
   bevelColorHL = "Magenta";
   justify = "Center";
   category = "LabText";
   fontSize = "17";
   colorFont = "DefaultTextA";
};
singleton GuiControlProfile(GuiTextBaseA_L : GuiTextBaseA_C) {
   locked = true;
   justify = "Left";
};
singleton GuiControlProfile(GuiTextBaseA_R : GuiTextBaseA_C) {
   locked = true;
   justify = "Right";
};
//------------------------------------------------------------------------------



The colorFont is a custom field that reference to a Colors Set. When, I update it the fontColor change fine for GuiTextBaseA_C but not his childs (GuiTextBaseA_L and GuiTextBaseA_R). Is there a way I can refresh those 2 childs so they use the updated parent color?

I'm doing some experiment now to find the simplest way to achieve that.

Link to comment
Share on other sites

I figured out that if I delete the Gui Profile before the singleton call, it work fine. So I think it's what I should do but I will work on something to avoid having to add the delete call before all profiles.

There's no way to make T3D delete a singleton/new if it exist before adding it, right? Is it hard to make a new prefix in C++ that would delete if exist before adding? I see some other use for that...

Link to comment
Share on other sites

Okay it mostly work except for the GuiContainer control which get their profile field changed to default when their profile is deleted... Anyone know why?


Edit:

Ok I found it happen because of GuiControl::onDeleteNotify. What I don't understand is why some are not notified...

Link to comment
Share on other sites

If the profile is deleted it reverts to default because it would crash if it didn't have a profile.


Also, after quickly skimming that code what I discovered was that we had a set of pre-named profiles that we altered at run-time for editing purposes. We then saved changes to the profiles so that the exported game could use them. The code I was thinking about was actually to get a list of available fonts from the OS and to determine a point size conversion to fit within gui controls - if the font is too tall to fit in the pixel height of the control the text will not render.


I'll see what I can come up with....

Link to comment
Share on other sites

Yeah, I found why the onDeleteNotify code is there. I hacked it to skip it during my refresh profile script and it make it worst leading to a crash.


So I need to look for another solution... I'm trying to figure how the profile linking with : works. Does it store something somewhere, if so I should be able to track the linked profiles and apply the changes to them also. But I want to prevent that if I save the profile, it will store the updated fields (which I prefer that they stay only in the parent)

Link to comment
Share on other sites

I found a way to make it work well. I simply scan all profiles files to detect the profiles that are linked ( Profile : ProfileLink ) and I store the data in globals so I can access them if needed, Now I can move toward font and fontSize...


I can't share scripts now since it's a big mess but I will try to clean up my system and share it in close future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...