Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectBases/IGUIObject.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | for (const std::pair<const CStr, IGUISetting*>& p : m_Settings) | ||||
delete p.second; | delete p.second; | ||||
if (!m_ScriptHandlers.empty()) | if (!m_ScriptHandlers.empty()) | ||||
JS_RemoveExtraGCRootsTracer(m_pGUI.GetScriptInterface()->GetGeneralJSContext(), Trace, this); | JS_RemoveExtraGCRootsTracer(m_pGUI.GetScriptInterface()->GetGeneralJSContext(), Trace, this); | ||||
// m_Children is deleted along all other GUI Objects in the CGUI destructor | // m_Children is deleted along all other GUI Objects in the CGUI destructor | ||||
} | } | ||||
IGUIObject* IGUIObject::CreateChild(const CParamNode& node) | |||||
{ | |||||
std::vector<std::pair<CStr, CStr>> nameSubst; | |||||
return m_pGUI.CreateChildFromParamNode(node, this, nameSubst, 0); | |||||
} | |||||
bool IGUIObject::DeleteChild(IGUIObject* child) | |||||
{ | |||||
// Don't delete someone else's child. | |||||
std::vector<IGUIObject*>::iterator it = std::find(m_Children.begin(), m_Children.end(), child); | |||||
if (it == m_Children.end()) | |||||
return false; | |||||
m_pGUI.DetachAndDeleteChild(child); | |||||
return true; | |||||
} | |||||
void IGUIObject::AddChild(IGUIObject& pChild) | void IGUIObject::AddChild(IGUIObject& pChild) | ||||
{ | { | ||||
pChild.SetParent(this); | pChild.SetParent(this); | ||||
m_Children.push_back(&pChild); | m_Children.push_back(&pChild); | ||||
} | } | ||||
void IGUIObject::RemoveChild(IGUIObject& pChild) | |||||
{ | |||||
std::vector<IGUIObject*>::iterator it = std::find(m_Children.begin(), m_Children.end(), &pChild); | |||||
if (it != m_Children.end()) | |||||
{ | |||||
(*it)->m_pParent = nullptr; | |||||
m_Children.erase(it); | |||||
} | |||||
} | |||||
template<typename T> | template<typename T> | ||||
void IGUIObject::RegisterSetting(const CStr& Name, T& Value) | void IGUIObject::RegisterSetting(const CStr& Name, T& Value) | ||||
{ | { | ||||
if (SettingExists(Name)) | if (SettingExists(Name)) | ||||
LOGERROR("The setting '%s' already exists on the object '%s'!", Name.c_str(), GetPresentableName().c_str()); | LOGERROR("The setting '%s' already exists on the object '%s'!", Name.c_str(), GetPresentableName().c_str()); | ||||
else | else | ||||
m_Settings.emplace(Name, new CGUISetting<T>(*this, Name, Value)); | m_Settings.emplace(Name, new CGUISetting<T>(*this, Name, Value)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 483 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator