void dskLAN::UpdateServerList() { ReadOpenGames(); ctrlTable* servertable = GetCtrl<ctrlTable>(tblServerId); unsigned int selection = servertable->GetSelection(); if(selection == 0xFFFF) selection = 0; unsigned short column = servertable->GetSortColumn(); if(column == 0xFFFF) column = 0; bool direction = servertable->GetSortDirection(); servertable->DeleteAllItems(); unsigned curId = 0; for(std::vector<GameInfo>::const_iterator it = openGames.begin(); it != openGames.end(); ++it) { std::string id = boost::lexical_cast<std::string>(curId++); std::string name = (it->info.hasPwd ? "(pwd) " : "") + it->info.name; //-V807 std::string player = boost::lexical_cast<std::string>(static_cast<unsigned>(it->info.curPlayer)) + "/"+ boost::lexical_cast<std::string>(static_cast<unsigned>(it->info.maxPlayer)); servertable->AddRow(0, id.c_str(), name.c_str(), it->info.map.c_str(), player.c_str(), it->info.version.c_str()); } servertable->SortRows(column, &direction); servertable->SetSelection(selection); }
void dskLAN::UpdateServerList() { ReadOpenGames(); auto* servertable = GetCtrl<ctrlTable>(ID_tblServer); unsigned selection = servertable->GetSelection(); if(selection == 0xFFFF) selection = 0; unsigned short column = servertable->GetSortColumn(); if(column == 0xFFFF) column = 0; bool direction = servertable->GetSortDirection(); servertable->DeleteAllItems(); unsigned curId = 0; for(const auto& gameInfo : openGames) { std::string id = helpers::toString(curId++); std::string name = (gameInfo.info.hasPwd ? "(pwd) " : "") + gameInfo.info.name; //-V807 std::string player = helpers::toString(gameInfo.info.curNumPlayers) + "/" + helpers::toString(gameInfo.info.maxNumPlayers); servertable->AddRow(0, id.c_str(), name.c_str(), gameInfo.info.map.c_str(), player.c_str(), gameInfo.info.version.c_str()); } servertable->SortRows(column, &direction); servertable->SetSelection(selection); }