Add skin config persistence, auto-load config on inject and safe config parsing
Save/load weapon skin and music selections in .mh, try/catch around int/float parsing, optional auto-load of one chosen config on inject
This commit is contained in:
@@ -73,6 +73,19 @@ auto CAndromedaClient::OnClientOutput() -> void
|
||||
|
||||
auto CAndromedaClient::OnCreateMove( CCSGOInput* pInput , CUserCmd* pUserCmd ) -> void
|
||||
{
|
||||
static bool bConfigLoaded = false;
|
||||
|
||||
if ( !bConfigLoaded )
|
||||
{
|
||||
bConfigLoaded = true;
|
||||
|
||||
if ( Settings::Config::AutoLoadOnInject )
|
||||
{
|
||||
Settings::Config::FileName = Settings::Config::AutoLoadFile;
|
||||
Settings::LoadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
if ( !Settings::SafeMode::Active )
|
||||
GetVisual()->OnCreateMove();
|
||||
|
||||
|
||||
@@ -846,6 +846,40 @@ auto CAndromedaMenu::RenderConfigPanel() -> void
|
||||
Settings::LoadConfig();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
Checkbox( "Beim Inject automatisch laden" , Settings::Config::AutoLoadOnInject );
|
||||
|
||||
if ( Settings::Config::AutoLoadOnInject )
|
||||
{
|
||||
const auto vAutoFiles = Settings::Config::ListFiles();
|
||||
|
||||
std::vector<const char*> vAutoItems;
|
||||
|
||||
for ( const auto& file : vAutoFiles )
|
||||
vAutoItems.push_back( file.c_str() );
|
||||
|
||||
if ( vAutoItems.empty() )
|
||||
vAutoItems.push_back( "(keine .mh gefunden)" );
|
||||
|
||||
static int iAutoLoadIdx = -1;
|
||||
|
||||
for ( int i = 0; i < static_cast<int>( vAutoFiles.size() ); i++ )
|
||||
{
|
||||
if ( vAutoFiles[ i ] == Settings::Config::AutoLoadFile )
|
||||
{
|
||||
iAutoLoadIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Combo( "Auto-Load Datei" , iAutoLoadIdx , vAutoItems.data() , static_cast<int>( vAutoItems.size() ) ) )
|
||||
{
|
||||
if ( iAutoLoadIdx >= 0 && iAutoLoadIdx < static_cast<int>( vAutoFiles.size() ) )
|
||||
Settings::Config::AutoLoadFile = vAutoFiles[ iAutoLoadIdx ];
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SeparatorText( "Menu" );
|
||||
|
||||
SliderInt( "Menu Alpha" , Settings::Menu::MenuAlpha , 100 , 255 );
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryItemsManager.hpp>
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
namespace Visual
|
||||
@@ -238,6 +240,8 @@ namespace Settings
|
||||
namespace Config
|
||||
{
|
||||
inline std::string FileName = "default.mh";
|
||||
inline auto AutoLoadOnInject = false;
|
||||
inline std::string AutoLoadFile = "default.mh";
|
||||
|
||||
inline auto GetDirectory() -> std::string
|
||||
{
|
||||
@@ -292,12 +296,12 @@ namespace Settings
|
||||
|
||||
inline auto ParseInt( const std::string& szValue ) -> int
|
||||
{
|
||||
return std::stoi( szValue );
|
||||
try { return std::stoi( szValue ); } catch ( ... ) { return 0; }
|
||||
}
|
||||
|
||||
inline auto ParseFloat( const std::string& szValue ) -> float
|
||||
{
|
||||
return std::stof( szValue );
|
||||
try { return std::stof( szValue ); } catch ( ... ) { return 0.f; }
|
||||
}
|
||||
|
||||
inline auto ParseColor( const std::string& szValue ) -> ImVec4
|
||||
@@ -389,6 +393,13 @@ namespace Settings
|
||||
MH_SEC( SafeMode )
|
||||
MH_WB( SafeMode , Active ) MH_WB( SafeMode , DrawIndicator )
|
||||
|
||||
MH_SEC( Skins )
|
||||
|
||||
for ( const auto& [ defIdx , paintKit ] : GetInventoryItemsManager()->GetWeaponSkinSelections() )
|
||||
File << "weapon_" << static_cast<int>( defIdx ) << "=" << paintKit << "\n";
|
||||
|
||||
File << "music=" << GetInventoryItemsManager()->GetMusicSelection() << "\n";
|
||||
|
||||
MH_SEC( Colors::Visual )
|
||||
MH_WC( Colors::Visual , PlayerBoxTT ) MH_WC( Colors::Visual , PlayerBoxTT_Visible )
|
||||
MH_WC( Colors::Visual , PlayerBoxCT ) MH_WC( Colors::Visual , PlayerBoxCT_Visible )
|
||||
@@ -510,6 +521,30 @@ namespace Settings
|
||||
MH_LC( Colors::Visual , GlowTT ) MH_LC( Colors::Visual , GlowTT_Visible )
|
||||
MH_LC( Colors::Visual , GlowCT ) MH_LC( Colors::Visual , GlowCT_Visible )
|
||||
|
||||
{
|
||||
auto* pMgr = GetInventoryItemsManager();
|
||||
|
||||
auto& Selections = pMgr->GetWeaponSkinSelections();
|
||||
Selections.clear();
|
||||
|
||||
const std::string szPrefix = "Skins.weapon_";
|
||||
|
||||
for ( const auto& [ key , value ] : mValues )
|
||||
{
|
||||
if ( key.rfind( szPrefix , 0 ) == 0 )
|
||||
{
|
||||
const int defIdx = ConfigIO::ParseInt( key.substr( szPrefix.size() ) );
|
||||
|
||||
if ( defIdx >= 0 && defIdx <= 0xFFFF )
|
||||
Selections[ static_cast<uint16_t>( defIdx ) ] = ConfigIO::ParseInt( value );
|
||||
}
|
||||
else if ( key == "Skins.music" )
|
||||
{
|
||||
pMgr->GetMusicSelection() = ConfigIO::ParseInt( value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef MH_LB
|
||||
#undef MH_LI
|
||||
#undef MH_LF
|
||||
|
||||
Reference in New Issue
Block a user