void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite) { // get associated resource C4Network2Res::Ref pRes = GetRefRes(); if (!pRes) return; const char *szResFile = pRes->getFile(); StdCopyStrBuf strErrCopyFile(LoadResStr("IDS_NET_ERR_COPYFILE")); if (!pRes->isTempFile()) { GetScreen()->ShowMessage(LoadResStr("IDS_NET_ERR_COPYFILE_LOCAL"), strErrCopyFile.getData(), C4GUI::Ico_Error); return; } const char *szFilename = GetFilename(pRes->getCore().getFileName()); /* const char *szSpecialPath = ""; if (WildcardMatch(C4CFN_PlayerFiles, szFilename)) // write players to player path szSpecialPath = Config.General.PlayerPath; */ const char *szTarget = Config.AtUserDataPath(szFilename); if (!fDoOverwrite && ItemExists(szTarget)) { // show a confirmation dlg, asking whether the resource should be overwritten GetScreen()->ShowRemoveDlg(new C4GUI::ConfirmationDialog( FormatString(LoadResStr("IDS_NET_RES_SAVE_OVERWRITE"), GetFilename(szTarget)).getData(), LoadResStr("IDS_NET_RES_SAVE"), new C4GUI::CallbackHandler<C4Network2ResDlg::ListItem>(this, &C4Network2ResDlg::ListItem::OnButtonSaveConfirm), C4GUI::MessageDialog::btnYesNo)); return; } if (!C4Group_CopyItem(szResFile, szTarget)) GetScreen()->ShowMessage(strErrCopyFile.getData(), strErrCopyFile.getData(), C4GUI::Ico_Error); else { GetScreen()->ShowMessage(FormatString(LoadResStr("IDS_NET_RES_SAVED_DESC"), GetFilename(szTarget)).getData(), LoadResStr("IDS_NET_RES_SAVED"), C4GUI::Ico_Save); } }
bool C4Network2ResDlg::ListItem::IsSavePossible() { // check resource bool fCanSave = false; C4Network2Res::Ref pRes = GetRefRes(); if (!pRes) return false; // temp files from network folder only if (pRes->isTempFile()) { // check type C4Network2ResType eType = pRes->getType(); if ((eType == NRT_Player && Config.Lobby.AllowPlayerSave) || eType == NRT_Scenario || eType == NRT_Definitions) // check complete if (!pRes->isLoading()) // save OK fCanSave = true; } return fCanSave; }