From 3d412a4b30a9f7c7f51ea6562e694315948bd3da Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 28 Nov 2018 16:00:02 +1300 Subject: cleaned up in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever. i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64 --- cheat/gmod/renderer.hpp | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 cheat/gmod/renderer.hpp (limited to 'cheat/gmod/renderer.hpp') diff --git a/cheat/gmod/renderer.hpp b/cheat/gmod/renderer.hpp new file mode 100644 index 0000000..1ae0c00 --- /dev/null +++ b/cheat/gmod/renderer.hpp @@ -0,0 +1,120 @@ +#pragma once +#include +#include +#include + +#include "util.hpp" +#include "sdk.hpp" + +enum e_font_style : size_t { + +}; + +enum FontAlign_t : size_t { + ALIGN_CENTER, + ALIGN_LEFT, + ALIGN_RIGHT +}; + +NAMESPACE_REGION( drawings ) + + +class c_fonts { +protected: + struct font_t { + friend class c_fonts; + font_t( std::string name, int size, + int weight, ulong_t flags ); + + operator HFont( ) { + return m_font; + } + + private: + void initialize( ); + + HFont m_font; + std::string m_name; + int m_size; + int m_weight; + ulong_t m_flags; + }; + + std::vector< font_t* > m_container; + friend struct c_fonts::font_t; +public: + void initialize( ); + + font_t f_esp_small{ xors( "Tahoma" ), 11, 500, FONTFLAG_OUTLINE }; + font_t f_bold{ xors( "Verdana" ), 18, 900, FONTFLAG_DROPSHADOW | FONTFLAG_ANTIALIAS }; + font_t f_12{ xors( "Verdana" ), 12, 700, 128 }; + font_t f_14{ xors( "Verdana" ), 14, 700, 128 }; + font_t f_16{ xors( "Verdana" ), 16, 700, 128 }; + font_t f_18{ xors( "Verdana" ), 18, 700, 128 }; +}; + + + +//im going to fill ur triangles +class c_drawings { +private: + //dumb hacky fix for template functions + void draw_string( const wchar_t* msg, HFont font, int x, int y, const clr_t& color ); + +public: + void draw_line( const vec2_t& begin, const vec2_t& end, const clr_t& color ); + void draw_line( int x, int y, int x1, int y2, const clr_t& color ); + void draw_rect( int x, int y, int w, int h, const clr_t& color ); + void draw_box( int x, int y, int w, int h, const clr_t& color ); //thicc + void draw_polygon( int count, vertex_t* vertices, const clr_t& col ); + void draw_circle( int x, int y, int r, const clr_t& col, int res = 48 ); + void draw_filled_circle( int x, int y, int r, const clr_t& col, int res = 48 ); + + template < FontAlign_t align = ALIGN_LEFT > //fuck ur sprintf nigga varargs nigga + void draw_string( HFont font, int x, int y, const clr_t& color, const wchar_t* msg, ... ) { + wchar_t* buffer = ( wchar_t* )_alloca( 2048 ); + va_list list{ }; + int wide, tall; + + memset( buffer, 0, 2048 ); + + __crt_va_start( list, msg ); + vswprintf_s( buffer, 1024, msg, list ); + __crt_va_end( list ); + + g_gmod.m_surface( )->GetTextSize( + font, buffer, wide, tall ); + + switch( align ) { + case ALIGN_CENTER: + x -= wide / 2; + break; + case ALIGN_RIGHT: + x -= wide; + break; + default: break; + } + + draw_string( buffer, font, x, y, color ); + } + + template < FontAlign_t align = ALIGN_LEFT > //debatable whether it should be center or not + void draw_string( HFont font, int x, int y, const clr_t& color, const char* msg, ... ) { + char* buffer = ( char* )_alloca( 1024 ); + va_list list{ }; + + memset( buffer, 0, 1024 ); + + __crt_va_start( list, msg ); + vsprintf_s( buffer, 1024, msg, list ); + __crt_va_end( list ); + + auto wide_str = util::ascii_to_unicode( buffer ); + draw_string< align >( font, x, y, color, wide_str.c_str( ) ); + } +}; + +END_REGION + +extern drawings::c_fonts g_fonts; +extern drawings::c_drawings g_renderer; \ No newline at end of file -- cgit v1.2.3