Ejemplo n.º 1
0
int main() {
  int count_eng = 0;
  int count_other = 0;
  char buf[1024];

  for (int i = 0; i < 100; i++) {
    strcpy(buf, eng[i]);
    count_eng += IsEnglish(buf);
    //printf("%d", IsEnglish(buf));
    if (IsEnglish(buf) == 0) {
      printf("%s\n", buf);
    }
  }

  for (int i = 0; i < 100; i++) {
    strcpy(buf, other[i]);
    count_other += IsEnglish(buf);
    //printf("%d", IsEnglish(buf));
    if (IsEnglish(buf) == 1) {
      printf("%s\n", buf);
    }
  }

  printf("eng\t%d\nother\t%d\n", count_eng, 100 - count_other);
  return 0;
}
Ejemplo n.º 2
0
// Initialize the fonts
void CMainMenus::InitFonts()
{
	m_pSmallFont = new CLTGUIFont;
	m_pLargeFont = new CLTGUIFont;
	
	// Initialize the bitmap fonts if we are in english
	if (IsEnglish())
	{
		char *lpszSmallFontPath="interface/fonts/MenuFont1.pcx";
		char *lpszSmallWidthPath="interface/fonts/MenuFont1.fnt";

		char *lpszLargeFontPath="interface/fonts/MenuFont1.pcx";
		char *lpszLargeWidthPath="interface/fonts/MenuFont1.fnt";
		
		if ( !m_pSmallFont->Init(m_pClientDE, lpszSmallFontPath, lpszSmallWidthPath) )
		{
			char szString[512];
			sprintf(szString, "Cannot load font: %s", lpszSmallFontPath);
			m_pClientDE->CPrint(szString);
		}
		
		if ( !m_pLargeFont->Init(m_pClientDE, lpszLargeFontPath, lpszLargeWidthPath) )
		{
			char szString[512];
			sprintf(szString, "Cannot load font: %s", lpszLargeFontPath);
			m_pClientDE->CPrint(szString);

			delete []m_pLargeFont;
			m_pLargeFont=DNULL;
		}
		
		// Load the large fading fonts
		m_pLargeFadeFonts = new CLTGUIFont[m_nNumLargeFadeFonts];

		int i;
		for (i=0; i < m_nNumLargeFadeFonts; i++)
		{
			char szPath[512];

			// Check to see if we should be loading a disabled font
			if (m_nNumLargeFadeFonts > 1 && i==m_nNumLargeFadeFonts-1)
			{
				sprintf(szPath, "interface/mainmenus/mm_font_dis.pcx", i+1);
			}
			else
			{
				sprintf(szPath, "interface/mainmenus/mm_font_0%d.pcx", i+1);
			}

			if ( !m_pLargeFadeFonts[i].Init(m_pClientDE, szPath, "interface/mainmenus/mm_font.fnt") )
			{
				char szString[512];
				sprintf(szString, "Cannot load font: %s", szPath);
				m_pClientDE->CPrint(szString);			
				
				delete []m_pLargeFadeFonts;

				// Set it to the large font
				m_pLargeFadeFonts=m_pLargeFont;
				m_nNumLargeFadeFonts=1;
			}		
		}
	}
	else
	{
		m_nNumLargeFadeFonts=0;

		// Initialize the engine fonts for non-english resource files
		InitEngineFont(m_pSmallFont, IDS_MENU_FONT_SMALL_NAME, IDS_MENU_FONT_SMALL_WIDTH, IDS_MENU_FONT_SMALL_HEIGHT);
		InitEngineFont(m_pLargeFont, IDS_MENU_FONT_LARGE_NAME, IDS_MENU_FONT_LARGE_WIDTH, IDS_MENU_FONT_LARGE_HEIGHT);

		// Initialize a title font if we aren't in english
		if (!IsEnglish())
		{
			m_pTitleFont = new CLTGUIFont;
			InitEngineFont(m_pTitleFont, IDS_MENU_FONT_TITLE_NAME, IDS_MENU_FONT_TITLE_WIDTH, IDS_MENU_FONT_TITLE_HEIGHT);
		}
	}

	// Set the wrapping method
	HSTRING hString=m_pClientDE->FormatString(IDS_FONT_WRAP_USE_SPACES);
	if (_mbsicmp((const unsigned char*)m_pClientDE->GetStringData(hString), (const unsigned char*)"1") == 0)
	{
		CLTGUIFont::SetWrapMethod(DTRUE);
	}
	else
	{
		CLTGUIFont::SetWrapMethod(DFALSE);
	}
}
LTBOOL CInterfaceResMgr::InitFonts()
{


	m_pSmallFont = debug_new(CLTGUIFont);
	m_pMediumFont = debug_new(CLTGUIFont);
	m_pLargeFont = debug_new(CLTGUIFont);
	m_pHelpFont = debug_new(CLTGUIFont);
	m_pTitleFont = debug_new(CLTGUIFont);
	m_pMsgForeFont = debug_new(CLTGUIFont);
	m_pHUDForeFont = debug_new(CLTGUIFont);
	m_pAirFont = debug_new(CLTGUIFont);
	m_pChooserFont = debug_new(CLTGUIFont);

	// Initialize the bitmap fonts if we are in english
	if (IsEnglish())
	{
        // ************* help font
		g_pLayoutMgr->GetHelpFont(g_szFontName,sizeof(g_szFontName));
		if (!SetupFont(m_pHelpFont))
		{
			debug_delete(m_pHelpFont);
            m_pHelpFont=LTNULL;
            return LTFALSE;
		}
        // *********** small font
		g_pLayoutMgr->GetSmallFontBase(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pSmallFont))
		{
			debug_delete(m_pSmallFont);
            m_pSmallFont=LTNULL;
            return LTFALSE;
		}

        // *********** medium font
		g_pLayoutMgr->GetMediumFontBase(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pMediumFont))
		{
			debug_delete(m_pMediumFont);
            m_pMediumFont=LTNULL;
            return LTFALSE;
		}

        // *********** Large font
		g_pLayoutMgr->GetLargeFontBase(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pLargeFont))
		{
			debug_delete(m_pLargeFont);
            m_pLargeFont=LTNULL;
            return LTFALSE;
		}


        // ************* Title font
		g_pLayoutMgr->GetTitleFont(g_szFontName,sizeof(g_szFontName));
		if (!SetupFont(m_pTitleFont))
		{
			if (!SetupFont(m_pTitleFont,LTFALSE))
			{
				debug_delete(m_pTitleFont);
				m_pTitleFont=LTNULL;
				return LTFALSE;
			}
		}


        // ************* Foreground HUD (i.e. white) HUD font
		g_pLayoutMgr->GetMsgForeFont(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pMsgForeFont))
		{
			debug_delete(m_pMsgForeFont);
            m_pMsgForeFont=LTNULL;
            return LTFALSE;
		}


        uint32 dwFlags = LTF_INCLUDE_SYMBOLS_1 | LTF_INCLUDE_NUMBERS | LTF_INCLUDE_SYMBOLS_2;
        // ************* Foreground HUD (i.e. white) HUD font
		g_pLayoutMgr->GetHUDForeFont(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pHUDForeFont,LTTRUE,dwFlags))
		{
			debug_delete(m_pHUDForeFont);
            m_pHUDForeFont=LTNULL;
            return LTFALSE;
		}

        // ************* Air font
		g_pLayoutMgr->GetAirFont(g_szFontName,sizeof(g_szFontName));
        if (!SetupFont(m_pAirFont,LTFALSE,dwFlags))
		{
			debug_delete(m_pAirFont);
            m_pAirFont=LTNULL;
            return LTFALSE;
		}

        // ************* Weapon Chooser font
		g_pLayoutMgr->GetChooserFont(g_szFontName,sizeof(g_szFontName));
		if (!SetupFont(m_pChooserFont,LTFALSE))
		{
			debug_delete(m_pChooserFont);
            m_pChooserFont=LTNULL;
            return LTFALSE;
		}
	}
	else
	{
        // TODO: put these into string table for localization
		// Initialize the engine fonts for non-english resource files
		if (!InitEngineFont(m_pSmallFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE))
            return LTFALSE;
		if (!InitEngineFont(m_pHelpFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE))
            return LTFALSE;
		if (!InitEngineFont(m_pMediumFont, IDS_MEDIUM_FONT_NAME, IDS_MEDIUM_FONT_WIDTH, IDS_MEDIUM_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pLargeFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pTitleFont, IDS_TITLE_FONT_NAME, IDS_TITLE_FONT_WIDTH, IDS_TITLE_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pMsgForeFont, IDS_MEDIUM_FONT_NAME, IDS_MEDIUM_FONT_WIDTH, IDS_MEDIUM_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pHUDForeFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pAirFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE))
            return LTFALSE;
		if (!InitEngineFont(m_pChooserFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE))
            return LTFALSE;

	}

    // TODO: reimplement this stuff
	// Set the wrapping method
//  HSTRING hString=g_pLTClient->FormatString(IDS_FONT_WRAP_USE_SPACES);
//  if (_mbsicmp((const unsigned char*)g_pLTClient->GetStringData(hString), (const unsigned char*)"1") == 0)
//	{
        CLTGUIFont::SetWrapMethod(LTTRUE);
//	}
//	else
//	{
//      CLTGUIFont::SetWrapMethod(LTFALSE);
//	}

    return LTTRUE;

}