mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
(Chinese) Add support for line breaks in ITEMS.XML
Added detection of the NEWLINE_CHAR character "±" to enable line breaks not only when text exceeds display width, but also upon encountering NEWLINE_CHAR. Note: This character has been conventionally adopted in the Chinese community as a line break marker within XML item descriptions. The modification affects Chinese text display only.
This commit is contained in:
+16
-5
@@ -199,7 +199,10 @@ WRAPPED_STRING *LineWrap(INT32 iFont, UINT16 usLineWidthPixels, UINT16 *pusLineW
|
|||||||
usCurrentWidthPixels = usCurrentWidthPixels + WFStringPixLength( OneChar, iFont);
|
usCurrentWidthPixels = usCurrentWidthPixels + WFStringPixLength( OneChar, iFont);
|
||||||
|
|
||||||
//If we are at the end of the string
|
//If we are at the end of the string
|
||||||
if(TempString[ usCurIndex ] == 0)
|
|
||||||
|
//Juqi: Add NEWLINE_CHAR detect
|
||||||
|
// NEWLINE_CHAR "±" is only used to handle Chinese ITMES.XML file.
|
||||||
|
if (TempString[ usCurIndex ] == 0 && !fNewLine)
|
||||||
{
|
{
|
||||||
//get to next WrappedString structure
|
//get to next WrappedString structure
|
||||||
pWrappedString = &FirstWrappedString;
|
pWrappedString = &FirstWrappedString;
|
||||||
@@ -224,10 +227,13 @@ WRAPPED_STRING *LineWrap(INT32 iFont, UINT16 usLineWidthPixels, UINT16 *pusLineW
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Juqi: Allow manual line breaks to be added in XML,
|
||||||
if( (g_lang != i18n::Lang::zh && usCurrentWidthPixels > usLineWidthPixels)
|
// rather than relying solely on width for automatic line breaks.
|
||||||
|
if((usCurrentWidthPixels > usLineWidthPixels || fNewLine)
|
||||||
|
&&
|
||||||
|
((g_lang != i18n::Lang::zh)
|
||||||
||
|
||
|
||||||
(g_lang == i18n::Lang::zh && usCurrentWidthPixels > usLineWidthPixels
|
(g_lang == i18n::Lang::zh
|
||||||
&& TempString[usCurIndex] != L','
|
&& TempString[usCurIndex] != L','
|
||||||
&& TempString[usCurIndex] != L'。'
|
&& TempString[usCurIndex] != L'。'
|
||||||
&& TempString[usCurIndex] != L';'
|
&& TempString[usCurIndex] != L';'
|
||||||
@@ -239,8 +245,9 @@ WRAPPED_STRING *LineWrap(INT32 iFont, UINT16 usLineWidthPixels, UINT16 *pusLineW
|
|||||||
&& TempString[usCurIndex] != L'?'
|
&& TempString[usCurIndex] != L'?'
|
||||||
&& TempString[usCurIndex] != L')'
|
&& TempString[usCurIndex] != L')'
|
||||||
&& TempString[usCurIndex] != L')'
|
&& TempString[usCurIndex] != L')'
|
||||||
)//||(DestString[ usDestIndex ]==NEWLINE_CHAR )||(fNewLine))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
//if an error has occured, and the string is too long
|
//if an error has occured, and the string is too long
|
||||||
@@ -251,6 +258,9 @@ WRAPPED_STRING *LineWrap(INT32 iFont, UINT16 usLineWidthPixels, UINT16 *pusLineW
|
|||||||
// Fix really long unbroken strings, the above code dosent work for it
|
// Fix really long unbroken strings, the above code dosent work for it
|
||||||
usLastMaxWidthIndex = usDestIndex;
|
usLastMaxWidthIndex = usDestIndex;
|
||||||
|
|
||||||
|
//Juqi: if NEWLINE_CHAR, don't go back
|
||||||
|
if (!fNewLine)
|
||||||
|
{
|
||||||
//Go back to begining of word
|
//Go back to begining of word
|
||||||
while(
|
while(
|
||||||
(g_lang != i18n::Lang::zh && DestString[ usDestIndex ] != L' ' && usCurIndex > 0 && usDestIndex > 0)
|
(g_lang != i18n::Lang::zh && DestString[ usDestIndex ] != L' ' && usCurIndex > 0 && usDestIndex > 0)
|
||||||
@@ -296,6 +306,7 @@ WRAPPED_STRING *LineWrap(INT32 iFont, UINT16 usLineWidthPixels, UINT16 *pusLineW
|
|||||||
|
|
||||||
// put next line into temp buffer
|
// put next line into temp buffer
|
||||||
DestString[usEndIndex] = 0;
|
DestString[usEndIndex] = 0;
|
||||||
|
} //Juqi: endif
|
||||||
|
|
||||||
//get to next WrappedString structure
|
//get to next WrappedString structure
|
||||||
pWrappedString = &FirstWrappedString;
|
pWrappedString = &FirstWrappedString;
|
||||||
|
|||||||
Reference in New Issue
Block a user