Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CGUI.cpp
Show First 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | CGUI::CGUI(const shared_ptr<ScriptRuntime>& runtime) | ||||
m_ScriptInterface->SetCallbackData(this); | m_ScriptInterface->SetCallbackData(this); | ||||
GuiScriptingInit(*m_ScriptInterface); | GuiScriptingInit(*m_ScriptInterface); | ||||
m_ScriptInterface->LoadGlobalScripts(); | m_ScriptInterface->LoadGlobalScripts(); | ||||
} | } | ||||
CGUI::~CGUI() | CGUI::~CGUI() | ||||
{ | { | ||||
Destroy(); | for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects) | ||||
delete p.second; | |||||
for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites) | |||||
delete p.second; | |||||
} | } | ||||
IGUIObject* CGUI::ConstructObject(const CStr& str) | IGUIObject* CGUI::ConstructObject(const CStr& str) | ||||
{ | { | ||||
if (m_ObjectTypes.count(str) > 0) | if (m_ObjectTypes.count(str) > 0) | ||||
return (*m_ObjectTypes[str])(*this); | return (*m_ObjectTypes[str])(*this); | ||||
// Error reporting will be handled with the nullptr return. | // Error reporting will be handled with the nullptr return. | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Z, const CRect& Rect, const CRect& UNUSED(Clipping)) | ||||
if (!Sprite) | if (!Sprite) | ||||
return; | return; | ||||
// TODO: Clipping? | // TODO: Clipping? | ||||
Sprite.Draw(*this, Rect, CellID, m_Sprites, Z); | Sprite.Draw(*this, Rect, CellID, m_Sprites, Z); | ||||
} | } | ||||
void CGUI::Destroy() | |||||
{ | |||||
// We can use the map to delete all | |||||
// now we don't want to cancel all if one Destroy fails | |||||
for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects) | |||||
{ | |||||
try | |||||
{ | |||||
p.second->Destroy(); | |||||
} | |||||
catch (PSERROR_GUI& e) | |||||
{ | |||||
UNUSED2(e); | |||||
debug_warn(L"CGUI::Destroy error"); | |||||
// TODO Gee: Handle | |||||
} | |||||
delete p.second; | |||||
} | |||||
m_pAllObjects.clear(); | |||||
for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites) | |||||
delete p.second; | |||||
m_Sprites.clear(); | |||||
m_Icons.clear(); | |||||
} | |||||
void CGUI::UpdateResolution() | void CGUI::UpdateResolution() | ||||
{ | { | ||||
// Update ALL cached | // Update ALL cached | ||||
m_BaseObject.RecurseObject(nullptr, &IGUIObject::UpdateCachedSize); | m_BaseObject.RecurseObject(nullptr, &IGUIObject::UpdateCachedSize); | ||||
} | } | ||||
void CGUI::AddObject(IGUIObject* pObject) | void CGUI::AddObject(IGUIObject* pObject) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 987 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator