Hello everyone, my game has several translations, and I have custom made a font to suit some languages. However, The dialog and display font changes perfectly, but any GUI font's do not change from the default font.
Here is my code to change the games font when changing languages:
case 8: if (Game.ChangeTranslation("Russian"))
{
// game as changed translation
Game.NormalFont = eFontfntRussian;
Game.SpeechFont = eFontfntRussian;
bTranslation.Text = "Russian";
}
break;
I've set the translation in a switch statement for a more organized look. But as above the GUI font does not change to this. Any thoughts?
GUI font is an individual property of each GUI object. You need to pass every button and label and change fonts for them.
I once wrote a script for doing that:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=53950.msg636543956#msg636543956
Thanks CW, that script is a great idea! I just have a question though. Is there a way I can use that loop in the function that already switches the translation fonts? or would I have to use the function ReplaceFontOnAllGUIs(int old_font, int new_font)
Quote from: Stranga on Sun 23/04/2017 16:28:21
Thanks CW, that script is a great idea! I just have a question though. Is there a way I can use that loop in the function that already switches the translation fonts? or would I have to use the function ReplaceFontOnAllGUIs(int old_font, int new_font)
EDIT: Ok, I am not sure I understand what you mean.
If you want to have that loop inside your existing function, you just need to copy it there. Maybe you will have to fix variable names after that.
If I am to give an advice, I'd recommend to keep that code in its distinct function, because that would be cleaner. You just place that function before yours language-changing function, and call it inside your function:
Game.NormalFont = eFontfntRussian;
Game.SpeechFont = eFontfntRussian;
ReplaceFontOnAllGUIs(eFontfntEnglish, eFontfntRussian); // use actual font names here
Thanks for the edit also CW. I've tried the code, when when I compile or test I get this error GlobalScript.asc(497): Error (line 497): Undefined token 'ReplaceFontOnGUI'
Quote from: Stranga on Sun 23/04/2017 16:51:43
Thanks for the edit also CW. I've tried the code, when when I compile or test I get this error GlobalScript.asc(497): Error (line 497): Undefined token 'ReplaceFontOnGUI'
Have you placed ReplaceFontOnGUI function BEFORE you use it?
I have yes, the error seems to be coming from here:
function ReplaceFontOnAllGUIs(int old_font, int new_font)
{
int i = 0;
while (i < Game.GUICount)
{
ReplaceFontOnGUI(gui[i], old_font, new_font);
i++;
}
}
Did you put ReplaceFontOnGUI function BEFORE ReplaceFontOnAllGUIs?
I think so.
Edit My bad I missed a line in the code
Excellent! Works Perfectly! Thanks yet again CW!