Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectBases/IGUIObject.cpp
Show All 20 Lines | |||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "gui/CGUISetting.h" | #include "gui/CGUISetting.h" | ||||
#include "gui/Scripting/JSInterface_GUIProxy.h" | #include "gui/Scripting/JSInterface_GUIProxy.h" | ||||
#include "js/Conversions.h" | #include "js/Conversions.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/XMB/XMBStorage.h" | |||||
#include "scriptinterface/ScriptContext.h" | #include "scriptinterface/ScriptContext.h" | ||||
#include "scriptinterface/ScriptExtraHeaders.h" | #include "scriptinterface/ScriptExtraHeaders.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "soundmanager/ISoundManager.h" | #include "soundmanager/ISoundManager.h" | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <unordered_map> | #include <unordered_map> | ||||
▲ Show 20 Lines • Show All 44 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(JS::HandleValue value) | |||||
{ | |||||
XMBData spec; | |||||
XMBStorage storage; | |||||
storage.LoadJSValue(*m_pGUI.GetScriptInterface().get(), value, "object"); | |||||
spec.Initialise(storage); | |||||
return m_pGUI.CreateChild(spec, spec.GetRoot(), this); | |||||
} | |||||
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; | |||||
// Calls RemoveChild(); | |||||
m_pGUI.DetachAndDeleteChild(child); | |||||
return true; | |||||
} | |||||
void IGUIObject::RegisterChild(IGUIObject* child) | void IGUIObject::RegisterChild(IGUIObject* child) | ||||
{ | { | ||||
child->SetParent(this); | child->SetParent(this); | ||||
m_Children.push_back(child); | m_Children.push_back(child); | ||||
} | } | ||||
void IGUIObject::UnregisterChild(IGUIObject* child) | void IGUIObject::UnregisterChild(IGUIObject* child) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator