Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | CGUI::CGUI(const shared_ptr<ScriptRuntime>& runtime) | ||||
: m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0) | : m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0) | ||||
{ | { | ||||
m_ScriptInterface.reset(new ScriptInterface("Engine", "GUIPage", runtime)); | m_ScriptInterface.reset(new ScriptInterface("Engine", "GUIPage", runtime)); | ||||
m_ScriptInterface->SetCallbackData(this); | m_ScriptInterface->SetCallbackData(this); | ||||
GuiScriptingInit(*m_ScriptInterface); | GuiScriptingInit(*m_ScriptInterface); | ||||
m_ScriptInterface->LoadGlobalScripts(); | m_ScriptInterface->LoadGlobalScripts(); | ||||
m_BaseObject = new CGUIDummyObject(this); | m_BaseObject = CGUIDummyObject::ConstructObject(this); | ||||
} | } | ||||
CGUI::~CGUI() | CGUI::~CGUI() | ||||
{ | { | ||||
Destroy(); | Destroy(); | ||||
if (m_BaseObject) | if (m_BaseObject) | ||||
delete m_BaseObject; | delete m_BaseObject; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, int CellID, const float& Z, const CRect& Rect, const CRect& UNUSED(Clipping)) | ||||
// TODO: Clipping? | // TODO: Clipping? | ||||
Sprite.Draw(Rect, CellID, m_Sprites, Z); | Sprite.Draw(Rect, CellID, m_Sprites, Z); | ||||
} | } | ||||
void CGUI::Destroy() | 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) | 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; | delete p.second; | ||||
} | |||||
m_pAllObjects.clear(); | m_pAllObjects.clear(); | ||||
for (const std::pair<CStr, CGUISprite*>& p : m_Sprites) | for (const std::pair<CStr, CGUISprite*>& p : m_Sprites) | ||||
delete p.second; | delete p.second; | ||||
m_Sprites.clear(); | m_Sprites.clear(); | ||||
m_Icons.clear(); | m_Icons.clear(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,328 Lines • ▼ Show 20 Lines | else | ||||
debug_warn(L"Invalid data - DTD shouldn't allow this"); | debug_warn(L"Invalid data - DTD shouldn't allow this"); | ||||
} | } | ||||
m_Icons[name] = icon; | m_Icons[name] = icon; | ||||
} | } | ||||
void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) | void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) | ||||
{ | { | ||||
IGUIObject* object = new CTooltip(this); | IGUIObject* object = CTooltip::ConstructObject(this); | ||||
for (XMBAttribute attr : Element.GetAttributes()) | for (XMBAttribute attr : Element.GetAttributes()) | ||||
{ | { | ||||
CStr attr_name(pFile->GetAttributeString(attr.Name)); | CStr attr_name(pFile->GetAttributeString(attr.Name)); | ||||
CStr attr_value(attr.Value); | CStr attr_value(attr.Value); | ||||
if (attr_name == "name") | if (attr_name == "name") | ||||
object->SetName("__tooltip_" + attr_value); | object->SetName("__tooltip_" + attr_value); | ||||
Show All 28 Lines |
Wildfire Games · Phabricator