Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 849 Lines • ▼ Show 20 Lines | |||||
bool CGUI::GetPreDefinedColor(const CStr& name, CColor& Output) const | bool CGUI::GetPreDefinedColor(const CStr& name, CColor& Output) const | ||||
{ | { | ||||
std::map<CStr, CColor>::const_iterator cit = m_PreDefinedColors.find(name); | std::map<CStr, CColor>::const_iterator cit = m_PreDefinedColors.find(name); | ||||
if (cit == m_PreDefinedColors.end()) | if (cit == m_PreDefinedColors.end()) | ||||
return false; | return false; | ||||
Output = cit->second; | Output = cit->second; | ||||
return true; | return true; | ||||
} | } | ||||
elexis: Perhaps insert the new function here, after all functions except the XML ones. | |||||
/** | /** | ||||
* @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); | ||||
▲ Show 20 Lines • Show All 783 Lines • ▼ Show 20 Lines | else if (attr_name == "sprite_bar_vertical_over") | ||||
scrollbar.m_SpriteBarVerticalOver = attr_value; | scrollbar.m_SpriteBarVerticalOver = attr_value; | ||||
else if (attr_name == "sprite_bar_vertical_pressed") | else if (attr_name == "sprite_bar_vertical_pressed") | ||||
scrollbar.m_SpriteBarVerticalPressed = attr_value; | scrollbar.m_SpriteBarVerticalPressed = attr_value; | ||||
} | } | ||||
m_ScrollBarStyles[name] = scrollbar; | m_ScrollBarStyles[name] = scrollbar; | ||||
} | } | ||||
bool CGUI::AddIcon(const CStr& name, const CStr& sprite, const CStr& size, bool replaceExisting) | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsMaybe const CStr& strSize? vladislavbelov: Maybe `const CStr& strSize`? | |||||
{ | |||||
if (IconExists(name)) | |||||
{ | |||||
if (!replaceExisting) | |||||
return false; | |||||
m_Icons.erase(name); | |||||
} | |||||
CSize cSize; | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsAnd CSize size? vladislavbelov: And `CSize size`? | |||||
if (!GUI<CSize>::ParseString(size.FromUTF8(), cSize)) | |||||
{ | |||||
LOGERROR("Error parsing '%s' (\"%s\") inside <icon>.", name, size); | |||||
return false; | |||||
} | |||||
m_Icons[name].m_Size = cSize; | |||||
m_Icons[name].m_SpriteName = sprite; | |||||
return true; | |||||
} | |||||
void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) | void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) | ||||
{ | { | ||||
SGUIIcon icon; | SGUIIcon icon; | ||||
CStr name; | CStr name; | ||||
for (XMBAttribute attr : Element.GetAttributes()) | for (XMBAttribute attr : Element.GetAttributes()) | ||||
{ | { | ||||
CStr attr_name(pFile->GetAttributeString(attr.Name)); | CStr attr_name(pFile->GetAttributeString(attr.Name)); | ||||
Show All 22 Lines | else if (attr_name == "cell_id") | ||||
else | else | ||||
icon.m_CellID = cell_id; | icon.m_CellID = cell_id; | ||||
} | } | ||||
else | 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; | ||||
} | } | ||||
elexisAuthorUnsubmitted Done Inline Actions
See above function. elexis: > Test Plan:
> Compare with the XML loading Icon code to see that this code does the same
See… | |||||
void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) | void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) | ||||
{ | { | ||||
IGUIObject* object = new CTooltip; | IGUIObject* object = new CTooltip; | ||||
for (XMBAttribute attr : Element.GetAttributes()) | for (XMBAttribute attr : Element.GetAttributes()) | ||||
{ | { | ||||
CStr attr_name(pFile->GetAttributeString(attr.Name)); | CStr attr_name(pFile->GetAttributeString(attr.Name)); | ||||
Show All 32 Lines |
Wildfire Games · Phabricator
Perhaps insert the new function here, after all functions except the XML ones.