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

Method CallbackCustomEntities

src/game/editor/editor.cpp:226–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool CEditor::CallbackCustomEntities(const char *pFilename, int StorageType, void *pUser)
227{
228 CEditor *pEditor = (CEditor *)pUser;
229
230 char aBuf[IO_MAX_PATH_LENGTH];
231 IStorage::StripPathAndExtension(pFilename, aBuf, sizeof(aBuf));
232
233 if(std::find(pEditor->m_vSelectEntitiesFiles.begin(), pEditor->m_vSelectEntitiesFiles.end(), std::string(aBuf)) != pEditor->m_vSelectEntitiesFiles.end())
234 {
235 pEditor->ShowFileDialogError("Custom entities cannot have the same name as default entities.");
236 return false;
237 }
238
239 CImageInfo ImgInfo;
240 if(!pEditor->Graphics()->LoadPng(ImgInfo, pFilename, StorageType))
241 {
242 pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFilename);
243 return false;
244 }
245
246 pEditor->m_SelectEntitiesImage = aBuf;
247 pEditor->m_AllowPlaceUnusedTiles = EUnusedEntities::ALLOWED_IMPLICIT;
248 pEditor->m_PreventUnusedTilesWasWarned = false;
249
250 pEditor->Graphics()->UnloadTexture(&pEditor->m_EntitiesTexture);
251 pEditor->m_EntitiesTexture = pEditor->Graphics()->LoadTextureRawMove(ImgInfo, pEditor->GetTextureUsageFlag());
252
253 pEditor->OnDialogClose();
254 return true;
255}
256
257void CEditor::DoAudioPreview(CUIRect View, const void *pPlayPauseButtonId, const void *pStopButtonId, const void *pSeekBarId, int SampleId)
258{

Callers

nothing calls this directly

Calls 10

beginMethod · 0.80
endMethod · 0.80
ShowFileDialogErrorMethod · 0.80
UnloadTextureMethod · 0.80
LoadTextureRawMoveMethod · 0.80
GetTextureUsageFlagMethod · 0.80
LoadPngMethod · 0.45
GraphicsMethod · 0.45
OnDialogCloseMethod · 0.45

Tested by

no test coverage detected