Translate graphic elements on GUI

Started by Tequila144, Wed 23/01/2008 12:19:00

Previous topic - Next topic

Tequila144

I have translate my game from Italian to English. 
The game uses a GUI with graphic elements (in Italian). 
I had thought about using this: 
 
if (Game.TranslationFilename == "English") { 
use GUI(english); 

 
but isn't good because in the game there are many lines; GUItalian Off and On (and i don't modify it).. 
Is possible, with script up, modify only the graphic elements of the Italian GUI?

Khris

Option 1:
Change the buttons' graphics depending on Game.TranslationFilename using GUIButton.NormalGraphic and related ones.

Option 2:
Set the GUIButton graphics like this:
Code: ags
function init_guis() {
  String s;
  s = "10"; restartYesButton.NormalGraphic = s.AsInt;
  s = "11"; restartNoButton.NormalGraphic = s.AsInt;
  ...
}

// in game start
init_guis();

Now "10", "11", ... will appear in the translation source and can be directly translated into the numbers of the english button graphic slots.

Tequila144

I have try the first option.. 
I have read the manual but I don't understanding how run the script:   
GUIButton.NormalGraphic 
 
For example, the gui is the GUI 0 and the button to modify (in english version) is the Button 0, the number of the spriteimage to use in the English version  is 190.

Then:

Code: ags

if (Game.TranslationFilename == "English") {  
 GUIButton.NormalGraphic ????
}  

Khris

Either name the button (scriptname field of the properties window). Say you call it "mybutton1".
Then the script line should read
Code: ags
  mybutton1.NormalGraphic = 190;


Alternatively, you can reference the buttons by using only the index numbers:
Code: ags
  GUIButton*b = gui[0].Controls[0].AsButton;    // .AsButton returns null if control isn't a button
  if (b != null) b.NormalGraphic = 190;

Tequila144

Quote from: KhrisMUC on Thu 24/01/2008 22:01:43
Either name the button (scriptname field of the properties window). Say you call it "mybutton1".
Then the script line should read
Code: ags
  mybutton1.NormalGraphic = 190;


Ok, but i have 4 GUI, do I specify that the button is of the GUI0?

Khris

No, it's not possible to have two buttons with the same name, even if they're on different GUIs.
Call them whatever you want, then use that name. Since there's only one button of that name, AGS doesn't need to know the GUI's name or number.
(Did you try it before asking, I wonder...)

Tequila144

Quote from: KhrisMUC on Thu 24/01/2008 22:45:25
No, it's not possible to have two buttons with the same name, even if they're on different GUIs.
Call them whatever you want, then use that name. Since there's only one button of that name, AGS doesn't need to know the GUI's name or number.
(Did you try it before asking, I wonder...)

Ok, sorry (but i not have AGS to the moment)..
and thanks.  ;)

SMF spam blocked by CleanTalk