Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Z, const CRect& Rect, const CRect& UNUSED(Clipping)) | ||||
Sprite.Draw(*this, Rect, CellID, m_Sprites, Z); | Sprite.Draw(*this, Rect, CellID, m_Sprites, Z); | ||||
} | } | ||||
void CGUI::UpdateResolution() | void CGUI::UpdateResolution() | ||||
{ | { | ||||
m_BaseObject.RecurseObject(nullptr, &IGUIObject::UpdateCachedSize); | m_BaseObject.RecurseObject(nullptr, &IGUIObject::UpdateCachedSize); | ||||
} | } | ||||
void CGUI::AddObjectType(const CStr& str, ConstructObjectFunction pFunc, std::unique_ptr<JSI_GUI::GUIObjectFactory>&& JSFactory) | |||||
{ | |||||
m_ObjectTypes.emplace(str, ObjectFactory{ pFunc, std::move(JSFactory) }); | |||||
} | |||||
IGUIObject* CGUI::ConstructObject(const CStr& str) | IGUIObject* CGUI::ConstructObject(const CStr& str) | ||||
{ | { | ||||
std::map<CStr, ConstructObjectFunction>::iterator it = m_ObjectTypes.find(str); | std::map<CStr, ObjectFactory>::iterator it = m_ObjectTypes.find(str); | ||||
if (it == m_ObjectTypes.end()) | if (it == m_ObjectTypes.end()) | ||||
return nullptr; | return nullptr; | ||||
return (*it->second)(*this); | return (*it->second.constructObject)(*this); | ||||
} | |||||
JSObject* CGUI::ConstructJSObject(const CStr& str) | |||||
{ | |||||
std::map<CStr, ObjectFactory>::iterator it = m_ObjectTypes.find(str); | |||||
if (it == m_ObjectTypes.end()) | |||||
return nullptr; | |||||
return it->second.guiObjectFactory->CreateObject(m_ScriptInterface->GetContext()); | |||||
} | } | ||||
bool CGUI::AddObject(IGUIObject& parent, IGUIObject& child) | bool CGUI::AddObject(IGUIObject& parent, IGUIObject& child) | ||||
{ | { | ||||
if (child.m_Name.empty()) | if (child.m_Name.empty()) | ||||
{ | { | ||||
LOGERROR("Can't register an object without name!"); | LOGERROR("Can't register an object without name!"); | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 952 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator