diff options
Diffstat (limited to 'devtools/create_bladerunner')
10 files changed, 327 insertions, 317 deletions
diff --git a/devtools/create_bladerunner/subtitles/README.md b/devtools/create_bladerunner/subtitles/README.md index ea438217bf..6df5849c1f 100644 --- a/devtools/create_bladerunner/subtitles/README.md +++ b/devtools/create_bladerunner/subtitles/README.md @@ -3,75 +3,75 @@ Some tools written in __Python 2.7__ to help add support for subtitles in Westwo The official English, German, French, Italian and Spanish versions of the game should be supported. ## Quick guide for volunteer transcribers -1. Please make sure you have an audio player installed in your Operating System (such as VLC). +1. Please make sure you have an audio player installed in your Operating System (such as VLC). -2. You will need python 2.7 installed for this guide, as well as the python libraries Pillow (or PIL), xlrd, xlwt, wave and xlutils. +2. You will need python 2.7 installed for this guide, as well as the python libraries Pillow (or PIL), xlrd, xlwt, wave and xlutils. -3. Using git, checkout the latest revision of the ScummVM repository from GitHub. +3. Using git, checkout the latest revision of the ScummVM repository from GitHub. -4. Make sure you've created a Blade Runner game directory and added Blade Runner in ScummVM as per the instructions in the wiki (the actual required files are __1.TLK, 2.TLK, 3.TLK, A.TLK and SPCHSFX.TLK__: <https://wiki.scummvm.org/index.php?title=User_Manual/Installing_a_game_for_use_with_ScummVM#Blade_Runner> +4. Make sure you've created a Blade Runner game directory and added Blade Runner in ScummVM as per the instructions in the wiki (the actual required files are __1.TLK, 2.TLK, 3.TLK, A.TLK and SPCHSFX.TLK__: <https://wiki.scummvm.org/index.php?title=User_Manual/Installing_a_game_for_use_with_ScummVM#Blade_Runner> For this guide it is assumed that this folder is: ``` C:\Westwood\Blade Runner\ ``` -5. Create a folder on your HDD to export all speech audio from the game. Eg. create: +5. Create a folder on your HDD to export all speech audio from the game. Eg. create: ``` C:\Westwood\Blade Runner\AUDIO_FRA\ ``` -6. Export all speech audio from the game and create an Excel file (xls) with links to the audio files. - * You will need to have some free HDD space for this step (around 650MB). - - * Using a command line interface (eg MSYS2) navigate to the ScummVM repository folder and issue a command like the one below, making sure you specify the correct target language code for your requirements; supported language codes are "EN\_ANY" for English, "FR\_FRA" for French, "DE\_DEU" for German, "IT\_ITA" for Italian, "ES\_ESP" for Spanish and "RU\_RUS" for Russian (version by Fargus Multimedia). - - * In the following example we assume we need to export the audio from the French version of the game. This could take a few minutes to complete. Please refer to the [quotesSpreadsheetCreator](#quotesspreadsheetcreator-quotespreadsheetcreatorpy) section of this document for more command-line options for this tool. -```bash -python2.7 devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py -op "/c/Westwood/Blade Runner/AUDIO_FRA" -ip "/c/Westwood/Blade Runner" -ian "devtools/create_bladerunner/subtitles/common/actornames.txt" -xwav -ld FR_FRA -``` +6. Export all speech audio from the game and create an Excel file (xls) with links to the audio files. + * You will need to have some free HDD space for this step (around 650MB). -7. When you've completed the above step, an Excel file should be created in your current folder, named "out-French.xls". Open this file with a spreadsheet editor app (tested with Microsoft Excel 2007 and LibreOffice Calc 6.2.4) and select the "INGQUO_#.TR#" sheet. - * Please keep the column A ("Filename") as is. Do not modify the contents of this column. - - * Edit column B ("Quote") to put in the text for your transcript of the corresponding audio file - - * Use column G ("ShortHandFileName") to play the audio file for the quote to be transcribed in the same line. You should be able to double click in MS Excel or Ctrl+Click on the specific cell; an audio player will be launched automatically to play the audio file. - - * Note that the columns used by the tool that will create the final subtitles file are only columns A and B. + * Using a command line interface (eg MSYS2) navigate to the ScummVM repository folder and issue a command like the one below, making sure you specify the correct target language code for your requirements; supported language codes are "EN\_ANY" for English, "FR\_FRA" for French, "DE\_DEU" for German, "IT\_ITA" for Italian, "ES\_ESP" for Spanish and "RU\_RUS" for Russian (version by Fargus Multimedia). + + * In the following example we assume we need to export the audio from the French version of the game. This could take a few minutes to complete. Please refer to the [quotesSpreadsheetCreator](#quotesspreadsheetcreator-quotespreadsheetcreatorpy) section of this document for more command-line options for this tool. + ``` + python2.7 devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py -op "/c/Westwood/Blade Runner/AUDIO_FRA" -ip "/c/Westwood/Blade Runner" -ian "devtools/create_bladerunner/subtitles/common/actornames.txt" -xwav -ld FR_FRA + ``` + +7. When you've completed the above step, an Excel file should be created in your current folder, named "out-French.xls". Open this file with a spreadsheet editor app (tested with Microsoft Excel 2007 and LibreOffice Calc 6.2.4) and select the "INGQUO_#.TR#" sheet. + * Please keep the column A ("Filename") as is. Do not modify the contents of this column. -8. The rest of the sheets in the Excel file, excluding the "SBTLVERS.TRE" which contains versioning info) are the sheets for the video cutscenes. We don't provide links to the audio cues for those subtitles, but we do provide the timings for the English version of these scenes which you can use as a guide, along with the English transcript available online here: <https://docs.google.com/spreadsheets/d/17ew0YyhSwqcqZg6bXrIgz0GkA62dhgViHN15lOu5Hj8/edit?usp=sharing> - * Note that the important columns used by the tool that will create the final subtitles file are in this case only columns A ("Frame Start"), B ("Frame End") and C ("Subtitle"). + * Edit column B ("Quote") to put in the text for your transcript of the corresponding audio file - * Fill in column C with the subtitle text, and set the values in columns A and B to adjust when the subtitle should start and when it should stop being displayed respectively. + * Use column G ("ShortHandFileName") to play the audio file for the quote to be transcribed in the same line. You should be able to double click in MS Excel or Ctrl+Click on the specific cell; an audio player will be launched automatically to play the audio file. -9. You may edit the info in the "SBTLVERS.TRE" sheet to fill in the credits and a version number for your transcript. + * Note that the columns used by the tool that will create the final subtitles file are only columns A and B. + +8. The rest of the sheets in the Excel file, excluding the "SBTLVERS.TRE" which contains versioning info) are the sheets for the video cutscenes. We don't provide links to the audio cues for those subtitles, but we do provide the timings for the English version of these scenes which you can use as a guide, along with the English transcript available online here: <https://docs.google.com/spreadsheets/d/17ew0YyhSwqcqZg6bXrIgz0GkA62dhgViHN15lOu5Hj8/edit?usp=sharing> + * Note that the important columns used by the tool that will create the final subtitles file are in this case only columns A ("Frame Start"), B ("Frame End") and C ("Subtitle"). + + * Fill in column C with the subtitle text, and set the values in columns A and B to adjust when the subtitle should start and when it should stop being displayed respectively. + +9. You may edit the info in the "SBTLVERS.TRE" sheet to fill in the credits and a version number for your transcript. 10. If you're transcribing for a non-Latin language, you will need to create a special font for the subtitles in order for the game to display your transcript properly. Please, refer to the [fontCreator](#fontcreator-fontcreatorpy) section of this document for this process. ## Building and installing a SUBTITLES.MIX file with a "make" command You need to follow these instructions: -1. Download the online Excel transcript and save it as "englishTranscript.xlsx" into the "devtools\create_bladerunner\subtitles\sampleInput" folder. +1. Download the online Excel transcript and save it as "englishTranscript.xlsx" into the "devtools\create_bladerunner\subtitles\sampleInput" folder. __The online Excel file is available here:__ <https://docs.google.com/spreadsheets/d/17ew0YyhSwqcqZg6bXrIgz0GkA62dhgViHN15lOu5Hj8/edit?usp=sharing> -2. Edit your font glyphs PNG file (or use the provided one in the sampleInput folder). This file should be stored as "subtitlesFont.png" into the "devtools\create\_bladerunner\subtitles\sampleInput" folder. +2. Edit your font glyphs PNG file (or use the provided one in the sampleInput folder). This file should be stored as "subtitlesFont.png" into the "devtools\create\_bladerunner\subtitles\sampleInput" folder. -3. Create an overrideEncodingSUBLTS.txt file in the sampleInput folder. This is a configuration file for the font file creation. A sample is provided in the sampleInput folder and documentation about this is below in this document (see "override encoding text file" in fontCreator). +3. Create an overrideEncodingSUBLTS.txt file in the sampleInput folder. This is a configuration file for the font file creation. A sample is provided in the sampleInput folder and documentation about this is below in this document (see "override encoding text file" in fontCreator). -4. Create a configureFontsTranslation.txt in the sampleInput folder. A configuration file for the MIX file creation. A sample is provided in the sampleInput folder and documentation about this is below in this document (see "text configuration file" in mixResourceCreator). +4. Create a configureFontsTranslation.txt in the sampleInput folder. A configuration file for the MIX file creation. A sample is provided in the sampleInput folder and documentation about this is below in this document (see "text configuration file" in mixResourceCreator). -5. From the ScummVM root folder run: +5. From the ScummVM root folder run: ``` make devtools/create_bladerunner/subtitles ``` -6. You may need to install some required Python 2 libraries such as Pillow (or PIL), xlrd, xlwt and wave (which is part of the Python 2 Standard Library). +6. You may need to install some required Python 2 libraries such as Pillow (or PIL), xlrd, xlwt and wave (which is part of the Python 2 Standard Library). -7. Copy the output file "SUBTITLES.MIX", created in the ScummVM root folder, into your Blade Runner game directory. +7. Copy the output file "SUBTITLES.MIX", created in the ScummVM root folder, into your Blade Runner game directory. -8. Launch the Blade Runner game using ScummVM. +8. Launch the Blade Runner game using ScummVM. ## quotesSpreadsheetCreator (quoteSpreadsheetCreator.py) (requires python libs *xlwt* (tested with version 1.3.0), *wave* (included in the Python 2 Standard Library) @@ -87,26 +87,26 @@ __The online Excel file is available here:__ Syntax Notes: -1. The "-op" switch should be followed by the path to the folder where the WAV files should be exported; This folder path will also be used as input when the output Excel will be created (for the "INGQUO\_x.TRx" sheet with the in-game quotes). +1. The "-op" switch should be followed by the path to the folder where the WAV files should be exported; This folder path will also be used as input when the output Excel will be created (for the "INGQUO\_x.TRx" sheet with the in-game quotes). -2. The "-ip" switch should be followed by the path to the game's folder, where the TLK and MIX files reside. +2. The "-ip" switch should be followed by the path to the game's folder, where the TLK and MIX files reside. -3. The "-ian" optional switch is followed by the path to the actornames.txt file -- if this is omitted then the file is assumed to reside in the current working directory. +3. The "-ian" optional switch is followed by the path to the actornames.txt file -- if this is omitted then the file is assumed to reside in the current working directory. -4. The "-ld" optional switch is followed by a language description for the language of the game you are exporting Text Resources from. This switch is meaningful when you also use the "-xtre" switch to export Text Resource files. - * Valid language values are: EN\_ANY, DE\_DEU, FR\_FRA, IT\_ITA, ES\_ESP, RU\_RUS +4. The "-ld" optional switch is followed by a language description for the language of the game you are exporting Text Resources from. This switch is meaningful when you also use the "-xtre" switch to export Text Resource files. + * Valid language values are: EN\_ANY, DE\_DEU, FR\_FRA, IT\_ITA, ES\_ESP, RU\_RUS - * Default language value is: EN\_ANY (English) + * Default language value is: EN\_ANY (English) -5. The "-xwav" optional switch will export __ALL__ game's audio files (AUD) (that are either speech or speech-related) in a WAV format. This is expected to run for a few minutes and take up quite a lot of your HDD space (around 650MB). +5. The "-xwav" optional switch will export __ALL__ game's audio files (AUD) (that are either speech or speech-related) in a WAV format. This is expected to run for a few minutes and take up quite a lot of your HDD space (around 650MB). -6. The "-xtre" optional switch will add extra sheets to the output Excel with the contents of each of the game's Text Resource files (TRx) (on sheet per TRx file). +6. The "-xtre" optional switch will add extra sheets to the output Excel with the contents of each of the game's Text Resource files (TRx) (on sheet per TRx file). -7. The "-xdevs" optional switch will add a sheet for Developer Commentary text and some additional voice-overs from SFX.MIX. +7. The "-xdevs" optional switch will add a sheet for Developer Commentary text and some additional voice-overs from SFX.MIX. -8. The "-xpogo" optional switch will add a sheet for the POGO text. +8. The "-xpogo" optional switch will add a sheet for the POGO text. -9. You may use all, a subset or none of the "-xwav", "-xtre", "-xpogo", "-xdevs" switches, depending on what you need to do. +9. You may use all, a subset or none of the "-xwav", "-xtre", "-xpogo", "-xdevs" switches, depending on what you need to do. 10. The "--trace" optional switch enables extra debug messages to be printed. @@ -131,44 +131,46 @@ The tool __requires__ a valid path to the actornames.txt file, which is included Syntax Notes: -1. The "-x" switch is followed by the path to the input Excel file (xls or xlsx) which should contain the transcript sheet(s). +1. The "-x" switch is followed by the path to the input Excel file (xls or xlsx) which should contain the transcript sheet(s). -2. The "-ian" optional switch is followed by the path to the actornames.txt file -- if this is omitted then the file is assumed to reside in the current working directory. +2. The "-ian" optional switch is followed by the path to the actornames.txt file -- if this is omitted then the file is assumed to reside in the current working directory. -3. The "-cft" optional switch is followed by the path to the text configuration file "configureFontsTranslation.txt" -- if this is omitted then the file is assumed to reside in the current working directory. +3. The "-cft" optional switch is followed by the path to the text configuration file "configureFontsTranslation.txt" -- if this is omitted then the file is assumed to reside in the current working directory. -4. The "-ld" optional switch is followed by a language description for the language of the game you are exporting Text Resources from. This switch is meaningful when you also use the "-xtre" switch to export Text Resource files. - * Valid language values are: EN\_ANY, DE\_DEU, FR\_FRA, IT\_ITA, ES\_ESP, RU\_RUS, EFIGS +4. The "-ld" optional switch is followed by a language description for the language of the game you are exporting Text Resources from. This switch is meaningful when you also use the "-xtre" switch to export Text Resource files. + * Valid language values are: EN\_ANY, DE\_DEU, FR\_FRA, IT\_ITA, ES\_ESP, RU\_RUS, EFIGS - * Default language value is: EN\_ANY (English) + * Default language value is: EN\_ANY (English) -5. The "--trace" optional switch enables extra debug messages to be printed. +5. The "--trace" optional switch enables extra debug messages to be printed. The __text configuration file "configureFontsTranslation.txt"__ is a __text file that should be saved in a UTF-8 encoding (no BOM)__, that contains the following: -1. Multiple lines (practically one per imported Font type) with the key "fontNameAndOutOfOrderGlyphs" and a '#'-separated value that contains: - * the name of an in-game Font "type" that will be included in the SUBTITLES.MIX resource archive. You could also have lines for Font "types" not imported in the SUBTITLES.MIX, but are already Font types used by the game (eg. KIA6PT) especially when you intend to add translated/ updated TRx files in the SUBTITLES.MIX (however even in that case, there are default settings for those fonts that the script will use if you don't specify alternative settings in this file to override them). Valid values can be: SUBTLS\_E (for all subtitles), KIA6PT, TAHOMA (for both TAHOMA18 and TAHOMA24), SYSTEM (this is basically for the ERRORMSG.TRx). +1. Multiple lines (practically one per imported Font type) with the key "fontNameAndOutOfOrderGlyphs" and a '#'-separated value that contains: + * the name of an in-game Font "type" that will be included in the SUBTITLES.MIX resource archive. You could also have lines for Font "types" not imported in the SUBTITLES.MIX, but are already Font types used by the game (eg. KIA6PT) especially when you intend to add translated/ updated TRx files in the SUBTITLES.MIX (however even in that case, there are default settings for those fonts that the script will use if you don't specify alternative settings in this file to override them). Valid values can be: SUBTLS\_E (for all subtitles), KIA6PT, TAHOMA (for both TAHOMA18 and TAHOMA24), SYSTEM (this is basically for the ERRORMSG.TRx). - * a '#' character after the font type + * a '#' character after the font type - * the name of the 8-bit string encoding (codepage) (eg. cp437 or windows-1252) that should be used to store the texts that uses this particular font "type" in the game's TRx text resource files. Valid values can be the standard encodings listed in python's page: + * the name of the 8-bit string encoding (codepage) (eg. cp437 or windows-1252) that should be used to store the texts that uses this particular font "type" in the game's TRx text resource files. Valid values can be the standard encodings listed in python's page: <https://docs.python.org/2.7/library/codecs.html#standard-encodings> - * a '#' character after the target Encoding - * a list of comma separated tuples that specify the mapping of special (out of order) character to placeholder characters from the selected codepage. See fontCreator section for more details on this. - * For example: -``` -fontNameAndOutOfOrderGlyphs=SUBTLS_E#windows-1253#í:Ά,ñ:¥,â:¦,é:§,Ά:£ -fontNameAndOutOfOrderGlyphs=KIA6PT#cp437# -fontNameAndOutOfOrderGlyphs=TAHOMA#cp437# -fontNameAndOutOfOrderGlyphs=SYSTEM#latin-1# -``` + * a '#' character after the target Encoding + + * a list of comma separated tuples that specify the mapping of special (out of order) character to placeholder characters from the selected codepage. See fontCreator section for more details on this. + + * For example: + ``` + fontNameAndOutOfOrderGlyphs=SUBTLS_E#windows-1253#í:Ά,ñ:¥,â:¦,é:§,Ά:£ + fontNameAndOutOfOrderGlyphs=KIA6PT#cp437# + fontNameAndOutOfOrderGlyphs=TAHOMA#cp437# + fontNameAndOutOfOrderGlyphs=SYSTEM#latin-1# + ``` Note: for font files (FON) that you have created or edited with the fontCreator tool (e.g for the "SUBTLS\_E.FON" file for subtitles, or another in-game font file eg. KIA6PT, TAHOMA) you __should copy the 8-bit encoding and the comma separated out of order character tuples from the respective "override encoding" text file that you used with the fontCreator tool for each new/ edited font in the configureFontsTranslation.txt fields__. - Additionally, __all the new and edited fonts (FON files that were output by the fontCreator script) should be in your working directory__ in order to include them in the SUBTITLES.MIX. +Additionally, __all the new and edited fonts (FON files that were output by the fontCreator script) should be in your working directory__ in order to include them in the SUBTITLES.MIX. - It's important to keep the naming of those files unchanged. __Supported name values for imported FON files__ are: SUBTLS\_E.FON, KIA6PT.FON, TAHOMA18.FON, TAHOMA24.FON and SYSTEM.FON (practically you won't be using the last one). +It's important to keep the naming of those files unchanged. __Supported name values for imported FON files__ are: SUBTLS\_E.FON, KIA6PT.FON, TAHOMA18.FON, TAHOMA24.FON and SYSTEM.FON (practically you won't be using the last one). ## fontCreator (fontCreator.py) (requires python Image library *Pillow* (tested with version 5.4.1)) @@ -192,103 +194,103 @@ This tool __requires an override encoding text file__ in its Syntax B mode (subt The override encoding file is a __text file that should be saved in a UTF-8 encoding (no BOM)__, that contains the following: -1. A key "targetEncoding" with a value of the name of the ASCII codepage (8-bit encoding) that should be used for the character fonts (eg windows-1253). Valid values can be the standard encodings listed in python's page: +1. A key "targetEncoding" with a value of the name of the ASCII codepage (8-bit encoding) that should be used for the character fonts (eg windows-1253). Valid values can be the standard encodings listed in python's page: <https://docs.python.org/2.7/library/codecs.html#standard-encodings> -2. A key "asciiCharList" with value the "all-characters" string with all the printable characters that will be used in-game, from the specified codepage. Keep in mind that: - * The first such character (typically this is the '!' character) should be repeated twice! +2. A key "asciiCharList" with value the "all-characters" string with all the printable characters that will be used in-game, from the specified codepage. Keep in mind that: + * The first such character (typically this is the '!' character) should be repeated twice! - * All characters must belong to the specified codepage. + * All characters must belong to the specified codepage. - * The order that the characters appear in the string should match their order in the ASCII table of the codepage. + * The order that the characters appear in the string should match their order in the ASCII table of the codepage. - * You don't need to use all the characters of the specified codepage in your "all-characters" string. + * You don't need to use all the characters of the specified codepage in your "all-characters" string. - * For any special characters that don't appear in the target codepage (eg ñ, é, í, â don't appear in the Greek codepage), you'll have to decide on an ASCII value for them (one not used by another character appearing in-game). + * For any special characters that don't appear in the target codepage (eg ñ, é, í, â don't appear in the Greek codepage), you'll have to decide on an ASCII value for them (one not used by another character appearing in-game). - * In the "all-characters" string you should put as placeholders the actual characters from the specified codepage that correspond to the ASCII values you have decided above; The placeholder characters should also be in the proper order (by their ASCII value) inside the string. + * In the "all-characters" string you should put as placeholders the actual characters from the specified codepage that correspond to the ASCII values you have decided above; The placeholder characters should also be in the proper order (by their ASCII value) inside the string. -3. A key "explicitKerningList" with value a list of comma separated tuples where each tuple specifies a character and its manually set kerning (x-offset) in pixels. Kerning can have integer (positive or negative) values. This list is optional and may be skipped, if you put a '-' instead of a list. - * Example: explicitKerningList=i:-1 +3. A key "explicitKerningList" with value a list of comma separated tuples where each tuple specifies a character and its manually set kerning (x-offset) in pixels. Kerning can have integer (positive or negative) values. This list is optional and may be skipped, if you put a '-' instead of a list. + * Example: explicitKerningList=i:-1 - * Don't use space(s) between the tuples! + * Don't use space(s) between the tuples! -4. A key "explicitWidthIncrement" with value a list of comma separated tuples where each tuple specifies a character and its manually set extended width in pixels. This should be a positive integer value. You can skip this list by not writing anything in the file after the previous (manual kerning) list. - * Example: explicitWidthIncrement=i:0,j:1,l:1 +4. A key "explicitWidthIncrement" with value a list of comma separated tuples where each tuple specifies a character and its manually set extended width in pixels. This should be a positive integer value. You can skip this list by not writing anything in the file after the previous (manual kerning) list. + * Example: explicitWidthIncrement=i:0,j:1,l:1 - * Don't use space(s) between the tuples! + * Don't use space(s) between the tuples! -5. A key "originalFontName" with the FON file's original name in the game (the one that it should replace). Use SUBLTS for the subtitles FON. - * Example: originalFontName=SUBLTS +5. A key "originalFontName" with the FON file's original name in the game (the one that it should replace). Use SUBLTS for the subtitles FON. + * Example: originalFontName=SUBLTS -6. A key "specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding" with value a list of comma separated tuples that indicates which character glyphs should replace the placeholder glyphs in your all-character string above. - * Example: specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=í:Ά,ñ:¥,â:¦,é:§,Ά:£ +6. A key "specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding" with value a list of comma separated tuples that indicates which character glyphs should replace the placeholder glyphs in your all-character string above. + * Example: specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=í:Ά,ñ:¥,â:¦,é:§,Ά:£ - * Don't use space(s) between the tuples! + * Don't use space(s) between the tuples! There is a sample of such file in the source folder for the fontCreator tool. __For the exporting of the game fonts (to PNG) mode__, the valid syntax expects only one (1) argument: -1. folderpathForMIXFiles: is the path where the game's MIX files are located (STARTUP.MIX is required). The exported font files will be: 10PT.FON.PNG, TAHOMA18.FON.PNG, TAHOMA24.FON.PNG and KIA6PT.FON.PNG. +1. folderpathForMIXFiles: is the path where the game's MIX files are located (STARTUP.MIX is required). The exported font files will be: 10PT.FON.PNG, TAHOMA18.FON.PNG, TAHOMA24.FON.PNG and KIA6PT.FON.PNG. __For the creation of subtitles' font mode__, there are six (6) mandatory launch arguments for the fontCreator tool: -1. imageRowPNGFilename: is the filename of the input PNG image file which should contain a row of (preferably) tab separated glyphs. Example: "Tahoma\_18ShdwTranspThreshZero003-G5.png". Keep in mind that: - * The first glyph should be repeated here too, as in the override encoding text file. +1. imageRowPNGFilename: is the filename of the input PNG image file which should contain a row of (preferably) tab separated glyphs. Example: "Tahoma\_18ShdwTranspThreshZero003-G5.png". Keep in mind that: + * The first glyph should be repeated here too, as in the override encoding text file. - * Background should be transparent. + * Background should be transparent. - * All colors used in the character glyphs should not have any transparency value (eg from Gimp 2, set Layer->Transparency->Threshold alpha to 0). There's no partial transparency supported by the game. A pixel will either by fully transparent or fully opaque. + * All colors used in the character glyphs should not have any transparency value (eg from Gimp 2, set Layer->Transparency->Threshold alpha to 0). There's no partial transparency supported by the game. A pixel will either by fully transparent or fully opaque. - * If you use special glyphs that are not in the specified ASCII codepage (eg ñ, é, í, â don't appear in the Greek codepage), then in this image file you should use the actual special glyphs - put them at the position of the placeholder characters in your "all-characters" string that you've specified in the override encoding text file. + * If you use special glyphs that are not in the specified ASCII codepage (eg ñ, é, í, â don't appear in the Greek codepage), then in this image file you should use the actual special glyphs - put them at the position of the placeholder characters in your "all-characters" string that you've specified in the override encoding text file. -2. targetFONfilename: Example: "SUBTLS\_E.FON" for the subtitles. +2. targetFONfilename: Example: "SUBTLS\_E.FON" for the subtitles. -3. minSpaceBetweenLettersInRowLeftToLeft: This is a length (positive integer) in pixels that indicates the __minimum__ distance between the left-most side of a glyph and the left-most side of the immediate subsequent glyph in the input image PNG (row of glyphs) file. +3. minSpaceBetweenLettersInRowLeftToLeft: This is a length (positive integer) in pixels that indicates the __minimum__ distance between the left-most side of a glyph and the left-most side of the immediate subsequent glyph in the input image PNG (row of glyphs) file. - This basically tells the tool how far (in the x axis) it can search for pixels that belong to the same glyph). You can input an approximate value here and adjust it based on the output of the tool (the tool should be able to detect ALL the glyphs in the PNG row image file and it will report how many it detected in its output) + This basically tells the tool how far (in the x axis) it can search for pixels that belong to the same glyph). You can input an approximate value here and adjust it based on the output of the tool (the tool should be able to detect ALL the glyphs in the PNG row image file and it will report how many it detected in its output) -4. minSpaceBetweenLettersInColumnTopToTop: This is a positive integer in pixels that indicates the __minimum__ distance between the top-most pixel of a glyph and the top-most pixel of a glyph on another row of the input image file. +4. minSpaceBetweenLettersInColumnTopToTop: This is a positive integer in pixels that indicates the __minimum__ distance between the top-most pixel of a glyph and the top-most pixel of a glyph on another row of the input image file. - It is highly recommended, though, that the input image file should contain only a single row of glyphs and this value should be higher than the maximum height among the glyphs, typically this should be set to approximately double the maximum height of glyph. + It is highly recommended, though, that the input image file should contain only a single row of glyphs and this value should be higher than the maximum height among the glyphs, typically this should be set to approximately double the maximum height of glyph. -5. kerningForFirstDummyFontGlyph: This is an integer that explicitly indicates the kerning, ie. offset in pixels (on the x-axis) of the first glyph (the one that is repeated twice). This can be measured by observing the indent that your image processing app adds when you enter the first glyph (typically it should be only a few pixels) +5. kerningForFirstDummyFontGlyph: This is an integer that explicitly indicates the kerning, ie. offset in pixels (on the x-axis) of the first glyph (the one that is repeated twice). This can be measured by observing the indent that your image processing app adds when you enter the first glyph (typically it should be only a few pixels) -6. whiteSpaceWidthInPixels: This is a positive integer value that sets the width in pixels for the single white space between words for the subtitles in-game. +6. whiteSpaceWidthInPixels: This is a positive integer value that sets the width in pixels for the single white space between words for the subtitles in-game. The "--trace" optional switch enables extra debug messages to be printed. A suggested method of creating decent looking PNG with the row of glyphs for your subtitles' font is the following: -1. Create the font row in __GIMP__ - * Start with a __new__ empty image, with transparent background. Choose a large enough canvas width (you can adjust it later) +1. Create the font row in __GIMP__ + * Start with a __new__ empty image, with transparent background. Choose a large enough canvas width (you can adjust it later) - * Paste as a new layer a tab separated alphanumeric sequence with all your glyphs (as specified above). Choose white as the font's color. + * Paste as a new layer a tab separated alphanumeric sequence with all your glyphs (as specified above). Choose white as the font's color. - * Adjust your canvas' width and height to make sure all the glyphs are within its borders. + * Adjust your canvas' width and height to make sure all the glyphs are within its borders. -2. Add layers for shadows if necessary (recommended) by duplicating the original layer with the (white colored) glyphs to create layers that would be used for the shadow effect. Those layers should be __colorified__ as black and placed behind the original layer, displaced by one (1) pixel from eg. the top, right, left, and bottom (it's recommended to do this for all of those four). +2. Add layers for shadows if necessary (recommended) by duplicating the original layer with the (white colored) glyphs to create layers that would be used for the shadow effect. Those layers should be __colorified__ as black and placed behind the original layer, displaced by one (1) pixel from eg. the top, right, left, and bottom (it's recommended to do this for all of those four). -3. __Merge all visible__ layers (maintaining an alpha channel for the background) +3. __Merge all visible__ layers (maintaining an alpha channel for the background) -4. __Select all__ and __float the selection__, which should create a floating selection with all the letter glyphs. - * __Promote that selection to a layer__ and __duplicate__ it. +4. __Select all__ and __float the selection__, which should create a floating selection with all the letter glyphs. + * __Promote that selection to a layer__ and __duplicate__ it. -5. Choose one of the duplicated layers and __COLORIFY__ it to pitch black. - * __Set the transparency threshold__ of this black layer to 0. +5. Choose one of the duplicated layers and __COLORIFY__ it to pitch black. + * __Set the transparency threshold__ of this black layer to 0. -6. Finally, place this completely black colored layer underneath the other one and __merge the visible__ layers. +6. Finally, place this completely black colored layer underneath the other one and __merge the visible__ layers. -7. Export your image to a PNG file. +7. Export your image to a PNG file. This should get rid of semi-transparent pixels while maintaining the "aliasing" effect. There could be a better way but this should work ok. # Credits and Special Thanks -- All the developer guys from the ScummVM (https://github.com/scummvm/scummvm) team, and especially the ones involved in the implementation of the BladeRunner engine for ScummVM (madmoose, peterkohaut, sev and everyone else). +- All the developer guys from the ScummVM (https://github.com/scummvm/scummvm) team, and especially the ones involved in the implementation of the BladeRunner engine for ScummVM (madmoose, peterkohaut, sev and everyone else). -- The information provided in this blog (http://westwoodbladerunner.blogspot.ca) by Michael Liebscher. +- The information provided in this blog (http://westwoodbladerunner.blogspot.ca) by Michael Liebscher. -- The creator of br-mixer (https://github.com/bdamer/br-mixer), Ben Damer, who also has a blog entry about the game resource file formats (http://afqa123.com/2015/03/07/deciphering-blade-runner/) +- The creator of br-mixer (https://github.com/bdamer/br-mixer), Ben Damer, who also has a blog entry about the game resource file formats (http://afqa123.com/2015/03/07/deciphering-blade-runner/) diff --git a/devtools/create_bladerunner/subtitles/common/vqasTextResource.py b/devtools/create_bladerunner/subtitles/common/vqasTextResource.py index daa8577027..f9b909be7c 100644 --- a/devtools/create_bladerunner/subtitles/common/vqasTextResource.py +++ b/devtools/create_bladerunner/subtitles/common/vqasTextResource.py @@ -458,7 +458,7 @@ ALL_VQA_TEXT_RESOURCES_LISTS = [ # # # -class vqasTextResource: +class vqasTextResource(object): m_traceModeEnabled = True # traceModeEnabled is bool to enable more printed debug messages def __init__(self, traceModeEnabled = True): @@ -466,20 +466,26 @@ class vqasTextResource: return def printAllVqasTextResource(self): + if self.m_traceModeEnabled: + print "[Trace] printing all VQAs Text" for (vqaKeyStr, vqaTreList) in ALL_VQA_TEXT_RESOURCES_LISTS: - print "VQA prefix: %s" % (vqaKeyStr) + print "VQA prefix: %s" % (vqaKeyStr) for (startFrameTre, endFrameTre, textTre, timeStartTre, timeEndTre, byActorTre) in vqaTreList: print "%s\t%s\t%s\t%s\t%s\t%s" % (startFrameTre, endFrameTre, textTre, timeStartTre, timeEndTre, byActorTre) return def getVqaEntriesList(self, sVQASheetPrefix): + if self.m_traceModeEnabled: + print "[Trace] getVqaEntriesList()" for (vqaKeyStr, vqaTreList) in ALL_VQA_TEXT_RESOURCES_LISTS: if (vqaKeyStr == sVQASheetPrefix.upper()): return vqaTreList return None - +# +# +# if __name__ == '__main__': - # main() + # main() print "[Debug] Running %s as main module" % (my_module_name) traceModeEnabled = False vqaTRInstance = vqasTextResource(traceModeEnabled) diff --git a/devtools/create_bladerunner/subtitles/fontCreator/fonFileLib.py b/devtools/create_bladerunner/subtitles/fontCreator/fonFileLib.py index c66b5fdc74..e998c597c5 100644 --- a/devtools/create_bladerunner/subtitles/fontCreator/fonFileLib.py +++ b/devtools/create_bladerunner/subtitles/fontCreator/fonFileLib.py @@ -8,37 +8,37 @@ structLibFound = False imagePilLibFound = False try: - import os + import os except ImportError: - print "[Error] os python library is required to be installed!" + print "[Error] os python library is required to be installed!" else: osLibFound = True try: - import sys + import sys except ImportError: - print "[Error] sys python library is required to be installed!" + print "[Error] sys python library is required to be installed!" else: sysLibFound = True try: - import shutil + import shutil except ImportError: - print "[Error] Shutil python library is required to be installed!" + print "[Error] Shutil python library is required to be installed!" else: shutilLibFound = True try: - import struct + import struct except ImportError: - print "[Error] struct python library is required to be installed!" + print "[Error] struct python library is required to be installed!" else: structLibFound = True try: - from PIL import Image + from PIL import Image except ImportError: - print "[Error] Image python library (PIL) is required to be installed!" + print "[Error] Image python library (PIL) is required to be installed!" else: imagePilLibFound = True @@ -55,29 +55,29 @@ from struct import * MY_MODULE_VERSION = "0.80" MY_MODULE_NAME = "fonFileLib" -class FonHeader: +class FonHeader(object): maxEntriesInTableOfDetails = -1 # this is probably always the number of entries in table of details, but it won't work for the corrupted TAHOMA18.FON file maxGlyphWidth = -1 # in pixels maxGlyphHeight = -1 # in pixels graphicSegmentByteSize = -1 # Graphic segment byte size - + def __init__(self): return -class fonFile: +class fonFile(object): m_header = FonHeader() - + simpleFontFileName = 'GENERIC.FON' - realNumOfCharactersInImageSegment = 0 # this is used for the workaround for the corrupted TAHOME18.FON + realNumOfCharactersInImageSegment = 0 # this is used for the workaround for the corrupted TAHOME18.FON nonEmptyCharacters = 0 - - glyphDetailEntriesLst = [] # list of 5-value tuples. Tuple values are (X-offset, Y-offset, Width, Height, Offset in Graphics segment) - glyphPixelData = None # buffer of pixel data for glyphs - + + glyphDetailEntriesLst = [] # list of 5-value tuples. Tuple values are (X-offset, Y-offset, Width, Height, Offset in Graphics segment) + glyphPixelData = None # buffer of pixel data for glyphs + m_traceModeEnabled = False - # traceModeEnabled is bool to enable more printed debug messages + # traceModeEnabled is bool to enable more printed debug messages def __init__(self, traceModeEnabled = True): del self.glyphDetailEntriesLst[:] self.glyphPixelData = None # buffer of pixel data for glyphs @@ -85,12 +85,12 @@ class fonFile: self.realNumOfCharactersInImageSegment = 0 # this is used for the workaround for the corrupted TAHOME18.FON self.nonEmptyCharacters = 0 self.m_traceModeEnabled = traceModeEnabled - + return - + def loadFonFile(self, fonBytesBuff, maxLength, fonFileName): self.simpleFontFileName = fonFileName - + offsInFonFile = 0 localLstOfDataOffsets = [] del localLstOfDataOffsets[:] @@ -101,26 +101,26 @@ class fonFile: tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes self.header().maxEntriesInTableOfDetails = tmpTuple[0] offsInFonFile += 4 - + if self.simpleFontFileName == 'TAHOMA18.FON': # deal with corrupted original 'TAHOMA18.FON' file self.realNumOfCharactersInImageSegment = 176 if self.m_traceModeEnabled: print "[Debug] SPECIAL CASE. WORKAROUND FOR CORRUPTED %s FILE. Only %d characters supported!" % (self.simpleFontFileName, self.realNumOfCharactersInImageSegment) else: self.realNumOfCharactersInImageSegment = self.header().maxEntriesInTableOfDetails - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes self.header().maxGlyphWidth = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes self.header().maxGlyphHeight = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes self.header().graphicSegmentByteSize = tmpTuple[0] offsInFonFile += 4 - + if self.m_traceModeEnabled: print "[Debug] Font file (FON) Header Info: " print "[Debug] Number of entries: %d, Glyph max-Width: %d, Glyph max-Height: %d, Graphic Segment size: %d" % (self.header().maxEntriesInTableOfDetails, self.header().maxGlyphWidth, self.header().maxGlyphHeight, self.header().graphicSegmentByteSize) @@ -135,23 +135,23 @@ class fonFile: tmpTuple = struct.unpack_from('i', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes tmpXOffset = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes tmpYOffset = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes tmpWidth = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes tmpHeight = tmpTuple[0] offsInFonFile += 4 - + tmpTuple = struct.unpack_from('I', fonBytesBuff, offsInFonFile) # unsigned integer 4 bytes tmpDataOffset = tmpTuple[0] offsInFonFile += 4 - + if tmpWidth == 0 or tmpHeight == 0: if self.m_traceModeEnabled: print "Index: %d\t UNUSED *****************************************************************" % (idx) @@ -165,42 +165,41 @@ class fonFile: # This never happens in the original files. Offsets are "re-used" but not really because it happens only for empty (height = 0) characters which all seem to point to the next non-empty character if self.m_traceModeEnabled: print "Index: %d\t RE-USING ANOTHER GLYPH *****************************************************************" % (idx) - + self.glyphDetailEntriesLst.append( ( tmpXOffset, tmpYOffset, tmpWidth, tmpHeight, tmpDataOffset) ) - + offsInFonFile = (4 * 4) + (self.header().maxEntriesInTableOfDetails * 5 * 4) # we need the total self.header().maxEntriesInTableOfDetails here and not self.realNumOfCharactersInImageSegment self.glyphPixelData = fonBytesBuff[offsInFonFile:] return True except: print "[Error] Loading Font file (FON) %s failed!" % (self.simpleFontFileName) raise - return False - + return False + def outputFonToPNG(self): - print "[Info] Exporting font file (FON) to PNG: %s" % (self.simpleFontFileName + ".PNG") - + print "[Info] Exporting font file (FON) to PNG: %s" % (self.simpleFontFileName + ".PNG") + targWidth = 0 targHeight = 0 paddingFromTopY = 2 paddingBetweenGlyphsX = 10 - - + if len(self.glyphDetailEntriesLst) == 0 or (len(self.glyphDetailEntriesLst) != self.realNumOfCharactersInImageSegment and len(self.glyphDetailEntriesLst) != self.header().maxEntriesInTableOfDetails) : print "[Error] Font file (FON) loading process did not complete correctly. Missing important data in structures. Cannot output image!" return - + # TODO asdf refine this code here. the dimensions calculation is very crude for now if self.header().maxGlyphWidth > 0 : targWidth = (self.header().maxGlyphWidth + paddingBetweenGlyphsX) * (self.realNumOfCharactersInImageSegment + 1) else: targWidth = 1080 - + # TODO asdf refine this code here. the dimensions calculation is very crude for now if self.header().maxGlyphHeight > 0 : targHeight = self.header().maxGlyphHeight * 2 else: targHeight = 480 - + imTargetGameFont = Image.new("RGBA",(targWidth, targHeight), (0,0,0,0)) #print imTargetGameFont.getbands() # @@ -222,12 +221,12 @@ class fonFile: if (glyphWidth == 0 or glyphHeight == 0): drawIdxDeductAmount += 1 drawIdx = idx - drawIdxDeductAmount - + for colorIdx in range(0, glyphWidth*glyphHeight): tmpTuple = struct.unpack_from('H', self.glyphPixelData, glyphDataOffs) # unsigned short 2 bytes pixelColor = tmpTuple[0] glyphDataOffs += 2 - + # if pixelColor > 0x8000: # print "[Debug] WEIRD CASE" # NEVER HAPPENS - TRANSPARENCY IS ON/OFF. There's no grades of transparency rgbacolour = (0,0,0,0) @@ -239,25 +238,25 @@ class fonFile: tmp8bitB1 = ( (pixelColor & 0x1f) ) << 3 rgbacolour = (tmp8bitR1,tmp8bitG1,tmp8bitB1, 255) # alpha: 1.0 fully opaque #rgbacolour = (255,255,255, 255) # alpha: 1.0 fully opaque - + if currX == glyphWidth: currX = 0 currY += 1 - + imTargetGameFont.putpixel(( (drawIdx + 1) * (self.header().maxGlyphWidth + paddingBetweenGlyphsX ) + currX, paddingFromTopY + glyphYoffs + currY), rgbacolour) currX += 1 try: imTargetGameFont.save(os.path.join('.', self.simpleFontFileName + ".PNG"), "PNG") except Exception as e: print '[Error] Unable to write to output PNG file. ' + str(e) - + def header(self): return self.m_header # # # if __name__ == '__main__': - # main() + # main() errorFound = False # By default assumes a file of name SUBTLS_E.FON in same directory # otherwise tries to use the first command line argument as input file @@ -268,7 +267,7 @@ if __name__ == '__main__': # 'SUBTLS_E.FON' # OUR EXTRA FONT USED FOR SUBTITLES inFONFile = None inFONFileName = 'SUBTLS_E.FON' # Subtitles font custom - + if len(sys.argv[1:]) > 0 \ and os.path.isfile(os.path.join('.', sys.argv[1])) \ and len(sys.argv[1]) >= 5 \ @@ -280,7 +279,7 @@ if __name__ == '__main__': else: print "[Error] No valid input file argument was specified and default input file %s is missing." % (inFONFileName) errorFound = True - + if not errorFound: try: print "[Info] Opening %s" % (inFONFileName) @@ -303,4 +302,5 @@ if __name__ == '__main__': else: #debug #print "[Debug] Running %s imported from another module" % (MY_MODULE_NAME) - pass
\ No newline at end of file + pass +
\ No newline at end of file diff --git a/devtools/create_bladerunner/subtitles/fontCreator/fontCreator.py b/devtools/create_bladerunner/subtitles/fontCreator/fontCreator.py index 177cc5c714..8f1301ba29 100644 --- a/devtools/create_bladerunner/subtitles/fontCreator/fontCreator.py +++ b/devtools/create_bladerunner/subtitles/fontCreator/fontCreator.py @@ -2,15 +2,15 @@ # -*- coding: UTF-8 -*- sysLibFound = False try: - import sys + import sys except ImportError: print ("[Error] sys python library is required to be installed!") else: sysLibFound = True -if (not sysLibFound): +if (not sysLibFound): sys.stdout.write("[Error] Errors were found when trying to import required python libraries\n") - sys.exit(1) + sys.exit(1) if not (sys.version_info[0] == 2 and sys.version_info[1] == 7): sys.stdout.write("[Error] Blade Runner Font Creator script requires Python 2.7\n") diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileDecode.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileDecode.py index 15733488bb..febd0c59f0 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileDecode.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileDecode.py @@ -5,23 +5,15 @@ ctypesLibFound = False structLibFound = False try: - import ctypes + import ctypes except ImportError: - print "[Error] ctypes python library is required to be installed!" + print "[Error] ctypes python library is required to be installed!" else: ctypesLibFound = True -try: - import struct -except ImportError: - print "[Error] struct python library is required to be installed!" -else: - structLibFound = True - -if (not ctypesLibFound) \ - or (not structLibFound): +if (not ctypesLibFound): sys.stdout.write("[Error] Errors were found when trying to import required python libraries\n") - sys.exit(1) + sys.exit(1) from struct import * @@ -97,7 +89,7 @@ def aud_decode_ima_chunk(audioBufferIn, index, sample, cs_chunk): index = 0 elif (index > 88): index = 88 - ## output buffer of shorts + ## output buffer of shorts #binDataOut = struct.pack('h'*len(audioBufferOut), *audioBufferOut) #return (binDataOut, index, sample) return (audioBufferOut, index, sample) @@ -126,23 +118,23 @@ def aud_decode_ws_chunk(inputChunkBuffer, cb_s, cb_d): #return binDataOut return outputChunkBuffer -# const xccTHA::byte* s_end = inputChunkBuffer + cb_s; # FIX +# const xccTHA::byte* s_end = inputChunkBuffer + cb_s; # FIX s_end = inpChBuffIter + cb_s - sample = ctypes.c_int(0x80).value #int sample + sample = ctypes.c_int(0x80).value #int sample while (inpChBuffIter < s_end): inpChBuffIter += 1 - count = ctypes.c_char(inputChunkBuffer[inpChBuffIter] & 0x3f).value # char count - switchKey = inputChunkBuffer[inpChBuffIter - 1] >> 6 # inputChunkBuffer[-1] # b[-1] is *(b - 1) + count = ctypes.c_char(inputChunkBuffer[inpChBuffIter] & 0x3f).value # char count + switchKey = inputChunkBuffer[inpChBuffIter - 1] >> 6 # inputChunkBuffer[-1] # b[-1] is *(b - 1) if switchKey == 0: count += 1 - for iter in range (count, 0, -1): + for iter0 in range (count, 0, -1): inpChBuffIter += 1 - code = ctypes.c_int(inputChunkBuffer[inpChBuffIter]).value # int code + code = ctypes.c_int(inputChunkBuffer[inpChBuffIter]).value # int code # assignment in C was right to left so: - # *(outputChunkBuffer++) = sample = clip8(sample + aud_ws_step_table2[code & 3]) + # *(outputChunkBuffer++) = sample = clip8(sample + aud_ws_step_table2[code & 3]) # is: - # *(outputChunkBuffer++) = (sample = clip8(sample + aud_ws_step_table2[code & 3])) + # *(outputChunkBuffer++) = (sample = clip8(sample + aud_ws_step_table2[code & 3])) # which is equivalent to these two commands: # sample = clip8(sample + aud_ws_step_table2[code & 3]) # *(outputChunkBuffer++) = sample @@ -163,7 +155,7 @@ def aud_decode_ws_chunk(inputChunkBuffer, cb_s, cb_d): count += 1 for iter in range (count, 0, -1): inpChBuffIter += 1 - code = inputChunkBuffer[inpChBuffIter] # int code + code = inputChunkBuffer[inpChBuffIter] # int code sample += aud_ws_step_table4[code & 0xf] sample = aud_decode_clip8(sample) outputChunkBuffer.append(ctypes.c_char(sample).value) @@ -181,7 +173,7 @@ def aud_decode_ws_chunk(inputChunkBuffer, cb_s, cb_d): outChBuffIter += 1 else: count += 1 - # memcpy(outputChunkBuffer, inputChunkBuffer, count) # FIX + # memcpy(outputChunkBuffer, inputChunkBuffer, count) # FIX for mcp in range(0, count): outputChunkBuffer.append(ctypes.c_char(inputChunkBuffer[inpChBuffIter + mcp]).value) inpChBuffIter += count @@ -193,7 +185,7 @@ def aud_decode_ws_chunk(inputChunkBuffer, cb_s, cb_d): for mst in range(0, count): outputChunkBuffer.append(ctypes.c_char(sample).value) outChBuffIter += count; - # output buffer of chars + # output buffer of chars #binDataOut = struct.pack('b'*len(outputChunkBuffer), *outputChunkBuffer) #return binDataOut return outputChunkBuffer @@ -201,7 +193,7 @@ def aud_decode_ws_chunk(inputChunkBuffer, cb_s, cb_d): # # # -class audFileDecode: +class audFileDecode(object): m_index = -1 m_sample = -1 m_traceModeEnabled = False @@ -228,7 +220,7 @@ if __name__ == '__main__': decodeInstance = audFileDecode() if decodeInstance.m_traceModeEnabled: print "[Debug] Running %s (%s) as main module" % (MY_MODULE_NAME, MY_MODULE_VERSION) - + else: #debug #print "[Debug] Running %s (%s) imported from another module" % (MY_MODULE_NAME, MY_MODULE_VERSION) diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py index 60dc3d6ab8..7cb4f455df 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py @@ -9,55 +9,39 @@ ctypesLibFound = False structLibFound = False try: - import os + import os except ImportError: - print "[Error] os python library is required to be installed!" + print "[Error] os python library is required to be installed!" else: osLibFound = True try: import sys except ImportError: - print "[Error] sys python library is required to be installed!" + print "[Error] sys python library is required to be installed!" else: sysLibFound = True try: - import shutil -except ImportError: - print "[Error] Shutil python library is required to be installed!" -else: - shutilLibFound = True - -try: import wave except ImportError: - print "[Error] Wave python library is required to be installed!" + print "[Error] Wave python library is required to be installed!" else: waveLibFound = True try: - import ctypes + import struct except ImportError: - print "[Error] ctypes python library is required to be installed!" -else: - ctypesLibFound = True - -try: - import struct -except ImportError: - print "[Error] struct python library is required to be installed!" + print "[Error] struct python library is required to be installed!" else: structLibFound = True if (not osLibFound) \ or (not sysLibFound) \ - or (not shutilLibFound) \ or (not waveLibFound) \ - or (not ctypesLibFound) \ or (not structLibFound): sys.stdout.write("[Error] Errors were found when trying to import required python libraries\n") - sys.exit(1) + sys.exit(1) from struct import * from audFileDecode import * @@ -70,24 +54,24 @@ aud_chunk_id = 0x0000deaf SIZE_OF_AUD_HEADER_IN_BYTES = 12 SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES = 8 -class AudHeader: - m_samplerate = 0 #// Frequency // int16_t // TODO should be unsigned (?) - m_size_in = 0 #// Size of file (without header) // int32_t // TODO should be unsigned (?) - m_size_out = 0 #// Size of output data // int32_t // TODO should be unsigned (?) - m_flags = 0 #// bit 0=stereo, bit 1=16bit // int8_t - m_compression = 0 #// 1=WW compressed, 99=IMA ADPCM (0x63) // int8_t +class AudHeader(object): + m_samplerate = 0 # Frequency // int16_t // TODO should be unsigned (?) + m_size_in = 0 # Size of file (without header) // int32_t // TODO should be unsigned (?) + m_size_out = 0 # Size of output data // int32_t // TODO should be unsigned (?) + m_flags = 0 # bit 0=stereo, bit 1=16bit // int8_t + m_compression = 0 # 1=WW compressed, 99=IMA ADPCM (0x63) // int8_t m_populated = False def __init__(self): return -#//The rest of the AUD files is divided in chunks. These are usually 512 -#//bytes long, except for the last one. -class AudChunkHeader: - m_ch_size_in = 0 #// Size of compressed data // int16_t // TODO should be unsigned (?) - m_ch_size_out = 0 #// Size of output data // int16_t // TODO should be unsigned (?) - m_ch_id = 0x0000FFFF #// Always 0x0000DEAF // int32_t +# The rest of the AUD files is divided in chunks. +# These are usually 512 bytes long, except for the last one. +class AudChunkHeader(object): + m_ch_size_in = 0 # Size of compressed data // int16_t // TODO should be unsigned (?) + m_ch_size_out = 0 # Size of output data // int16_t // TODO should be unsigned (?) + m_ch_id = 0x0000FFFF # Always 0x0000DEAF // int32_t def __init__(self): return @@ -95,7 +79,7 @@ class AudChunkHeader: # # # -class audFile: +class audFile(object): m_header = AudHeader() m_traceModeEnabled = False m_simpleAudioFileName = 'GENERIC.AUD' @@ -121,6 +105,8 @@ class audFile: cbinaryDataOutLst = [] offsInAudFile = SIZE_OF_AUD_HEADER_IN_BYTES for i in range(0, (len(audBytesBuff) - SIZE_OF_AUD_HEADER_IN_BYTES) / 2): + if (self.m_traceModeEnabled): + print "[Trace] Reading bytes %d, %d" % (2*i, 2*i + 1) tmpTupleL = struct.unpack_from('B', audBytesBuff, offsInAudFile) offsInAudFile += 1 tmpTupleH = struct.unpack_from('B', audBytesBuff, offsInAudFile) @@ -128,7 +114,7 @@ class audFile: cbinaryDataOutLst.append(tmpTupleL[0]) cbinaryDataOutLst.append(tmpTupleH[0]) cvirtualBinaryD = struct.pack('B'*len(cbinaryDataOutLst), *cbinaryDataOutLst) - + if (not cvirtualBinaryD and (len(audBytesBuff) - SIZE_OF_AUD_HEADER_IN_BYTES) > 0): print "[Error] audio file could not be exported properly (0 data read): %s" % (filename) return 1 @@ -163,7 +149,7 @@ class audFile: # header.data_chunk_header.id = wav_data_id; # "data" # header.data_chunk_header.size = cb_sample * cs_remaining; # error = f.write(&header, sizeof(t_wav_header)); -# return error ? error : f.write(d); +# return error ? error : f.write(d); return 0 # TODO fix @@ -192,7 +178,7 @@ class audFile: if self.get_samplerate() < 8000 or self.get_samplerate() > 48000 or self.header().m_size_in > (maxLength - SIZE_OF_AUD_HEADER_IN_BYTES ): print "[Warning] Bad AUD Header info in file %s, size_in: %d, maxLen: %d" % (self.m_simpleAudioFileName, self.header().m_size_in, (maxLength - SIZE_OF_AUD_HEADER_IN_BYTES)) if self.header().m_size_in == 0: - # handle special case where only the header of the AUD file is present and the size_in is 0. + # handle special case where only the header of the AUD file is present and the size_in is 0. # fill the header with "valid" info for an empty wav file self.header().m_size_out = 0 self.header().m_samplerate = 22050 @@ -212,20 +198,22 @@ class audFile: elif self.header().m_compression == 0: # no compression. At least some AUD files in SFX.MIX have this if (self.header().m_flags != 2): return False - self.header().m_populated = True + self.header().m_populated = True return True - + # int AudFile::get_chunk_header(int i, std::fstream& fs, AudFileNS::pos_type startAudFilepos, AudFileNS::pos_type endAudFilepos, AudChunkHeader& outAudChunkHeader) - def get_chunk_header(self, chunkIdx, inAudFileBytesBuffer, inAudFileSize ): + def get_chunk_header(self, chunkIdx, inAudFileBytesBuffer, inAudFileSize): #fs.seekg(int(startAudFilepos) + int(SIZE_OF_AUD_HEADER_IN_BYTES), fs.beg); #AudFileNS::pos_type rAudPos; #rAudPos = fs.tellg(); outAudChunkHeader = AudChunkHeader() rAudPos = SIZE_OF_AUD_HEADER_IN_BYTES + if (self.m_traceModeEnabled): + print "[Trace] Getting chunk header at %d" % (rAudPos) #AudChunkHeader tmpInremediateChunkheader; tmpInremediateChunkheader = AudChunkHeader() - #while (i--) # value of i is decreased after checked by while loop + #while (i--) # value of i is decreased after checked by while loop while(chunkIdx > 0): chunkIdx -= 1 if (rAudPos + SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES > inAudFileSize): @@ -240,9 +228,9 @@ class audFile: tmpAudFileOffset += 2 tmpTuple = struct.unpack_from('I', inAudFileBytesBuffer, tmpAudFileOffset) tmpInremediateChunkheader.m_ch_id = tmpTuple[0] - tmpAudFileOffset += 4 + tmpAudFileOffset += 4 #fs.read((char*)&tmpInremediateChunkheader, SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES); - rAudPos += SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES + tmpInremediateChunkheader.m_ch_size_in + rAudPos += SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES + tmpInremediateChunkheader.m_ch_size_in #fs.seekg(int(rAudPos), fs.beg); if (rAudPos + SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES > inAudFileSize ): @@ -263,12 +251,14 @@ class audFile: return (-1, rAudPos, None) rAudPos += SIZE_OF_AUD_CHUNK_HEADER_IN_BYTES return (0, rAudPos, outAudChunkHeader) # //reinterpret_cast<const AudChunkHeader*>(r); - + # int AudFile::get_chunk_data(int i, std::fstream& fs, int sizeToRead, AudFileNS::byte* byteChunkDataPtr) def get_chunk_data(self, inAudFileBytesBuffer, startOffs, sizeToRead): #fs.read((char*)byteChunkDataPtr, sizeToRead) outChunkDataLst = [] - #print "[Debug] startOffs: %d, sizeToRead: %d" % (startOffs, sizeToRead) + if (self.m_traceModeEnabled): + print "[Trace] Getting chunk data" + print "[Trace] startOffs: %d, sizeToRead: %d" % (startOffs, sizeToRead) for i in range(startOffs, startOffs + sizeToRead): #outChunkDataLst.append(ctypes.c_char(inAudFileBytesBuffer[i]).value) #outChunkDataLst.append(ctypes.c_byte(inAudFileBytesBuffer[i]).value) @@ -289,22 +279,25 @@ class audFile: # Cvirtual_binary d; binaryDataOutLst = [] binaryDataOutBuff = None - cb_audio = self.get_cb_sample() * self.get_c_samples() # int cb_audio - basically this should be the size_out + cb_audio = self.get_cb_sample() * self.get_c_samples() # int cb_audio - basically this should be the size_out if speccompression == 1: # write_start allocates space for virtualBinary # AudFileNS::byte* w = d.write_start(cb_audio); - errGetChunk = 0 # int errGetChunk + errGetChunk = 0 # int errGetChunk #for (int chunk_i = 0; w != d.data_end(); chunk_i++) chunk_i = 0 wIndex = 0 while (wIndex < cb_audio): - #AudChunkHeader out_chunk_header; + #AudChunkHeader out_chunk_header; #out_chunk_header = AudChunkHeader() - (errGetChunk, bufferDataPos, out_chunk_header) = self.get_chunk_header(chunk_i, audBytesBuff, len(audBytesBuff)) + (errGetChunk, bufferDataPos, out_chunk_header) = self.get_chunk_header(chunk_i, audBytesBuff, len(audBytesBuff)) if errGetChunk != 0: -# print "[Warning] Error OR End file case while getting uncompressed chunk header!" + if self.m_traceModeEnabled: + print "[Trace] Error OR End file case while getting uncompressed chunk header!" break - #print "[Debug] Get uncompressed chunk header returned: %d " % (out_chunk_header.m_ch_id) + + if self.m_traceModeEnabled: + print "[Trace] Get uncompressed chunk header returned: %d " % (out_chunk_header.m_ch_id) #Cvirtual_binary out_chunk_data; #AudFileNS::byte* byteChunkDataPtr = out_chunk_data.write_start(out_chunk_header.m_ch_size_in); (errorGCD, byteChunkDataLst) = self.get_chunk_data(audBytesBuff, bufferDataPos, out_chunk_header.m_ch_size_in) @@ -318,60 +311,64 @@ class audFile: decodeInstance = audFileDecode(self.m_traceModeEnabled); #decodeInstance.init(); #AudFileNS::byte* w = d.write_start(cb_audio); - errGetChunk = 0 # int errGetChunk + errGetChunk = 0 # int errGetChunk # for (int chunk_i = 0; w != d.data_end(); chunk_i++) chunk_i = 0 wIndex = 0 while (wIndex < cb_audio): - #print("[Debug] chunkI: %d\t Windex: %d\t cb_audio: %d") % (chunk_i,wIndex,cb_audio) - #AudChunkHeader out_chunk_header; + if self.m_traceModeEnabled: + print("[Trace] chunkI: %d\t Windex: %d\t cb_audio: %d") % (chunk_i,wIndex,cb_audio) + #AudChunkHeader out_chunk_header; #out_chunk_header = AudChunkHeader() #errGetChunk = self.get_chunk_header(chunk_i, fs, startAudFilepos, endAudFilepos, out_chunk_header); (errGetChunk, bufferDataPos, out_chunk_header) = self.get_chunk_header(chunk_i, audBytesBuff, len(audBytesBuff)) if errGetChunk != 0: print "[Warning] Error OR End file case while getting COMPRESSED chunk header!" break - #print "[Debug] Get COMPRESSED chunk header returned:: headerInSize: %d headerOutSize: %d id: %d" % (out_chunk_header.m_ch_size_in, out_chunk_header.m_ch_size_out, out_chunk_header.m_ch_id) + if self.m_traceModeEnabled: + print "[Trace] Get COMPRESSED chunk header returned:: headerInSize: %d headerOutSize: %d id: %d" % (out_chunk_header.m_ch_size_in, out_chunk_header.m_ch_size_out, out_chunk_header.m_ch_id) #Cvirtual_binary out_chunk_data; #AudFileNS::byte* byteChunkDataPtr = out_chunk_data.write_start(out_chunk_header.m_ch_size_in); (errorGCD, byteChunkDataLst) = self.get_chunk_data(audBytesBuff, bufferDataPos, out_chunk_header.m_ch_size_in) # export decoded chunk to w (output) buffer (of SHORTS) at the point where we're currently at (so append there) - #print "[Debug] byteChunkDataLst len: %d, m_ch_size_in was: %d" % (len(byteChunkDataLst), out_chunk_header.m_ch_size_in) + if self.m_traceModeEnabled: + print "[Trace] byteChunkDataLst len: %d, m_ch_size_in was: %d" % (len(byteChunkDataLst), out_chunk_header.m_ch_size_in) decodedAudioChunkAsLst = decodeInstance.decode_chunk(byteChunkDataLst, out_chunk_header.m_ch_size_out / self.get_cb_sample()); binaryDataOutLst.extend(decodedAudioChunkAsLst) wIndex += out_chunk_header.m_ch_size_out - #print("[Debug] New Windex: %d\t cb_audio: %d") % (wIndex,cb_audio) + if self.m_traceModeEnabled: + print("[Trace] New Windex: %d\t cb_audio: %d") % (wIndex,cb_audio) chunk_i += 1 binaryDataOutBuff = struct.pack('h'*len(binaryDataOutLst), *binaryDataOutLst) if self.m_traceModeEnabled: if binaryDataOutBuff is not None: if self.m_traceModeEnabled: - print "[Debug] Decoding Done." + print "[Trace] Decoding Done." else: #if binaryDataOutBuff is None: print "[Error] Decoding yielded errors (data out buffer is null)." return binaryDataOutBuff - + def header(self): return self.m_header - - def get_c_samples(self): + + def get_c_samples(self): return self.m_header.m_size_out / self.get_cb_sample() - + def get_samplerate(self): return self.m_header.m_samplerate; - + # flag bit 0 is stereo(set) mono(clear) - def get_c_channels(self): + def get_c_channels(self): return 2 if (self.m_header.m_flags & 0x01) else 1; - - # flag bit 1 is 16bit(set) 8bit (clear) + + # flag bit 1 is 16bit(set) 8bit (clear) def get_cb_sample(self): return 2 if (self.m_header.m_flags & 0x02) else 1 # # -# +# if __name__ == '__main__': - # main() + # main() errorFound = False # By default assumes a file of name 000000.AUD in same directory # otherwise tries to use the first command line argument as input file @@ -389,7 +386,7 @@ if __name__ == '__main__': else: print "[Error] No valid input file argument was specified and default input file %s is missing." % (inAUDFileName) errorFound = True - + if not errorFound: try: print "[Info] Opening %s" % (inAUDFileName) @@ -398,7 +395,7 @@ if __name__ == '__main__': errorFound = True print "[Error] Unexpected event:", sys.exc_info()[0] raise - if not errorFound: + if not errorFound: allOfAudFileInBuffer = inAUDFile.read() audFileInstance = audFile(True) if audFileInstance.m_traceModeEnabled: @@ -412,4 +409,5 @@ if __name__ == '__main__': else: #debug #print "[Debug] Running %s (%s) imported from another module" % (MY_MODULE_NAME, MY_MODULE_VERSION) - pass
\ No newline at end of file + pass +
\ No newline at end of file diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/devCommentaryText.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/devCommentaryText.py index 9ec4e10cdf..2bf04f1d3b 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/devCommentaryText.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/devCommentaryText.py @@ -28,7 +28,7 @@ EXTRA_SPEECH_AUDIO_TUPLE_LIST = [ ('67_1080R.AUD', "*Crowd talk*"), ('67_1100R.AUD', "*Crowd talk*"), ('67_1140R.AUD', "*Crowd talk*"), - ('67_1160R.AUD', "*Crowd talk*") + ('67_1160R.AUD', "*Crowd talk*") ] # we use the spoken quote id that triggers the comment as an ID for the DEV commentary quote @@ -40,7 +40,7 @@ DEV_ISEZ_QUOTES_TUPLE_LIST = [ ("IS-23-0130.AUD", "JM: Did it have a huge, ugly piece of chrome on it?"), # Officer Leary ("IS-23-0090.AUD", "JM: This officer has a talent for vivid metaphors."), # Officer Leary ("IS-00-4540.AUD", "DL: What is that supposed to mean? I didn't write this line..."), - ("IS-00-4515.AUD", "MG: Hey, leave that officer alone. Can't you see he's busy?\nJM: (...mmm, donuts...)"), # clicking on Leary after we get his statement + ("IS-00-4515.AUD", "MG: Hey, leave that officer alone. Can't you see he's busy?\nJM: (...mmm, donuts...)"), # clicking on Leary after we get his statement ("IS-23-0060.AUD", "MG: It's all fun and games until someone loses a tiger cub."), # Officer Leary ("IS-00-9991.AUD", "JM: Chrome...is that what that is?"), # pick up chrome ("IS-00-4510.AUD", "JM: It's hard to imagine that thing on either a car or a horse.\nMG: McCoy! What a witty chap...\nJM: He keeps me chuckling non-stop!"), @@ -50,7 +50,7 @@ DEV_ISEZ_QUOTES_TUPLE_LIST = [ # # # -class devCommentaryText: +class devCommentaryText(object): m_traceModeEnabled = True # traceModeEnabled is bool to enable more printed debug messages def __init__(self, traceModeEnabled = True): @@ -58,6 +58,8 @@ class devCommentaryText: return def printTexts(self): + if self.m_traceModeEnabled: + print "[Trace] Printing all dev commentary text" print "\nAUDIO COMMENTARY" print "------------------" for (idTre, textTre) in DEV_AUDIO_COMMENTARY_TUPLE_LIST: @@ -73,16 +75,25 @@ class devCommentaryText: return def getAudioCommentaryTextEntriesList(self): + if self.m_traceModeEnabled: + print "[Trace] getAudioCommentaryTextEntriesList" return DEV_AUDIO_COMMENTARY_TUPLE_LIST def getISEZTextEntriesList(self): + + if self.m_traceModeEnabled: + print "[Trace] getISEZTextEntriesList" return DEV_ISEZ_QUOTES_TUPLE_LIST - + def getExtraSpeechAudioEntriesList(self): + if self.m_traceModeEnabled: + print "[Trace] getExtraSpeechAudioEntriesList" return EXTRA_SPEECH_AUDIO_TUPLE_LIST - +# +# +# if __name__ == '__main__': - # main() + # main() print "[Debug] Running %s as main module" % (my_module_name) traceModeEnabled = False devCommentaryTextInstance = devCommentaryText(traceModeEnabled) diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/pogoTextResource.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/pogoTextResource.py index ca7ca3c0e1..0130cc0d92 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/pogoTextResource.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/pogoTextResource.py @@ -167,10 +167,9 @@ POGO_TEXT_RESOURCE_TUPLE_LIST = [ (157, "Zion National Park"), (158, "We 3 coders give special thanks to:") ] -# -# -# -class pogoTextResource: + + +class pogoTextResource(object): m_traceModeEnabled = True # traceModeEnabled is bool to enable more printed debug messages def __init__(self, traceModeEnabled = True): @@ -178,15 +177,22 @@ class pogoTextResource: return def printPogo(self): + if self.m_traceModeEnabled: + print "[Trace] printing Pogo..." for (idTre, textTre) in POGO_TEXT_RESOURCE_TUPLE_LIST: print "%s\t%s" % (idTre, textTre) return def getPogoEntriesList(self): + if self.m_traceModeEnabled: + print "[Trace] getPogoEntriesList()" return POGO_TEXT_RESOURCE_TUPLE_LIST - + +# +# +# if __name__ == '__main__': - # main() + # main() print "[Debug] Running %s as main module" % (my_module_name) traceModeEnabled = False pogoTRInstance = pogoTextResource(traceModeEnabled) diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py index 82481433b7..2db0228479 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/quoteSpreadsheetCreator.py @@ -2,20 +2,22 @@ # -*- coding: UTF-8 -*- sysLibFound = False try: - import sys + import sys except ImportError: print ("[Error] sys python library is required to be installed!") else: sysLibFound = True - -if (not sysLibFound): + +if (not sysLibFound): sys.stdout.write("[Error] Errors were found when trying to import required python libraries\n") - sys.exit(1) + sys.exit(1) -if not (sys.version_info[0] == 2 and sys.version_info[1] == 7): +if not (sys.version_info[0] == 2 and sys.version_info[1] == 7): sys.stdout.write("[Error] Blade Runner Quotes Spreadsheet Creator script requires Python 2.7\n") sys.exit(1) - + import sortBladeRunnerWavs02 + if __name__ == "__main__": - sortBladeRunnerWavs02.main(sys.argv[0:])
\ No newline at end of file + sortBladeRunnerWavs02.main(sys.argv[0:]) +
\ No newline at end of file diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py index a76673ef0c..b83a34b975 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py @@ -7,36 +7,28 @@ shutilLibFound = False structLibFound = False try: - import os + import os except ImportError: - print "[Error] os python library is required to be installed!" + print "[Error] os python library is required to be installed!" else: osLibFound = True try: - import sys + import sys except ImportError: - print "[Error] sys python library is required to be installed!" + print "[Error] sys python library is required to be installed!" else: sysLibFound = True try: - import shutil + import struct except ImportError: - print "[Error] Shutil python library is required to be installed!" -else: - shutilLibFound = True - -try: - import struct -except ImportError: - print "[Error] struct python library is required to be installed!" + print "[Error] struct python library is required to be installed!" else: structLibFound = True if (not osLibFound) \ or (not sysLibFound) \ - or (not shutilLibFound) \ or (not structLibFound): sys.stdout.write("[Error] Errors were found when trying to import required python libraries\n") sys.exit(1) @@ -47,27 +39,27 @@ MY_MODULE_VERSION = "0.50" MY_MODULE_NAME = "treFileLib" -class TreHeader: +class TreHeader(object): numOfTextResources = -1 def __init__(self): return -class treFile: +class treFile(object): m_header = TreHeader() simpleTextResourceFileName = 'GENERIC.TRE' stringEntriesLst = [] # list of two-value tuples. First value is ID, second value is String content stringOffsets = [] m_traceModeEnabled = False - # traceModeEnabled is bool to enable more printed debug messages + # traceModeEnabled is bool to enable more printed debug messages def __init__(self, traceModeEnabled = True): del self.stringEntriesLst[:] del self.stringOffsets[:] self.simpleTextResourceFileName = 'GENERIC.TRE' self.m_traceModeEnabled = traceModeEnabled return - + def loadTreFile(self, treBytesBuff, maxLength, treFileName): self.simpleTextResourceFileName = treFileName offsInTreFile = 0 @@ -87,7 +79,7 @@ class treFile: tmpTuple = struct.unpack_from('I', treBytesBuff, offsInTreFile) # unsigned integer 4 bytes self.stringEntriesLst.append( (tmpTuple[0], '') ) offsInTreFile += 4 - + # string offsets table (each entry is unsigned integer 4 bytes) for idx in range(0, self.header().numOfTextResources): tmpTuple = struct.unpack_from('I', treBytesBuff, offsInTreFile) # unsigned integer 4 bytes @@ -95,13 +87,13 @@ class treFile: offsInTreFile += 4 # # strings (all entries are null terminated) - # TODO +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + # TODO +++ absStartOfIndexTable = 4 #absStartOfOffsetTable = absStartOfIndexTable + (self.header().numOfTextResources * 4) #absStartOfStringTable = absStartOfOffsetTable + ((self.header().numOfTextResources+1) * 4) - + #print "[Debug] buffer type: " , type(treBytesBuff) # it is str - + for idx in range(0, self.header().numOfTextResources): currOffset = self.stringOffsets[idx] + absStartOfIndexTable # the buffer (treBytesBuff) where we read the TRE file into, is "str" type but contains multiple null terminated strings @@ -122,7 +114,7 @@ class treFile: except: print "[Error] Loading Text Resource %s failed!" % (self.simpleTextResourceFileName) return False - + def header(self): return self.m_header # @@ -147,7 +139,7 @@ if __name__ == '__main__': else: print "[Error] No valid input file argument was specified and default input file %s is missing." % (inTREFileName) errorFound = True - + if not errorFound: try: print "[Info] Opening %s" % (inTREFileName) @@ -169,4 +161,5 @@ if __name__ == '__main__': else: #debug #print "[Debug] Running %s (%s) imported from another module" % (MY_MODULE_NAME, MY_MODULE_VERSION) - pass
\ No newline at end of file + pass +
\ No newline at end of file |