Hello! I have writed next code:
Handler::Handler()
{
window.create(sf::VideoMode(800,600),"SpeedCuber Challenge");
window.setFramerateLimit(60);
Menu menu(window);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
menu.callback();
window.clear(sf::Color(203,201,207));
menu.draw();
window.display();
}
}
Menu::Menu(sf::RenderWindow& window): guiWindow(window)
{
stage = 0;
guiWindow.globalFont.loadFromFile("res/Font/DejaVuSans.ttf");
changeMenu();
}
void Menu::draw()
{
guiWindow.draw();
}
void Menu::callback()
{
tgui::Callback callback;
while (guiWindow.getCallback(callback))
{
#ifdef DEBUG
std::cout << callback.callbackID << "\n";
#endif
switch (callback.callbackID)
{
case 2:
{
// Make sure the button was pressed
if (callback.trigger == tgui::Callback::mouseClick)
{
++stage;
changeMenu();
exit(1);
}
break;
}
}
}
}
void Menu::changeMenu()
{
switch (stage)
{
case 0:
{
guiWindow.removeAllObjects();
tgui::Button* BTNserver = guiWindow.add<tgui::Button>();
BTNserver->load("res/Button/Black");
BTNserver->setSize(200,100);
BTNserver->setPosition(400-BTNserver->getSize().x/2,100);
BTNserver->setText("Server");
BTNserver->callbackID = 1;
tgui::Button* BTNclient = guiWindow.add<tgui::Button>();
BTNclient->load("res/Button/Black");
BTNclient->setSize(200,100);
BTNclient->setPosition(400-BTNclient->getSize().x/2,200);
BTNclient->setText("Client");
BTNclient->callbackID = 2;
break;
}
case 2:
{
guiWindow.removeAllObjects();
tgui::Label* LBLaddress = guiWindow.add<tgui::Label>();
LBLaddress->setText("Address:");
LBLaddress->setPosition(1,1);
tgui::EditBox* EDBaddress = guiWindow.add<tgui::EditBox>();
EDBaddress->load("res/EditBox/Black");
EDBaddress->setPosition(20,20);
EDBaddress->setSize(100,40);
break;
}
}
}
And can't figure out how to make the BTNclient(ID=2) to work... When I click on him doesn't happen nothing. When I click need to increment the stage and redraw another objects( changeMenu()).
The code is the sample from my 2 classes( Handler, Menu).
----
I'm on Linux and tried to install it bun when I finished and tryed the example I got error: "TGUI/TGUI.hpp can't find". So the headers(include folder) can't be finded so I verified in /usr/local/include and there was no TGUI folder with headers so I copied the folder from include and putted in /usr/local/include to can figure out the problem.