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/internal_rewrite/ui_draw.h | 161 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 cheat/internal_rewrite/ui_draw.h (limited to 'cheat/internal_rewrite/ui_draw.h') diff --git a/cheat/internal_rewrite/ui_draw.h b/cheat/internal_rewrite/ui_draw.h new file mode 100644 index 0000000..d95b1c2 --- /dev/null +++ b/cheat/internal_rewrite/ui_draw.h @@ -0,0 +1,161 @@ +#pragma once +#include "color.hpp" +#include "d3d.hpp" +#include "icons.hpp" +#include "d3d_sprite.hpp" +#include "input_system.hpp" + +namespace ui +{ + extern float get_csgo_frametime( ); + /*__forceinline auto ui_get_background_texture( ) { + static auto buffer = std::make_shared< byte[ 512 ] >( ); + static auto color = D3DCOLOR_RGBA( 27, 27, 27, 233 ); + static auto color_bright = D3DCOLOR_RGBA( 31, 31, 31, 255 ); + static IDirect3DTexture9* texture; + + if ( !texture ) { + for ( int i = 0; i < 512; i += 4 ) { + *( ulong_t* )( uintptr_t( buffer.get( ) ) + i ) = !( i % 12 ) ? color : color_bright; + } + + D3DXCreateTextureFromFileInMemory( g_d3d.get_device( ), buffer.get( ), 512, &texture ); + } + + return texture; + }*/ + + extern float anim_time; + + __forceinline void set_animtime( float animtime ) { + anim_time = animtime; + } + + __forceinline void setup_sprites( IDirect3DDevice9* device ) { + //fuck msvc + icons::sprite_legit.init( device, icons::legit_icon, icons::legit_size, 66, 66 ); + icons::sprite_rage.init( device, icons::rage_icon, icons::rage_size, 66, 66 ); + icons::sprite_visuals.init( device, icons::raw::visuals, icons::visuals_size, 66, 66 ); + icons::sprite_misc.init( device, icons::misc_icon, icons::misc_size, 66, 66 ); + icons::sprite_config.init( device, icons::config_icon, icons::config_size, 66, 66 ); + } + + __forceinline clr_t ui_get_accent_col( ) { + clr_t col_start = g_settings.menu.menu_color; + + float brightness = col_start.brightness( ) / 255.f; + float saturation = col_start.saturation( ); + + float new_brightness = brightness > .5f ? brightness - 0.2f : brightness + 0.2f; + float new_saturation = saturation > .5f ? saturation - 0.2f : saturation + 0.2f; + + clr_t col_end = clr_t::from_hsb( col_start.hue( ), new_saturation, new_brightness ); + col_end.a( ) = col_start.a( ); + + clr_t col = clr_t::blend( col_start, col_end, anim_time ); + return col; + } + + __forceinline clr_t& ui_get_disabled_col( ) { + static clr_t col = clr_t( 61, 61, 61, 255 ); + return col; + } + + __forceinline clr_t& ui_get_bg_col( ) { + static clr_t col = clr_t( 24, 25, 27, 255 ); + return col; + } + + __forceinline clr_t& ui_get_text_col( ) { + static clr_t col = clr_t( 221, 221, 221, 255 ); + return col; + } + + __forceinline void ui_draw_gradient( int x, int y, int w, int h, clr_t start, + clr_t end, GradientType_t type = GRADIENT_HORIZONTAL ) { + + g_d3d.draw_gradient( start, end, x, y, w, h, type ); + } + + __forceinline void ui_draw_line( int x, int y, int x1, int y1, clr_t color ) { + g_d3d.draw_line( color, x, y, x1, y1 ); + } + + __forceinline void ui_draw_rect( int x, int y, int w, int h, clr_t color ) { + g_d3d.draw_filled_rect( color, x, y, w, h ); + } + + __forceinline void ui_draw_outlined_rect( int x, int y, int w, int h, clr_t color ) { + g_d3d.draw_rect( color, x, y, w, h ); + } + + __forceinline void ui_draw_circle( int x, int y, int r, clr_t color, int res = 48 ) { + g_d3d.draw_circle( color, x, y, r, res ); + } + + __forceinline void ui_draw_filled_circle( int x, int y, int r, clr_t color, int res = 48 ) { + g_d3d.draw_filled_circle( color, x, y, r, res ); + } + + __forceinline void ui_draw_string( int x, int y, bool center, clr_t color, const char* str, ... ) { + char buf[ 2048 ]{ }; + va_list list{ }; + + __crt_va_start( list, str ); + vsprintf_s( buf, 2048, str, list ); + __crt_va_end( list ); + + g_d3d.draw_text( d3d::fonts.f_menu, color, x, y, + center ? ALIGN_CENTER : ALIGN_LEFT, D3DFONTFLAG_DROPSHADOW, buf ); + } + + __forceinline void ui_get_text_size( int& w, int& h, const char* text, ... ) { + char* buf = ( char* )_alloca( 2048 ); + va_list list{ }; + + __crt_va_start( list, text ); + vsprintf_s( buf, 2048, text, list ); + __crt_va_end( list ); + + w = g_d3d.get_text_width( d3d::fonts.f_menu, 0, buf ); + h = g_d3d.get_text_height( d3d::fonts.f_menu, 0, buf ); + } + + __forceinline void ui_get_cursor_pos( int& x, int& y ) { + g_input.get_cursor_pos( x, y ); + } + + __forceinline float ui_get_frametime( ) { + return get_csgo_frametime( ); + } + + __forceinline void ui_draw_cursor( ) { + const clr_t black( 0, 0, 0, 255 ), accent( ui_get_accent_col( ) ); + int x, y; + ui_get_cursor_pos( x, y ); + + + for ( int i{ }; i <= 9; ++i ) { + ui_draw_line( x, y, x + i, y + 11, accent ); + } + + for ( int i{ }; i <= 7; ++i ) { + ui_draw_line( x, y + 9 + i, x + i, y + 9, accent ); + } + + for ( int i{ }; i <= 3; ++i ) { + ui_draw_line( x + 6 + i, y + 11, x, y + i, accent ); + } + + ui_draw_line( x + 5, y + 11, x + 8, y + 18, accent ); + ui_draw_line( x + 4, y + 11, x + 7, y + 18, accent ); + + ui_draw_line( x, y, x, y + 17, black ); + ui_draw_line( x, y + 17, x + 3, y + 14, black ); + ui_draw_line( x + 4, y + 14, x + 7, y + 19, black ); + ui_draw_line( x + 7, y + 18, x + 9, y + 18, black ); + ui_draw_line( x + 10, y + 18, x + 7, y + 12, black ); + ui_draw_line( x + 7, y + 12, x + 11, y + 12, black ); + ui_draw_line( x + 11, y + 12, x, y, black ); + } +} \ No newline at end of file -- cgit v1.2.3