Mud-H Posted April 7, 2015 Share Posted April 7, 2015 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...). Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted April 7, 2015 Share Posted April 7, 2015 Short of having GUI check onWake for screensize and choosing which of multiple different guiObjects to display - no.hax FTW! ;) Quote Link to comment Share on other sites More sharing options...
rlranft Posted April 7, 2015 Share Posted April 7, 2015 "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.... Quote Link to comment Share on other sites More sharing options...
doc Posted April 8, 2015 Share Posted April 8, 2015 you can modify the gui controls from c++ to change color indipendently, I did it for my game. You can also probably change the font profile from there.take a look to guiTextCtrl and gfont.cpp Quote Link to comment Share on other sites More sharing options...
rlranft Posted April 8, 2015 Share Posted April 8, 2015 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. Quote Link to comment Share on other sites More sharing options...
Mud-H Posted April 8, 2015 Author Share Posted April 8, 2015 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. Quote Link to comment Share on other sites More sharing options...
Mud-H Posted April 8, 2015 Author Share Posted April 8, 2015 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... Quote Link to comment Share on other sites More sharing options...
Mud-H Posted April 8, 2015 Author Share Posted April 8, 2015 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... Quote Link to comment Share on other sites More sharing options...
rlranft Posted April 8, 2015 Share Posted April 8, 2015 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.... Quote Link to comment Share on other sites More sharing options...
Mud-H Posted April 9, 2015 Author Share Posted April 9, 2015 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) Quote Link to comment Share on other sites More sharing options...
Mud-H Posted April 9, 2015 Author Share Posted April 9, 2015 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. 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.