Skip to content

Commit f609388

Browse files
committed
Changed SString strQuality to enum eFontQuality
1 parent 70defb3 commit f609388

File tree

4 files changed

+44
-46
lines changed

4 files changed

+44
-46
lines changed

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Drawing.cpp

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,13 @@ int CLuaFunctionDefs::dxUpdateScreenSource ( lua_State* luaVM )
852852
int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM )
853853
{
854854
// 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;
856856

857857
CScriptArgReader argStream ( luaVM );
858858
argStream.ReadString ( strFilePath );
859859
argStream.ReadNumber ( iSize, 9 );
860860
argStream.ReadBool ( bBold, false );
861-
argStream.ReadString ( strQuality, "proof" );
861+
argStream.ReadEnumString ( ulFontQuality, FONT_QUALITY_PROOF );
862862

863863
if ( !argStream.HasErrors () )
864864
{
@@ -872,53 +872,17 @@ int CLuaFunctionDefs::dxCreateFont ( lua_State* luaVM )
872872
{
873873
if ( FileExists ( strPath ) )
874874
{
875-
DWORD ulQuality = 0xFF;
876-
877-
strQuality = strQuality.ToLower();
875+
CClientDxFont* pDxFont = g_pClientGame->GetManager()->GetRenderElementManager()->CreateDxFont( strPath, iSize, bBold, ulFontQuality );
878876

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 )
896878
{
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;
919883
}
920-
else
921-
argStream.SetCustomError( strFilePath, "Invalid font quality" );
884+
885+
argStream.SetCustomError( strFilePath, "Error creating font" );
922886
}
923887
else
924888
argStream.SetCustomError( strFilePath, "File not found" );

MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,20 @@ IMPLEMENT_ENUM_BEGIN( eFontType )
394394
ADD_ENUM( FONT_BECKETT, "beckett" )
395395
IMPLEMENT_ENUM_END_DEFAULTS( "font-type", FONT_DEFAULT, "" )
396396

397+
IMPLEMENT_ENUM_BEGIN( eFontQuality )
398+
ADD_ENUM( FONT_QUALITY_DEFAULT, "default" )
399+
ADD_ENUM( FONT_QUALITY_DRAFT, "draft" )
400+
ADD_ENUM( FONT_QUALITY_PROOF, "proof" )
401+
#if( WINVER >= 0x0400 )
402+
ADD_ENUM( FONT_QUALITY_NONANTIALIASED, "nonantialiased" )
403+
ADD_ENUM( FONT_QUALITY_ANTIALIASED, "antialiased" )
404+
#endif
405+
#if( _WIN32_WINNT >= _WIN32_WINNT_WINXP )
406+
ADD_ENUM( FONT_QUALITY_CLEARTYPE, "cleartype" )
407+
ADD_ENUM( FONT_QUALITY_CLEARTYPE_NATURAL, "cleartype_natural" )
408+
#endif
409+
IMPLEMENT_ENUM_END_DEFAULTS( "font-quality", FONT_QUALITY_DEFAULT, "" )
410+
397411
IMPLEMENT_ENUM_BEGIN ( eAudioLookupIndex )
398412
ADD_ENUM ( AUDIO_LOOKUP_FEET, "feet" )
399413
ADD_ENUM ( AUDIO_LOOKUP_GENRL, "genrl" )

MTA10/mods/shared_logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ DECLARE_ENUM( eWeaponState );
3636
DECLARE_ENUM( eWeaponFlags );
3737
DECLARE_ENUM( eVehicleComponent );
3838
DECLARE_ENUM( eFontType );
39+
DECLARE_ENUM( eFontQuality );
3940
DECLARE_ENUM( eAudioLookupIndex );
4041
DECLARE_ENUM( eAspectRatio );
4142
DECLARE_ENUM( eRadioStreamIndex );

MTA10/sdk/core/CGraphicsInterface.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ enum eFontType
3333
NUM_FONTS
3434
};
3535

36+
enum eFontQuality
37+
{
38+
FONT_QUALITY_DEFAULT = DEFAULT_QUALITY,
39+
FONT_QUALITY_DRAFT = DRAFT_QUALITY,
40+
FONT_QUALITY_PROOF = PROOF_QUALITY,
41+
42+
#if( WINVER >= 0x0400 )
43+
FONT_QUALITY_NONANTIALIASED = NONANTIALIASED_QUALITY,
44+
FONT_QUALITY_ANTIALIASED = ANTIALIASED_QUALITY,
45+
#endif
46+
47+
#if( _WIN32_WINNT >= _WIN32_WINNT_WINXP )
48+
FONT_QUALITY_CLEARTYPE = CLEARTYPE_QUALITY,
49+
FONT_QUALITY_CLEARTYPE_NATURAL = CLEARTYPE_NATURAL_QUALITY,
50+
#endif
51+
52+
NUM_QUALITIES
53+
};
54+
3655
namespace EBlendMode
3756
{
3857
enum EBlendModeType

0 commit comments

Comments
 (0)