Template Voice and Text trigger button code breaks in translation

Started by Gal Shemesh, Tue 20/06/2023 23:23:05

Previous topic - Next topic

Gal Shemesh

Hi everyone,

I think I've found another bug when working with translation in buttons that change their text from within scripts, like the 'Voice and Text' button in the settings panel of the Template game for changing between 'Voice and Text', 'Voice only' and 'Text Only.

I'm currently making an updated version of the template game and I made it with an option to switch between English and Hebrew during runtime, along with speech for both languages so it will give a better starting point for users with a multilanguage game in mind.

I made a Hebrew translation file and traslated all three modes of the 'btnVoice'. They all show up correctly when running the game in Hebrew. Clicking on the button in English works flawlessly and cycles back up when it reaches its last 'else if' statement. However, when the game shows the text based on the translation file, the function seems to break after 1 click on any of the modes and the button stops working - I checked them all by changing to English, putting the button on the state I wanted to check, reverted to Hebrew and clicked on it. The buttons changes to the text from the translation file, but the function breaks. It doesn't matter what text I fill in the translation file - it can be either Hebrew, English or a number. As long as the text is not the same as written in the function, the function breaks instead of go looking for the text in the translation file. This is the code:

Code: ags
function btnVoice_OnClick(GUIControl *control, MouseButton button)
{
  if (btnVoice.Text == "Voice and Text")
  {
    Speech.VoiceMode = eSpeechVoiceOnly;
    btnVoice.Text = "Voice only";
  }
  else if (btnVoice.Text == "Voice only")
  {
    Speech.VoiceMode = eSpeechTextOnly;
    btnVoice.Text = "Text only";
  }
  else if (btnVoice.Text == "Text only")
  {
    Speech.VoiceMode = eSpeechVoiceAndText;
    btnVoice.Text = "Voice and Text";
  }
}

Is this a bug? I'm not sure if it's related to the same cause, but I posted another issue that the buttons also don't get translated correctly and are showing their Hebrew text from Left-to-Right instead of from Right-to-Left, and it's although all the rest of my game looks from Right-to-Left. Here's the thead link: https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/buttons-text-remains-left-to-right-rtl-when-the-game-runs-in-right-to-left/msg636655887/#msg636655887]https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/buttons-text-remains-left-to-right-rtl-when-the-game-runs-in-right-to-left/msg636655887/#msg636655887

Thanks
Gal Shemesh,
goldeng

Crimson Wizard

This is a known issue in the old version of template, where the script logic relied on the human-readable text.
The newest version of template should be fixed since AGS 3.6.0.

Here's the fixed code:
https://github.com/adventuregamestudio/ags-template-source/blob/169184f96a559b392f5205054d218440f1b0cd46/Sierra-style/GlobalScript.asc#L384-L401

Khris

Just for reference, the original code is a very bad way to do this but could've been fixed by wrapping the strings in GetTranslation() calls.

Gal Shemesh

Quote from: Crimson Wizard on Tue 20/06/2023 23:33:36This is a known issue in the old version of template, where the script logic relied on the human-readable text.
The newest version of template should be fixed since AGS 3.6.0.

Here's the fixed code:
https://github.com/adventuregamestudio/ags-template-source/blob/169184f96a559b392f5205054d218440f1b0cd46/Sierra-style/GlobalScript.asc#L384-L401

Thanks! The new code makes much more sense after reading it.

@Khris, thank you too!
Gal Shemesh,
goldeng

SMF spam blocked by CleanTalk