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];
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::LoadFontValues() { EAXJMP(0x7187C0); }

void CFont::ReadFontsDAT()
{
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)
unsigned char CFont::FindSubFontCharacter(char character, unsigned char bFontType)
{
UNREFERENCED_PARAMETER(bFontType);
if ( character == 4 )
@@ -149,44 +85,44 @@ unsigned char CFont::AssignBottomFontIndex(unsigned char character, unsigned cha
return character;
}

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

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

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

void CFont::SetTextColour(CRGBA colour)
void CFont::SetColor(CRGBA colour)
{
DWORD dwFunc = (DWORD)FUNC_CFont__SetTextColour;
_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::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
#define __CFONT

#define WIN32_LEAN_AND_MEAN

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

public:
static CSprite2d Sprite[NUM_FONT_SHEETS];

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

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

public:
static void ReadFontsDAT();
static unsigned char AssignBottomFontIndex(unsigned char character, unsigned char bFontType);
static void SetTextLetterSize(float scaleX, float scaleY);
static void SetTextLetterSizeWithLanguageScaling(float scaleX, float scaleY);
// TODO: Make private?
static CSprite2d Sprite[NUM_FONT_SHEETS];
static sFontSizes Size[NUM_FONT_SHEETS];
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 SetTextColour(CRGBA colour);
static void SetColor(CRGBA colour);
static void SetTextBorderRGBA(CRGBA colour);
static void SetTextShadow(unsigned char bShadow);
static void SetTextOutline(unsigned char bOutline);
@@ -102,6 +104,9 @@ class CFont
static void PrintString(float posX, float posY, const char* pText);
static void PrintStringFromBottom(float posX, float posY, const char* pText);
static void SetWrapx(float fWrap);

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

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

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

// TODO: Flashing
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::SetTextColour(BaseColors[11]);
CFont::SetColor(BaseColors[11]);
CFont::PrintString(_x(32.0f), _y(148.0f), gString);
}

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

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

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

0 comments on commit 7ed519c

Please sign in to comment.