C++, create a list of "ids"

Asked

Viewed 53 times

0

This is the code

if (otherpages == 2)
{
    ImGui::Columns(2, nullptr, false);
    ImGui::Checkbox("Enable Medal Changer", &Settings::MedalChanger::enabled);
    static int medal_id = 0;
    ImGui::InputInt("Medal ID", &medal_id);
    if (ImGui::Button("Add") && medal_id != 0) {
        Settings::MedalChanger::medals.insert(Settings::MedalChanger::medals.end(), medal_id);
        medal_id = 0;
    }
    ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
    ImGui::ListBoxHeader("Medal List");
    for (int m = 0; m < Settings::MedalChanger::medals.size(); m++) {
        if (ImGui::Selectable(std::to_string(Settings::MedalChanger::medals[m]).c_str())) {
            if (Settings::MedalChanger::equipped_medal == Settings::MedalChanger::medals[m]) {
                Settings::MedalChanger::equipped_medal = 0;
                Settings::MedalChanger::equipped_medal_override = false;
            }
            Settings::MedalChanger::medals.erase(Settings::MedalChanger::medals.begin() + m);
        }
    }
    ImGui::ListBoxFooter();
    ImGui::PopStyleColor();
    ImGui::Checkbox("Equipped Medal Override", &Settings::MedalChanger::equipped_medal_override);
    if (Settings::MedalChanger::equipped_medal_override) {
        static int equipped_medal = 0;
        ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
        if (ImGui::Combo("Equipped Medal", &equipped_medal, [](void* data, int idx, const char** out_text)
        {
            *out_text = std::to_string(Settings::MedalChanger::medals[idx]).c_str();
            return true;
        }, nullptr, Settings::MedalChanger::medals.size(), 5)) {
            Settings::MedalChanger::equipped_medal = Settings::MedalChanger::medals[equipped_medal];
        }
        ImGui::PopStyleColor();
    }
    if (ImGui::Button("Apply##Medals")) {
        SendClientHello();
    }

this part of the code, it does with q add numbers 0, ai click on +, 1 I wanted to instead of this already put a list with all the ids.

static int medal_id = 0;
ImGui::InputInt("Medal ID", &medal_id);
if (ImGui::Button("Add") && medal_id != 0) {
    Settings::MedalChanger::medals.insert(Settings::MedalChanger::medals.end(), medal_id);
  • If you are using a GUI library, indicate which one is and preferably meta the appropriate tag

  • I am using the Gui

  • I wanted to make a list instead of adding item by item, a list with all the ids already there only the person choose and click to add and do not stick an id at a time.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.