Skip to content

Commit 6bd2c3e

Browse files
author
louyihua
committed
Some fixes for better japanese support
1 parent 4ba4cf3 commit 6bd2c3e

10 files changed

+207
-151
lines changed

big5font.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
unsigned char big5font[] = {
1+
#if !defined(PAL_UNICODE) && defined(PAL_WIN95)
2+
3+
#ifndef _FONT_C
4+
#error "This file should only be included inside font.c!"
5+
#endif
6+
7+
static unsigned char big5font[] = {
28
0xb0, 0x34, 0x07, 0x00, 0x10, 0x10, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
410
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -29516,3 +29522,4 @@ unsigned char big5font[] = {
2951629522
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2951729523
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2951829524
};
29525+
#endif

font.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "font.h"
2525
#include "util.h"
2626

27+
#define _FONT_C
28+
2729
#if defined(PAL_UNICODE)
2830

2931
#include "fontglyph.h"
@@ -262,7 +264,7 @@ BOOL fIsBig5 = FALSE;
262264

263265
INT
264266
PAL_InitFont(
265-
VOID
267+
VOID
266268
)
267269
/*++
268270
Purpose:
@@ -299,7 +301,7 @@ Return value:
299301

300302
VOID
301303
PAL_FreeFont(
302-
VOID
304+
VOID
303305
)
304306
/*++
305307
Purpose:
@@ -329,10 +331,10 @@ static BOOL is_gb(unsigned char b1, unsigned char b2)
329331

330332
VOID
331333
PAL_DrawCharOnSurface(
332-
WORD wChar,
333-
SDL_Surface *lpSurface,
334-
PAL_POS pos,
335-
BYTE bColor
334+
WORD wChar,
335+
SDL_Surface *lpSurface,
336+
PAL_POS pos,
337+
BYTE bColor
336338
)
337339
/*++
338340
Purpose:
@@ -426,10 +428,10 @@ None.
426428

427429
VOID
428430
PAL_DrawASCIICharOnSurface(
429-
BYTE bChar,
430-
SDL_Surface *lpSurface,
431-
PAL_POS pos,
432-
BYTE bColor
431+
BYTE bChar,
432+
SDL_Surface *lpSurface,
433+
PAL_POS pos,
434+
BYTE bColor
433435
)
434436
/*++
435437
Purpose:

fontglyph.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#ifndef _FONTGLYPH_H
2424
#define _FONTGLYPH_H
2525

26-
#ifndef FONT_H
27-
#error "This file should only be included after font.h!"
26+
#ifndef _FONT_C
27+
#error "This file should only be included inside font.c!"
2828
#endif
2929

3030
#ifdef __cplusplus

gbfont.h

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
* SUCH DAMAGE.
2525
*
2626
*/
27+
#if !defined(PAL_UNICODE) && defined(PAL_WIN95)
28+
29+
#ifndef _FONT_C
30+
#error "This file should only be included inside font.c!"
31+
#endif
32+
2733
unsigned char gbfont[] = {
2834
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2935
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -17698,3 +17704,4 @@ unsigned char gbfont[] = {
1769817704
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1769917705
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1770017706
};
17707+
#endif

script.c

+40-13
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,35 @@ PAL_AdditionalCredits(
519519
--*/
520520
{
521521
#ifdef PAL_UNICODE
522+
LPCWSTR rgszcps[][CP_MAX] = {
523+
// Traditional Chinese, Simplified Chinese, Japanese
524+
{ L"", L"", L"" },
525+
{ L" (\x7D93\x5178\x7279\x5225\x7BC7", L" (\x7ECF\x5178\x7279\x522B\x7BC7", L"(\x53E4\x5178\x7684\x306A\x30D0\x30FC\x30B8\x30E7\x30F3" },
526+
{ L"", L"", L"" },
527+
{ L"", L"", L"" },
528+
{ L"", L"", L"" },
529+
#if defined(__SYMBIAN32__) || defined(GPH) || defined(GEKKO) || defined(DINGOO) || defined(ANDROID)
530+
{ L"", L"", L"" },
531+
#endif
532+
{ L"", L"", L"" },
533+
{ L"\x672C\x7A0B\x5F0F\x662F\x81EA\x7531\x8EDF\x9AD4\xFF0C\x6309\x7167 GNU General",
534+
L"\x672C\x7A0B\x5E8F\x662F\x81EA\x7531\x8F6F\x4EF6\xFF0C\x6309\x7167 GNU General",
535+
L"\x3053\x306E\x30D7\x30ED\x30B0\x30E9\x30E0\x306F\x30D5\x30EA\x30FC\x30BD\x30D5\x30C8\x30A6\x30A7\x30A2\x3001"
536+
},
537+
{ L"Public License (GPLv3) \x767C\x4F48", L"Public License (GPLv3) \x53D1\x5E03", L"GNU General Public License (GPLv3)\x306E" },
538+
{ L"", L"", L"\x4E0B\x3067\x30EA\x30EA\x30FC\x30B9\x3055\x308C\x3066" },
539+
{ L" ...\x6309 Enter \x7D50\x675F", L" ...\x6309 Enter \x7ED3\x675F", L"...Enter\x30AD\x30FC\x3092\x62BC\x3057\x3066\x7D42\x4E86\x3057\x307E\x3059" }
540+
};
541+
522542
LPCWSTR rgszStrings[] = {
523543
L"SDLPAL (http://sdlpal.codeplex.com/)",
524544
# ifdef PAL_CLASSIC
525-
L" (\x7D93\x5178\x7279\x5225\x7BC7 " WIDETEXT(__DATE__) L")",
545+
L" %s " WIDETEXT(__DATE__) L")",
526546
# else
527547
L" (" WIDETEXT(__DATE__) L")",
528548
# endif
529549
L" ",
530-
L" (c) 2009-2011, Wei Mingzhi",
550+
L" (c) 2009-2015, Wei Mingzhi",
531551
532552
# ifdef __SYMBIAN32__
533553
L" Symbian S60 \x79FB\x690D (c) 2009, netwan.",
@@ -545,12 +565,11 @@ PAL_AdditionalCredits(
545565
L" ANDROID \x79FB\x690D (c) 2013, Rikku2000.",
546566
# endif
547567
L" ",
548-
L"\x672C\x7A0B\x5F0F\x662F\x81EA\x7531\x8EDF\x9AD4\xFF0C\x6309\x7167"
549-
L" GNU General",
550-
L"Public License (GPLv3) \x767C\x4F48",
551-
L" ",
552-
L" ...\x6309 Enter \x7D50\x675F",
553-
L""
568+
L"%s",
569+
L"%s",
570+
L"%s",
571+
L" %s",
572+
NULL
554573
};
555574
#else
556575
LPCSTR rgszStrings[] = {
@@ -561,7 +580,7 @@ PAL_AdditionalCredits(
561580
" (" __DATE__ ")",
562581
# endif
563582
" ",
564-
" (c) 2009-2014, Wei Mingzhi",
583+
" (c) 2009-2015, Wei Mingzhi",
565584
566585
# ifdef __SYMBIAN32__
567586
" Symbian S60 \xB2\xBE\xB4\xD3 (c) 2009, netwan.",
@@ -575,13 +594,16 @@ PAL_AdditionalCredits(
575594
# ifdef DINGOO
576595
" DINGOO & Dingux \xB2\xBE\xB4\xD3 (c) 2011, Rikku2000.",
577596
# endif
578-
" ",
597+
# ifdef ANDROID
598+
" ANDROID \xB2\xBE\xB4\xD3 (c) 2013, Rikku2000.",
599+
# endif
600+
" ",
579601
"\xA5\xBB\xB5\x7B\xA6\xA1\xAC\x4F\xA6\xDB\xA5\xD1\xB3\x6E\xC5\xE9\xA1\x41\xAB\xF6\xB7\xD3"
580602
" GNU General",
581603
"Public License (GPLv3) \xB5\x6F\xA7\x47",
582604
" ",
583605
" ...\xAB\xF6 Enter \xB5\xB2\xA7\xF4",
584-
""
606+
NULL
585607
};
586608
#endif
587609

@@ -594,10 +616,15 @@ PAL_AdditionalCredits(
594616

595617
PAL_DrawOpeningMenuBackground();
596618

597-
while (rgszStrings[i][0] != '\0')
619+
for (i = 0; rgszStrings[i]; i++)
598620
{
621+
#ifdef PAL_UNICODE
622+
WCHAR buffer[50];
623+
swprintf(buffer, 50, rgszStrings[i], rgszcps[i][gpGlobals->iCodePage]);
624+
PAL_DrawText(buffer, PAL_XY(25, 20 + i * 16), DESCTEXT_COLOR, TRUE, FALSE);
625+
#else
599626
PAL_DrawText(rgszStrings[i], PAL_XY(25, 20 + i * 16), DESCTEXT_COLOR, TRUE, FALSE);
600-
i++;
627+
#endif
601628
}
602629

603630
PAL_SetPalette(0, FALSE);

ui.c

+106
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,112 @@ PAL_DrawNumber(
683683
}
684684
}
685685

686+
INT
687+
PAL_MenuTextMaxWidth(
688+
LPMENUITEM rgMenuItem,
689+
INT nMenuItem
690+
)
691+
/*++
692+
Purpose:
693+
694+
Calculate the maximal text width of all the menu items in number of full width characters.
695+
696+
Parameters:
697+
698+
[IN] rgMenuItem - Pointer to the menu item array.
699+
[IN] nMenuItem - Number of menu items.
700+
701+
Return value:
702+
703+
Maximal text width.
704+
705+
--*/
706+
{
707+
int i, r = 0;
708+
for (i = 0; i < nMenuItem; i++)
709+
{
710+
LPCWSTR itemText = PAL_GetWord(rgMenuItem[i].wNumWord);
711+
int j = 0, l = wcslen(itemText), w = 0;
712+
for (j = 0; j < l; j++)
713+
{
714+
w += PAL_CharWidth(itemText[j]);
715+
}
716+
w = (w + 8) >> 4;
717+
if (r < w)
718+
{
719+
r = w;
720+
}
721+
}
722+
return r;
723+
}
724+
725+
INT
726+
PAL_WordMaxWidth(
727+
INT nFirstWord,
728+
INT nWordNum
729+
)
730+
/*++
731+
Purpose:
732+
733+
Calculate the maximal text width of a specific range of words in number of full width characters.
734+
735+
Parameters:
736+
737+
[IN] nFirstWord - First index of word.
738+
[IN] nWordNum - Number of words.
739+
740+
Return value:
741+
742+
Maximal text width.
743+
744+
--*/
745+
{
746+
int i, r = 0;
747+
for (i = 0; i < nWordNum; i++)
748+
{
749+
LPCWSTR itemText = PAL_GetWord(nFirstWord + i);
750+
int j = 0, l = wcslen(itemText), w = 0;
751+
for (j = 0; j < l; j++)
752+
{
753+
w += PAL_CharWidth(itemText[j]);
754+
}
755+
w = (w + 8) >> 4;
756+
if (r < w)
757+
{
758+
r = w;
759+
}
760+
}
761+
return r;
762+
}
763+
764+
INT
765+
PAL_WordWidth(
766+
INT nWordIndex
767+
)
768+
/*++
769+
Purpose:
770+
771+
Calculate the text width of a specific word.
772+
773+
Parameters:
774+
775+
[IN] nWordNum - Index of the word.
776+
777+
Return value:
778+
779+
Text width.
780+
781+
--*/
782+
{
783+
LPCWSTR itemText = PAL_GetWord(nWordIndex);
784+
int i, l = wcslen(itemText), w = 0;
785+
for (i = 0; i < l; i++)
786+
{
787+
w += PAL_CharWidth(itemText[i]);
788+
}
789+
return (w + 8) >> 4;
790+
}
791+
686792
#ifndef PAL_WIN95
687793

688794
LPOBJECTDESC

ui.h

+17
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ PAL_DrawNumber(
218218
NUMALIGN align
219219
);
220220

221+
INT
222+
PAL_MenuTextMaxWidth(
223+
LPMENUITEM rgMenuItem,
224+
INT nMenuItem
225+
);
226+
227+
INT
228+
PAL_WordMaxWidth(
229+
INT nFirstWord,
230+
INT nWordNum
231+
);
232+
233+
INT
234+
PAL_WordWidth(
235+
INT nWordIndex
236+
);
237+
221238
#ifndef PAL_WIN95
222239
LPOBJECTDESC
223240
PAL_LoadObjectDesc(

uibattle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ PAL_BattleUIMiscItemSubMenuUpdate(
503503
#else
504504
PAL_BattleUIDrawMiscMenu(0, TRUE);
505505
#endif
506-
PAL_CreateBox(PAL_XY(30, 50), 1, 1, 0, FALSE);
506+
PAL_CreateBox(PAL_XY(30, 50), 1, PAL_MenuTextMaxWidth(rgMenuItem, 2) - 1, 0, FALSE);
507507

508508
//
509509
// Draw the menu items

0 commit comments

Comments
 (0)