mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
code review
This commit is contained in:
parent
0f94f35dcf
commit
b23c69b9d6
@ -348,14 +348,14 @@ void SelectionTab::clickReleased(const Point & cursorPosition)
|
||||
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.type = tabType == ESelectionScreen::newGame ? LobbyDelete::EType::RANDOMMAP : LobbyDelete::EType::SAVEGAME;
|
||||
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.type = LobbyDelete::EType::SAVEGAME_FOLDER;
|
||||
ld.name = curFolder + curItems[py]->folderName;
|
||||
CSH->sendLobbyPack(ld);
|
||||
}, nullptr);
|
||||
@ -935,7 +935,7 @@ std::vector<ResourcePath> SelectionTab::parseSaves(const std::unordered_set<Reso
|
||||
return unsupported;
|
||||
}
|
||||
|
||||
void SelectionTab::handleUnsupportedSavegames(const std::vector<ResourcePath> files)
|
||||
void SelectionTab::handleUnsupportedSavegames(const std::vector<ResourcePath> & files)
|
||||
{
|
||||
if(CSH->isHost() && files.size())
|
||||
{
|
||||
@ -945,7 +945,7 @@ void SelectionTab::handleUnsupportedSavegames(const std::vector<ResourcePath> fi
|
||||
for(auto & file : files)
|
||||
{
|
||||
LobbyDelete ld;
|
||||
ld.type = LobbyDelete::SAVEGAME;
|
||||
ld.type = LobbyDelete::EType::SAVEGAME;
|
||||
ld.name = file.getName();
|
||||
CSH->sendLobbyPack(ld);
|
||||
}
|
||||
|
@ -133,5 +133,5 @@ private:
|
||||
void parseCampaigns(const std::unordered_set<ResourcePath> & files);
|
||||
std::unordered_set<ResourcePath> getFiles(std::string dirURI, EResType resType);
|
||||
|
||||
void handleUnsupportedSavegames(const std::vector<ResourcePath> files);
|
||||
void handleUnsupportedSavegames(const std::vector<ResourcePath> & files);
|
||||
};
|
||||
|
@ -385,11 +385,11 @@ struct DLL_LINKAGE LobbyPvPAction : public CLobbyPackToServer
|
||||
|
||||
struct DLL_LINKAGE LobbyDelete : public CLobbyPackToServer
|
||||
{
|
||||
enum EType : ui8 {
|
||||
enum class EType : ui8 {
|
||||
SAVEGAME, SAVEGAME_FOLDER, RANDOMMAP
|
||||
};
|
||||
|
||||
EType type = SAVEGAME;
|
||||
EType type = EType::SAVEGAME;
|
||||
std::string name;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
@ -442,15 +442,15 @@ void ClientPermissionsCheckerNetPackVisitor::visitLobbyDelete(LobbyDelete & pack
|
||||
|
||||
void ApplyOnServerNetPackVisitor::visitLobbyDelete(LobbyDelete & pack)
|
||||
{
|
||||
if(pack.type == LobbyDelete::SAVEGAME || pack.type == LobbyDelete::RANDOMMAP)
|
||||
if(pack.type == LobbyDelete::EType::SAVEGAME || pack.type == LobbyDelete::EType::RANDOMMAP)
|
||||
{
|
||||
auto res = ResourcePath(pack.name, pack.type == LobbyDelete::SAVEGAME ? EResType::SAVEGAME : EResType::MAP);
|
||||
auto res = ResourcePath(pack.name, pack.type == LobbyDelete::EType::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)
|
||||
else if(pack.type == LobbyDelete::EType::SAVEGAME_FOLDER)
|
||||
{
|
||||
auto res = ResourcePath("Saves/" + pack.name, EResType::DIRECTORY);
|
||||
auto folder = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(res));
|
||||
|
Loading…
Reference in New Issue
Block a user