Author Topic: Polish letters in AGS  (Read 535 times)

Jack Orlando

  • Posts: 4
Polish letters in AGS
« on: 25 Feb 2018, 17:37 »
Hello!
I am currently trying to create my first game in AGS and I stumbled on a problem.
Polish language has "strange" letters, like ś, ć, ł, ź, and ż.  When I use them in dialogue they are replaced by "?" signs.
Is there some way to add polish letters to AGS?
« Last Edit: 14 Apr 2018, 17:42 by Snarky »

Crimson Wizard

  • Posts: 8,731
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Polish letters in AGS
« Reply #1 on: 25 Feb 2018, 17:52 »
First of all, AGS is a strictly ANSI program (non Unicode) and requires ANSI-compliant fonts. You need to use font which corresponds to Polish ANSI codepage.
I am not an expert there, but from the quick searching it may be ANSI-1250.
You would need to find or create a font (i.e. use some font editor to copy letters to proper indexes) that corresponds to it.

You may also find some information about AGS font support in this article: http://www.adventuregamestudio.co.uk/wiki/Fonts
« Last Edit: 25 Feb 2018, 17:55 by Crimson Wizard »

Jack Orlando

  • Posts: 4
Re: Polish letters in AGS
« Reply #2 on: 25 Feb 2018, 17:57 »
Thank you for a quick reply!
Problem resolved!

Whyshchuck

  • Posts: 9
Re: Polish letters in AGS- Resolved!
« Reply #3 on: 28 Mar 2018, 10:27 »
Hello,

I would like to extend issue a little.
I'm also writing the game in Polish and managed to draw new characters using font editor and then type type them using ASCII codes.
Problem starts as I want to add textbox to my game.
If player is asked to enter his name, and wants to write "Łukasz", he will just type ALT+L... ukasz. But ALT+L refers to character further than 256 (it will be displayed and saved in string as "^ukasz").
How to make Textbox which will edit input in real time and replace one character with another?

Thanks!


Snarky

  • Global Moderator
  • Posts: 6,706
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Polish letters in AGS- Resolved!
« Reply #4 on: 28 Mar 2018, 15:44 »
Until recently I'd say it couldn't be done, but you might be in luck: You could probably use the TextField module I just published, and hack the HandleKeyPress function with some special-case logic for the key-combinations you're interested in. However, it might behave unpredictably on other keyboard layouts or language locales.

Whyshchuck

  • Posts: 9
Re: Polish letters in AGS- Resolved!
« Reply #5 on: 29 Mar 2018, 09:19 »
Thanks for your response, Snarky.

Your module looks extremely useful. I will experiment with it a bit next days, and will try to give you some feedback.
 

Whyshchuck

  • Posts: 9
Re: Polish letters in AGS- Resolved!
« Reply #6 on: 14 Apr 2018, 13:56 »
Snarky, I've experimented a bit with your script.
While 1.1.0 was crashing, 1.2.0 is working but I still can't manage to find the way to exchange keycode.

I've tried something like this:
      if (keycode == eKeyL && IsKeyPressed(372) == true)
and this:
      if (keycode == 77 && IsKeyPressed(372) == true)
but as I understand, AGS doesn't see pressed L, while ALT pressed, because it see them together as producing different keycode (I don't know how to check what exactly).
Maybe you have any idea how I can solve this problem. Maybe there is some way to check, what keycode is hidden behind Alt+particular characters.

Thanks!

Crimson Wizard

  • Posts: 8,731
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Polish letters in AGS- Resolved!
« Reply #7 on: 14 Apr 2018, 14:42 »
Maybe there is some way to check, what keycode is hidden behind Alt+particular characters.

In theory you could simply Display them:   Display("keycode: %d", keycode).
Alternatively, you may even write the keycodes to the text file (using File API in AGS), then press all letters you are curious about in a row.
But idk how useful or convenient this approach (and its results) may be.

Snarky

  • Global Moderator
  • Posts: 6,706
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Polish letters in AGS- Resolved!
« Reply #8 on: 14 Apr 2018, 15:05 »
There are a couple of ways to do this. The easiest is to just check the Alt+L key combination directly. To figure out the keycode, you could simply add a Display() call to the top of the function:

Code: Adventure Game Studio
  1. Display("The keycode pressed is %d",keycode);

However, if you look here, you can find the relevant values:

Code: Adventure Game Studio
  1. #define ALT_OFFSET (-236)
  2. #define ALT_RANGE_START 301
  3. #define ALT_RANGE_END 326

This means that keycodes between 301 and 326 are ALT+letter combinations, and you get the keycode value of the letter itself by subtracting 236. Since L is 76, Alt+L=76+236=312.

If you need more button combinations than just Alt+L, you should probably use something like the IsKeyPressedCombi() function in that code to handle them together.

Whyshchuck

  • Posts: 9
Re: Polish letters in AGS- Resolved!
« Reply #9 on: 14 Apr 2018, 16:05 »
I think that it may be fault of windows setup, but Display shows keycode 94 for all letters out of the 256 char table: ł, Ł, ś, ć, Ś, Ć etc...
I've tried to switch keyboard to english, but it's even worse: AGS doesn't see ALT pressed and shows ł as 76, ś as 86, so as l and s

Snarky, I will try to force it with your functions. Thanks

Snarky

  • Global Moderator
  • Posts: 6,706
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Polish letters in AGS
« Reply #10 on: 14 Apr 2018, 17:43 »
I don't see how that would give a different result, but sure, try it.

Meanwhile I've edited the thread title because I find it annoying to see the title claiming the issue is solved when it's not.

Crimson Wizard

  • Posts: 8,731
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Polish letters in AGS
« Reply #11 on: 14 Apr 2018, 18:13 »
Meanwhile I've edited the thread title because I find it annoying to see the title claiming the issue is solved when it's not.

Original thread was about displaying letters, which was solved.

User input is a separate thing here, since there is no guarantee that AGS does it correctly. It may for instance switch any keycode that it does not support to some smaller value. I recall seeing some weird stuff in keycode handling code.

Imho one alternative that might be tried here is to script custom key input handling, not relying on key_press function and keycodes it receives, but checking IsKeyPressed in repeatedly_execute.

Whyshchuck

  • Posts: 9
Re: Polish letters in AGS
« Reply #12 on: 14 Apr 2018, 19:05 »
Imho one alternative that might be tried here is to script custom key input handling, not relying on key_press function and keycodes it receives, but checking IsKeyPressed in repeatedly_execute.

That was great suggestion. I've managed to mix Snarky's script with kecode rules and additional iskeypressed conditions and it works, while
- it can be simplified, as I created separate condition for lower-case and upper-case of every letter
- 211 is Ł, 243 is ł, 212 is Ć and 244 is ć
- it needs multiplication for other diacritic signs
Code: Adventure Game Studio
  1.       if (keycode == 94)
  2.       {
  3.         if ((IsKeyPressed(eKeyL)) && (IsKeyPressed (404)))
  4.         {
  5.  
  6.           _textFieldTexts[id] = _textFieldTexts[id].InsertChar(211, this._caretIndex);
  7.           this._caretIndex++;
  8.           this.UpdateDisplay();
  9.         }
  10.        
  11.         else if (IsKeyPressed(eKeyL))
  12.         {
  13.           _textFieldTexts[id] = _textFieldTexts[id].InsertChar(243, this._caretIndex);
  14.           this._caretIndex++;
  15.           this.UpdateDisplay();
  16.         }
  17.         if ((IsKeyPressed(eKeyC)) && (IsKeyPressed (404)))
  18.         {
  19.           _textFieldTexts[id] = _textFieldTexts[id].InsertChar(212, this._caretIndex);
  20.           this._caretIndex++;
  21.         this.UpdateDisplay();
  22.         }
  23.         else if (IsKeyPressed(eKeyC))
  24.         {
  25.  
  26.           _textFieldTexts[id] = _textFieldTexts[id].InsertChar(244, this._caretIndex);
  27.           this._caretIndex++;
  28.         this.UpdateDisplay();
  29.         }
  30. }