SFGUI rendering issue c++

401 views Asked by At

I'm making a server menu system however when I remove all the items from the sfgui system and move on to another game state the labels from the previous game state are visible under a circumstance which I will explain in a minute, first let me show you the issue.

Server Menu: Server Menu.

Here you can see the issue: Here you can see the issue

The code for removal is as follows.

void S_ServerMenu::Exit() {
  ServerSelectWindow->Show(false);
  desktop.RemoveAll();
  desktop.Refresh();
}

However this issue only occurs on refresh of servers here is the code for refresh.

void S_ServerMenu::RefreshServers() {
  Document d;
  d.Parse<0>(LoadInServers().c_str());
  servers = ServerParser(d);
  ServerListTable->RemoveAll();
  ServerListTable->RefreshAll();
  for(int i = 0; i < servers.size(); i++) {
    auto label = sfg::Label::Create();

    label->SetText(servers[i].Name);

    MenuItem utm;
    utm.lbl = label;
    utm.index = i;
    utm.owner = this;
    label->SetAlignment(sf::Vector2f(0, 0));
    label->FontSize = 16;
    label->SetParent(ServerListTable);
    label->cont = ServerSelectWindowContainer;
    ServerListTable->Attach(label, sf::Rect<sf::Uint32>(1, i, 1, 1), sfg::Table::FILL | sfg::Table::EXPAND);

    label->GetSignal(sfg::Label::OnLeftClick).Connect(std::bind(&MenuItem::Clicked, utm));
  }
  ServerSelectWindow->RefreshAll();
}

Do any of you know how to solve this if so that would be great.

1

There are 1 answers

0
user2437820 On BEST ANSWER

I fixed this by creating a separate Desktop for each screen.