Changeset View
Changeset View
Standalone View
Standalone View
source/gui/IGUIObject.cpp
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | if (aspectratio) | ||||
{ | { | ||||
float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/aspectratio; | float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/aspectratio; | ||||
m_CachedActualSize.bottom -= delta/2.f; | m_CachedActualSize.bottom -= delta/2.f; | ||||
m_CachedActualSize.top += delta/2.f; | m_CachedActualSize.top += delta/2.f; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void IGUIObject::LoadStyle(CGUI& pGUI, const CStr& StyleName) | void IGUIObject::LoadStyle(const CStr& StyleName) | ||||
{ | { | ||||
if (pGUI.HasStyle(StyleName)) | if (!m_pGUI.HasStyle(StyleName)) | ||||
LoadStyle(pGUI.GetStyle(StyleName)); | |||||
else | |||||
debug_warn(L"IGUIObject::LoadStyle failed"); | debug_warn(L"IGUIObject::LoadStyle failed"); | ||||
} | |||||
void IGUIObject::LoadStyle(const SGUIStyle& Style) | // The default style may specify settings for any GUI object type. | ||||
{ | // Other styles are reported if they specify a Setting that does not exist, | ||||
// Iterate settings, it won't be able to set them all probably, but that doesn't matter | // so that the XML author is informed that he specified a Setting that cannot be set. | ||||
for (const std::pair<CStr, CStrW>& p : Style.m_SettingsDefaults) | |||||
for (const std::pair<CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults) | |||||
{ | { | ||||
// Try set setting in object | if (SettingExists(p.first)) | ||||
SetSetting(p.first, p.second); | SetSetting(p.first, p.second); | ||||
else if (StyleName != "default") | |||||
elexis: It would be good to remove it for `default` as well, but that file is already duplicated… | |||||
// It doesn't matter if it fail, it's not suppose to be able to set every setting. | LOGWARNING("GUI object has no setting \"%s\", but the style \"%s\" defines it", p.first, StyleName.c_str()); | ||||
// since it's generic. | |||||
// The beauty with styles is that it can contain more settings | |||||
// than exists for the objects using it. So if the SetSetting | |||||
// fails, don't care. | |||||
} | } | ||||
} | } | ||||
float IGUIObject::GetBufferedZ() const | float IGUIObject::GetBufferedZ() const | ||||
{ | { | ||||
const float Z = GetSetting<float>("z"); | const float Z = GetSetting<float>("z"); | ||||
if (GetSetting<bool>("absolute")) | if (GetSetting<bool>("absolute")) | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
It would be good to remove it for default as well, but that file is already duplicated, probably needs to be moved too, so I suggest to investigate this in a separate diff, otherwide I'm in a dependency infinite loop, as this patch is also a preparation for other diffs (except for the LOGWARNING line)