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); } }
C4Network2Res::Ref C4Network2ResList::AddByCore(const C4Network2ResCore &Core, bool fLoad) // by main thread { // already in list? C4Network2Res::Ref pRes = getRefRes(Core.getID()); if (pRes) return pRes; #ifdef C4NET2RES_LOAD_ALL // load without check (if possible) if (Core.isLoadable()) return AddLoad(Core); #endif // create new pRes = new C4Network2Res(this); // try set by core if (!pRes->SetByCore(Core, true)) { pRes.Clear(); // try load (if specified) return fLoad ? AddLoad(Core) : NULL; } // log Application.InteractiveThread.ThreadLogS("Network: Found identical %s. Not loading.", pRes->getCore().getFileName()); // add to list Add(pRes); // ok return pRes; }