@@ -852,13 +852,13 @@ int CLuaFunctionDefs::dxUpdateScreenSource ( lua_State* luaVM )
852
852
int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM )
853
853
{
854
854
// element dxCreateFont( string filepath [, int size=9, bool bold=false ] )
855
- SString strFilePath, strQuality ; int iSize; bool bBold;
855
+ SString strFilePath; int iSize; bool bBold; eFontQuality ulFontQuality ;
856
856
857
857
CScriptArgReader argStream ( luaVM );
858
858
argStream.ReadString ( strFilePath );
859
859
argStream.ReadNumber ( iSize, 9 );
860
860
argStream.ReadBool ( bBold, false );
861
- argStream.ReadString ( strQuality, " proof " );
861
+ argStream.ReadEnumString ( ulFontQuality, FONT_QUALITY_PROOF );
862
862
863
863
if ( !argStream.HasErrors () )
864
864
{
@@ -872,53 +872,17 @@ int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM )
872
872
{
873
873
if ( FileExists ( strPath ) )
874
874
{
875
- DWORD ulQuality = 0xFF ;
876
-
877
- strQuality = strQuality.ToLower ();
875
+ CClientDxFont* pDxFont = g_pClientGame->GetManager ()->GetRenderElementManager ()->CreateDxFont ( strPath, iSize, bBold, ulFontQuality );
878
876
879
- if ( strQuality.compare ( " default" ) == 0 )
880
- {
881
- ulQuality = DEFAULT_QUALITY;
882
- }
883
- else if ( strQuality.compare ( " draft" ) == 0 )
884
- {
885
- ulQuality = DRAFT_QUALITY;
886
- }
887
- else if ( strQuality.compare ( " proof" ) == 0 )
888
- {
889
- ulQuality = PROOF_QUALITY;
890
- }
891
- else if ( strQuality.compare ( " nonantialiased" ) == 0 )
892
- {
893
- ulQuality = NONANTIALIASED_QUALITY;
894
- }
895
- else if ( strQuality.compare ( " antialiased" ) == 0 )
877
+ if ( pDxFont )
896
878
{
897
- ulQuality = ANTIALIASED_QUALITY;
898
- }
899
- else if ( strQuality.compare ( " cleartype" ) == 0 )
900
- {
901
- ulQuality = CLEARTYPE_QUALITY;
902
- }
903
- else if ( strQuality.compare ( " cleartype_natural" ) == 0 )
904
- {
905
- ulQuality = CLEARTYPE_NATURAL_QUALITY;
906
- }
907
-
908
- if ( ulQuality != 0xFF )
909
- {
910
- CClientDxFont* pDxFont = g_pClientGame->GetManager ()->GetRenderElementManager ()->CreateDxFont ( strPath, iSize, bBold, ulQuality );
911
- if ( pDxFont )
912
- {
913
- // Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's ElementGroup? **
914
- pDxFont->SetParent ( pParentResource->GetResourceDynamicEntity () );
915
- lua_pushelement ( luaVM, pDxFont );
916
- return 1 ;
917
- }
918
- argStream.SetCustomError ( strFilePath, " Error creating font" );
879
+ // Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's ElementGroup? **
880
+ pDxFont->SetParent ( pParentResource->GetResourceDynamicEntity () );
881
+ lua_pushelement ( luaVM, pDxFont );
882
+ return 1 ;
919
883
}
920
- else
921
- argStream.SetCustomError ( strFilePath, " Invalid font quality " );
884
+
885
+ argStream.SetCustomError ( strFilePath, " Error creating font " );
922
886
}
923
887
else
924
888
argStream.SetCustomError ( strFilePath, " File not found" );
0 commit comments