Skip to content
Permalink
Browse files
Renamed some stuff to match libGTASA
More textures moved to use SPTA

git-svn-id: svn://localhost/vcspc/trunk@29 9f344024-d43e-4b27-bde7-3d027e20192d
  • Loading branch information
silent committed Dec 22, 2013
1 parent 769a49a commit 7ed519c28b15cd2eac41c95cc40e5716dfc5720b
@@ -2,76 +2,12 @@


CSprite2d CFont::Sprite[NUM_FONT_SHEETS]; CSprite2d CFont::Sprite[NUM_FONT_SHEETS];
CFont::sFontSizes CFont::Size[NUM_FONT_SHEETS]; CFont::sFontSizes CFont::Size[NUM_FONT_SHEETS];
CFont::tDetails& CFont::Details = *(CFont::tDetails*)0xC71A60;


WRAPPER void CFont::SetWrapx(float fWrap) { WRAPARG(fWrap); EAXJMP(0x7194D0); } WRAPPER void CFont::SetWrapx(float fWrap) { WRAPARG(fWrap); EAXJMP(0x7194D0); }
WRAPPER void CFont::LoadFontValues() { EAXJMP(0x7187C0); }


void CFont::ReadFontsDAT() unsigned char CFont::FindSubFontCharacter(char character, unsigned char bFontType)
{
DWORD dwFunc = (DWORD)FUNC_CFont__ReadFontsDAT;
_asm call dwFunc
}

/*signed char Upcase(signed char character, signed char unk)
{
if ( unk == 1 )
{
if ( character == 26 )
return 154;
if ( character >= 8 && character <= 9 )
{
unsigned char result = character;
result += 86;
return result;
}
if ( character == 4 )
return 93;
if ( character == 7 )
return 206;
if ( character == 14 )
return 207;
}
if ( character != 1 || unk != 1 )
{
if ( character == 143 )
return 205;
if ( character == 31 )
return 91;
if ( character == 6 )
return 10;
if ( character == 62 )
return 32;
if ( character >= 16 && character <= 25 )
return (character + 128);
if ( character >= 33 && character <= 58 )
return (character + 122);
if ( character >= 65 && character <= 90 )
return (character + 90);
if ( character >= 96 && character <= 118 )
return (character + 85);
if ( character >= 119 && character <= 140 )
return (character + 62);
if ( character >= 141 && character <= 142 )
return 204;
}
else
return 208;
return character;
}*/

unsigned char CFont::AssignBottomFontIndex(unsigned char character, unsigned char bFontType)
{ {
UNREFERENCED_PARAMETER(bFontType); UNREFERENCED_PARAMETER(bFontType);
if ( character == 4 ) if ( character == 4 )
@@ -149,44 +85,44 @@ unsigned char CFont::AssignBottomFontIndex(unsigned char character, unsigned cha
return character; return character;
} }


void CFont::SetTextLetterSize(float scaleX, float scaleY) void CFont::SetScale(float scaleX, float scaleY)
{ {
fontDetails->textLetterSizeX = scaleX; Details.textLetterSizeX = scaleX;
fontDetails->textLetterSizeY = scaleY; Details.textLetterSizeY = scaleY;
} }


void CFont::SetTextLetterSizeWithLanguageScaling(float scaleX, float scaleY) void CFont::SetScaleLang(float scaleX, float scaleY)
{ {
fontDetails->textLetterSizeY = scaleY; Details.textLetterSizeY = scaleY;
switch ( menu->GetLanguage() ) switch ( FrontEndMenuManager.GetLanguage() )
{ {
//case LANG_Spanish: //case LANG_Spanish:
// fontDetails->textLetterSizeX = scaleX * 0.85f; // Details.textLetterSizeX = scaleX * 0.85f;
// break; // return;
case LANG_Polish: case LANG_Polish:
fontDetails->textLetterSizeX = scaleX * 0.95f; Details.textLetterSizeX = scaleX * 0.95f;
break; return;
default: // LANG_English default: // LANG_English
fontDetails->textLetterSizeX = scaleX; Details.textLetterSizeX = scaleX;
break; return;
} }
} }


void CFont::SetFontStyle(unsigned char bFont) void CFont::SetFontStyle(unsigned char bFont)
{ {
if ( bFont == FONT_Hud ) if ( bFont == FONT_Hud )
{ {
fontDetails->bSpriteToUse = 3; Details.bSpriteToUse = 3;
fontDetails->bFontStyle = 1; Details.bFontStyle = 1;
} }
else else
{ {
fontDetails->bSpriteToUse = bFont; Details.bSpriteToUse = bFont;
fontDetails->bFontStyle = 0; Details.bFontStyle = 0;
} }
} }


void CFont::SetTextColour(CRGBA colour) void CFont::SetColor(CRGBA colour)
{ {
DWORD dwFunc = (DWORD)FUNC_CFont__SetTextColour; DWORD dwFunc = (DWORD)FUNC_CFont__SetTextColour;
_asm _asm
@@ -340,4 +276,28 @@ void CFont::SetTextAlignment(unsigned char bAlign)
} }


WRAPPER void CFont::PrintString(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A700); } WRAPPER void CFont::PrintString(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A700); }
WRAPPER void CFont::PrintStringFromBottom(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A820); } WRAPPER void CFont::PrintStringFromBottom(float posX, float posY, const char* pText) { WRAPARG(posX); WRAPARG(posY); WRAPARG(pText); EAXJMP(0x71A820); }

void CFont::Initialise()
{
CPNGArchive FontsSPTA("models\\fonts.spta");
FontsSPTA.SetDirectory(nullptr);

Sprite[0].SetTextureFromSPTA(FontsSPTA, "font1");
Sprite[1].SetTextureFromSPTA(FontsSPTA, "font2");
Sprite[2].SetTextureFromSPTA(FontsSPTA, "font3");
Sprite[3].SetTextureFromSPTA(FontsSPTA, "font4");

FontsSPTA.CloseArchive();

// TODO: Dummy CFont stuff may not be needed at all?
LoadFontValues();

// TODO: Buttons
}

void CFont::Shutdown()
{
for ( int i = 0; i < NUM_FONT_SHEETS; ++i )
Sprite[i].Delete();
}
@@ -1,9 +1,6 @@
#ifndef __CFONT #ifndef __CFONT
#define __CFONT #define __CFONT


#define WIN32_LEAN_AND_MEAN

#define FUNC_CFont__ReadFontsDAT 0x7187C0
#define FUNC_CFont__ResetSlantedTextPos 0x719400 #define FUNC_CFont__ResetSlantedTextPos 0x719400
#define FUNC_CFont__SetTextSlanted 0x719420 #define FUNC_CFont__SetTextSlanted 0x719420
#define FUNC_CFont__SetTextColour 0x719430 #define FUNC_CFont__SetTextColour 0x719430
@@ -46,7 +43,7 @@ enum eFontFileIDs
class CFont class CFont
{ {
public: public:
struct Details struct tDetails
{ {
CRGBA textDrawBoxColor; CRGBA textDrawBoxColor;
float textLetterSizeX; float textLetterSizeX;
@@ -67,26 +64,31 @@ class CFont
signed char bFontOutline, bFontOutline2; signed char bFontOutline, bFontOutline2;
}; };


public:
static CSprite2d Sprite[NUM_FONT_SHEETS];

#pragma pack(push, 1) #pragma pack(push, 1)
static struct sFontSizes struct sFontSizes
{ {
unsigned char bPropValue[208]; unsigned char bPropValue[208];
unsigned char bSpaceChar; unsigned char bSpaceChar;
unsigned char bUnpropValue; unsigned char bUnpropValue;


} Size[NUM_FONT_SHEETS]; };
#pragma pack(pop) #pragma pack(pop)


public: public:
static void ReadFontsDAT(); // TODO: Make private?
static unsigned char AssignBottomFontIndex(unsigned char character, unsigned char bFontType); static CSprite2d Sprite[NUM_FONT_SHEETS];
static void SetTextLetterSize(float scaleX, float scaleY); static sFontSizes Size[NUM_FONT_SHEETS];
static void SetTextLetterSizeWithLanguageScaling(float scaleX, float scaleY); static tDetails& Details;

private:
static void LoadFontValues();

public:
static unsigned char FindSubFontCharacter(char character, unsigned char bFontType);
static void SetScale(float scaleX, float scaleY);
static void SetScaleLang(float scaleX, float scaleY);
static void SetFontStyle(unsigned char bFont); static void SetFontStyle(unsigned char bFont);
static void SetTextColour(CRGBA colour); static void SetColor(CRGBA colour);
static void SetTextBorderRGBA(CRGBA colour); static void SetTextBorderRGBA(CRGBA colour);
static void SetTextShadow(unsigned char bShadow); static void SetTextShadow(unsigned char bShadow);
static void SetTextOutline(unsigned char bOutline); static void SetTextOutline(unsigned char bOutline);
@@ -102,6 +104,9 @@ class CFont
static void PrintString(float posX, float posY, const char* pText); static void PrintString(float posX, float posY, const char* pText);
static void PrintStringFromBottom(float posX, float posY, const char* pText); static void PrintStringFromBottom(float posX, float posY, const char* pText);
static void SetWrapx(float fWrap); static void SetWrapx(float fWrap);

static void Initialise();
static void Shutdown();
}; };


const char* GetFontsDATByLanguage(); const char* GetFontsDATByLanguage();
@@ -15,8 +15,8 @@ void CGridref::Draw()
CFont::SetTextAlignment(ALIGN_Center); CFont::SetTextAlignment(ALIGN_Center);
CFont::SetTextOutline(1); CFont::SetTextOutline(1);
CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255));
CFont::SetTextLetterSize(_width(0.35), _height(0.65)); CFont::SetScale(_width(0.35), _height(0.65));
CFont::SetTextColour(CRGBA(BaseColors[2])); CFont::SetColor(CRGBA(BaseColors[2]));
_snprintf(ZoneID, sizeof(ZoneID), "%c%d", zoneX + 100, zoneY); _snprintf(ZoneID, sizeof(ZoneID), "%c%d", zoneX + 100, zoneY);
CFont::PrintString(_x(150.0), _y(7.5), ZoneID); CFont::PrintString(_x(150.0), _y(7.5), ZoneID);
CFont::PrintString(_x(115.0), _y(7.5), GetNameByID(zoneX, zoneY)); CFont::PrintString(_x(115.0), _y(7.5), GetNameByID(zoneX, zoneY));
@@ -54,7 +54,7 @@ void CText::ReloadFontsFiles(bool bUnk)
CTxdStore::SetCurrentTxd(slot); CTxdStore::SetCurrentTxd(slot);
texFonts[0].Load("font2", "font2m"); texFonts[0].Load("font2", "font2m");
texFonts[1].Load("font1", "font1m"); texFonts[1].Load("font1", "font1m");
CFont::ReadFontsDAT(); CFont::LoadFontValues();
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
} }
#endif #endif
@@ -62,13 +62,13 @@ void CDarkel::DrawMessages()
} }
} }
CFont::SetTextBackground(0, 0); CFont::SetTextBackground(0, 0);
CFont::SetTextLetterSize(_width(0.5f), _height(1.1f)); CFont::SetScale(_width(0.5f), _height(1.1f));
CFont::SetTextAlignment(ALIGN_Right); CFont::SetTextAlignment(ALIGN_Right);
CFont::SetTextWrapX(0.0f); // ? CFont::SetTextWrapX(0.0f); // ?
CFont::SetFontStyle(FONT_Eurostile); CFont::SetFontStyle(FONT_Eurostile);
CFont::SetTextOutline(1); CFont::SetTextOutline(1);
CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255)); CFont::SetTextBorderRGBA(CRGBA(0, 0, 0, 255));
CFont::SetTextColour(BaseColors[4]); CFont::SetColor(BaseColors[4]);


if ( TimeLimit >= 0 ) if ( TimeLimit >= 0 )
{ {
@@ -85,10 +85,10 @@ void CDarkel::DrawMessages()


// TODO: Flashing // TODO: Flashing
CFont::SetTextUseProportionalValues(true); CFont::SetTextUseProportionalValues(true);
CFont::PrintString(_x(88.0f + fPosXOffset), _y(148.0f), gxt->GetText("TIME")); CFont::PrintString(_x(88.0f + fPosXOffset), _y(148.0f), TheText.GetText("TIME"));


CFont::SetTextUseProportionalValues(false); CFont::SetTextUseProportionalValues(false);
CFont::SetTextColour(BaseColors[11]); CFont::SetColor(BaseColors[11]);
CFont::PrintString(_x(32.0f), _y(148.0f), gString); CFont::PrintString(_x(32.0f), _y(148.0f), gString);
} }


@@ -103,8 +103,8 @@ void CDarkel::DrawMessages()
fPosXOffset = 0.0f; fPosXOffset = 0.0f;


CFont::SetTextUseProportionalValues(true); CFont::SetTextUseProportionalValues(true);
CFont::SetTextColour(BaseColors[8]); CFont::SetColor(BaseColors[8]);
CFont::PrintString(_x(88.0f + fPosXOffset), _y(175.0f), gxt->GetText("RAMP_KL")); CFont::PrintString(_x(88.0f + fPosXOffset), _y(175.0f), TheText.GetText("RAMP_KL"));


CFont::SetTextUseProportionalValues(false); CFont::SetTextUseProportionalValues(false);
CFont::PrintString(_x(32.0f), _y(175.0f), gString); CFont::PrintString(_x(32.0f), _y(175.0f), gString);
@@ -115,7 +115,7 @@ void CDarkel::DrawMessages()
if ( bStandardSoundAndMessages ) if ( bStandardSoundAndMessages )
{ {
if ( CTimer::m_snTimeInMilliseconds - TimeOfFrenzyStart < 5000 ) if ( CTimer::m_snTimeInMilliseconds - TimeOfFrenzyStart < 5000 )
CMessages::AddBigMessage(gxt->GetText("KILLPA"), 3000, 0); CMessages::AddBigMessage(TheText.GetText("KILLPA"), 3000, 0);
} }
return; return;
} }

0 comments on commit 7ed519c

Please sign in to comment.