Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show All 37 Lines | |||||
#include "ps/Globals.h" | #include "ps/Globals.h" | ||||
#include "ps/Hotkey.h" | #include "ps/Hotkey.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "scriptinterface/ScriptContext.h" | #include "scriptinterface/ScriptContext.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
vladislavbelov: It’s bad to have a simulation dependency in GUI without a reason, move the header to some… | |||||
#include <string> | #include <string> | ||||
#include <unordered_map> | #include <unordered_map> | ||||
#include <unordered_set> | #include <unordered_set> | ||||
extern int g_yres; | extern int g_yres; | ||||
const double SELECT_DBLCLICK_RATE = 0.5; | const double SELECT_DBLCLICK_RATE = 0.5; | ||||
const u32 MAX_OBJECT_DEPTH = 100; // Max number of nesting for GUI includes. Used to detect recursive inclusion | const u32 MAX_OBJECT_DEPTH = 100; // Max number of nesting for GUI includes. Used to detect recursive inclusion | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | IGUIObject* CGUI::ConstructObject(const CStr& str) | ||||
std::map<CStr, ConstructObjectFunction>::iterator it = m_ObjectTypes.find(str); | std::map<CStr, ConstructObjectFunction>::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)(*this); | ||||
} | } | ||||
IGUIObject* CGUI::CreateChild(const XMBData& file, const XMBElement& element, IGUIObject* parent) | |||||
{ | |||||
std::unordered_set<VfsPath> paths; | |||||
std::vector<std::pair<CStr, CStr>> nameSubst; | |||||
IGUIObject* child = Xeromyces_ReadObject(file, element, parent, nameSubst, paths, 0); | |||||
if (!child) | |||||
return nullptr; | |||||
child->RecurseObject(nullptr, &IGUIObject::UpdateCachedSize); | |||||
SGUIMessage msg(GUIM_LOAD); | |||||
child->RecurseObject(nullptr, &IGUIObject::HandleMessage, msg); | |||||
child->ScriptEvent(EventNameLoad); | |||||
return child; | |||||
} | |||||
void CGUI::DetachAndDeleteChild(IGUIObject* child) | |||||
{ | |||||
if (!child) | |||||
return; | |||||
if (!child->m_pParent) | |||||
{ | |||||
LOGERROR("Cannot delete the root object of a page"); | |||||
return; | |||||
} | |||||
child->m_pParent->UnregisterChild(child); | |||||
m_pAllObjects.erase(child->m_Name); | |||||
delete child; | |||||
} | |||||
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 948 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
It’s bad to have a simulation dependency in GUI without a reason, move the header to some common place.