Author Topic: HANDLE_CHARSETS help?  (Read 208 times)

Offline qwertyqwerty

  • Planewalker
  • *****
  • Posts: 50
HANDLE_CHARSETS help?
« on: April 20, 2017, 11:42:00 AM »
I'm trying to get my head around this function, and have some questions:

1) What's the point of reload_array? The doc says "You should use this variable for reloading those TRA files loaded by LANGUAGE which should also be converted". Aren't they all supposed to be converted? Why would someone want to not reload the files that have been converted?

2) How do I use noconvert_array? Are filenames supposed to be relative to MOD_FOLDER? tra_path? I've tried various combinations, and it doesn't seem to make a difference.

3) Why does everyone (I checked a few mods) seem to initialize convert_array and noconvert_array with empty arrays? Is it necessary?
« Last Edit: April 21, 2017, 12:02:25 AM by qwertyqwerty »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 833
Re: HANDLE_CHARSETS help?
« Reply #1 on: April 20, 2017, 12:01:15 PM »
1. You use HANDLE_CHARSETS on all TRA files containing game text. A subset of those may have been loaded into the global scope by LANGUAGE before HANDLE_CHARSETS is called. These need to be reloaded. You specifically do not want to load everything into the global scope, for all the usual reasons for why you want to keep things locally scoped.

2. It's filenames only, without extensions or paths. If noconvert_array contains "setup" no file called "setup.tra" will be converted.

3. I have no idea. No, it is not necessary. Edwin Romance does not do this and to the extent there is official working code for calling HANDLE_CHARSETS, ER is it.

Offline qwertyqwerty

  • Planewalker
  • *****
  • Posts: 50
Re: HANDLE_CHARSETS help?
« Reply #2 on: April 21, 2017, 12:35:36 AM »
1. But weidu already has all the information about which files were loaded by LANGUAGE, and if they have been converted, right? In that case, I don't see the purpose of having reload_array variable in the first place, it only opens a human error possibility.

2. I see. So if I need to skip convert for a file, I should keep in mind that it will be skipped in all languages.

3. What's the best practice for handling TRA currently, then? Supposing that I have multiple languages, multiple scripts and dialogs, and custom weidu prompts?
Should TRA be split per dialog and loaded on COMPILE with AUTO_TRA? Setup and weidu prompts into no-convert separate files? And the rest of in-game text put into common "text.tra"?

Code: [Select]
AUTO_TRA ~%MOD_FOLDER%/tra/%s~

ALWAYS
  ACTION_IF ENGINE_IS ~bgee bg2ee iwdee eet~ BEGIN
    ACTION_DEFINE_ARRAY charsetsNoConvertArray BEGIN setup weidu END
    ACTION_DEFINE_ARRAY charsetsReloadArray BEGIN text END
    LAF ~HANDLE_CHARSETS~
      INT_VAR
        infer_charsets = 1
      STR_VAR
        tra_path = ~%MOD_FOLDER%/tra~
        iconv_path = ~%MOD_FOLDER%/tools/iconv~
        noconvert_array = charsetsNoConvertArray
        reload_array = charsetsReloadArray
    END
  END
END

LANGUAGE ~English~ ~english~ ~%MOD_FOLDER%/tra/english/text.tra~ ~%MOD_FOLDER%/tra/english/setup.tra~ ~%MOD_FOLDER%/tra/english/weidu.tra~
LANGUAGE ~Deutsch~ ~german~ ~%MOD_FOLDER%/tra/german/text.tra~ ~%MOD_FOLDER%/tra/german/setup.tra~ ~%MOD_FOLDER%/tra/german/weidu.tra~
« Last Edit: April 21, 2017, 12:38:10 AM by qwertyqwerty »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 833
Re: HANDLE_CHARSETS help?
« Reply #3 on: April 21, 2017, 11:36:19 AM »
1. But weidu already has all the information about which files were loaded by LANGUAGE, and if they have been converted, right? In that case, I don't see the purpose of having reload_array variable in the first place, it only opens a human error possibility.
WeiDU in the nebulous sense can re-arrive at which specific TRA files were loaded by LANGUAGE. The actions-n-patches code hasn't got the first clue. The trarefs just exist, and if they don't, that's an error. I can make reload_array obsolete, but it's a rather niche use-case and the long plan has kind of not been to rely on HANDLE_CHARSETS forever (but it certainly looks like it's going to be a long while).

Quote
3. What's the best practice for handling TRA currently, then? Supposing that I have multiple languages, multiple scripts and dialogs, and custom weidu prompts?
Should TRA be split per dialog and loaded on COMPILE with AUTO_TRA? Setup and weidu prompts into no-convert separate files? And the rest of in-game text put into common "text.tra"?
Text that's destined for TLK should be put in a separate file from text that is used during the installation, so the files may be independently encoded. Apart from that, I think it's mostly personal preference. Yeah, I'd say a different TRA file for each D. More generally, I would advocate wise use of local scoping to avoid conflicts. For example, any time you might be tempted to use different integer ranges to avoid tra-space conflicts, you might instead want to use different files and, say, WITH_TRA.

Offline qwertyqwerty

  • Planewalker
  • *****
  • Posts: 50
Re: HANDLE_CHARSETS help?
« Reply #4 on: April 22, 2017, 11:38:01 AM »
thank you fro clarification

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: