This commit is contained in:
Sergeanur 2020-03-31 08:38:22 +03:00
parent 92ec403191
commit c0c09f2720
10 changed files with 650 additions and 118 deletions

View File

@ -1388,7 +1388,7 @@ void CGarages::PrintMessages()
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f)); CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f));
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
#if defined(PS2) || defined (FIX_BUGS) #if defined(PS2) || defined (FIX_BUGS)

View File

@ -576,7 +576,7 @@ void CMenuManager::Draw()
if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') { if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') {
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
#ifdef PS2_LIKE_MENU #ifdef PS2_LIKE_MENU
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(1.3f)); CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(1.3f));
@ -590,7 +590,7 @@ void CMenuManager::Draw()
nextYToUse += 24.0f + 10.0f; nextYToUse += 24.0f + 10.0f;
} }
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetScale(MENU_X(0.9f * actionTextScaleX), MENU_Y(0.9f * actionTextScaleY)); CFont::SetScale(MENU_X(0.9f * actionTextScaleX), MENU_Y(0.9f * actionTextScaleY));
CFont::SetRightJustifyOff(); // AG used SetAlignment(ALIGN_LEFT); CFont::SetRightJustifyOff(); // AG used SetAlignment(ALIGN_LEFT);
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
@ -646,7 +646,7 @@ void CMenuManager::Draw()
columnWidth = 320; columnWidth = 320;
headerHeight = 240; headerHeight = 240;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
CFont::SetCentreOn(); CFont::SetCentreOn();
break; break;
@ -663,7 +663,7 @@ void CMenuManager::Draw()
columnWidth = 50; columnWidth = 50;
headerHeight = 0; headerHeight = 0;
lineHeight = 20; lineHeight = 20;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.55f), MENU_Y(actionTextScaleY = 0.8f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.55f), MENU_Y(actionTextScaleY = 0.8f));
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
break; break;
@ -673,7 +673,7 @@ void CMenuManager::Draw()
columnWidth = 120; columnWidth = 120;
headerHeight = 38; headerHeight = 38;
lineHeight = 20; lineHeight = 20;
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetScale(MENU_X(actionTextScaleX = 0.45f), MENU_Y(actionTextScaleY = 0.7f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.45f), MENU_Y(actionTextScaleY = 0.7f));
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
break; break;
@ -685,7 +685,7 @@ void CMenuManager::Draw()
columnWidth = 320; columnWidth = 320;
headerHeight = 60; headerHeight = 60;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
CFont::SetCentreOn(); CFont::SetCentreOn();
break; break;
@ -693,7 +693,7 @@ void CMenuManager::Draw()
columnWidth = 320; columnWidth = 320;
headerHeight = 140; headerHeight = 140;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
CFont::SetCentreOn(); CFont::SetCentreOn();
break; break;
@ -701,7 +701,7 @@ void CMenuManager::Draw()
columnWidth = 320; columnWidth = 320;
headerHeight = 117; headerHeight = 117;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
CFont::SetCentreOn(); CFont::SetCentreOn();
break; break;
@ -710,7 +710,7 @@ void CMenuManager::Draw()
columnWidth = 180; columnWidth = 180;
headerHeight = 60; headerHeight = 60;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
break; break;
#endif #endif
@ -718,7 +718,7 @@ void CMenuManager::Draw()
columnWidth = 320; columnWidth = 320;
headerHeight = 40; headerHeight = 40;
lineHeight = 24; lineHeight = 24;
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f));
CFont::SetCentreOn(); CFont::SetCentreOn();
break; break;
@ -1736,6 +1736,9 @@ void CMenuManager::InitialiseChangedLanguageSettings()
case LANGUAGE_RUSSIAN: case LANGUAGE_RUSSIAN:
CFont::ReloadFonts(FONT_LANGSET_RUSSIAN); CFont::ReloadFonts(FONT_LANGSET_RUSSIAN);
break; break;
case LANGUAGE_JAPANESE:
CFont::ReloadFonts(FONT_LANGSET_JAPANESE);
break;
default: default:
CFont::ReloadFonts(FONT_LANGSET_EFIGS); CFont::ReloadFonts(FONT_LANGSET_EFIGS);
break; break;
@ -2962,6 +2965,12 @@ CMenuManager::ProcessButtonPresses(void)
CMenuManager::InitialiseChangedLanguageSettings(); CMenuManager::InitialiseChangedLanguageSettings();
SaveSettings(); SaveSettings();
break; break;
case MENUACTION_LANG_JAP:
m_PrefsLanguage = LANGUAGE_JAPANESE;
m_bFrontEnd_ReloadObrTxtGxt = true;
CMenuManager::InitialiseChangedLanguageSettings();
SaveSettings();
break;
#endif #endif
case MENUACTION_POPULATESLOTS_CHANGEMENU: case MENUACTION_POPULATESLOTS_CHANGEMENU:
PcSaveHelper.PopulateSlotInfo(); PcSaveHelper.PopulateSlotInfo();

View File

@ -53,6 +53,7 @@ enum eLanguages
LANGUAGE_SPANISH, LANGUAGE_SPANISH,
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
LANGUAGE_RUSSIAN, LANGUAGE_RUSSIAN,
LANGUAGE_JAPANESE,
#endif #endif
}; };
@ -306,6 +307,7 @@ enum eMenuAction
MENUACTION_UNK110, MENUACTION_UNK110,
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
MENUACTION_LANG_RUS, MENUACTION_LANG_RUS,
MENUACTION_LANG_JAP,
#endif #endif
}; };

View File

@ -67,6 +67,7 @@ const CMenuScreen aScreens[] = {
MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE,
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_LANG_JAP, "FEL_JAP", SAVESLOT_NONE, MENUPAGE_NONE,
#endif #endif
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
}, },

View File

@ -6,11 +6,16 @@
CFontDetails &CFont::Details = *(CFontDetails*)0x8F317C; CFontDetails &CFont::Details = *(CFontDetails*)0x8F317C;
int16 &CFont::NewLine = *(int16*)0x95CC94; int16 &CFont::NewLine = *(int16*)0x95CC94;
#ifdef MORE_LANGUAGES
CSprite2d CFont::Sprite[4];
#else
CSprite2d *CFont::Sprite = (CSprite2d*)0x95CC04; CSprite2d *CFont::Sprite = (CSprite2d*)0x95CC04;
#endif
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
uint8 CFont::LanguageSet = FONT_LANGSET_EFIGS; uint8 CFont::LanguageSet = FONT_LANGSET_EFIGS;
int32 CFont::Slot = -1; int32 CFont::Slot = -1;
#define JAP_TERMINATION (0x8000 | '~')
int16 CFont::Size[2][3][193] = { int16 CFont::Size[2][3][193] = {
{ {
@ -116,6 +121,24 @@ int16 CFont::Size[3][193] = {
#endif #endif
}; };
int16 Size_jp[] = {
15, 14, 16, 20, 19, 26, 22, 11, 18, 18, 27, 26, 13, //; 0
19, 20, 27, 19, 15, 19, 19, 21, 19, 20, 18, 19, 15, //; 13
13, 28, 15, 32, 15, 35, 15, 19, 19, 19, 19, 17, 16, //; 26
19, 20, 15, 19, 20, 14, 17, 19, 19, 19, 19, 19, 19, //; 39
19, 19, 20, 25, 20, 19, 19, 33, 31, 39, 37, 39, 37, //; 52
21, 21, 21, 19, 17, 15, 23, 21, 15, 19, 20, 16, 19, //; 65
19, 19, 20, 20, 17, 22, 19, 22, 22, 19, 22, 22, 23, //; 78
35, 35, 35, 35, 37, 19, 19, 19, 19, 29, 19, 19, 19, //; 91
19, 19, 9, 9, 9, 9, 19, 19, 19, 19, 19, 19, 19, 19, //; 104
19, 19, 19, 19, 19, 30, 19, 19, 19, 19, 19, 10, 10, //; 118
10, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 23, 35, //; 131
12, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 144
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 157
19, 19, 19, 11, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 170
19, 19, 19, 19, 19, 19, 19, 19, 19, 21
};
wchar foreign_table[128] = { wchar foreign_table[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -144,6 +167,9 @@ CFont::Initialise(void)
case FONT_LANGSET_RUSSIAN: case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(slot, "MODELS/FONTS_R.TXD"); CTxdStore::LoadTxd(slot, "MODELS/FONTS_R.TXD");
break; break;
case FONT_LANGSET_JAPANESE:
CTxdStore::LoadTxd(slot, "MODELS/FONTS_J.TXD");
break;
} }
#else #else
CTxdStore::LoadTxd(slot, "MODELS/FONTS.TXD"); CTxdStore::LoadTxd(slot, "MODELS/FONTS.TXD");
@ -152,7 +178,12 @@ CFont::Initialise(void)
CTxdStore::PushCurrentTxd(); CTxdStore::PushCurrentTxd();
CTxdStore::SetCurrentTxd(slot); CTxdStore::SetCurrentTxd(slot);
Sprite[0].SetTexture("font2", "font2_mask"); Sprite[0].SetTexture("font2", "font2_mask");
Sprite[1].SetTexture("pager", "pager_mask"); if (LanguageSet == FONT_LANGSET_JAPANESE) {
Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
}
else
Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask"); Sprite[2].SetTexture("font1", "font1_mask");
SetScale(1.0f, 1.0f); SetScale(1.0f, 1.0f);
SetSlantRefPoint(SCREEN_WIDTH, 0.0f); SetSlantRefPoint(SCREEN_WIDTH, 0.0f);
@ -160,8 +191,8 @@ CFont::Initialise(void)
SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0)); SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0));
SetJustifyOff(); SetJustifyOff();
SetCentreOff(); SetCentreOff();
SetWrapx(640.0f); SetWrapx(DEFAULT_SCREEN_WIDTH);
SetCentreSize(640.0f); SetCentreSize(DEFAULT_SCREEN_WIDTH);
SetBackgroundOff(); SetBackgroundOff();
SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80)); SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80));
SetBackGroundOnlyTextOff(); SetBackGroundOnlyTextOff();
@ -181,6 +212,8 @@ CFont::ReloadFonts(uint8 set)
Sprite[0].Delete(); Sprite[0].Delete();
Sprite[1].Delete(); Sprite[1].Delete();
Sprite[2].Delete(); Sprite[2].Delete();
if (LanguageSet == FONT_LANGSET_JAPANESE)
Sprite[3].Delete();
CTxdStore::PushCurrentTxd(); CTxdStore::PushCurrentTxd();
CTxdStore::RemoveTxd(Slot); CTxdStore::RemoveTxd(Slot);
switch (set) switch (set)
@ -192,10 +225,18 @@ CFont::ReloadFonts(uint8 set)
case FONT_LANGSET_RUSSIAN: case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(Slot, "MODELS/FONTS_R.TXD"); CTxdStore::LoadTxd(Slot, "MODELS/FONTS_R.TXD");
break; break;
case FONT_LANGSET_JAPANESE:
CTxdStore::LoadTxd(Slot, "MODELS/FONTS_J.TXD");
break;
} }
CTxdStore::SetCurrentTxd(Slot); CTxdStore::SetCurrentTxd(Slot);
Sprite[0].SetTexture("font2", "font2_mask"); Sprite[0].SetTexture("font2", "font2_mask");
Sprite[1].SetTexture("pager", "pager_mask"); if (set == FONT_LANGSET_JAPANESE) {
Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
}
else
Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask"); Sprite[2].SetTexture("font1", "font1_mask");
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
} }
@ -209,6 +250,8 @@ CFont::Shutdown(void)
Sprite[0].Delete(); Sprite[0].Delete();
Sprite[1].Delete(); Sprite[1].Delete();
Sprite[2].Delete(); Sprite[2].Delete();
if (LanguageSet == FONT_LANGSET_JAPANESE)
Sprite[3].Delete();
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
CTxdStore::RemoveTxdSlot(Slot); CTxdStore::RemoveTxdSlot(Slot);
Slot = -1; Slot = -1;
@ -223,6 +266,8 @@ CFont::InitPerFrame(void)
Details.bank = CSprite2d::GetBank(30, Sprite[0].m_pTexture); Details.bank = CSprite2d::GetBank(30, Sprite[0].m_pTexture);
CSprite2d::GetBank(15, Sprite[1].m_pTexture); CSprite2d::GetBank(15, Sprite[1].m_pTexture);
CSprite2d::GetBank(15, Sprite[2].m_pTexture); CSprite2d::GetBank(15, Sprite[2].m_pTexture);
if (LanguageSet == FONT_LANGSET_JAPANESE)
CSprite2d::GetBank(15, Sprite[3].m_pTexture);
SetDropShadowPosition(0); SetDropShadowPosition(0);
NewLine = 0; NewLine = 0;
} }
@ -235,8 +280,13 @@ CFont::PrintChar(float x, float y, wchar c)
return; return;
float w = GetCharacterWidth(c) / 32.0f; float w = GetCharacterWidth(c) / 32.0f;
float xoff = c & 0xF; float xoff = c % 16;
float yoff = c >> 4; float yoff = c / 16;
if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_PAGER || Details.style == FONT_JAPANESE)) {
w = 21.0f;
xoff = (float)(c % 48);// *w / 1024.0f;
yoff = c / 48;
}
if(Details.style == FONT_BANK || Details.style == FONT_HEADING){ if(Details.style == FONT_BANK || Details.style == FONT_HEADING){
if(Details.dropShadowPosition != 0){ if(Details.dropShadowPosition != 0){
@ -260,17 +310,76 @@ CFont::PrintChar(float x, float y, wchar c)
(xoff+1.0f)/16.0f - 0.001f, yoff/12.8f, (xoff+1.0f)/16.0f - 0.001f, yoff/12.8f,
xoff/16.0f, (yoff+1.0f)/12.8f - 0.002f, xoff/16.0f, (yoff+1.0f)/12.8f - 0.002f,
(xoff+1.0f)/16.0f - 0.001f, (yoff+1.0f)/12.8f - 0.002f); (xoff+1.0f)/16.0f - 0.001f, (yoff+1.0f)/12.8f - 0.002f);
}else{ }else if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_PAGER || Details.style == FONT_JAPANESE)) {
if (Details.dropShadowPosition != 0) {
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition),
y + SCREEN_SCALE_Y(Details.dropShadowPosition),
x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f,
y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY / 2.75f),
Details.dropColor,
xoff * w / 1024.0f, yoff / 25.6f,
xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f,
xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
}
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x, y, CRect(x, y,
x + 32.0f * Details.scaleX * w, x + 32.0f * Details.scaleX * 1.0f,
y + 32.0f * Details.scaleY * 0.5f), y + 40.0f * Details.scaleY / 2.75f),
Details.color,
xoff * w / 1024.0f, yoff / 25.6f,
xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f - 0.002f,
xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
}
else
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x, y,
x + 32.0f * Details.scaleX * w,
y + 32.0f * Details.scaleY * 0.5f),
Details.color, Details.color,
xoff/16.0f, yoff/16.0f, xoff/16.0f, yoff/16.0f,
(xoff+w)/16.0f, yoff/16.0f, (xoff+w)/16.0f, yoff/16.0f,
xoff/16.0f, (yoff+1.0f)/16.0f, xoff/16.0f, (yoff+1.0f)/16.0f,
(xoff+w)/16.0f - 0.0001f, (yoff+1.0f)/16.0f - 0.0001f); (xoff+w)/16.0f - 0.0001f, (yoff+1.0f)/16.0f - 0.0001f);
}
bool someJapCheck(wchar *a1)
{
wchar v2;
v2 = *a1;
if (v2 != 0xE7
&& v2 != 0x124
&& v2 != 0x126
&& v2 != 0x128
&& v2 != 0x104
&& v2 != ','
&& v2 != '>'
&& v2 != '!'
&& v2 != 0x99
&& v2 != '?'
&& v2 != ':')
{
return false;
} }
return true;
}
bool sub_511630(wchar *s)
{
if (*s >= 'A' && *s <= 'Z')
return true;
if (*s >= 'a' && *s <= 'z')
return true;
if (*s >= '0' && *s <= ':')
return true;
if (*s == '(' || *s == ')')
return true;
if (*s == 'D' || *s == '$')
return true;
return false;
} }
void void
@ -308,17 +417,19 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
for(;;){ for(;;){
if(*s == '\0') if(*s == '\0')
return; return;
int xend = Details.centre ? Details.centreSize : float xend = Details.centre ? Details.centreSize :
Details.rightJustify ? xstart - Details.rightJustifyWrap : Details.rightJustify ? xstart - Details.rightJustifyWrap :
Details.wrapX; Details.wrapX;
if(x + GetStringWidth(s) > xend && !first){ if(x + GetStringWidth(s) > xend && !first){
if (LanguageSet == FONT_LANGSET_JAPANESE && someJapCheck(s))
s--;
// flush line // flush line
float spaceWidth = !Details.justify || Details.centre ? 0.0f : float spaceWidth = !Details.justify || Details.centre ? 0.0f :
(Details.wrapX - lineLength) / numSpaces; (Details.wrapX - lineLength) / numSpaces;
float xleft = Details.centre ? xstart - x/2 : float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x : Details.rightJustify ? xstart - x :
xstart; xstart;
PrintString(xleft, y, start, s, spaceWidth); PrintString(xleft, y, start, s, spaceWidth, xstart);
// reset things // reset things
lineLength = 0.0f; lineLength = 0.0f;
numSpaces = 0; numSpaces = 0;
@ -327,7 +438,10 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
x = 0.0f; x = 0.0f;
else else
x = xstart; x = xstart;
y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY; if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER))
y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
else
y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
start = s; start = s;
}else }else
break; break;
@ -341,8 +455,32 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
numSpaces++; numSpaces++;
first = false; first = false;
x += GetStringWidth(s) + GetCharacterSize(*t - ' '); x += GetStringWidth(s) + GetCharacterSize(*t - ' ');
if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER) && sub_511630(s))
x += 21.0f;
lineLength = x; lineLength = x;
s = t+1; s = t+1;
if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER) && !*s) {
x += GetStringWidth(s);
if (sub_511630(s))
x += 21.0f;
float xleft = Details.centre ? xstart - x / 2 :
Details.rightJustify ? xstart - x :
xstart;
if (PrintString(xleft, y, start, s, 0.0f, xstart))
{
start = s;
if (!Details.centre && !Details.rightJustify)
x = xstart;
else
x = 0.0f;
y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
numSpaces = 0;
first = true;
lineLength = 0.0f;
}
}
} }
// print rest // print rest
if(t[0] == ' ' && t[1] == '\0') if(t[0] == ' ' && t[1] == '\0')
@ -352,7 +490,21 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
float xleft = Details.centre ? xstart - x/2 : float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x : Details.rightJustify ? xstart - x :
xstart; xstart;
PrintString(xleft, y, start, s, 0.0f); #ifdef MORE_LANGUAGES
if (PrintString(xleft, y, start, s, 0.0f, xstart) && LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER)) {
start = s;
if (!Details.centre && !Details.rightJustify)
x = xstart;
else
x = 0.0f;
y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
numSpaces = 0;
first = true;
lineLength = 0.0f;
}
#else
PrintString(xleft, y, start, s, 0.0f)
#endif
} }
} }
@ -362,8 +514,28 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
int n; int n;
float x, y; float x, y;
wchar *t; wchar *t;
n = 0; n = 0;
bool v14 = false;
#ifdef MORE_LANGUAGES
if (LanguageSet == FONT_LANGSET_JAPANESE) {
t = s;
wchar unused;
while (*t) {
if (*t == JAP_TERMINATION || *t == '~')
t = ParseToken(t, &unused, true);
if (NewLine) {
n++;
NewLine = false;
v14 = true;
}
t++;
}
}
#endif
if (v14) n--;
if(Details.centre || Details.rightJustify) if(Details.centre || Details.rightJustify)
x = 0.0f; x = 0.0f;
else else
@ -371,7 +543,17 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
y = ystart; y = ystart;
while(*s){ while(*s){
if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){ float f = (Details.centre ? Details.centreSize : Details.wrapX);
if (LanguageSet == FONT_LANGSET_JAPANESE)
{
f -= SCREEN_SCALE_X(21.0f * 2.0f);
}
if(x + GetStringWidth(s) > f){
if (LanguageSet == FONT_LANGSET_JAPANESE)
{
if (someJapCheck(s))
s--;
}
// reached end of line // reached end of line
if(Details.centre || Details.rightJustify) if(Details.centre || Details.rightJustify)
x = 0.0f; x = 0.0f;
@ -379,19 +561,28 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
x = xstart; x = xstart;
n++; n++;
// Why even? // Why even?
y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY; if (LanguageSet == FONT_LANGSET_JAPANESE)
y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
else
y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{ }else{
// still space in current line // still space in current line
t = GetNextSpace(s); t = GetNextSpace(s);
if(*t == '\0'){ if(*t == '\0'){
// end of string // end of string
x += GetStringWidth(s); x += GetStringWidth(s);
if ((LanguageSet == FONT_LANGSET_JAPANESE) && sub_511630(s))
x += 21.0f;
n++; n++;
s = t; s = t;
}else{ }else{
x += GetStringWidth(s); x += GetStringWidth(s);
x += GetCharacterSize(*t - ' '); if ((LanguageSet == FONT_LANGSET_JAPANESE) && sub_511630(s))
x += 21.0f;
s = t+1; s = t+1;
x += GetCharacterSize(*t - ' ');
if (LanguageSet == FONT_LANGSET_JAPANESE && !*s)
n++;
} }
} }
} }
@ -409,37 +600,43 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
maxlength = 0; maxlength = 0;
numLines = 0; numLines = 0;
if(Details.centre || Details.rightJustify)
x = 0.0f;
else
x = xstart;
y = ystart;
while(*s){ if (LanguageSet == FONT_LANGSET_JAPANESE) {
if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){ numLines = GetNumberLines(xstart, ystart, s);
// reached end of line //maxlength = Details.centreSize;
if(x > maxlength) }else{
maxlength = x; if(Details.centre || Details.rightJustify)
if(Details.centre || Details.rightJustify) x = 0.0f;
x = 0.0f; else
else x = xstart;
x = xstart; y = ystart;
numLines++;
y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY; while(*s){
}else{ if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
// still space in current line // reached end of line
t = GetNextSpace(s);
if(*t == '\0'){
// end of string
x += GetStringWidth(s);
if(x > maxlength) if(x > maxlength)
maxlength = x; maxlength = x;
if(Details.centre || Details.rightJustify)
x = 0.0f;
else
x = xstart;
numLines++; numLines++;
s = t; y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{ }else{
x += GetStringWidth(s); // still space in current line
x += GetCharacterSize(*t - ' '); t = GetNextSpace(s);
s = t+1; if(*t == '\0'){
// end of string
x += GetStringWidth(s);
if(x > maxlength)
maxlength = x;
numLines++;
s = t;
}else{
x += GetStringWidth(s);
x += GetCharacterSize(*t - ' ');
s = t+1;
}
} }
} }
} }
@ -448,26 +645,89 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
if(Details.backgroundOnlyText){ if(Details.backgroundOnlyText){
rect->left = xstart - maxlength/2 - 4.0f; rect->left = xstart - maxlength/2 - 4.0f;
rect->right = xstart + maxlength/2 + 4.0f; rect->right = xstart + maxlength/2 + 4.0f;
rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER))
ystart + 2.0f; {
rect->top = ystart - 2.0f; rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 1.454545454545455;
rect->top = ystart - 1.454545454545455;
}
else
{
rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
rect->top = ystart - 2.0f;
}
}else{ }else{
rect->left = xstart - Details.centreSize*0.5f - 4.0f; rect->left = xstart - Details.centreSize*0.5f - 4.0f;
rect->right = xstart + Details.centreSize*0.5f + 4.0f; rect->right = xstart + Details.centreSize*0.5f + 4.0f;
rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER))
ystart + 2.0f; {
rect->top = ystart - 2.0f; rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 1.454545454545455;
rect->top = ystart - 1.454545454545455;
}
else
{
rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
rect->top = ystart - 2.0f;
}
} }
}else{ }else{
rect->left = xstart - 4.0f; rect->left = xstart - 4.0f;
rect->right = Details.wrapX; rect->right = Details.wrapX;
// WTF? // WTF?
rect->bottom = ystart - 4.0f + 4.0f; rect->bottom = ystart - 4.0f + 4.0f;
rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + if (LanguageSet == FONT_LANGSET_JAPANESE && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER))
ystart + 2.0f + 2.0f; rect->top = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + 1.454545454545455;
else
rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + 2.0f;
} }
} }
#ifdef MORE_LANGUAGES
bool
CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX)
{
wchar *s, c, unused;
if (LanguageSet == FONT_LANGSET_JAPANESE) {
float v14 = 0.0f;
for (s = start; s < end; s++) {
if (*s == JAP_TERMINATION || *s == '~')
s = ParseToken(s, &unused, true);
if (NewLine) {
NewLine = false;
break;
}
v14 += GetCharacterSize(*s - ' ');
}
s = start;
if (Details.centre)
{
x = japX - v14 * 0.5;
}
else if (Details.rightJustify)
{
x = japX - v14;
}
}
for (s = start; s < end; s++) {
if (*s == '~' || (LanguageSet == FONT_LANGSET_JAPANESE && *s == JAP_TERMINATION))
s = ParseToken(s, &unused);
if (NewLine && LanguageSet == FONT_LANGSET_JAPANESE) {
NewLine = false;
end = s;
return true;
}
c = *s - ' ';
if (Details.slant != 0.0f && LanguageSet != FONT_LANGSET_JAPANESE)
y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
PrintChar(x, y, c);
x += GetCharacterSize(c);
if (c == 0 && (!NewLine || LanguageSet != FONT_LANGSET_JAPANESE)) // space
x += spwidth;
}
return false;
}
#else
void void
CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth) CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
{ {
@ -485,12 +745,42 @@ CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
x += spwidth; x += spwidth;
} }
} }
#endif
float float
CFont::GetCharacterWidth(wchar c) CFont::GetCharacterWidth(wchar c)
{ {
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
if (Details.proportional) if (CFont::LanguageSet == FONT_LANGSET_JAPANESE)
{
if (!Details.proportional)
return Size[0][Details.style][192];
if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
switch (Details.style)
{
case FONT_JAPANESE:
return Size_jp[c];
default:
return Size[0][Details.style][c];
}
}
if (c < 254 && Details.style == FONT_PAGER)
return 29.4f;
switch (Details.style)
{
case FONT_JAPANESE:
return 29.4f;
case FONT_BANK:
return 10.0f;
case FONT_PAGER:
return 31.5f;
case FONT_HEADING:
return Size[0][Details.style][c];
}
}
else if (Details.proportional)
return Size[LanguageSet][Details.style][c]; return Size[LanguageSet][Details.style][c];
else else
return Size[LanguageSet][Details.style][192]; return Size[LanguageSet][Details.style][192];
@ -506,7 +796,36 @@ float
CFont::GetCharacterSize(wchar c) CFont::GetCharacterSize(wchar c)
{ {
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
if(Details.proportional)
if (CFont::LanguageSet == FONT_LANGSET_JAPANESE)
{
if (!Details.proportional)
return Size[0][Details.style][192] * Details.scaleX;
if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
switch (Details.style)
{
case FONT_JAPANESE:
return Size_jp[c] * Details.scaleX;
default:
return Size[0][Details.style][c] * Details.scaleX;
}
}
if (c < 254 && (Details.style == FONT_PAGER))
return 29.4f * Details.scaleX;
switch (Details.style)
{
case FONT_JAPANESE:
return 29.4f * Details.scaleX;
case FONT_BANK:
return 10.0f * Details.scaleX;
case FONT_PAGER:
return 31.5f * Details.scaleX;
case FONT_HEADING:
return Size[0][Details.style][c] * Details.scaleX;
}
}
else if(Details.proportional)
return Size[LanguageSet][Details.style][c] * Details.scaleX; return Size[LanguageSet][Details.style][c] * Details.scaleX;
else else
return Size[LanguageSet][Details.style][192] * Details.scaleX; return Size[LanguageSet][Details.style][192] * Details.scaleX;
@ -524,15 +843,40 @@ CFont::GetStringWidth(wchar *s, bool spaces)
float w; float w;
w = 0.0f; w = 0.0f;
for(; (*s != ' ' || spaces) && *s != '\0'; s++){
if(*s == '~'){ if (LanguageSet == FONT_LANGSET_JAPANESE)
s++; {
while(*s != '~') s++; do
s++; {
if(*s == ' ' && !spaces) if ((*s != ' ' || spaces) && *s != '\0') {
break; do {
while (*s == '~' || *s == JAP_TERMINATION) {
s++;
while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
s++;
//if (*s != JAP_TERMINATION && *s != '~')
// ++s;
continue;
}
w += GetCharacterSize(*s - ' ');
//if (*s != JAP_TERMINATION && *s != '~')
++s;
} while (*s == '~' || *s == JAP_TERMINATION);
}
} while (sub_511630(s));
}
else
{
for (; (*s != ' ' || spaces) && *s != '\0'; s++) {
if (*s == '~' || (*s == JAP_TERMINATION && LanguageSet == FONT_LANGSET_JAPANESE)) {
s++;
while (!(*s == '~' || (*s == JAP_TERMINATION && LanguageSet == FONT_LANGSET_JAPANESE))) s++;
s++;
if (*s == ' ' && !spaces)
break;
}
w += GetCharacterSize(*s - ' ');
} }
w += GetCharacterSize(*s - ' ');
} }
return w; return w;
} }
@ -540,17 +884,116 @@ CFont::GetStringWidth(wchar *s, bool spaces)
wchar* wchar*
CFont::GetNextSpace(wchar *s) CFont::GetNextSpace(wchar *s)
{ {
for(; *s != ' ' && *s != '\0'; s++) if (LanguageSet == FONT_LANGSET_JAPANESE) {
if(*s == '~'){ while (*s == ' ' || !*s) {
s++; LABEL_11:
while(*s != '~') s++; if (!sub_511630(s))
s++; return s;
if(*s == ' ')
break;
} }
while (true)
{
if (*s == JAP_TERMINATION || *s == '~')
{
do
++s;
while (*s != JAP_TERMINATION && *s != '~');
++s;
if (*s == ' ')
return s;
}
++s;
if (*s != JAP_TERMINATION && *s != '~')
goto LABEL_11;
}
return s;
//for (; *s != ' ' && *s != '\0';) {
// if (!sub_511630(s))
// break;
// //for (; *s == '~' || *s == JAP_TERMINATION;s++) {
// // s++;
// // while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
// // s++;
// // if (*s == ' ')
// // return s;
// // if (!sub_511630(s))
// // return s;
// //}
// while (true)
// {
// if (*s == '~' || *s == JAP_TERMINATION) {
// s++;
// while (*s != '~' || *s == JAP_TERMINATION) s++;
// s++;
// if (*s == ' ')
// return s;
// }
// s++;
// if (!(*s == '~' || *s == JAP_TERMINATION))
// break;
// }
//}
//return s;
for (;*s != ' ' && *s != '\0' && sub_511630(s); s++ ) {
if (*s == '~' || *s == JAP_TERMINATION)
{
s++;
while (*s != '~' && *s != JAP_TERMINATION) s++;
s++;
if (*s == ' ' || ((*s != '~' && *s != JAP_TERMINATION) && !sub_511630(s)))
break;
}
}
}
else
{
for(; *s != ' ' && *s != '\0'; s++)
if(*s == '~' || (*s == JAP_TERMINATION && LanguageSet == FONT_LANGSET_JAPANESE)){
s++;
while(*s != '~' || (*s == JAP_TERMINATION && LanguageSet == FONT_LANGSET_JAPANESE)) s++;
s++;
if(*s == ' ')
break;
}
}
return s; return s;
} }
#ifdef MORE_LANGUAGES
wchar*
CFont::ParseToken(wchar *s, wchar*, bool japShit)
{
s++;
if ((Details.color.r || Details.color.g || Details.color.b) && !japShit) {
wchar c = *s;
if (LanguageSet == FONT_LANGSET_JAPANESE)
c &= 0x7FFF;
switch (c) {
case 'N':
case 'n':
NewLine = true;
break;
case 'b': SetColor(CRGBA(128, 167, 243, 255)); break;
case 'g': SetColor(CRGBA(95, 160, 106, 255)); break;
case 'h': SetColor(CRGBA(225, 225, 225, 255)); break;
case 'l': SetColor(CRGBA(0, 0, 0, 255)); break;
case 'p': SetColor(CRGBA(168, 110, 252, 255)); break;
case 'r': SetColor(CRGBA(113, 43, 73, 255)); break;
case 'w': SetColor(CRGBA(175, 175, 175, 255)); break;
case 'y': SetColor(CRGBA(210, 196, 106, 255)); break;
}
} else if (LanguageSet == FONT_LANGSET_JAPANESE) {
if ((*s & 0x7FFF) == 'N' || (*s & 0x7FFF) == 'n')
NewLine = true;
}
while (((LanguageSet != FONT_LANGSET_JAPANESE) || (*s != JAP_TERMINATION)) && *s != '~') s++;
return s + 1;
}
#else
wchar* wchar*
CFont::ParseToken(wchar *s, wchar*) CFont::ParseToken(wchar *s, wchar*)
{ {
@ -573,6 +1016,7 @@ CFont::ParseToken(wchar *s, wchar*)
while(*s != '~') s++; while(*s != '~') s++;
return s+1; return s+1;
} }
#endif
void void
CFont::DrawFonts(void) CFont::DrawFonts(void)
@ -580,6 +1024,8 @@ CFont::DrawFonts(void)
CSprite2d::DrawBank(Details.bank); CSprite2d::DrawBank(Details.bank);
CSprite2d::DrawBank(Details.bank+1); CSprite2d::DrawBank(Details.bank+1);
CSprite2d::DrawBank(Details.bank+2); CSprite2d::DrawBank(Details.bank+2);
if (LanguageSet == FONT_LANGSET_JAPANESE)
CSprite2d::DrawBank(Details.bank+3);
} }
wchar wchar
@ -590,6 +1036,40 @@ CFont::character_code(uint8 c)
return foreign_table[c-128]; return foreign_table[c-128];
} }
void
CFont::SetScale(float x, float y)
{
/*if (LanguageSet == FONT_LANGSET_JAPANESE) {
x *= 1.35f;
y *= 1.25f;
}*/
Details.scaleX = x;
Details.scaleY = y;
}
void
CFont::SetBackgroundColor(CRGBA col)
{
Details.backgroundColor = col;
}
void
CFont::SetColor(CRGBA col)
{
Details.color = col;
if (Details.alphaFade < 255.0f)
Details.color.a *= Details.alphaFade / 255.0f;
}
void
CFont::SetDropColor(CRGBA col)
{
Details.dropColor = col;
if (Details.alphaFade < 255.0f)
Details.dropColor.a *= Details.alphaFade / 255.0f;
}
STARTPATCHES STARTPATCHES
InjectHook(0x500A40, CFont::Initialise, PATCH_JUMP); InjectHook(0x500A40, CFont::Initialise, PATCH_JUMP);
@ -599,7 +1079,7 @@ STARTPATCHES
InjectHook(0x500F50, (void (*)(float, float, wchar*))CFont::PrintString, PATCH_JUMP); InjectHook(0x500F50, (void (*)(float, float, wchar*))CFont::PrintString, PATCH_JUMP);
InjectHook(0x501260, CFont::GetNumberLines, PATCH_JUMP); InjectHook(0x501260, CFont::GetNumberLines, PATCH_JUMP);
InjectHook(0x5013B0, CFont::GetTextRect, PATCH_JUMP); InjectHook(0x5013B0, CFont::GetTextRect, PATCH_JUMP);
InjectHook(0x501730, (void (*)(float, float, wchar*, wchar*, float))CFont::PrintString, PATCH_JUMP); //InjectHook(0x501730, (void (*)(float, float, wchar*, wchar*, float))CFont::PrintString, PATCH_JUMP);
InjectHook(0x5017E0, CFont::GetCharacterWidth, PATCH_JUMP); InjectHook(0x5017E0, CFont::GetCharacterWidth, PATCH_JUMP);
InjectHook(0x501840, CFont::GetCharacterSize, PATCH_JUMP); InjectHook(0x501840, CFont::GetCharacterSize, PATCH_JUMP);
InjectHook(0x5018A0, CFont::GetStringWidth, PATCH_JUMP); InjectHook(0x5018A0, CFont::GetStringWidth, PATCH_JUMP);

View File

@ -31,6 +31,9 @@ enum {
FONT_BANK, FONT_BANK,
FONT_PAGER, FONT_PAGER,
FONT_HEADING, FONT_HEADING,
#ifdef MORE_LANGUAGES
FONT_JAPANESE,
#endif
}; };
enum { enum {
@ -43,21 +46,27 @@ enum {
enum enum
{ {
FONT_LANGSET_EFIGS, FONT_LANGSET_EFIGS,
FONT_LANGSET_RUSSIAN FONT_LANGSET_RUSSIAN,
FONT_LANGSET_JAPANESE
}; };
#endif #endif
#define FONTJAP(style) (CFont::LanguageSet == FONT_LANGSET_JAPANESE ? FONT_JAPANESE : style)
class CFont class CFont
{ {
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
static int16 Size[2][3][193]; static int16 Size[2][3][193];
public:
static uint8 LanguageSet; static uint8 LanguageSet;
private:
static int32 Slot; static int32 Slot;
static CSprite2d Sprite[4];
#else #else
static int16 Size[3][193]; static int16 Size[3][193];
static CSprite2d* Sprite; //[3]
#endif #endif
static int16 &NewLine; static int16 &NewLine;
static CSprite2d *Sprite; //[3]
public: public:
static CFontDetails& Details; static CFontDetails& Details;
@ -68,17 +77,25 @@ public:
static void PrintString(float x, float y, wchar *s); static void PrintString(float x, float y, wchar *s);
static int GetNumberLines(float xstart, float ystart, wchar *s); static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s); static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
#ifdef MORE_LANGUAGES
static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
#else
static void PrintString(float x, float y, wchar *start, wchar *end, float spwidth); static void PrintString(float x, float y, wchar *start, wchar *end, float spwidth);
#endif
static float GetCharacterWidth(wchar c); static float GetCharacterWidth(wchar c);
static float GetCharacterSize(wchar c); static float GetCharacterSize(wchar c);
static float GetStringWidth(wchar *s, bool spaces = false); static float GetStringWidth(wchar *s, bool spaces = false);
static wchar *GetNextSpace(wchar *s); static uint16 *GetNextSpace(wchar *s);
static wchar *ParseToken(wchar *s, wchar*); #ifdef MORE_LANGUAGES
static uint16 *ParseToken(wchar *s, wchar*, bool japShit = false);
#else
static uint16 *ParseToken(wchar *s, wchar*);
#endif
static void DrawFonts(void); static void DrawFonts(void);
static wchar character_code(uint8 c); static uint16 character_code(uint8 c);
static CFontDetails GetDetails() { return Details; } static CFontDetails GetDetails() { return Details; }
static void SetScale(float x, float y) { Details.scaleX = x; Details.scaleY = y; } static void SetScale(float x, float y);
static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; } static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
static void SetSlant(float s) { Details.slant = s; } static void SetSlant(float s) { Details.slant = s; }
static void SetJustifyOn(void) { static void SetJustifyOn(void) {
@ -137,19 +154,11 @@ public:
static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; } static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
static void SetAlphaFade(float fade) { Details.alphaFade = fade; } static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; } static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
static void SetBackgroundColor(CRGBA col);
static void SetColor(CRGBA col);
static void SetDropColor(CRGBA col);
// TODO: really just CRGBA but that isn't passed correctly #ifdef MORE_LANGUAGES
static void SetBackgroundColor(const CRGBA &col) { Details.backgroundColor = col; }
static void SetColor(const CRGBA &col) {
Details.color = col;
if(Details.alphaFade < 255.0f)
Details.color.a *= Details.alphaFade/255.0f;
}
static void SetDropColor(const CRGBA &col) {
Details.dropColor = col;
if(Details.alphaFade < 255.0f)
Details.dropColor.a *= Details.alphaFade/255.0f;
}
static void ReloadFonts(uint8 set); static void ReloadFonts(uint8 set);
#endif
}; };

View File

@ -21,8 +21,11 @@
#include "User.h" #include "User.h"
#include "World.h" #include "World.h"
wchar *CHud::m_HelpMessage = (wchar*)0x86B888; //wchar *CHud::m_HelpMessage = (wchar*)0x86B888;
wchar *CHud::m_LastHelpMessage = (wchar*)0x6E8F28; //wchar *CHud::m_LastHelpMessage = (wchar*)0x6E8F28;
wchar CHud::m_HelpMessage[256];
wchar CHud::m_LastHelpMessage[256];
int32 &CHud::m_HelpMessageState = *(int32*)0x880E1C; int32 &CHud::m_HelpMessageState = *(int32*)0x880E1C;
int32 &CHud::m_HelpMessageTimer = *(int32*)0x880FA4; int32 &CHud::m_HelpMessageTimer = *(int32*)0x880FA4;
int32 &CHud::m_HelpMessageFadeTimer = *(int32*)0x8F6258; int32 &CHud::m_HelpMessageFadeTimer = *(int32*)0x8F6258;
@ -661,7 +664,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
@ -702,7 +705,7 @@ void CHud::Draw()
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONTJAP(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255)); CFont::SetColor(CRGBA(244, 20, 20, 255));
CFont::SetWrapx(SCREEN_SCALE_X(640.0f)); CFont::SetWrapx(SCREEN_SCALE_X(640.0f));
CFont::SetPropOff(); CFont::SetPropOff();
@ -857,7 +860,7 @@ void CHud::Draw()
else else
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont); CFont::SetFontStyle(FONTJAP(CTheScripts::IntroTextLines[i].m_nFont));
CFont::PrintString(SCREEN_SCALE_X(640.0f - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(448.0f - CTheScripts::IntroTextLines[i].m_fAtY), IntroText->m_Text); CFont::PrintString(SCREEN_SCALE_X(640.0f - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(448.0f - CTheScripts::IntroTextLines[i].m_fAtY), IntroText->m_Text);
} }
} }
@ -897,7 +900,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.120f)); CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.120f));
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f); float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX; float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX;
@ -1085,12 +1088,17 @@ void CHud::DrawAfterFade()
if (CGame::germanGame) if (CGame::germanGame)
CFont::SetScale(SCREEN_SCALE_X(0.52f * 0.85f), SCREEN_SCALE_Y(1.1f * 0.85f)); CFont::SetScale(SCREEN_SCALE_X(0.52f * 0.85f), SCREEN_SCALE_Y(1.1f * 0.85f));
else if (CFont::LanguageSet == FONT_LANGSET_JAPANESE)
CFont::SetScale(SCREEN_SCALE_X(0.52f) * 1.35f, SCREEN_SCALE_Y(1.1f) * 1.25f);
else else
CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f)); CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f)); if (CFont::LanguageSet == FONT_LANGSET_JAPANESE)
CFont::SetFontStyle(FONT_BANK); CFont::SetWrapx(SCREEN_SCALE_X(229.0f + 26.0f - 4.0f));
else
CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f));
CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetBackgroundOn(); CFont::SetBackgroundOn();
CFont::SetBackGroundOnlyTextOff(); CFont::SetBackGroundOnlyTextOff();
CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.8f)); CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.8f));
@ -1113,7 +1121,7 @@ void CHud::DrawAfterFade()
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(600.0f)); CFont::SetCentreSize(SCREEN_SCALE_X(600.0f));
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]);
@ -1130,7 +1138,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); CFont::SetCentreSize(SCREEN_SCALE_X(620.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]); CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]);
@ -1193,7 +1201,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONTJAP(FONT_BANK));
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]);

View File

@ -35,8 +35,8 @@ class CHud
public: public:
static CSprite2d *Sprites; static CSprite2d *Sprites;
static int32 &SpriteBrightness; static int32 &SpriteBrightness;
static wchar *m_HelpMessage; static wchar m_HelpMessage[256];
static wchar *m_LastHelpMessage; static wchar m_LastHelpMessage[256];
static int32 &m_HelpMessageState; static int32 &m_HelpMessageState;
static int32 &m_HelpMessageTimer; static int32 &m_HelpMessageTimer;
static int32 &m_HelpMessageFadeTimer; static int32 &m_HelpMessageFadeTimer;

View File

@ -12,6 +12,8 @@
#include "ControllerConfig.h" #include "ControllerConfig.h"
#include "Font.h"
tMessage(&CMessages::BriefMessages)[NUMBRIEFMESSAGES] = *(tMessage(*)[NUMBRIEFMESSAGES])*(uintptr*)0x8786E0; tMessage(&CMessages::BriefMessages)[NUMBRIEFMESSAGES] = *(tMessage(*)[NUMBRIEFMESSAGES])*(uintptr*)0x8786E0;
tPreviousBrief(&CMessages::PreviousBriefs)[NUMPREVIOUSBRIEFS] = *(tPreviousBrief(*)[NUMPREVIOUSBRIEFS])*(uintptr*)0x713C08; tPreviousBrief(&CMessages::PreviousBriefs)[NUMPREVIOUSBRIEFS] = *(tPreviousBrief(*)[NUMPREVIOUSBRIEFS])*(uintptr*)0x713C08;
tBigMessage(&CMessages::BIGMessages)[NUMBIGMESSAGES] = *(tBigMessage(*)[NUMBIGMESSAGES])*(uintptr*)0x773628; tBigMessage(&CMessages::BIGMessages)[NUMBIGMESSAGES] = *(tBigMessage(*)[NUMBIGMESSAGES])*(uintptr*)0x773628;
@ -53,6 +55,13 @@ CMessages::WideStringCopy(wchar *dst, wchar *src, uint16 size)
dst[i] = '\0'; dst[i] = '\0';
} }
wchar jappy(wchar c)
{
if (CFont::LanguageSet == FONT_LANGSET_JAPANESE)
return c & 0x7fff;
return c;
}
bool bool
CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
{ {
@ -62,10 +71,10 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
return false; return false;
for (int32 i = 0; i < size; i++) { for (int32 i = 0; i < size; i++) {
if (!str1[i]) if (!jappy(str1[i]))
break; break;
if (str1[i] != str2[i]) if (jappy(str1[i]) != jappy(str2[i]))
return false; return false;
} }
return true; return true;
@ -371,7 +380,10 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32
int32 i = 0; int32 i = 0;
for (int32 c = 0; c < size;) { for (int32 c = 0; c < size;) {
if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { if ((CFont::LanguageSet == FONT_LANGSET_JAPANESE && str[c] == (0x8000 | '~') && str[c + 1] == (0x8000 | '1') && str[c + 2] == (0x8000 | '~')) ||
(CFont::LanguageSet != FONT_LANGSET_JAPANESE && str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~'))
{
//if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') {
switch (i) { switch (i) {
case 0: sprintf(numStr, "%d", n1); break; case 0: sprintf(numStr, "%d", n1); break;
case 1: sprintf(numStr, "%d", n2); break; case 1: sprintf(numStr, "%d", n2); break;
@ -409,7 +421,10 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2)
wchar *_str1 = str1; wchar *_str1 = str1;
uint16 i; uint16 i;
for (i = 0; i < total_size; ) { for (i = 0; i < total_size; ) {
if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') { if ((CFont::LanguageSet == FONT_LANGSET_JAPANESE && *_str1 == (0x8000 | '~') && *(_str1 + 1) == (0x8000 | 'a') && *(_str1 + 2) == (0x8000 | '~'))
|| (CFont::LanguageSet != FONT_LANGSET_JAPANESE && *_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~'))
{
//if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') {
_str1 += 3; _str1 += 3;
for (int j = 0; j < str2_size; j++) { for (int j = 0; j < str2_size; j++) {
tempstr[i++] = str2[j]; tempstr[i++] = str2[j];
@ -440,7 +455,8 @@ CMessages::InsertPlayerControlKeysInString(wchar *str)
wchar *_outstr = outstr; wchar *_outstr = outstr;
for (i = 0; i < strSize;) { for (i = 0; i < strSize;) {
if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') { if ((CFont::LanguageSet == FONT_LANGSET_JAPANESE && str[i] == (0x8000 | '~') && str[i + 1] == (0x8000 | 'k') && str[i + 2] == (0x8000 | '~')) ||
(CFont::LanguageSet != FONT_LANGSET_JAPANESE && str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~')) {
i += 4; i += 4;
for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS; cont++) { for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS; cont++) {
uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]); uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]);

View File

@ -47,6 +47,9 @@ CText::Load(void)
case LANGUAGE_RUSSIAN: case LANGUAGE_RUSSIAN:
sprintf(filename, "RUSSIAN.GXT"); sprintf(filename, "RUSSIAN.GXT");
break; break;
case LANGUAGE_JAPANESE:
sprintf(filename, "JAPANESE.GXT");
break;
#endif #endif
} }
@ -257,13 +260,15 @@ AsciiToUnicode(const char *src, wchar *dst)
while((*dst++ = *src++) != '\0'); while((*dst++ = *src++) != '\0');
} }
#include "Game.h"
char* char*
UnicodeToAscii(wchar *src) UnicodeToAscii(wchar *src)
{ {
static char aStr[256]; static char aStr[256];
int len; int len;
for(len = 0; *src != '\0' && len < 256-1; len++, src++) for(len = 0; *src != '\0' && len < 256-1; len++, src++)
if(*src < 128) if(*src < 128 || (CGame::russianGame && *src < 256))
aStr[len] = *src; aStr[len] = *src;
else else
aStr[len] = '#'; aStr[len] = '#';
@ -321,4 +326,6 @@ STARTPATCHES
InjectHook(0x52C120, &CData::Load, PATCH_JUMP); InjectHook(0x52C120, &CData::Load, PATCH_JUMP);
InjectHook(0x52C200, &CData::Unload, PATCH_JUMP); InjectHook(0x52C200, &CData::Unload, PATCH_JUMP);
InjectHook(0x52C2F0, &UnicodeToAscii, PATCH_JUMP);
ENDPATCHES ENDPATCHES