MCPcopy Create free account
hub / github.com/defold/defold / CompLabelCreate

Function CompLabelCreate

engine/gamesys/src/gamesys/components/comp_label.cpp:308–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306 }
307
308 dmGameObject::CreateResult CompLabelCreate(const dmGameObject::ComponentCreateParams& params)
309 {
310 LabelWorld* world = (LabelWorld*)params.m_World;
311
312 if (world->m_Components.Full())
313 {
314 ShowFullBufferError("Label", "label.max_count", world->m_Components.Capacity());
315 return dmGameObject::CREATE_RESULT_UNKNOWN_ERROR;
316 }
317
318 LabelResource* resource = (LabelResource*)params.m_Resource;
319 dmGameSystemDDF::LabelDesc* ddf = resource->m_DDF;
320
321 uint32_t index = world->m_Components.Alloc();
322 LabelComponent* component = &world->m_Components.Get(index);
323 memset(component, 0, sizeof(LabelComponent));
324 component->m_Instance = params.m_Instance;
325 component->m_Scale = params.m_Scale;
326 component->m_Position = params.m_Position;
327 component->m_Rotation = params.m_Rotation;
328 component->m_Resource = resource;
329 component->m_RenderConstants = 0;
330 component->m_ListenerInstance = 0x0;
331 component->m_ListenerComponent = 0xff;
332 component->m_ComponentIndex = params.m_ComponentIndex;
333 component->m_Enabled = 1;
334 component->m_UserAllocatedText = 0;
335
336 InitParametersFromDescription(component, ddf);
337
338 *params.m_UserData = (uintptr_t)index;
339 return dmGameObject::CREATE_RESULT_OK;
340 }
341
342 dmGameObject::CreateResult CompLabelDestroy(const dmGameObject::ComponentDestroyParams& params)
343 {

Callers

nothing calls this directly

Calls 6

ShowFullBufferErrorFunction · 0.85
AllocMethod · 0.80
FullMethod · 0.45
CapacityMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected