Browse Source

Fix typos and add comments

louyihua 9 years ago
parent
commit
d01049520f
5 changed files with 84 additions and 19 deletions
  1. 17 3
      font.c
  2. 11 8
      text.c
  3. 2 2
      text.h
  4. 50 4
      uigame.c
  5. 4 2
      uigame.h

+ 17 - 3
font.c

@@ -35,7 +35,7 @@ PAL_InitFont(
 /*++
   Purpose:
 
-    Load the font files.
+    None.
 
   Parameters:
 
@@ -43,7 +43,7 @@ PAL_InitFont(
 
   Return value:
 
-    0 if succeed.
+    Always return 0.
 
 --*/
 {
@@ -57,7 +57,7 @@ PAL_FreeFont(
 /*++
   Purpose:
 
-    Free the memory used for fonts.
+    None.
 
   Parameters:
 
@@ -161,6 +161,20 @@ INT
 PAL_CharWidth(
    WORD                     wChar
 )
+/*++
+  Purpose:
+
+    Get the text width of a character.
+
+  Parameters:
+
+    [IN]  wChar - the unicode character for width calculation.
+
+  Return value:
+
+    The width of the character, 16 for full-width char and 8 for half-width char.
+
+--*/
 {
 	if ((wChar >= 0xd800 && wChar < unicode_upper_base) || wChar >= unicode_upper_top)
 	{

+ 11 - 8
text.c

@@ -1202,9 +1202,9 @@ PAL_DialogIsPlayingRNG(
 #ifdef PAL_UNICODE
 INT
 PAL_MultiByteToWideChar(
-   unsigned char *mbs,
+   LPCSTR        mbs,
    int           mbslength,
-   WCHAR         *wcs,
+   LPWSTR        wcs,
    int           wcslength
 )
 /*++
@@ -1214,14 +1214,17 @@ PAL_MultiByteToWideChar(
 
   Parameters:
 
-    [IN]  mbs - .
-	[IN]  mbslength - .
-	[IN]  wcs - .
-	[IN]  wcslength - .
+    [IN]  mbs - Pointer to the multi-byte string.
+	[IN]  mbslength - Length of the multi-byte string, or -1 for auto-detect.
+	[IN]  wcs - Pointer to the wide string buffer.
+	[IN]  wcslength - Length of the wide string buffer.
 
   Return value:
 
-    The length
+    The length of converted wide string. If mbslength is set to -1, the returned
+	value includes the terminal null-char; otherwise, the null-char is not included.
+	If wcslength is set to 0, wcs can be set to NULL and the return value is the
+	required length of the wide string buffer.
 
 --*/
 {
@@ -1380,4 +1383,4 @@ PAL_MultiByteToWideChar(
 
 	}
 }
-#endif
+#endif

+ 2 - 2
text.h

@@ -120,9 +120,9 @@ PAL_DialogIsPlayingRNG(
 #ifdef PAL_UNICODE
 INT
 PAL_MultiByteToWideChar(
-   unsigned char *mbs,
+   LPCSTR        mbs,
    int           mbslength,
-   WCHAR         *wcs,
+   LPWSTR        wcs,
    int           wcslength
 );
 #endif

+ 50 - 4
uigame.c

@@ -18,6 +18,8 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
+// Modified by Lou Yihua <louyihua@21cn.com> with Japanese support, 2015
+//
 
 #include "main.h"
 
@@ -1931,6 +1933,21 @@ PAL_MenuTextMaxWidth(
    LPMENUITEM     rgMenuItem,
    INT            nMenuItem
 )
+/*++
+  Purpose:
+
+    Calculate the maximal text width of all the menu items in number of full width characters.
+
+  Parameters:
+
+    [IN]  rgMenuItem - Pointer to the menu item array.
+	[IN]  nMenuItem - Number of menu items.
+
+  Return value:
+
+    Maximal text width.
+
+--*/
 {
 	int i, r = 0;
 	for (i = 0; i < nMenuItem; i++)
@@ -1952,14 +1969,29 @@ PAL_MenuTextMaxWidth(
 
 INT
 PAL_WordMaxWidth(
-   INT            nFirstWorld,
+   INT            nFirstWord,
    INT            nWordNum
 )
+/*++
+  Purpose:
+
+    Calculate the maximal text width of a specific range of words in number of full width characters.
+
+  Parameters:
+
+    [IN]  nFirstWord - First index of word.
+	[IN]  nWordNum - Number of words.
+
+  Return value:
+
+    Maximal text width.
+
+--*/
 {
 	int i, r = 0;
 	for (i = 0; i < nWordNum; i++)
 	{
-		LPCWSTR itemText = PAL_GetWord(nFirstWorld + i);
+		LPCWSTR itemText = PAL_GetWord(nFirstWord + i);
 		int j = 0, l = wcslen(itemText), w = 0;
 		for (j = 0; j < l; j++)
 		{
@@ -1976,10 +2008,24 @@ PAL_WordMaxWidth(
 
 INT
 PAL_WordWidth(
-   INT            nWordNum
+   INT            nWordIndex
 )
+/*++
+  Purpose:
+
+    Calculate the text width of a specific word.
+
+  Parameters:
+
+	[IN]  nWordNum - Index of the word.
+
+  Return value:
+
+    Text width.
+
+--*/
 {
-	LPCWSTR itemText = PAL_GetWord(nWordNum);
+	LPCWSTR itemText = PAL_GetWord(nWordIndex);
 	int i, l = wcslen(itemText), w = 0;
 	for (i = 0; i < l; i++)
 	{

+ 4 - 2
uigame.h

@@ -18,6 +18,8 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
+// Modified by Lou Yihua <louyihua@21cn.com> with Japanese support, 2015
+//
 
 #ifndef UIGAME_H
 #define UIGAME_H
@@ -97,13 +99,13 @@ PAL_MenuTextMaxWidth(
 
 INT
 PAL_WordMaxWidth(
-   INT            nFirstWorld,
+   INT            nFirstWord,
    INT            nWordNum
 );
 
 INT
 PAL_WordWidth(
-   INT            nFirstWorld
+   INT            nWordIndex
 );
 
 #ifdef __cplusplus