add some fonts, update default font to tf2build

This commit is contained in:
nullifiedcat 2017-08-19 15:01:19 +03:00
parent 5ca6159617
commit 1ce6b306b4
10 changed files with 20 additions and 20 deletions

BIN
data/fonts/roboto.ttf Executable file

Binary file not shown.

BIN
data/fonts/tf2build.ttf Executable file

Binary file not shown.

BIN
data/fonts/unispace.ttf Normal file

Binary file not shown.

BIN
data/fonts/verasans.ttf Normal file

Binary file not shown.

View File

@ -39,15 +39,15 @@ void AddSideString(const std::string& string, const rgba_t& color) {
void DrawStrings() { void DrawStrings() {
int y { 8 }; int y { 8 };
for (size_t i = 0; i < side_strings_count; ++i) { for (size_t i = 0; i < side_strings_count; ++i) {
FTGL_Draw(side_strings[i], 8, y, fonts::ftgl_ESP, side_strings_colors[i]); FTGL_Draw(side_strings[i], 8, y, fonts::font_main, side_strings_colors[i]);
y += fonts::ftgl_ESP->height + 1; y += fonts::font_main->height + 1;
} }
y = draw::height / 2; y = draw::height / 2;
for (size_t i = 0; i < center_strings_count; ++i) { for (size_t i = 0; i < center_strings_count; ++i) {
int sx; int sx;
FTGL_StringLength(center_strings[i], fonts::ftgl_ESP, &sx, nullptr); FTGL_StringLength(center_strings[i], fonts::font_main, &sx, nullptr);
FTGL_Draw(center_strings[i], (draw::width - sx) / 2, y, fonts::ftgl_ESP, center_strings_colors[i]); FTGL_Draw(center_strings[i], (draw::width - sx) / 2, y, fonts::font_main, center_strings_colors[i]);
y += fonts::ftgl_ESP->height + 1; y += fonts::font_main->height + 1;
} }
} }
@ -65,8 +65,8 @@ float draw::fov = 90.0f;
namespace fonts { namespace fonts {
ftgl::texture_font_t* ftgl_ESP = nullptr; ftgl::texture_font_t* font_main = nullptr;
CatVar esp_ftgl_font(CV_STRING, "font_ftgl_esp", "opensans-bold", "FTGL Font"); CatVar font_ftgl(CV_STRING, "font_ftgl", "tf2build", "FTGL Font");
} }
@ -77,8 +77,8 @@ void draw::Initialize() {
FTGL_PreInit(); FTGL_PreInit();
fonts::esp_ftgl_font.InstallChangeCallback([](IConVar* var, const char* pOldValue, float flOldValue) { fonts::font_ftgl.InstallChangeCallback([](IConVar* var, const char* pOldValue, float flOldValue) {
FTGL_ChangeFont(&fonts::ftgl_ESP, fonts::esp_ftgl_font.GetString()); FTGL_ChangeFont(&fonts::font_main, fonts::font_ftgl.GetString());
(void)flOldValue; (void)flOldValue;
}); });
} }

View File

@ -22,7 +22,7 @@ class CatEnum;
namespace fonts { namespace fonts {
extern ftgl::texture_font_t* ftgl_ESP; extern ftgl::texture_font_t* font_main;
} }

View File

@ -40,7 +40,7 @@ void FTGL_PreInit() {
mat4_set_identity(&view); mat4_set_identity(&view);
mat4_set_identity(&model); mat4_set_identity(&model);
mat4_set_orthographic(&projection, 0, draw::width, 0, draw::height, -1, 1); mat4_set_orthographic(&projection, 0, draw::width, 0, draw::height, -1, 1);
fonts::ftgl_ESP = ftgl::texture_font_new_from_file(atlas, 14, DATA_PATH "/fonts/opensans-bold.ttf"); fonts::font_main = ftgl::texture_font_new_from_file(atlas, 14, DATA_PATH "/fonts/tf2build.ttf");
logging::Info("Pre-Init done %d %d", draw::width, draw::height); logging::Info("Pre-Init done %d %d", draw::width, draw::height);
} }

View File

@ -500,13 +500,13 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
draw_point = Vector(max_x + 2, min_y, 0); draw_point = Vector(max_x + 2, min_y, 0);
} break; } break;
case 1: { // BOTTOM RIGHT case 1: { // BOTTOM RIGHT
draw_point = Vector(max_x + 2, max_y - data.at(ent->m_IDX).string_count * ((int)fonts::ftgl_ESP->height), 0); draw_point = Vector(max_x + 2, max_y - data.at(ent->m_IDX).string_count * ((int)fonts::font_main->height), 0);
} break; } break;
case 2: { // CENTER case 2: { // CENTER
origin_is_zero = true; // origin is still zero so we set to true origin_is_zero = true; // origin is still zero so we set to true
} break; } break;
case 3: { // ABOVE case 3: { // ABOVE
draw_point = Vector(min_x, min_y - data.at(ent->m_IDX).string_count * ((int)fonts::ftgl_ESP->height), 0); draw_point = Vector(min_x, min_y - data.at(ent->m_IDX).string_count * ((int)fonts::font_main->height), 0);
} break; } break;
case 4: { // BELOW case 4: { // BELOW
draw_point = Vector(min_x, max_y, 0); draw_point = Vector(min_x, max_y, 0);
@ -530,15 +530,15 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
// If the origin is centered, we use one method. if not, the other // If the origin is centered, we use one method. if not, the other
if (!origin_is_zero) { if (!origin_is_zero) {
FTGL_Draw(string.data, draw_point.x, draw_point.y, fonts::ftgl_ESP, color); FTGL_Draw(string.data, draw_point.x, draw_point.y, fonts::font_main, color);
} else { } else {
int size_x; int size_x;
FTGL_StringLength(string.data, fonts::ftgl_ESP, &size_x); FTGL_StringLength(string.data, fonts::font_main, &size_x);
FTGL_Draw(string.data, draw_point.x - size_x / 2, draw_point.y, fonts::ftgl_ESP, color); FTGL_Draw(string.data, draw_point.x - size_x / 2, draw_point.y, fonts::font_main, color);
} }
// Add to the y due to their being text in that spot // Add to the y due to their being text in that spot
draw_point.y += (int)fonts::ftgl_ESP->height - 1; draw_point.y += (int)fonts::font_main->height - 1;
} }
} }

View File

@ -835,8 +835,8 @@ void DrawConnection(index_t a, connection_s& b) {
if (b.flags & CF_LOW_AMMO) flags += "A"; if (b.flags & CF_LOW_AMMO) flags += "A";
if (b.flags & CF_LOW_HEALTH) flags += "H"; if (b.flags & CF_LOW_HEALTH) flags += "H";
int size_x = 0, size_y = 0; int size_x = 0, size_y = 0;
FTGL_StringLength(flags, fonts::ftgl_ESP, &size_x, &size_y); FTGL_StringLength(flags, fonts::font_main, &size_x, &size_y);
FTGL_Draw(flags, wts_cc.x - size_x / 2, wts_cc.y - size_y - 4, fonts::ftgl_ESP); FTGL_Draw(flags, wts_cc.x - size_x / 2, wts_cc.y - size_y - 4, fonts::font_main);
} }
} }
@ -880,7 +880,7 @@ void DrawNode(index_t node, bool draw_back) {
if (not draw::WorldToScreen(n.xyz(), wts)) if (not draw::WorldToScreen(n.xyz(), wts))
return; return;
FTGL_Draw(std::to_string(node), wts.x, wts.y, fonts::ftgl_ESP, *color); FTGL_Draw(std::to_string(node), wts.x, wts.y, fonts::font_main, *color);
} }
} }