diff options
| author | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
| commit | 3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch) | |
| tree | 26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /cheat/tf2/renderer.cpp | |
| parent | e4729e4393d90271a3814c7a79950a660c48325a (diff) | |
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
Diffstat (limited to 'cheat/tf2/renderer.cpp')
| -rw-r--r-- | cheat/tf2/renderer.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/cheat/tf2/renderer.cpp b/cheat/tf2/renderer.cpp new file mode 100644 index 0000000..8f5e8e7 --- /dev/null +++ b/cheat/tf2/renderer.cpp @@ -0,0 +1,93 @@ +#include "renderer.hpp"
+#include "interfaces.h"
+
+#undef CreateFont
+
+
+drawings::c_fonts g_fonts;
+drawings::c_drawings g_renderer;
+
+NAMESPACE_REGION( drawings )
+
+c_fonts::font_t::font_t( std::string name, int size,
+ int weight, ulong_t flags ) :
+ m_name( name ), m_size( size ),
+ m_weight( weight ), m_flags( flags ) {
+ g_fonts.m_container.push_back( this );
+};
+
+void c_fonts::font_t::initialize( ) {
+ m_font = cl.m_surface( )->CreateFnt( );
+ cl.m_surface( )->SetFontGlyphSet(
+ m_font, m_name.c_str( ), m_size,
+ m_weight, 0, 0,
+ m_flags
+ );
+}
+
+void c_fonts::initialize( ) {
+ for( auto& it : m_container ) {
+ it->initialize( );
+ }
+}
+
+void c_drawings::draw_string( const wchar_t* text, HFont font, int x, int y, const clr_t& color ) {
+ cl.m_surface( )->DrawSetTextPos( x, y );
+ cl.m_surface( )->DrawSetTextFont( font );
+ cl.m_surface( )->DrawSetTextColor( color );
+ cl.m_surface( )->DrawPrintText( text, wcslen( text ) );
+}
+
+void c_drawings::draw_rect( int x, int y, int w, int h, const clr_t& color ) {
+ cl.m_surface( )->DrawSetColor( color );
+ cl.m_surface( )->DrawFilledRect( x, y, x + w, y + h );
+}
+
+void c_drawings::draw_line( int x, int y, int x1, int y1, const clr_t& clr ) {
+ cl.m_surface( )->DrawSetColor( clr );
+ cl.m_surface( )->DrawLine( x, y, x1, y1 );
+}
+
+void c_drawings::draw_box( int x, int y, int w, int h, const clr_t& clr ) {
+ draw_line( x, y, x + w, y, clr );
+ draw_line( x + w, y, x + w, y + h, clr );
+ draw_line( x, y + h, x + w + 1, y + h, clr );
+ draw_line( x, y, x, y + h, clr );
+}
+
+void c_drawings::draw_circle( int x, int y, int r, const clr_t& col, int res ) {
+ cl.m_surface( )->DrawSetColor( col );
+ cl.m_surface( )->DrawOutlinedCircle( x, y, r, res );
+}
+
+void c_drawings::draw_filled_circle( int x, int y, int r, const clr_t& col, int res ) {
+ vertex_t* v = ( vertex_t* )( _alloca( res * sizeof( vertex_t ) ) );
+ const float step = M_PI * 2.0f / res;
+
+ for( size_t i{ }; i < res; ++i ) {
+ float theta = i * step;
+ float x_off = r * cos( theta );
+ float y_off = r * sin( theta );
+ v[ i ].init( x + x_off, y + y_off );
+ }
+
+ draw_polygon( res, v, col );
+}
+
+void c_drawings::draw_line( const vec2_t& begin, const vec2_t& end, const clr_t& clr ) {
+ draw_line( ( int )begin.x, ( int )begin.y, ( int )end.x, ( int )end.y, clr );
+}
+
+void c_drawings::draw_polygon( int count, vertex_t* vertices, const clr_t& col ) {
+ static int texture = cl.m_surface( )->CreateNewTextureID( true );
+
+ clr_t buf( 255, 255, 255 );
+
+ cl.m_surface( )->DrawSetTextureRGBA( texture, ( byte* )( &buf ), 1, 1 );
+ cl.m_surface( )->DrawSetColor( col );
+ cl.m_surface( )->DrawSetTexture( texture );
+
+ cl.m_surface( )->DrawTexturedPolygon( count, vertices );
+}
+
+END_REGION
\ No newline at end of file |
