Skip to content

Commit

Permalink
just small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hero622 committed Aug 16, 2024
1 parent 424c204 commit c845803
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/core/menu/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void gui::framework::sliderf( float& val, float min, float max, const std::strin
cur_menu.cursor.y += size.y + text_size.y + 4;
}

void gui::framework::combo( std::size_t& val, std::vector< std::string > items, const std::string& label ) {
void gui::framework::combo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ) {
auto cur_pos = cur_menu.pos + cur_menu.cursor;

const auto size = vec2_t( 160, 26 );
Expand Down Expand Up @@ -271,7 +271,7 @@ void gui::framework::combo( std::size_t& val, std::vector< std::string > items,
cur_menu.cursor.y += size.y + text_size.y + 4;
}

void gui::framework::multicombo( std::size_t& val, std::vector< std::string > items, const std::string& label ) {
void gui::framework::multicombo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ) {
auto cur_pos = cur_menu.pos + cur_menu.cursor;

const auto size = vec2_t( 160, 26 );
Expand Down
4 changes: 2 additions & 2 deletions src/core/menu/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace gui {
bool checkbox( bool& val, const std::string& label );
void slider( int& val, int min, int max, const std::string& label );
void sliderf( float& val, float min, float max, const std::string& label );
void combo( std::size_t& val, std::vector< std::string > items, const std::string& label );
void multicombo( std::size_t& val, std::vector< std::string > items, const std::string& label );
void combo( std::size_t& val, const std::vector< std::string >& items, const std::string& label );
void multicombo( std::size_t& val, const std::vector< std::string >& items, const std::string& label );
} // namespace framework
} // namespace gui
6 changes: 4 additions & 2 deletions src/core/shared/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ void* c_common::get_interface( const char* module_name, const char* interface_na

result = fn( interface_name, nullptr );

if ( !result )
if ( !result ) {
util::console::log( "[!] couldn't find interface %s in %s.\n", interface_name, module_name );
return nullptr;
}

util::console::log( "[+] found interface %s in %s at %p.\n", interface_name, module_name, result );

return result;
}

util::console::log( "[!] couldn't find interface %s in %s.\n", interface_name, module_name );
util::console::log( "[!] couldn't find CreateInterface fn in %s.\n", module_name );

return nullptr;
}
Expand Down
52 changes: 42 additions & 10 deletions src/sdk/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <vector>

// member functions only for now (__thiscall conv etc.)
// return value dismissed for now
class signal_t {
friend class c_signal;

Expand Down Expand Up @@ -73,21 +72,54 @@ class c_signal {
}
#define _SIGNAL3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) \
static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3 ) { \
t ret = 0; \
const auto sig = photon->signal->get( #name ); \
t ret = 0; \
auto sig = photon->signal->get( #name ); \
for ( const auto& cbk : sig->get_callbacks( ) ) { \
using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t ); \
ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3 ); \
} \
return ret; \
}
#define _SIGNAL4( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4 ) \
static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4 ) { \
t ret = 0; \
auto sig = photon->signal->get( #name ); \
for ( const auto& cbk : sig->get_callbacks( ) ) { \
using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t ); \
ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4 ); \
} \
return ret; \
}
#define _SIGNAL5( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4, a5_t, a5 ) \
static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5 ) { \
t ret = 0; \
auto sig = photon->signal->get( #name ); \
for ( const auto& cbk : sig->get_callbacks( ) ) { \
using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t, a5_t ); \
ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t, a5_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4, a5 ); \
} \
return ret; \
}
#define _SIGNAL6( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4, a5_t, a5, a6_t, a6 ) \
static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5, a6_t a6 ) { \
t ret = 0; \
auto sig = photon->signal->get( #name ); \
for ( const auto& cbk : sig->get_callbacks( ) ) { \
using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ); \
ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4, a5, a6 ); \
} \
return ret; \
}

#define _SIGNAL_CALLBACK0( t, name ) t name##_cbk( t( __rescall* original )( void* ), void* ecx )
#define _SIGNAL_CALLBACK1( t, name, a1_t, a1 ) t name##_cbk( t( __rescall* original )( void*, a1_t ), void* ecx, a1_t a1 )
#define _SIGNAL_CALLBACK2( t, name, a1_t, a1, a2_t, a2 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t ), void* ecx, a1_t a1, a2_t a2 )
#define _SIGNAL_CALLBACK3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3 )
#define _SIGNAL_CALLBACK0( t, name ) t name##_cbk( t( __rescall* original )( void* ), void* ecx )
#define _SIGNAL_CALLBACK1( t, name, a1_t, a1 ) t name##_cbk( t( __rescall* original )( void*, a1_t ), void* ecx, a1_t a1 )
#define _SIGNAL_CALLBACK2( t, name, a1_t, a1, a2_t, a2 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t ), void* ecx, a1_t a1, a2_t a2 )
#define _SIGNAL_CALLBACK3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3 )
#define _SIGNAL_CALLBACK4( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4 )
#define _SIGNAL_CALLBACK5( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4, a5_t, a5 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t, a5_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5 )
#define _SIGNAL_CALLBACK6( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4, a5_t, a5, a6_t, a6 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5, a6_t a6 )

#define _SIGNAL_NAME( _0, _1, _2, _3, _4, _5, _6, NAME, ... ) NAME
#define _SIGNAL_NAME( _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, NAME, ... ) NAME

#define SIGNAL( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL3, _3, _SIGNAL2, _2, _SIGNAL1, _1, _SIGNAL0 )( t, name __VA_OPT__(, ) __VA_ARGS__ )
#define SIGNAL_CALLBACK( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL_CALLBACK3, _3, _SIGNAL_CALLBACK2, _2, _SIGNAL_CALLBACK1, _1, _SIGNAL_CALLBACK0 )( t, name __VA_OPT__(, ) __VA_ARGS__ )
#define SIGNAL( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL6, _6, _SIGNAL5, _5, _SIGNAL4, _4, _SIGNAL3, _3, _SIGNAL2, _2, _SIGNAL1, _1, _SIGNAL0 )( t, name __VA_OPT__(, ) __VA_ARGS__ )
#define SIGNAL_CALLBACK( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL_CALLBACK6, _6, _SIGNAL_CALLBACK5, _5, _SIGNAL_CALLBACK4, _4, _SIGNAL_CALLBACK3, _3, _SIGNAL_CALLBACK2, _2, _SIGNAL_CALLBACK1, _1, _SIGNAL_CALLBACK0 )( t, name __VA_OPT__(, ) __VA_ARGS__ )

0 comments on commit c845803

Please sign in to comment.