MCPcopy Create free account
hub / github.com/ddnet/ddnet / CallbackSaveImage

Method CallbackSaveImage

src/game/editor/editor.cpp:186–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186bool CEditor::CallbackSaveImage(const char *pFilename, int StorageType, void *pUser)
187{
188 dbg_assert(StorageType == IStorage::TYPE_SAVE, "Saving only allowed for IStorage::TYPE_SAVE");
189
190 CEditor *pEditor = static_cast<CEditor *>(pUser);
191
192 std::shared_ptr<CEditorImage> pImg = pEditor->Map()->SelectedImage();
193
194 if(CImageLoader::SavePng(pEditor->Storage()->OpenFile(pFilename, IOFLAG_WRITE, StorageType), pFilename, *pImg))
195 {
196 pEditor->OnDialogClose();
197 return true;
198 }
199 else
200 {
201 pEditor->ShowFileDialogError("Failed to write image to file '%s'.", pFilename);
202 return false;
203 }
204}
205
206bool CEditor::CallbackSaveSound(const char *pFilename, int StorageType, void *pUser)
207{

Callers

nothing calls this directly

Calls 6

SelectedImageMethod · 0.80
ShowFileDialogErrorMethod · 0.80
MapMethod · 0.45
OpenFileMethod · 0.45
StorageMethod · 0.45
OnDialogCloseMethod · 0.45

Tested by

no test coverage detected