Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUIText.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | void SGenerateTextImage::SetupSpriteCall( | ||||
SpriteCall.m_Sprite = TextureName; | SpriteCall.m_Sprite = TextureName; | ||||
m_YFrom = SpriteCall.m_Area.top - BufferZone; | m_YFrom = SpriteCall.m_Area.top - BufferZone; | ||||
m_YTo = SpriteCall.m_Area.bottom + BufferZone; | m_YTo = SpriteCall.m_Area.bottom + BufferZone; | ||||
m_Indentation = Size.Width + BufferZone * 2; | m_Indentation = Size.Width + BufferZone * 2; | ||||
} | } | ||||
CGUIText::CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& FontW, const float Width, const float BufferZone, const IGUIObject* pObject) | CGUIText::CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& FontW, const float Width, const float BufferZone, const EAlign align, const IGUIObject* pObject) | ||||
{ | { | ||||
if (string.m_Words.empty()) | if (string.m_Words.empty()) | ||||
return; | return; | ||||
CStrIntern Font(FontW.ToUTF8()); | CStrIntern Font(FontW.ToUTF8()); | ||||
float x = BufferZone, y = BufferZone; // drawing pointer | float x = BufferZone, y = BufferZone; // drawing pointer | ||||
int from = 0; | int from = 0; | ||||
bool FirstLine = true; // Necessary because text in the first line is shorter | bool FirstLine = true; // Necessary because text in the first line is shorter | ||||
// (it doesn't count the line spacing) | // (it doesn't count the line spacing) | ||||
// Images on the left or the right side. | // Images on the left or the right side. | ||||
SGenerateTextImages Images; | SGenerateTextImages Images; | ||||
int pos_last_img = -1; // Position in the string where last img (either left or right) were encountered. | int pos_last_img = -1; // Position in the string where last img (either left or right) were encountered. | ||||
// in order to avoid duplicate processing. | // in order to avoid duplicate processing. | ||||
// get the alignment type for the control we are computing the text for since | |||||
// we are computing the horizontal alignment in this method in order to not have | |||||
// to run through the TextCalls a second time in the CalculateTextPosition method again | |||||
EAlign align = EAlign::LEFT; | |||||
if (pObject->SettingExists("text_align")) | |||||
align = pObject->GetSetting<EAlign>("text_align"); | |||||
// Go through string word by word | // Go through string word by word | ||||
for (int i = 0; i < static_cast<int>(string.m_Words.size()) - 1; ++i) | for (int i = 0; i < static_cast<int>(string.m_Words.size()) - 1; ++i) | ||||
{ | { | ||||
// Pre-process each line one time, so we know which floating images | // Pre-process each line one time, so we know which floating images | ||||
// will be added for that line. | // will be added for that line. | ||||
// Generated stuff is stored in Feedback. | // Generated stuff is stored in Feedback. | ||||
CGUIString::SFeedback Feedback; | CGUIString::SFeedback Feedback; | ||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator