From 3136327c5afe6448c69f55492cd9bb75f798f98b Mon Sep 17 00:00:00 2001 From: lalien Date: Tue, 21 Aug 2012 10:31:12 +0000 Subject: [PATCH] reapplied lost Russian letters fix from revision 4877 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Fixed some problems with russian letters in IMP page (by ViSoR) -Added 2 letters for French (Ligatures Æ, æ, Œ, œ). Now we have support for all French alphabet -Converted French text to UTF-8 for simple use in ather OS Language git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5489 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/IMP Begin Screen.cpp | 86 +++++++++++++++++++++++++++---- Standard Gaming Platform/Font.cpp | 46 +++++++++-------- 2 files changed, 101 insertions(+), 31 deletions(-) diff --git a/Laptop/IMP Begin Screen.cpp b/Laptop/IMP Begin Screen.cpp index c6151d0b..7959ddf7 100644 --- a/Laptop/IMP Begin Screen.cpp +++ b/Laptop/IMP Begin Screen.cpp @@ -114,6 +114,9 @@ void RenderGender( void ); void DecrementTextEnterMode( void ); void Print8CharacterOnlyString( void ); BOOLEAN CheckCharacterInputForEgg( void ); +UINT32 GetCyrillicUnicodeChar( UINT32 uiKey ); +UINT32 TranslateKey( UINT32 uiKey, unsigned char* translationTable ); +BOOLEAN CheckIsKeyValid( UINT32 uiKey ); // mouse region callbacks void SelectFullNameRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason ); @@ -572,18 +575,29 @@ void HandleBeginScreenTextEvent( UINT32 uiKey ) break; default: //Heinz (18.01.2009): Russian layout + // ViSoR (07.01.2012) : Russian and Belarussian layouts // -#if defined(RUSSIAN) - if( ( (DWORD)GetKeyboardLayout(0) & 0xFFFF ) == 0x419) +#if defined(RUSSIAN) || defined(BELARUSSIAN) + if( ( (DWORD)GetKeyboardLayout(0) & 0xFFFF ) == 0x419) // Russian { - unsigned char RussianTranslationTable[] = - " #########-.0123456789#####_#ڨ"; - if(uiKey >= ' ' && uiKey <= '~') uiKey = RussianTranslationTable[uiKey-' ']; - else uiKey = '#'; + unsigned char TranslationTable[] = + " #########-.0123456789#####_#ڨ"; + + uiKey = TranslateKey( uiKey, TranslationTable ); + uiKey = GetCyrillicUnicodeChar( uiKey ); } - else if( !(uiKey >= 'A' && uiKey <= 'Z' || uiKey >= 'a' && uiKey <= 'z' || uiKey >= '0' && uiKey <= '9' || - uiKey == '_' || uiKey == '.' || uiKey == ' ') ) uiKey = '#'; - if(uiKey != '#') + else if ( ( (DWORD)GetKeyboardLayout(0) & 0xFFFF ) == 0x423) // Belarussian + { + unsigned char TranslationTable[] = + " #########-.0123456789###Բҡ#'#_#'"; + + uiKey = TranslateKey( uiKey, TranslationTable ); + uiKey = GetCyrillicUnicodeChar( uiKey ); + } + else if( !CheckIsKeyValid( uiKey ) ) + uiKey = '#'; + + if( uiKey != '#') #else #ifndef USE_CODE_PAGE if( uiKey >= 'A' && uiKey <= 'Z' || @@ -674,7 +688,61 @@ void HandleBeginScreenTextEvent( UINT32 uiKey ) return; } +UINT32 GetCyrillicUnicodeChar( UINT32 uiKey ) +{ + // - + if (uiKey >= 192 && uiKey <= 255) + uiKey += 0x0350; + // + if (uiKey == 168) + uiKey = 0x0401; + + // + if (uiKey == 184) + uiKey = 0x0451; + + // + if (uiKey == 161) + uiKey = 0x040E; + + // + if (uiKey == 162) + uiKey = 0x045E; + + // + if (uiKey == 178) + uiKey = 0x0406; + + // + if (uiKey == 179) + uiKey = 0x0456; + + return uiKey; +} + +BOOLEAN CheckIsKeyValid( UINT32 uiKey ) +{ + if( uiKey >= 'A' && uiKey <= 'Z' || + uiKey >= 'a' && uiKey <= 'z' || + uiKey >= '0' && uiKey <= '9' || + uiKey == '_' || + uiKey == '.' || + uiKey == ' ') + return TRUE; + else + return FALSE; +} + +UINT32 TranslateKey( UINT32 uiKey, unsigned char* translationTable ) +{ + if( uiKey >= ' ' && uiKey <= '~' ) + uiKey = translationTable[uiKey-' ']; + else + uiKey = '#'; + + return uiKey; +} void DisplayFullNameStringCursor( void ) { diff --git a/Standard Gaming Platform/Font.cpp b/Standard Gaming Platform/Font.cpp index 93108ff1..b022d11c 100644 --- a/Standard Gaming Platform/Font.cpp +++ b/Standard Gaming Platform/Font.cpp @@ -724,7 +724,8 @@ INT16 GetIndex(CHAR16 siChar) UINT16 ssCount=0; UINT16 usNumberOfSymbols = pFManager->pTranslationTable->usNumberOfSymbols; - siChar = GetUnicodeChar(siChar); +//inshy: We don't need anymore ANSI convertation to UNICODE. +//siChar = GetUnicodeChar(siChar); // search the Translation Table and return the index for the font pTrav = pFManager->pTranslationTable->DynamicArrayOf16BitValues; @@ -745,7 +746,8 @@ INT16 GetIndex(CHAR16 siChar) return 0; } - +//inshy: We don't need anymore ANSI convertation to UNICODE. +/* CHAR16 GetUnicodeChar(CHAR16 siChar) { #ifdef GERMAN @@ -918,7 +920,7 @@ CHAR16 GetUnicodeChar(CHAR16 siChar) //case 236: siChar = 236; break; //i' //case 210: siChar = 210; break; //O' //case 242: siChar = 242; break; //o' -//inshy: I've added the character codes for French ligatures to the sources, but I haven't added them in the fonts! +//inshy: French ligatures //Ligature //case 198: siChar = 198; break; // //case 140: siChar = 338; break; // @@ -930,6 +932,7 @@ CHAR16 GetUnicodeChar(CHAR16 siChar) return siChar; } +*/ //***************************************************************************** // SetFont @@ -1969,23 +1972,23 @@ FontTranslationTable *CreateEnglishTransTable( ) temp++; // POLISH letters in UNICODE - *temp = 260; // () + *temp = 260; // (on) temp++; - *temp = 262; // () + *temp = 262; // (tse) temp++; - *temp = 280; // () + *temp = 280; // (en') temp++; - *temp = 321; // () + *temp = 321; // (el') temp++; - *temp = 323; // () + *temp = 323; // (en) temp++; - *temp = 211; // ( ) + *temp = 211; // (o kratkoe) temp++; - *temp = 346; // () + *temp = 346; // (es') temp++; - *temp = 379; // () + *temp = 379; // (zhet) temp++; - *temp = 377; // () + *temp = 377; // (zet) temp++; *temp = 261; // () temp++; @@ -2070,16 +2073,15 @@ FontTranslationTable *CreateEnglishTransTable( ) *temp = 242; //o' temp++; -//inshy: I've added the character codes for French ligatures to the sources, but I haven't added them in the fonts! -//Ligature -// *temp = 198; // -// temp++; -// *temp = 338; // -// temp++; -// *temp = 230; // -// temp++; -// *temp = 339; // -// temp++; +//French ligatures + *temp = 198; // + temp++; + *temp = 338; // + temp++; + *temp = 230; // + temp++; + *temp = 339; // + temp++; // Font glyphs for spell targeting icons