예제 #1
0
	static int Font_NewIndex( lua_State *L ) {
		luaFont_t *font = CheckFont( L, 1 );
		const char *key = lua_tostring( L, 2 );

		lua_getmetatable( L, 1 );
		lua_getfield( L, -1, key );

		if ( !lua_isnil( L, -1 ) ) {
			return 1;
		}

		// assume it's a field
		const fontProperty_t *property = (fontProperty_t *)bsearch(key, fontProperties, numFontProperties,
			sizeof(fontProperty_t), FontPropertyCompare
		);
		if ( property ) {
			if ( property->Set ) {
				property->Set( L, font );
			}
		}
		else {
			// ...
		}

		return 0;
	}
예제 #2
0
	static int Font_Index( lua_State *L ) {
		luaFont_t *font = CheckFont( L, 1 );
		const char *key = lua_tostring( L, 2 );
		int returnValues = 0;

		lua_getmetatable( L, 1 );
		lua_getfield( L, -1, key );
		if ( !lua_isnil( L, -1 ) ) {
			return 1;
		}

		// assume it's a field
		const fontProperty_t *property = (fontProperty_t *)bsearch( key, fontProperties, numFontProperties,
			sizeof(fontProperty_t), FontPropertyCompare
		);
		if ( property ) {
			if ( property->Get ) {
				returnValues += property->Get( L, font );
			}
		}
		else {
			lua_pushnil( L );
			returnValues++;
		}

		return returnValues;
	}
예제 #3
0
	//Func: tostring( Font )
	//Retn: string representing the Font instance (for debug/error messages)
	static int Font_ToString( lua_State *L ) {
		luaFont_t *font = CheckFont( L, 1 );
		lua_pushfstring( L, "Font(%d)", font->index );
		return 1;
	}
예제 #4
0
	//Func: Font1 == Font2
	//Retn: boolean value of whether Font1 is the same font as Font2
	static int Font_Equals( lua_State *L ) {
		luaFont_t *f1 = CheckFont( L, 1 );
		luaFont_t *f2 = CheckFont( L, 2 );
		lua_pushboolean( L, (f1->index == f2->index) ? 1 : 0 );
		return 1;
	}
예제 #5
0
CGUIFont* GUIFontManager::LoadTTF(const std::string& strFontName, const std::string& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, const RESOLUTION_INFO *sourceRes, bool preserveAspect)
{
  float originalAspect = aspect;

  //check if font already exists
  CGUIFont* pFont = GetFont(strFontName, false);
  if (pFont)
    return pFont;

  if (!sourceRes) // no source res specified, so assume the skin res
    sourceRes = &m_skinResolution;

  float newSize = (float)iSize;
  RescaleFontSizeAndAspect(&newSize, &aspect, *sourceRes, preserveAspect);

  // First try to load the font from the skin
  std::string strPath;
  if (!CURL::IsFullPath(strFilename))
  {
    strPath = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "fonts");
    strPath = URIUtils::AddFileToFolder(strPath, strFilename);
  }
  else
    strPath = strFilename;

#ifdef TARGET_POSIX
  strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
#endif

  // Check if the file exists, otherwise try loading it from the global media dir
  std::string file = URIUtils::GetFileName(strFilename);
  if (!CheckFont(strPath,"special://home/media/Fonts",file))
    CheckFont(strPath,"special://xbmc/media/Fonts",file);

  // check if we already have this font file loaded (font object could differ only by color or style)
  std::string TTFfontName = StringUtils::Format("%s_%f_%f%s", strFilename.c_str(), newSize, aspect, border ? "_border" : "");

  CGUIFontTTFBase* pFontFile = GetFontFile(TTFfontName);
  if (!pFontFile)
  {
    pFontFile = new CGUIFontTTF(TTFfontName);
    bool bFontLoaded = pFontFile->Load(strPath, newSize, aspect, 1.0f, border);

    if (!bFontLoaded)
    {
      delete pFontFile;

      // font could not be loaded - try Arial.ttf, which we distribute
      if (strFilename != "arial.ttf")
      {
        CLog::Log(LOGERROR, "Couldn't load font name: %s(%s), trying to substitute arial.ttf", strFontName.c_str(), strFilename.c_str());
        return LoadTTF(strFontName, "arial.ttf", textColor, shadowColor, iSize, iStyle, border, lineSpacing, originalAspect);
      }
      CLog::Log(LOGERROR, "Couldn't load font name:%s file:%s", strFontName.c_str(), strPath.c_str());

      return NULL;
    }

    m_vecFontFiles.push_back(pFontFile);
  }

  // font file is loaded, create our CGUIFont
  CGUIFont *pNewFont = new CGUIFont(strFontName, iStyle, textColor, shadowColor, lineSpacing, (float)iSize, pFontFile);
  m_vecFonts.push_back(pNewFont);

  // Store the original TTF font info in case we need to reload it in a different resolution
  OrigFontInfo fontInfo;
  fontInfo.size = iSize;
  fontInfo.aspect = originalAspect;
  fontInfo.fontFilePath = strPath;
  fontInfo.fileName = strFilename;
  fontInfo.sourceRes = *sourceRes;
  fontInfo.preserveAspect = preserveAspect;
  fontInfo.border = border;
  m_vecFontInfo.push_back(fontInfo);

  return pNewFont;
}
// STEP1
int WINAPI WinMain(HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow)
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	InitLog(CCLOGSTYLE_DEBUGSTRING|CCLOGSTYLE_FILE);
	g_dwMainThreadID= GetCurrentThreadId();
	

	char szModuleFileName[_MAX_DIR] = {0,};
	GetModuleFileName(NULL, szModuleFileName, _MAX_DIR);
	PathRemoveFileSpec(szModuleFileName);
	SetCurrentDirectory(szModuleFileName);
	cclog("-------------------------------------------------------------\n");
	cclog("Current working directory: %s\n", szModuleFileName);
	cclog("-------------------------------------------------------------\n");
	srand( (unsigned)time( NULL ));
	cclog("GUNZ " STRFILEVER " launched. build ("__DATE__" "__TIME__") \n");
	char szDateRun[128]="";
	char szTimeRun[128]="";
	_strdate( szDateRun );
	_strtime( szTimeRun );
	cclog("Log time (%s %s)\n", szDateRun, szTimeRun);
	CCSysInfoLog();

	g_App.InitFileSystem();
	ZGetConfiguration()->Load();

	ZStringResManager::MakeInstance();
	if( !ZApplication::GetInstance()->InitLocale() )
	{
		CCLog("Locale Init error !!!\n");
		return false;
	}

	DWORD ver_major = 0;
	DWORD ver_minor = 0;
	TCHAR ver_letter = ' ';



	if(CheckFont()==false) {
		CCLog("CheckFont() failed.\n");
		return 0;
	}

	RSetFunction(RF_CREATE	,	OnCreate);
	RSetFunction(RF_RENDER	,	OnRender);
	RSetFunction(RF_UPDATE	,	OnUpdate);
	RSetFunction(RF_DESTROY ,	OnDestroy);
	RSetFunction(RF_INVALIDATE,	OnInvalidate);
	RSetFunction(RF_RESTORE,	OnRestore);
	RSetFunction(RF_ACTIVATE,	OnActivate);
	RSetFunction(RF_DEACTIVATE,	OnDeActivate);
	RSetFunction(RF_ERROR,		OnError);

	SetModeParams();

//	STEP2	
	cclog("Entering RMain()\n");
	const int nRMainReturn = RMain(APPLICATION_NAME,this_inst,prev_inst,cmdline,cmdshow,&g_ModeParams,WndProc,IDI_ICON1);
	if( 0 != nRMainReturn )
		return nRMainReturn;


	if( 0 != RInitD3D(&g_ModeParams) )
	{
		MessageBox(g_hWnd, "fail to initialize DirectX", NULL, MB_OK);
		cclog( "error init RInitD3D\n" );
		return 0;
	}
	cclog("Entering RRun()\n");
	const int nRRunReturn = RRun();
	ShowWindow(g_hWnd, SW_MINIMIZE);

	cclog("========================== DONE ===============================\n");

	ZStringResManager::FreeInstance();
	return 0;//nRRunReturn;
	}