Вопрос ImGui::Listbox перегрузка хуй пойми че

Начинающий
Статус
Оффлайн
Регистрация
2 Июн 2022
Сообщения
30
Реакции[?]
2
Поинты[?]
2K
Хочу сделать лист бокс из списка чамсов и менять их в игре. В imgui demo взял код, пытался чето выпкнуть сам. По итогу чат гпт насрал мне этот код, но у меня идет перегрузка.

chams.cpp:
void __stdcall hooks::DrawModel(
    void* results,
    const CDrawModelInfo& info,
    CMatrix3x4* bones,
    float* flexWeights,
    float* flexDelayedWeights,
    const CVector& modelOrigin,
    const int32_t flags
) noexcept
{
    if (globals::localPlayer && info.renderable) {
        CEntity* entity = info.renderable->GetIClientUnknown()->GetBaseEntity();

        if (Functional::Chams::chams) {
            if (entity && entity->IsPlayer() && entity->GetTeam() != globals::localPlayer->GetTeam()) {

                static IMaterial* material = interfaces::materialSystem->FindMaterial(Functional::Chams::items[Functional::Chams::chamsName]);

                // при изменении помещать в глобалы
                constexpr float hidden[3] = { 1.06f, 0.38f, 1.73f };
                const float visible[3] = { 1.06f, 0.38f, 1.73f };

                interfaces::studioRender->SetAlphaModulation(1.f); // прозрачность

                // show thr walls
                material->SetMaterialVarFlag(IMaterial::IGNOREZ, true);
                interfaces::studioRender->SetColorModulation(hidden);
                interfaces::studioRender->ForcedMaterialOverride(material);
                DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

                // dnt show thr walls
                material->SetMaterialVarFlag(IMaterial::IGNOREZ, false);
                interfaces::studioRender->SetColorModulation(visible);
                interfaces::studioRender->ForcedMaterialOverride(material);
                DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

                return interfaces::studioRender->ForcedMaterialOverride(nullptr);
            }
        }
    }

    DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);
}
gui.cpp:
            case 3:
                ImGui::Checkbox("Chams", &Functional::Chams::chams);
                if (Functional::Chams::chams) {                   
                    static int item_current = 2;
                    ImGui::ListBox("Type chams", &item_current, Functional::Chams::items[Functional::Chams::chamsName], IM_ARRAYSIZE(Functional::Chams::items[Functional::Chams::chamsName]), 4);
                }
                break;
vars.h:
namespace Chams {
        inline bool chams = false;
        //inline const char* chamsName = "models/inventory_items/trophy_majors/crystal_blue";
        inline int chamsName = 0;
        inline const char* items[] = {
            "models/inventory_items/trophy_majors/gold",
            "models/gibs/glass/glass",
            "models/inventory_items/trophy_majors/gloss",
            "vgui/achievements/glow",
            "models/inventory_items/wildfire_gold/wildfire_gold_detail",
            "models/inventory_items/trophy_majors/velvet",
            "models/inventory_items/trophy_majors/crystal_blue",
        };
    }
1681223513091.png
 
Эксперт
Статус
Оффлайн
Регистрация
30 Дек 2019
Сообщения
1,967
Реакции[?]
958
Поинты[?]
19K
menu:
C++:
const char* items_name[] = { "Solid", "Material", "Metal", "Glow", "Outline" };
ImGui::Combo( "Chams materials", &g_Configs.ChamsMaterial, items_name, IM_ARRAYSIZE( items_name ) );
config:
C++:
int ChamsMaterial = 0;
chams:
C++:
static int LastMaterial = false;
IMaterial* Material = nullptr;
if ( LastMaterial != g_Configs.ChamsMaterial ) {
    Material = Interfaces::MaterialSystem->FindMaterial( "material name" );
    LastMaterial = g_Configs.ChamsMaterial;
}

if ( Material != nullptr ) {
    Draw chams
}
 
Начинающий
Статус
Оффлайн
Регистрация
2 Июн 2022
Сообщения
30
Реакции[?]
2
Поинты[?]
2K
menu:
C++:
const char* items_name[] = { "Solid", "Material", "Metal", "Glow", "Outline" };
ImGui::Combo( "Chams materials", &g_Configs.ChamsMaterial, items_name, IM_ARRAYSIZE( items_name ) );
config:
C++:
int ChamsMaterial = 0;
chams:
C++:
static int LastMaterial = false;
IMaterial* Material = nullptr;
if ( LastMaterial != g_Configs.ChamsMaterial ) {
    Material = Interfaces::MaterialSystem->FindMaterial( "material name" );
    LastMaterial = g_Configs.ChamsMaterial;
}

if ( Material != nullptr ) {
    Draw chams
}
нихуя не поменялось
1681247894837.png

hooks.cpp:
void __stdcall hooks::DrawModel(
    void* results,
    const CDrawModelInfo& info,
    CMatrix3x4* bones,
    float* flexWeights,
    float* flexDelayedWeights,
    const CVector& modelOrigin,
    const int32_t flags
) noexcept
{
    if (globals::localPlayer && info.renderable) {
        CEntity* entity = info.renderable->GetIClientUnknown()->GetBaseEntity();

        if (Functional::Chams::chams) {
            if (entity && entity->IsPlayer() && entity->GetTeam() != globals::localPlayer->GetTeam()) {

                static IMaterial* material = interfaces::materialSystem->FindMaterial(Functional::Chams::items[Functional::Chams::selected_material]);

                // при изменении помещать в глобалы
                constexpr float hidden[3] = { 1.06f, 0.38f, 1.73f };
                const float visible[3] = { 1.06f, 0.38f, 1.73f };

                interfaces::studioRender->SetAlphaModulation(1.f); // прозрачность

                // show thr walls
                material->SetMaterialVarFlag(IMaterial::IGNOREZ, true);
                interfaces::studioRender->SetColorModulation(hidden);
                interfaces::studioRender->ForcedMaterialOverride(material);
                DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

                // dnt show thr walls
                material->SetMaterialVarFlag(IMaterial::IGNOREZ, false);
                interfaces::studioRender->SetColorModulation(visible);
                interfaces::studioRender->ForcedMaterialOverride(material);
                DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

                return interfaces::studioRender->ForcedMaterialOverride(nullptr);
            }
        }
    }

    DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);
}
vars.h:
namespace Chams {
        inline bool chams = false;
        //inline const char* chamsName = "models/inventory_items/trophy_majors/crystal_blue";
        inline int chamsName = 0;
        inline const char* items[] = {
            "models/inventory_items/trophy_majors/gold",
            "models/gibs/glass/glass",
            "models/inventory_items/trophy_majors/gloss",
            "vgui/achievements/glow",
            "models/inventory_items/wildfire_gold/wildfire_gold_detail",
            "models/inventory_items/trophy_majors/velvet",
            "models/inventory_items/trophy_majors/crystal_blue",
        };
        inline static int selected_material = 0;
    }
gui.cpp:
            case 3:
                ImGui::Checkbox("Chams", &Functional::Chams::chams);
                if (Functional::Chams::chams) {                  
                   
                    ImGui::Combo("Chams materials", &Functional::Chams::selected_material, Functional::Chams::items, IM_ARRAYSIZE(Functional::Chams::items));
                }
                break;
 
Эксперт
Статус
Оффлайн
Регистрация
30 Дек 2019
Сообщения
1,967
Реакции[?]
958
Поинты[?]
19K
нихуя не поменялось
Посмотреть вложение 244500

hooks.cpp:
void __stdcall hooks::DrawModel(
    void* results,
    const CDrawModelInfo& info,
    CMatrix3x4* bones,
    float* flexWeights,
    float* flexDelayedWeights,
    const CVector& modelOrigin,
    const int32_t flags
) noexcept
{
    if (globals::localPlayer && info.renderable) {
        CEntity* entity = info.renderable->GetIClientUnknown()->GetBaseEntity();

        if (Functional::Chams::chams) {
            if (entity && entity->IsPlayer() && entity->GetTeam() != globals::localPlayer->GetTeam()) {

                static IMaterial* material = interfaces::materialSystem->FindMaterial(
[CODE]static int LastMaterial = false;
IMaterial* Material = nullptr;
if ( LastMaterial != Functional::Chams::selected_material ) {
    Material = Interfaces::MaterialSystem->FindMaterial( Functional::Chams::items[Functional::Chams::selected_material] );
    LastMaterial = Functional::Chams::selected_material;
}
);

// при изменении помещать в глобалы
constexpr float hidden[3] = { 1.06f, 0.38f, 1.73f };
const float visible[3] = { 1.06f, 0.38f, 1.73f };

interfaces::studioRender->SetAlphaModulation(1.f); // прозрачность

// show thr walls
material->SetMaterialVarFlag(IMaterial::IGNOREZ, true);
interfaces::studioRender->SetColorModulation(hidden);
interfaces::studioRender->ForcedMaterialOverride(material);
DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

// dnt show thr walls
material->SetMaterialVarFlag(IMaterial::IGNOREZ, false);
interfaces::studioRender->SetColorModulation(visible);
interfaces::studioRender->ForcedMaterialOverride(material);
DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);

return interfaces::studioRender->ForcedMaterialOverride(nullptr);
}
}
}

DrawModelOriginal(interfaces::studioRender, results, info, bones, flexWeights, flexDelayedWeights, modelOrigin, flags);
}[/CODE]

vars.h:
namespace Chams {
        inline bool chams = false;
        //inline const char* chamsName = "models/inventory_items/trophy_majors/crystal_blue";
        inline int chamsName = 0;
        inline const char* items[] = {
            "models/inventory_items/trophy_majors/gold",
            "models/gibs/glass/glass",
            "models/inventory_items/trophy_majors/gloss",
            "vgui/achievements/glow",
            "models/inventory_items/wildfire_gold/wildfire_gold_detail",
            "models/inventory_items/trophy_majors/velvet",
            "models/inventory_items/trophy_majors/crystal_blue",
        };
        inline static int selected_material = 0;
    }
gui.cpp:
            case 3:
                ImGui::Checkbox("Chams", &Functional::Chams::chams);
                if (Functional::Chams::chams) {              
               
                    ImGui::Combo("Chams materials", &Functional::Chams::selected_material, Functional::Chams::items, IM_ARRAYSIZE(Functional::Chams::items));
                }
                break;
так у тебя материал это статик переменная, проверяй на изменение и меняй отдельно like this:
C++:
static int LastMaterial = 0;
if ( LastMaterial != Functional::Chams::selected_material ) {
    Material = Interfaces::MaterialSystem->FindMaterial( Functional::Chams::items[Functional::Chams::selected_material] );
    LastMaterial = Functional::Chams::selected_material;
}
вообще, лучше 1 раз, где нибудь в мейне, собери все материла, а уже потом их черз свитч выбирай
 
Сверху Снизу