Начинающий
-
Автор темы
- #1
So i am trying to add a skin changer to the source but it is not showing in the menu what am i doing wrong?
it is for the fixed legendware.
it is for the fixed legendware.
Код:
else if (visual_tab == 2)
{
tab_start("Inventory", column_1, 0, size_a_x, size_a_y);
{
ImGui::TabName(crypt_str("Skins"));
// hey stewen, what r u doing there? he, hm heee, DRUGS
static bool drugs = false;
// some animation logic(switch)
static bool active_animation = false;
static bool preview_reverse = false;
static float switch_alpha = 1.f;
static int next_id = -1;
if (active_animation)
{
if (preview_reverse)
{
if (switch_alpha == 1.f) //-V550
{
preview_reverse = false;
active_animation = false;
}
switch_alpha = math::clamp(switch_alpha + (4.f * ImGui::GetIO().DeltaTime), 0.01f, 1.f);
}
else
{
if (switch_alpha == 0.01f) //-V550
{
preview_reverse = true;
}
switch_alpha = math::clamp(switch_alpha - (4.f * ImGui::GetIO().DeltaTime), 0.01f, 1.f);
}
}
else
switch_alpha = math::clamp(switch_alpha + (4.f * ImGui::GetIO().DeltaTime), 0.0f, 1.f);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, (1.f - preview_alpha) * public_alpha * switch_alpha);
child_title(current_profile == -1 ? crypt_str("Skinchanger") : game_data::weapon_names[current_profile].name);
ImGui::Spacing();
ImGui::BeginChild(crypt_str("##SKINCHANGER__CHILD"), ImVec2(586 * dpi_scale, (child_height - 35) * dpi_scale));
{
// we need to count our items in 1 line
auto same_line_counter = 0;
// if we didnt choose any weapon
if (current_profile == -1)
{
for (auto i = 0; i < g_cfg.skins.skinChanger.size(); i++)
{
// do we need update our preview for some reasons?
if (!all_skins[i])
{
g_cfg.skins.skinChanger.at(i).update();
all_skins[i] = get_skin_preview(get_wep(i, (i == 0 || i == 1) ? g_cfg.skins.skinChanger.at(i).definition_override_vector_index : -1, i == 0).c_str(), g_cfg.skins.skinChanger.at(i).skin_name, device); //-V810
}
// we licked on weapon
if (ImGui::ImageButton(all_skins[i], ImVec2(87, 76)))
{
next_id = i;
active_animation = true;
}
// if our animation step is half from all - switch profile
if (active_animation && preview_reverse)
{
ImGui::SetScrollY(0);
current_profile = next_id;
}
if (same_line_counter < 4) { // continue push same-line
ImGui::SameLine();
same_line_counter++;
}
else { // we have maximum elements in 1 line
same_line_counter = 0;
}
}
}
else
{
// update skin preview bool
static bool need_update[36];
// we pressed crypt_str("Save & Close") button
static bool leave;
// update if we have nullptr texture or if we push force update
if (!all_skins[current_profile] || need_update[current_profile])
{
all_skins[current_profile] = get_skin_preview(get_wep(current_profile, (current_profile == 0 || current_profile == 1) ? g_cfg.skins.skinChanger.at(current_profile).definition_override_vector_index : -1, current_profile == 0).c_str(), g_cfg.skins.skinChanger.at(current_profile).skin_name, device); //-V810
need_update[current_profile] = false;
}
// get settings for selected weapon
auto& selected_entry = g_cfg.skins.skinChanger[current_profile];
selected_entry.itemIdIndex = current_profile;
ImGui::BeginGroup();
ImGui::PushItemWidth(260 * dpi_scale);
// search input later
static char search_skins[64] = "\0";
static auto item_index = selected_entry.paint_kit_vector_index;
if (!current_profile)
{
ImGui::Text(crypt_str("Knife"));
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 5 * c_menu::get().dpi_scale);
if (ImGui::Combo(crypt_str("##Knife_combo"), &selected_entry.definition_override_vector_index, [](void* data, int idx, const char** out_text)
{
*out_text = game_data::knife_names[idx].name;
return true;
}, nullptr, IM_ARRAYSIZE(game_data::knife_names)))
need_update[current_profile] = true; // push force update
}
else if (current_profile == 1)
{
ImGui::Text(crypt_str("Gloves"));
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 5 * c_menu::get().dpi_scale);
if (ImGui::Combo(crypt_str("##Glove_combo"), &selected_entry.definition_override_vector_index, [](void* data, int idx, const char** out_text)
{
*out_text = game_data::glove_names[idx].name;
return true;
}, nullptr, IM_ARRAYSIZE(game_data::glove_names)))
{
item_index = 0; // set new generated paintkits element to 0;
need_update[current_profile] = true; // push force update
}
}
else
selected_entry.definition_override_vector_index = 0;
if (current_profile != 1)
{
ImGui::Text(crypt_str("Search"));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (ImGui::InputText(crypt_str("##search"), search_skins, sizeof(search_skins)))
item_index = -1;
ImGui::PopStyleVar();
}
auto main_kits = current_profile == 1 ? SkinChanger::gloveKits : SkinChanger::skinKits;
auto display_index = 0;
SkinChanger::displayKits = main_kits;
// we dont need custom gloves
if (current_profile == 1)
{
for (auto i = 0; i < main_kits.size(); i++)
{
auto main_name = main_kits.at(i).name;
for (auto i = 0; i < main_name.size(); i++)
if (iswalpha((main_name.at(i))))
main_name.at(i) = towlower(main_name.at(i));
char search_name[64];
if (!strcmp(game_data::glove_names[selected_entry.definition_override_vector_index].name, crypt_str("Hydra")))
strcpy_s(search_name, sizeof(search_name), crypt_str("Bloodhound"));
else
strcpy_s(search_name, sizeof(search_name), game_data::glove_names[selected_entry.definition_override_vector_index].name);
for (auto i = 0; i < sizeof(search_name); i++)
if (iswalpha(search_name[i]))
search_name[i] = towlower(search_name[i]);
if (main_name.find(search_name) != std::string::npos)
{
SkinChanger::displayKits.at(display_index) = main_kits.at(i);
display_index++;
}
}
SkinChanger::displayKits.erase(SkinChanger::displayKits.begin() + display_index, SkinChanger::displayKits.end());
}
else
{
if (strcmp(search_skins, crypt_str(""))) //-V526
{
for (auto i = 0; i < main_kits.size(); i++)
{
auto main_name = main_kits.at(i).name;
for (auto i = 0; i < main_name.size(); i++)
if (iswalpha(main_name.at(i)))
main_name.at(i) = towlower(main_name.at(i));
char search_name[64];
strcpy_s(search_name, sizeof(search_name), search_skins);
for (auto i = 0; i < sizeof(search_name); i++)
if (iswalpha(search_name[i]))
search_name[i] = towlower(search_name[i]);
if (main_name.find(search_name) != std::string::npos)
{
SkinChanger::displayKits.at(display_index) = main_kits.at(i);
display_index++;
}
}
SkinChanger::displayKits.erase(SkinChanger::displayKits.begin() + display_index, SkinChanger::displayKits.end());
}
else
item_index = selected_entry.paint_kit_vector_index;
}
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (!SkinChanger::displayKits.empty())
{
if (ImGui::ListBox(crypt_str("##PAINTKITS"), &item_index, [](void* data, int idx, const char** out_text) //-V107
{
//while (SkinChanger::displayKits.at(idx).name.find(crypt_str("С‘")) != std::string::npos) //-V807
// SkinChanger::displayKits.at(idx).name.replace(SkinChanger::displayKits.at(idx).name.find(crypt_str("С‘")), 2, crypt_str("Рµ"));
*out_text = SkinChanger::displayKits.at(idx).name.c_str();
return true;
}, nullptr, SkinChanger::displayKits.size(), SkinChanger::displayKits.size() > 9 ? 9 : SkinChanger::displayKits.size()) || !all_skins[current_profile])
{
SkinChanger::scheduleHudUpdate();
need_update[current_profile] = true;
auto i = 0;
while (i < main_kits.size())
{
if (main_kits.at(i).id == SkinChanger::displayKits.at(item_index).id)
{
selected_entry.paint_kit_vector_index = i;
break;
}
i++;
}
}
}
ImGui::PopStyleVar();
if (ImGui::InputInt(crypt_str("Seed"), &selected_entry.seed, 1, 5000))
SkinChanger::scheduleHudUpdate();
if (ImGui::InputInt(crypt_str("StatTrak"), &selected_entry.stat_trak, 1, 15))
SkinChanger::scheduleHudUpdate();
if (ImGui::SliderFloat(crypt_str("Wear"), &selected_entry.wear, 0.0f, 1.0f))
drugs = true;
else if (drugs)
{
SkinChanger::scheduleHudUpdate();
drugs = false;
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 6 * c_menu::get().dpi_scale);
ImGui::Text(crypt_str("Quality"));
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 5 * c_menu::get().dpi_scale);
if (ImGui::Combo(crypt_str("##Quality_combo"), &selected_entry.entity_quality_vector_index, [](void* data, int idx, const char** out_text)
{
*out_text = game_data::quality_names[idx].name;
return true;
}, nullptr, IM_ARRAYSIZE(game_data::quality_names)))
SkinChanger::scheduleHudUpdate();
if (current_profile != 1)
{
if (!g_cfg.skins.custom_name_tag[current_profile].empty())
strcpy_s(selected_entry.custom_name, sizeof(selected_entry.custom_name), g_cfg.skins.custom_name_tag[current_profile].c_str());
ImGui::Text(crypt_str("Name Tag"));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (ImGui::InputText(crypt_str("##nametag"), selected_entry.custom_name, sizeof(selected_entry.custom_name)))
{
g_cfg.skins.custom_name_tag[current_profile] = selected_entry.custom_name;
SkinChanger::scheduleHudUpdate();
}
ImGui::PopStyleVar();
}
ImGui::PopItemWidth();
ImGui::EndGroup();
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 30);
ImGui::BeginGroup();
if (ImGui::ImageButton(all_skins[current_profile], ImVec2(190, 155)))
{
// maybe i will do smth later where, who knows :/
}
if (ImGui::CustomButton(crypt_str("Close"), crypt_str("##CLOSE__SKING"), ImVec2(198 * dpi_scale, 26 * dpi_scale)))
{
// start animation
active_animation = true;
next_id = -1;
leave = true;
}
ImGui::Checkbox(crypt_str("Force rare animations"), &g_cfg.skins.rare_animations);
ImGui::EndGroup();
// update element
selected_entry.update();
// we need to reset profile in the end to prevent render images with massive's index == -1
if (leave && (preview_reverse || !active_animation))
{
ImGui::SetScrollY(0);
current_profile = next_id;
leave = false;
}
}
}
ImGui::EndChild();
//tab_end();
}
tab_end();
}
}