AGS 3.6.0 WIP (Alpha 21) - SDL2-based engine + Unicode support

Started by Crimson Wizard, Thu 25/03/2021 02:28:54

Previous topic - Next topic

Crimson Wizard

#200
Quote from: Andrea1992 on Thu 17/03/2022 04:03:20
Room 5,
To get there, from the bedroom (initial room) go outside using the door, then talk to the girl that arrives (only character in that room). This sends you to the room 5, where the cutscene esc problem occurs,
thanks

Ok I finally found the actual cause for this, it happens when you have WaitMouse/Key(-1) in the middle of the cutscene. Engine does not handle -1 (infinite timeout) properly when skipping the cutscene.

EDIT: again, the fixed temp build:
https://cirrus-ci.com/task/5993769815244800

Quote
So, when you update to alpha 22 or beta,  will the fix be included?

Yes of course.

heltenjon


Stranga

I've encountered a problem with translations in list boxes and dialogue options displaying symbols rather than being translated, not sure if a bug or my mistake but here's what I'm referring to:

Screenshots:
Spoiler

Happens with all listboxes and dialogue


This happened when I tried navigating the dialogue options via keyboard, never ran into it in the previous alphas only 3.6.0.20


[close]
My Dialogue Script:
Spoiler
Code: ags

// new module script

//int dlg_opt_color = ;
int dlg_opt_acolor = 2047;
int dlg_opt_ncolor = 65535;
int DlgCursorPos = 1;

import int  KeyUp[2];
import int  KeyDown[2];
import int  KeyLeft[2];
import int  KeyRight[2];
import int  KeyAction[2];
import int  KeyBack;
import int  KeyMenu;
import int  KeySprint[2];
import int KeyInventory[2];


function dialog_options_get_dimensions(DialogOptionsRenderingInfo *info)
{
  // Create a 200x200 dialog options area at (50,100)
  info.X = 30;
  info.Y = 100;
  info.Width = 256;
  info.Height = 256;
  info.ActiveOptionID = 1; // set to first option
}

function dialog_options_render(DialogOptionsRenderingInfo *info)
{
  btnCoverUp.Visible = true;
  DialogOpen = true;
  //info.Surface.Clear(dlg_opt_color);
  int i = 1,  ypos = 24,  xpos = 0; 
  // Render all the options that are enabled
  while (i <= info.DialogToRender.OptionCount)
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    { 
      if (info.ActiveOptionID == i)
      {
        btnPointer.SetPosition(xpos+26, ypos+95); //Cursor Position 
        info.Surface.DrawingColor = dlg_opt_acolor;
      }
       else
       {
        info.Surface.DrawingColor = dlg_opt_ncolor;
       }
      
      info.Surface.DrawStringWrapped(5, ypos, info.Width - 10, 
      eFontfntSnatcher, eAlignLeft, info.DialogToRender.GetOptionText(i));
      ypos += GetTextHeight(info.DialogToRender.GetOptionText(i), eFontfntSnatcher, info.Width - 10); 
    }
    //aClick.Play();
    i++;
  }
}

function dialog_options_key_press(DialogOptionsRenderingInfo *info, eKeyCode keycode) 
{
  switch (keycode)
  {
  case KeyUp[0]:
  case KeyUp[1]:
  aCursor.Play();
    // check all options upwards until found an active one
    for (int next_opt = info.ActiveOptionID - 1; next_opt >= 1; next_opt--)
    {
      if (info.DialogToRender.GetOptionState(next_opt) == eOptionOn)
      {
        info.ActiveOptionID = next_opt;
        break;
      }
    }
  break;
  case KeyDown[0]:
  case KeyDown[1]:
  aCursor.Play();
    // check all options downwards until found an active one
    for (int next_opt = info.ActiveOptionID + 1; next_opt <= info.DialogToRender.OptionCount; next_opt++)
    {
      if (info.DialogToRender.GetOptionState(next_opt) == eOptionOn)
      {
        info.ActiveOptionID = next_opt;
        break;
      }
    }
  break;
  }
  
if(CanPress)
  {
    switch(keycode)
    {
      case KeyAction[0]:
      case KeyAction[1]:
      aSelector.Play();
      DialogOpen = false;
      btnPointer.Visible = false;
      btnCoverUp.Visible = false;
      info.RunActiveOption(); 
      break;
    }
  }
}

function dialog_options_repexec(DialogOptionsRenderingInfo *info)
{
  btnPointer.Visible = true;
}



[close]

Crimson Wizard

#203
Quote from: Stranga on Sat 19/03/2022 00:13:56
I've encountered a problem with translations in list boxes and dialogue options displaying symbols rather than being translated, not sure if a bug or my mistake but here's what I'm referring to:

I recall dialog options worked before, did this new error appear after some changes, or engine update, or with another language?

Is the given translation saved in UTF-8 and has "Encoding" set in TRS? Does it use correct font that has necessary characters?

Does the same language/font work everywhere else, e.g. on labels, speech etc?

eri0o

I managed to reproduce the mentioned crash and noted down a way to reproduce here with a minimal game: https://github.com/adventuregamestudio/ags/issues/1582

I could not reproduce the mentioned issue with the translation though. Stranga, if you could make a tiny example game of the mentioned issue with symbols and translations it would be helpful!

Stranga

@Crimson Wizard

The error code is something new as I loaded a backup on 3.6.0.17 and the dialogue navigation works fine, however, the text is still not being translated in list boxes and dialogue, everything else works fine (labels, buttons e.c.t).
Example of labels working fine:
Spoiler

My text box is a label.
[close]

UTF-8 Encoding has been  set in the TRS file, I also tested it with another font but it still shows the same symbols

Example:
Spoiler
[close]

@eri0o I'll get to work on a small build for you to test soon :)

Crimson Wizard

#206
The temp build with a keyboard fix may be downloaded here:
https://cirrus-ci.com/task/5721016642043904

please tell if it fixes the key input.

But i don't yet know what is wrong with translations. I'll have to think more about it, or wait for your small test game.

QuoteI loaded a backup on 3.6.0.17 and the dialogue navigation works fine, however, the text is still not being translated in list boxes and dialogue
So, if I understand correctly, translation in dialog options did not work in 3.6.0.17 too?

I remember that previously you had issue with some languages, but they were fixed?
https://www.adventuregamestudio.co.uk/forums/index.php?topic=58976.msg636644048#msg636644048

Do you use same font as on labels there, or a different one?

Stranga

Ok, temp build fixes keyboard issue, great! :)

Strangely when I started a fresh empty game and make a list box and a dialogue both with translated lines they worked. However, when I made a game out of a template they didn't work, I compared both versions' TRS files and didn't find any differences, both had UTF-8 encoding on them. Strangely I changed the Text Format under general settings to UTF8 and it worked?
Screenshot:
Spoiler
[close]

However, this didn't work on my game, only on the test game so there's isn't much for debugging.

QuoteSo, if I understand correctly, translation in dialog options did not work in 3.6.0.17 too?
That's correct, it didn't work on that version either

QuoteI remember that previously you had issues with some languages, but they were fixed?
https://www.adventuregamestudio.co.uk/forums/index.php?topic=58976.msg636644048#msg636644048

I thought that would've been the case but it seems to still show those symbols when I applied that particular fix to this problem.

QuoteDo you use the same font as on labels there, or a different one?
Yes, everything has the same fonts.

Something is telling me that it may be an issue with my scripting somewhere. I'll look into it further but here's the test build I quickly made: http://www.fileconvoy.com/dfl.php?id=gd863cb389b33e2171000418743282b849981e52b80

EDIT:
QuoteStrangely I changed the Text Format under general settings to ASCII then back to UTF8 and it worked?
Only the dialogue worked not the listbox

BREAKTHROUGH: I think I found the problem, the list box fonts are not changing when I change translations

I'm using this script to change all fonts in game but it seems to be missing listboxes:
Spoiler
Code: ags

function ReplaceFontOnAllGUIs(int old_font, int new_font)
{
  int i = 0;
  while (i < Game.GUICount)
  {
    ReplaceFontOnGUI(gui[i], old_font, new_font);
    i++;
  }
}
[close]

Yep! That's definitely the problem! Still not sure how to fix it, unfortunately.
Found it:
Spoiler
Code: ags

function ReplaceFontOnGUI(GUI *g, int old_font, int new_font)
{
  int i = 0;
  while (i < g.ControlCount)
  {
    Button *b = g.Controls[i].AsButton;
    if (b != null)
    {
      if (b.Font == old_font)
        b.Font = new_font;
    }
    Label *l = g.Controls[i].AsLabel;
    if (l != null)
    {
      if (l.Font == old_font)
        l.Font = new_font;
    }
    ListBox *lb = g.Controls[i].AsListBox; //HERE!
    if (lb != null)
    {
      if (lb.Font == old_font)
        lb.Font = new_font;
    }
    i++;
  }
}
[close]

Crimson Wizard

#208
Quote from: Stranga on Sat 19/03/2022 04:24:55
Strangely when I started a fresh empty game and make a list box and a dialogue both with translated lines they worked. However, when I made a game out of a template they didn't work, I compared both versions' TRS files and didn't find any differences, both had UTF-8 encoding on them. Strangely I changed the Text Format under general settings to UTF8 and it worked?

According to the plan, the game should switch to UTF-8 mode if active translation is UTF-8, even if the game itself has the Text Format set to ascii.
I will double check that this works.

EDIT: Ok I found and fixed two more recent bugs...
1. if game was ASCII, but translation UTF-8, then the translation keys were incorrectly loaded, so translation could not be performed
2. winsetup did not list translation names properly (did not cut ".tra" extensions from them)

Temp build with fixes will be available here when the building process is complete (about 20-30 mins after me posting):
https://cirrus-ci.com/task/4630726241943552

Crimson Wizard

@Stranga, i opened a 3.6.0 Beta thread: https://www.adventuregamestudio.co.uk/forums/index.php?topic=59842.0
let's continue discussing problem there (i will lock this thread soon).

SMF spam blocked by CleanTalk