Сделай слайдер красивее #include "../menu.h" #include "../../config_vars.h" using…
- User
Сделай слайдер красивее
#include "../menu.h" #include "../../config_vars.h"
using namespace ImGui;
static const char* patch_formant_string_float_to_int( const char* fmt ) { if ( fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0 ) // Fast legacy path for "%.0f" which is expected to be the most common case. return "%d"; const char* fmt_start = ImParseFormatFindStart( fmt ); // Find % ( if any, and ignore %% ) const char* fmt_end = ImParseFormatFindEnd( fmt_start ); // Find end of format specifier, which itself is an exercise of confidence/recklessness ( because snprintf is dependent on libc or user ). if ( fmt_end > fmt_start && fmt_end[-1] == 'f' ) { if ( fmt_start == fmt && fmt_end[0] == 0 ) return ( "%d" ); ImGuiContext& g = *GImGui; ImFormatString( g.TempBuffer, IM_ARRAYSIZE( g.TempBuffer ), ( "%.*s%%d%s" ), ( int )( fmt_start - fmt ), fmt, fmt_end ); // Honor leading and trailing decorations, but lose alignment/precision. return g.TempBuffer; } return fmt; }
bool c_menu::slider_scalar( const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power ) { return false; }
bool c_menu::slider_int(const char* label, int* v, int v_min, int v_max, const char* format, float power) { return ImGui::SliderInt( label, v, v_min, v_max, format ); }
- Assistant
bool c_menu::slider_int(const char* label, int* v, int v_min, int v_max, const char* format, float power) { return ImGui::SliderInt(label, v, v_min, v_max, patch_formant_string_float_to_int(format)); }