C++ ? and build fix I think

This commit is contained in:
Baoulettes 2022-05-21 17:32:05 +02:00 committed by GitHub
commit c41bb4d45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -390,7 +390,7 @@ namespace SohImGui {
} }
} }
void EnhancementRadioButton(std::string text, std::string cvarName, int id) { void EnhancementRadioButton(const char* text, const char* cvarName, int id) {
/*Usage : /*Usage :
EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); EnhancementRadioButton("My Visible Name","gMyCVarName", MyID);
First arg is the visible name of the Radio button First arg is the visible name of the Radio button
@ -401,14 +401,12 @@ namespace SohImGui {
EnhancementRadioButton("German", "gLanguages", 1); EnhancementRadioButton("German", "gLanguages", 1);
EnhancementRadioButton("French", "gLanguages", 2); EnhancementRadioButton("French", "gLanguages", 2);
*/ */
char* unique_name = (char* ) malloc(1 + strlen(text)+ strlen(cvarName)); std::string make_invisible = "##";
strcpy(unique_name, text); make_invisible += text;
strcat(unique_name, cvarName); make_invisible += cvarName;
char* non_visible_unique_name = (char* ) malloc(1 + strlen("##")+ strlen(unique_name));
strcpy(non_visible_unique_name, "##");
strcat(non_visible_unique_name, unique_name);
int val = CVar_GetS32(cvarName, 0); int val = CVar_GetS32(cvarName, 0);
if (ImGui::RadioButton(non_visible_unique_name, id == val)) { if (ImGui::RadioButton(make_invisible.c_str(), id == val)) {
CVar_SetS32(cvarName, id); CVar_SetS32(cvarName, id);
needs_save = true; needs_save = true;
} }