1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

refresh list

This commit is contained in:
Laserlicht 2024-11-01 00:52:19 +01:00
parent 38c25cd13e
commit 164aac4db2
5 changed files with 23 additions and 6 deletions

View File

@ -226,7 +226,7 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState &
else
lobby->updateAfterStateChange();
if(pack.hostChanged)
if(pack.hostChanged || pack.refreshList)
lobby->toggleMode(handler.isHost());
}

View File

@ -262,10 +262,10 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
void SelectionTab::toggleMode()
{
allItems.clear();
curItems.clear();
if(CSH->isGuest())
{
allItems.clear();
curItems.clear();
if(slider)
slider->block(true);
}
@ -344,6 +344,14 @@ void SelectionTab::clickReleased(const Point & cursorPosition)
}
std::cout << (curItems[py]->isFolder ? curItems[py]->folderName : curItems[py]->fullFileURI) << "\n";
if(!curItems[py]->isFolder)
CInfoWindow::showYesNoDialog(CGI->generaltexth->translate("vcmi.lobby.deleteFile") + "\n\n" + curItems[py]->fullFileURI, std::vector<std::shared_ptr<CComponent>>(), [this, py](){
LobbyDelete ld;
ld.type = tabType == ESelectionScreen::newGame ? LobbyDelete::RANDOMMAP : LobbyDelete::SAVEGAME;
ld.name = curItems[py]->fileURI;
CSH->sendLobbyPack(ld);
}, nullptr);
}
}
#ifdef VCMI_MOBILE

View File

@ -170,12 +170,15 @@ struct DLL_LINKAGE LobbyUpdateState : public CLobbyPackToPropagate
{
LobbyState state;
bool hostChanged = false; // Used on client-side only
bool refreshList = false;
void visitTyped(ICPackVisitor & visitor) override;
template <typename Handler> void serialize(Handler &h)
{
h & state;
if (h.version >= Handler::Version::LOBBY_DELETE)
h & refreshList;
}
};

View File

@ -65,6 +65,7 @@ enum class ESerializationVersion : int32_t
LOCAL_PLAYER_STATE_DATA, // 866 - player state contains arbitrary client-side data
REMOVE_TOWN_PTR, // 867 - removed pointer to CTown from CGTownInstance
REMOVE_OBJECT_TYPENAME, // 868 - remove typename from CGObjectInstance
LOBBY_DELETE, // 869 - possibility to delete savegames and random maps
CURRENT = REMOVE_OBJECT_TYPENAME
CURRENT = LOBBY_DELETE
};

View File

@ -442,10 +442,15 @@ void ClientPermissionsCheckerNetPackVisitor::visitLobbyDelete(LobbyDelete & pack
void ApplyOnServerNetPackVisitor::visitLobbyDelete(LobbyDelete & pack)
{
if(pack.type == LobbyDelete::SAVEGAME)
if(pack.type == LobbyDelete::SAVEGAME || pack.type == LobbyDelete::RANDOMMAP)
{
auto res = ResourcePath(pack.name, EResType::SAVEGAME);
auto res = ResourcePath(pack.name, pack.type == LobbyDelete::SAVEGAME ? EResType::SAVEGAME : EResType::MAP);
auto file = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(res));
boost::filesystem::remove(file);
}
LobbyUpdateState lus;
lus.state = srv;
lus.refreshList = true;
srv.announcePack(lus);
}