I see that in Kathy Rain Options.
Select 5 languages:Mine only have 3 :tongue:
I think is with:
function ListBox1_OnSelectionChanged(GUIControl *control)
{
if (Game.ChangeTranslation("Spanish") == true)
{
(Game.ChangeTranslation("Spanish");
}
}
But how I fill the selection in the option panel.
There is no way to know what languages are available using built-in commands, which is a design oversight of AGS, but you should be able to work around that by getting a list of "*.tra" files in the game directory:
ListOfTranslations.FillDirList("$INSTALLDIR$/*.tra");
where ListOfTranslations is a ListBox (which may also be hidden, if you dont want to show it directly).
You may still need to edit the resulting list by taking each item and stripping the ".tra" part. Something like -
for (int i = 0; i < ListOfTranslations.ItemCount; i++)
{
String item = ListOfTranslations.Items[i];
String newItem = item.Substring(0, item.Length - 4);
ListOfTranslations.Items[i] = newItem;
}
To change the language:
function ListOfTranslations_OnSelectionChanged(GUIControl *control)
{
String newLang = ListOfTranslations.Items[ListOfTranslations.SelectedIndex];
Game.ChangeTranslation(newLang);
}
I haven't tested this, so might need some fixes or improvement here and there.
In game_start:
ListBox1.AddItem("Spanish");
ListBox1.AddItem("English");
ListBox1.AddItem("Italian");
Then change your function:
function ListBox1_OnSelectionChanged(GUIControl *control)
{
String tra = ListBox1.Items[ListBox1.SelectedIndex];
if (!Game.ChangeTranslation(tra)) Display("Unable to change translation to %s!", tra);
}
I'll also recommend renaming the GUI control from "ListBox1" to something like "lbTranslation", to make the code more readable.
Quote from: krisAwesome
TY work great. TY.