Hello! Firstly sorry for my bad english.
Recently I try to make a menu build with a identical panel but with differents position.y like a "list of panel".
Like that:

Here is the loop that I built the menu:
But the problem is that I don't know how to handle all the buttons because I would each buttons call a same function but with diferent arguments. I tried many times to use callbacks but it's the first time I have to use.
On the tutorial I saw this:
I don't even know if my way to is good. If someone know a better way to make that kind of menu I enjoy him to tell it to me.
Thanks to read! (and sorry again for my frenchi enhlish :/)
Recently I try to make a menu build with a identical panel but with differents position.y like a "list of panel".
Like that:

Here is the loop that I built the menu:
Code Select
for(int i=0;i<_worlds.size();i++)
{
tgui::Panel::Ptr panel;
panel->setSize(390, 130);
panel->setPosition(100, /*(i * 130) +*/ 10);
tgui::Label::Ptr label(*panel);
label->load("Resources/Gui/test/test.conf");
label->setTextFont(*ResourcesManager::LoadFont("Orbitron-Regular.ttf"));
label->setText(_worlds[i]);
label->setPosition(10, 10);
label->setTextColor(sf::Color::Blue);
tgui::Button::Ptr playButton(*panel);
playButton->load("Resources/Gui/test/test.conf");
playButton->setTextFont(*ResourcesManager::LoadFont("Orbitron-Regular.ttf"));
playButton->setPosition(60, 60);
playButton->setSize(130, 30);
playButton->setText(Lang::GetWord("worldselection.gui.play"));
int id = 0;
playButton->bindCallback(/*Here I don't know what to type*/);
tgui::Button::Ptr deleteButton(*panel);
deleteButton->load("Resources/Gui/test/test.conf");
deleteButton->setTextFont(*ResourcesManager::LoadFont("Orbitron-Regular.ttf"));
deleteButton->setPosition(200, 60);
deleteButton->setSize(130, 30);
deleteButton->setText(Lang::GetWord("worldselection.gui.delete"));
deleteButton->bindCallback(/*Here either*/);
deleteButton->setCallbackId(2);
_gui.add(panel, std::string("panel_" + Util::toString(i)));
}
But the problem is that I don't know how to handle all the buttons because I would each buttons call a same function but with diferent arguments. I tried many times to use callbacks but it's the first time I have to use.
On the tutorial I saw this:
QuoteUntil now, the functions did not have any parameters. But you can technically use any function to which you have bound parameters.But I never seen std::bind or std::ref before.Code Selectvoid function(tgui::Gui& gui);
button->bindCallback(std::bind(function, std::ref(gui)), tgui::CheckBox::Checked | tgui::CheckBox::Unchecked);
I don't even know if my way to is good. If someone know a better way to make that kind of menu I enjoy him to tell it to me.
Thanks to read! (and sorry again for my frenchi enhlish :/)