mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
delete folder
This commit is contained in:
parent
164aac4db2
commit
b06efa2d13
@ -208,7 +208,6 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
|
||||
case ESelectionScreen::saveGame:
|
||||
positionsToShow = 16;
|
||||
tabTitle = "{" + CGI->generaltexth->arraytxt[231] + "}";
|
||||
tabTitleDelete = "{red|" + CGI->generaltexth->translate("vcmi.lobby.deleteSaveGameTitle") + "}";
|
||||
break;
|
||||
case ESelectionScreen::campaignList:
|
||||
tabTitle = "{" + CGI->generaltexth->allTexts[726] + "}";
|
||||
@ -232,7 +231,7 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
|
||||
sortByDate->setOverlay(std::make_shared<CPicture>(ImagePath::builtin("lobby/selectionTabSortDate")));
|
||||
buttonsSortBy.push_back(sortByDate);
|
||||
|
||||
if(tabType == ESelectionScreen::loadGame || tabType == ESelectionScreen::saveGame || tabType == ESelectionScreen::newGame)
|
||||
if(tabType == ESelectionScreen::loadGame || tabType == ESelectionScreen::newGame)
|
||||
{
|
||||
buttonDeleteMode = std::make_shared<CButton>(Point(367, 18), AnimationPath::builtin("lobby/deleteButton"), CButton::tooltip("", CGI->generaltexth->translate("vcmi.lobby.deleteMode")), [this, tabTitle, tabTitleDelete](){
|
||||
deleteMode = !deleteMode;
|
||||
@ -343,8 +342,6 @@ void SelectionTab::clickReleased(const Point & cursorPosition)
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
@ -352,6 +349,13 @@ void SelectionTab::clickReleased(const Point & cursorPosition)
|
||||
ld.name = curItems[py]->fileURI;
|
||||
CSH->sendLobbyPack(ld);
|
||||
}, nullptr);
|
||||
else
|
||||
CInfoWindow::showYesNoDialog(CGI->generaltexth->translate("vcmi.lobby.deleteFolder") + "\n\n" + curFolder + curItems[py]->folderName, std::vector<std::shared_ptr<CComponent>>(), [this, py](){
|
||||
LobbyDelete ld;
|
||||
ld.type = LobbyDelete::SAVEGAME_FOLDER;
|
||||
ld.name = curFolder + curItems[py]->folderName;
|
||||
CSH->sendLobbyPack(ld);
|
||||
}, nullptr);
|
||||
}
|
||||
}
|
||||
#ifdef VCMI_MOBILE
|
||||
|
@ -447,6 +447,14 @@ void ApplyOnServerNetPackVisitor::visitLobbyDelete(LobbyDelete & pack)
|
||||
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);
|
||||
if(boost::filesystem::is_empty(file.parent_path()))
|
||||
boost::filesystem::remove(file.parent_path());
|
||||
}
|
||||
else if(pack.type == LobbyDelete::SAVEGAME_FOLDER)
|
||||
{
|
||||
auto res = ResourcePath("Saves/" + pack.name, EResType::DIRECTORY);
|
||||
auto folder = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(res));
|
||||
boost::filesystem::remove_all(folder);
|
||||
}
|
||||
|
||||
LobbyUpdateState lus;
|
||||
|
Loading…
Reference in New Issue
Block a user