Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
std::map<CStr, const SGUIScrollBarStyle>::const_iterator it = m_ScrollBarStyles.find(style); | std::map<CStr, const SGUIScrollBarStyle>::const_iterator it = m_ScrollBarStyles.find(style); | ||||
if (it == m_ScrollBarStyles.end()) | if (it == m_ScrollBarStyles.end()) | ||||
return nullptr; | return nullptr; | ||||
return &it->second; | return &it->second; | ||||
} | } | ||||
bool CGUI::GetPreDefinedColor(const CStr& name, CGUIColor& Output) const | |||||
{ | |||||
std::map<CStr, CGUIColor>::const_iterator cit = m_PreDefinedColors.find(name); | |||||
if (cit == m_PreDefinedColors.end()) | |||||
return false; | |||||
Output = cit->second; | |||||
return true; | |||||
} | |||||
/** | /** | ||||
* @callgraph | * @callgraph | ||||
*/ | */ | ||||
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths) | void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths) | ||||
{ | { | ||||
Paths.insert(Filename); | Paths.insert(Filename); | ||||
CXeromyces XeroFile; | CXeromyces XeroFile; | ||||
▲ Show 20 Lines • Show All 610 Lines • ▼ Show 20 Lines | else if (attr_name == "z_level") | ||||
float z_level; | float z_level; | ||||
if (!GUI<float>::ParseString(this, attr_value, z_level)) | if (!GUI<float>::ParseString(this, attr_value, z_level)) | ||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | ||||
else | else | ||||
Image->m_DeltaZ = z_level/100.f; | Image->m_DeltaZ = z_level/100.f; | ||||
} | } | ||||
else if (attr_name == "backcolor") | else if (attr_name == "backcolor") | ||||
{ | { | ||||
CGUIColor color; | if (!GUI<CGUIColor>::ParseString(this, attr_value, Image->m_BackColor)) | ||||
if (!GUI<CGUIColor>::ParseString(this, attr_value, color)) | |||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | ||||
else | |||||
Image->m_BackColor = color; | |||||
} | } | ||||
else if (attr_name == "bordercolor") | else if (attr_name == "bordercolor") | ||||
{ | { | ||||
CGUIColor color; | if (!GUI<CGUIColor>::ParseString(this, attr_value, Image->m_BorderColor)) | ||||
if (!GUI<CGUIColor>::ParseString(this, attr_value, color)) | |||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | ||||
else | |||||
Image->m_BorderColor = color; | |||||
} | } | ||||
else if (attr_name == "border") | else if (attr_name == "border") | ||||
{ | { | ||||
bool b; | bool b; | ||||
if (!GUI<bool>::ParseString(this, attr_value, b)) | if (!GUI<bool>::ParseString(this, attr_value, b)) | ||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); | ||||
else | else | ||||
Image->m_Border = b; | Image->m_Border = b; | ||||
Show All 26 Lines | |||||
void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImageEffects& effects) | void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImageEffects& effects) | ||||
{ | { | ||||
for (XMBAttribute attr : Element.GetAttributes()) | for (XMBAttribute attr : Element.GetAttributes()) | ||||
{ | { | ||||
CStr attr_name(pFile->GetAttributeString(attr.Name)); | CStr attr_name(pFile->GetAttributeString(attr.Name)); | ||||
if (attr_name == "add_color") | if (attr_name == "add_color") | ||||
{ | { | ||||
CGUIColor color; | if (!effects.m_AddColor.ParseString(this, attr.Value, 0)) | ||||
if (!color.ParseString(this, attr.Value, 0)) | |||||
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr.Value); | LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr.Value); | ||||
else effects.m_AddColor = color; | |||||
} | } | ||||
else if (attr_name == "grayscale") | else if (attr_name == "grayscale") | ||||
effects.m_Greyscale = true; | effects.m_Greyscale = true; | ||||
else | else | ||||
debug_warn(L"Invalid data - DTD shouldn't allow this"); | debug_warn(L"Invalid data - DTD shouldn't allow this"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) | ||||
} | } | ||||
AddObject(object); | AddObject(object); | ||||
} | } | ||||
void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile) | void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile) | ||||
{ | { | ||||
XMBAttributeList attributes = Element.GetAttributes(); | XMBAttributeList attributes = Element.GetAttributes(); | ||||
CGUIColor color; | |||||
CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name")); | CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name")); | ||||
// Try parsing value | // Try parsing value | ||||
CStr value(Element.GetText()); | CStr value(Element.GetText()); | ||||
if (value.empty()) | if (value.empty()) | ||||
return; | return; | ||||
// Try setting color to value | CColor color; | ||||
if (!color.ParseString(this, value)) | if (color.ParseString(value)) | ||||
{ | { | ||||
LOGERROR("GUI: Unable to create custom color '%s'. Invalid color syntax.", name.c_str()); | m_PreDefinedColors.erase(name); | ||||
return; | m_PreDefinedColors.emplace( | ||||
std::piecewise_construct, | |||||
std::forward_as_tuple(name), | |||||
std::forward_as_tuple(color.r, color.g, color.b, color.a)); | |||||
} | } | ||||
else | |||||
m_PreDefinedColors[name] = color; | LOGERROR("GUI: Unable to create custom color '%s'. Invalid color syntax.", name.c_str()); | ||||
} | } |
Wildfire Games · Phabricator