Skip to content

Commit

Permalink
GTA 3 / CFont
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkingGitHub committed Apr 14, 2017
1 parent 8278eba commit f957a26
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 10 deletions.
212 changes: 212 additions & 0 deletions plugin_III/game_III/CFont.cpp
@@ -0,0 +1,212 @@
/*
Plugin-SDK (Grand Theft Auto) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CFont.h"

CFontDetails &CFont::Details = *(CFontDetails *)0x8F317C;
CSprite2d *CFont::Sprite = (CSprite2d *)0x95CC04;
_int16 &CFont::NewLine = *(_int16 *)0x95CC94;
char *aStr = (char *)0x64C624;

// Converted from cdecl void CFont::DrawFonts(void) 0x501B50
void CFont::DrawFonts() {
plugin::Call<0x501B50>();
}

// Converted from cdecl wchar_t* CFont::GetNextSpace(wchar_t *str) 0x501960
wchar_t* CFont::GetNextSpace(wchar_t* str) {
return plugin::CallAndReturn<wchar_t*, 0x501960, wchar_t*>(str);
}

// Converted from cdecl int CFont::GetNumberLines(float x,float y,wchar_t *text) 0x501260
int CFont::GetNumberLines(float x, float y, wchar_t* text) {
return plugin::CallAndReturn<int, 0x501260, float, float, wchar_t*>(x, y, text);
}

// Converted from cdecl float CFont::GetStringWidth(wchar_t *str,bool sentence) 0x5018A0
float CFont::GetStringWidth(wchar_t* str, bool sentence) {
return plugin::CallAndReturn<float, 0x5018A0, wchar_t*, bool>(str, sentence);
}

// Converted from cdecl CRect* CFont::GetTextRect(CRect *rect_out,float x,float y,wchar_t *text) 0x5013B0
CRect* CFont::GetTextRect(CRect* rect_out, float x, float y, wchar_t* text) {
return plugin::CallAndReturn<CRect*, 0x5013B0, CRect*, float, float, wchar_t*>(rect_out, x, y, text);
}

// Converted from cdecl void CFont::InitPerFrame(void) 0x500BE0
void CFont::InitPerFrame() {
plugin::Call<0x500BE0>();
}

// Converted from cdecl void CFont::Initialise(void) 0x500A40
void CFont::Initialise() {
plugin::Call<0x500A40>();
}

// Converted from cdecl wchar_t* CFont::ParseToken(wchar_t *str) 0x5019A0
wchar_t* CFont::ParseToken(wchar_t* str) {
return plugin::CallAndReturn<wchar_t*, 0x5019A0, wchar_t*>(str);
}

// Converted from cdecl void CFont::PrintChar(float x,float y,short character) 0x500C30
void CFont::PrintChar(float x, float y, short character) {
plugin::Call<0x500C30, float, float, short>(x, y, character);
}

// Converted from cdecl void CFont::PrintString(float x,float y,wchar_t *text) 0x500F50
void CFont::PrintString(float x, float y, wchar_t* text) {
plugin::Call<0x500F50, float, float, wchar_t*>(x, y, text);
}

// Converted from cdecl void CFont::PrintString(float x,float y,wchar_t *str1,wchar_t *str2,float) 0x501730
void CFont::PrintString(float x, float y, wchar_t* str1, wchar_t* str2, float arg4) {
plugin::Call<0x501730, float, float, wchar_t*, wchar_t*, float>(x, y, str1, str2, arg4);
}

// Converted from cdecl void CFont::SetAlphaFade(float alpha) 0x501DD0
void CFont::SetAlphaFade(float alpha) {
plugin::Call<0x501DD0, float>(alpha);
}

// Converted from cdecl void CFont::SetBackGroundOnlyTextOff(void) 0x501D40
void CFont::SetBackGroundOnlyTextOff() {
plugin::Call<0x501D40>();
}

// Converted from cdecl void CFont::SetBackGroundOnlyTextOn(void) 0x501D30
void CFont::SetBackGroundOnlyTextOn() {
plugin::Call<0x501D30>();
}

// Converted from cdecl void CFont::SetBackgroundColor(CRGBA color) 0x501D00
void CFont::SetBackgroundColor(CRGBA color) {
plugin::Call<0x501D00, CRGBA*>(&color);
}

// Converted from cdecl void CFont::SetBackgroundOff(void) 0x501CF0
void CFont::SetBackgroundOff() {
plugin::Call<0x501CF0>();
}

// Converted from cdecl void CFont::SetBackgroundOn(void) 0x501CE0
void CFont::SetBackgroundOn() {
plugin::Call<0x501CE0>();
}

// Converted from cdecl void CFont::SetCentreOff(void) 0x501CB0
void CFont::SetCentreOff() {
plugin::Call<0x501CB0>();
}

// Converted from cdecl void CFont::SetCentreOn(void) 0x501C90
void CFont::SetCentreOn() {
plugin::Call<0x501C90>();
}

// Converted from cdecl void CFont::SetCentreSize(float size) 0x501CD0
void CFont::SetCentreSize(float size) {
plugin::Call<0x501CD0, float>(size);
}

// Converted from cdecl void CFont::SetColor(CRGBA color) 0x501BD0
void CFont::SetColor(CRGBA color) {
plugin::Call<0x501BD0, CRGBA*>(&color);
}

// Converted from cdecl void CFont::SetDropColor(CRGBA color) 0x501DE0
void CFont::SetDropColor(CRGBA color) {
plugin::Call<0x501DE0, CRGBA*>(&color);
}

// Converted from cdecl void CFont::SetDropShadowPosition(short value) 0x501E70
void CFont::SetDropShadowPosition(short value) {
plugin::Call<0x501E70, short>(value);
}

// Converted from cdecl void CFont::SetFontStyle(short style) 0x501DB0
void CFont::SetFontStyle(short style) {
plugin::Call<0x501DB0, short>(style);
}

// Converted from cdecl void CFont::SetJustifyOff(void) 0x501C80
void CFont::SetJustifyOff() {
plugin::Call<0x501C80>();
}

// Converted from cdecl void CFont::SetJustifyOn(void) 0x501C60
void CFont::SetJustifyOn() {
plugin::Call<0x501C60>();
}

// Converted from cdecl void CFont::SetPropOff(void) 0x501D90
void CFont::SetPropOff() {
plugin::Call<0x501D90>();
}

// Converted from cdecl void CFont::SetPropOn(void) 0x501DA0
void CFont::SetPropOn() {
plugin::Call<0x501DA0>();
}

// Converted from cdecl void CFont::SetRightJustifyOff(void) 0x501D70
void CFont::SetRightJustifyOff() {
plugin::Call<0x501D70>();
}

// Converted from cdecl void CFont::SetRightJustifyOn(void) 0x501D50
void CFont::SetRightJustifyOn() {
plugin::Call<0x501D50>();
}

// Converted from cdecl void CFont::SetRightJustifyWrap(float value) 0x501DC0
void CFont::SetRightJustifyWrap(float value) {
plugin::Call<0x501DC0, float>(value);
}

// Converted from cdecl void CFont::SetScale(float width,float height) 0x501B80
void CFont::SetScale(float width, float height) {
plugin::Call<0x501B80, float, float>(width, height);
}

// Converted from cdecl void CFont::SetSlant(float value) 0x501BC0
void CFont::SetSlant(float value) {
plugin::Call<0x501BC0, float>(value);
}

// Converted from cdecl void CFont::SetSlantRefPoint(float x,float y) 0x501BA0
void CFont::SetSlantRefPoint(float x, float y) {
plugin::Call<0x501BA0, float, float>(x, y);
}

// Converted from cdecl void CFont::SetWrapx(float value) 0x501CC0
void CFont::SetWrapx(float value) {
plugin::Call<0x501CC0, float>(value);
}

// Converted from cdecl void CFont::Shutdown(void) 0x500BA0
void CFont::Shutdown() {
plugin::Call<0x500BA0>();
}

// Converted from cdecl short CFont::character_code(uchar character) 0x501E80
short CFont::character_code(unsigned char character) {
return plugin::CallAndReturn<short, 0x501E80, unsigned char>(character);
}

// Converted from cdecl void AsciiToUnicode(char const* str_ascii,wchar_t * str_unicode) 0x5009C0
void AsciiToUnicode(char const* str_ascii, wchar_t* str_unicode) {
plugin::Call<0x5009C0, char const*, wchar_t*>(str_ascii, str_unicode);
}

// Converted from cdecl int UnicodeStrlen(wchar_t const* str) 0x500A20
int UnicodeStrlen(wchar_t const* str) {
return plugin::CallAndReturn<int, 0x500A20, wchar_t const*>(str);
}

// Converted from cdecl char* UnicodeToAscii(wchar_t *str_unicode) 0x52C2F0
char* UnicodeToAscii(wchar_t* str_unicode) {
return plugin::CallAndReturn<char*, 0x52C2F0, wchar_t*>(str_unicode);
}
81 changes: 81 additions & 0 deletions plugin_III/game_III/CFont.h
@@ -0,0 +1,81 @@
/*
Plugin-SDK (Grand Theft Auto) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "plbase\PluginBase_III.h"
#include "CRGBA.h"
#include "CRect.h"
#include "CFontDetails.h"
#include "CSprite2d.h"

class CFont {
public:
// variables
static CFontDetails &Details;
static CSprite2d *Sprite;
static _int16 &NewLine;

// funcs

static void DrawFonts();
// get next ' ' character in a string
static wchar_t* GetNextSpace(wchar_t* str);
static int GetNumberLines(float x, float y, wchar_t* text);
static float GetStringWidth(wchar_t* str, bool sentence);
static CRect* GetTextRect(CRect* rect_out, float x, float y, wchar_t* text);
static void InitPerFrame();
// CFont initialisation
static void Initialise();
static wchar_t* ParseToken(wchar_t* str);
// this adds a single character into rendering buffer
static void PrintChar(float x, float y, short character);
static void PrintString(float x, float y, wchar_t* text);
static void PrintString(float x, float y, wchar_t* str1, wchar_t* str2, float arg4);
// like a 'global' font alpha, multiplied with each text alpha (from SetColor)
static void SetAlphaFade(float alpha);
static void SetBackGroundOnlyTextOff();
static void SetBackGroundOnlyTextOn();
// sets background color
static void SetBackgroundColor(CRGBA color);
static void SetBackgroundOff();
static void SetBackgroundOn();
static void SetCentreOff();
static void SetCentreOn();
// set line width at center
static void SetCentreSize(float size);
// set text color
static void SetColor(CRGBA color);
// drop color is used for text shadow and text outline
static void SetDropColor(CRGBA color);
// set shadow size
static void SetDropShadowPosition(short value);
// set text style
static void SetFontStyle(short style);
static void SetJustifyOff();
static void SetJustifyOn();
static void SetPropOff();
static void SetPropOn();
static void SetRightJustifyOff();
static void SetRightJustifyOn();
static void SetRightJustifyWrap(float value);
// text scaling
static void SetScale(float width, float height);
// set text rotation angle
static void SetSlant(float value);
// set text rotation point
static void SetSlantRefPoint(float x, float y);
// set line width at right
static void SetWrapx(float value);
// CFont closing
static void Shutdown();
static short character_code(unsigned char character);
};

void AsciiToUnicode(char const* str_ascii, wchar_t* str_unicode);
int UnicodeStrlen(wchar_t const* str);
char* UnicodeToAscii(wchar_t* str_unicode);
extern char *aStr;
12 changes: 12 additions & 0 deletions plugin_III/game_III/CFontDetails.cpp
@@ -0,0 +1,12 @@
/*
Plugin-SDK (Grand Theft Auto) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CFontDetails.h"

// Converted from thiscall void CFontDetails::~CFontDetails() 0x501F10
CFontDetails::~CFontDetails() {
plugin::CallMethod<0x501F10, CFontDetails *>(this);
}
47 changes: 47 additions & 0 deletions plugin_III/game_III/CFontDetails.h
@@ -0,0 +1,47 @@
/*
Plugin-SDK (Grand Theft Auto) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "plbase\PluginBase_III.h"
#include "CRGBA.h"
#include "CVector2D.h"

#pragma pack(push, 2)
class CFontDetails {
public:
CRGBA m_Color;
CVector2D m_vScale;
float m_fSlant;
CVector2D m_vSlantRefPoint;
bool m_bJustify;
bool m_bCentre;
bool m_bRightJustify;
bool m_bBackground;
bool m_bBackGroundOnlyText;
bool m_bProp;
private:
char _pad1E[2];
public:
float m_fAlphaFade;
CRGBA m_BackgroundColor;
float m_fWrapX;
float m_fCentreSize;
float m_fRightJustifyWrap;
_int16 m_nStyle;
private:
char _pad36[2];
public:
int field_38;
_int16 m_nDropShadowPosition;
CRGBA m_DropColor;

//funcs
~CFontDetails();
};
#pragma pack(pop)

VALIDATE_SIZE(CFontDetails, 0x42);
12 changes: 12 additions & 0 deletions plugin_III/game_III/CPlane.cpp
Expand Up @@ -82,3 +82,15 @@ unsigned int *DropOffCesnaMissionStatus = (unsigned int *)0x64CFF0;
unsigned int *DropOffCesnaMissionStartTime = (unsigned int *)0x64CFF4;
CPlane **pDropOffCesna = (CPlane **)0x8E2A38;
CPlane **pDrugRunCesna = (CPlane **)0x8F5F80;
unsigned int *NumPathNodes = (unsigned int *)0x8F2BE4;
unsigned int *NumPath2Nodes = (unsigned int *)0x941498;
unsigned int *NumPath3Nodes = (unsigned int *)0x9414D8;
unsigned int *NumPath4Nodes = (unsigned int *)0x9412C8;
float *TotalLengthOfFlightPath = (float *)0x8F2C6C;
float *TotalLengthOfFlightPath2 = (float *)0x64CFBC;
float *TotalLengthOfFlightPath3 = (float *)0x64CFD0;
float *TotalLengthOfFlightPath4 = (float *)0x64CFDC;
CPathNode **pPathNodes = (CPathNode **)0x8F1B68;
CPathNode **pPath2Nodes = (CPathNode **)0x885B8C;
CPathNode **pPath3Nodes = (CPathNode **)0x885B78;
CPathNode **pPath4Nodes = (CPathNode **)0x885AD8;

0 comments on commit f957a26

Please sign in to comment.