GuiElement#textColor | string [optional] Normal state text color, defaults to white [1, 1, 1, 1]. Format: "[r] [g] [b] [a]" where each value is in the range of [0.0, 1.0]. The first three values represent red, green and blue color channels and the last is the alpha (translucency) value. When setting this property in guiProfiles.xml, preset values as defined at the top of that file may also be used. |
GuiElement#textSelectedColor | string [optional] Selected state color, works like #textColor. |
GuiElement#text2SelectedColor | string [optional] Selected state shadow color, works like #textColor. |
GuiElement#textHighlightedColor | string [optional] Highlighted state color, works like #textColor. |
GuiElement#text2HighlightedColor | string [optional] Highlighted state shadow color, works like #textColor. |
GuiElement#textDisabledColor | string [optional] Disabled state color, works like #textColor. |
GuiElement#text2DisabledColor | string [optional] Disabled state shadow color, works like #textColor. |
GuiElement#text2Color | string [optional] Normal state shadow color, works like #textColor. |
GuiElement#textOffset | string [optional] Pixel offset of text from element origin in reference resolution, defaults to [0, 0]. Format: "[x]px [y]px" |
GuiElement#textFocusedOffset | string [optional] Pixel offset of text when focused, works like #textOffset. |
GuiElement#text2Offset | string [optional] Pixel offset of text shadow, works like #textOffset. |
GuiElement#text2FocusedOffset | string [optional] Pixel offset of text shadow when focused, works like #textOffset. |
GuiElement#textSize | string [optional] Pixel size of text in reference resolution, defaults to 0.03 * reference height. Format: "[size]px" |
GuiElement#text2Size | string [optional] Pixel size of text shadow, works like #textSize. |
GuiElement#textResizeWidth | string [optional] Pixel width of text in reference resolution, which text will be fit into if it is larger. Default is no refitting. Format: "[width]px" |
GuiElement#textMaxWidth | string [optional] Maximum pixel width of text in reference resolution after which it will be truncated. Default is no maximum. Format: "[width]px" |
GuiElement#textWrapWidth | string [optional] Maximum pixel width of text in reference resolution after which it will be wrapped around to the next line. Default is no wrapping. Requires #textMaxNumLines to also be set. Format: "[width]px" |
GuiElement#textAutoSize | boolean [optional] If set to true, the size of the elemement is updated to fit the text in its width. Useful for flow layouts |
GuiElement#textBold | bool [optional] If true, displays text in bold letters. |
GuiElement#textSelectedBold | bool [optional] If true, displays text in bold letters when selected. |
GuiElement#textHighlightedBold | bool [optional] If true, displays text in bold letters when highlighted. |
GuiElement#textUpperCase | bool [optional] If true, displays text in upper case letters. |
GuiElement#text2Bold | bool [optional] If true, displays text shadow in bold letters. |
GuiElement#text2SelectedBold | bool [optional] If true, displays text shadow in bold letters when selected. |
GuiElement#text2HighlightedBold | bool [optional] If true, displays text shadow in bold letters when highlighted. |
GuiElement#textResetSize | bool [optional] If true, resets text size when text changes. |
GuiElement#textLinesPerPage | int [optional] Number of text lines per page. |
GuiElement#textMaxNumLines | int [optional] Maximum number of lines when wrapping around to next line. Only active when #textWrapWidth is also set. |
GuiElement#textLineHeightScale | float [optional] Scale of line heights. |
GuiElement#textAlignment | string [optional] Text alignment within element borders, defaults to left alignment. Valid values are "right", "center" and "left" |
GuiElement#textVerticalAlignment | string [optional] Vertical text alignment within element borders, defaults to middle alignment. Valid values are "top", "middle", "bottom" |
GuiElement#ignoreDisabled | bool [optional] If true, will display normal state colors when disabled instead of disabled state colors. |
GuiElement#text | string [optional] Initial text value. Variable text names prefixed with "$l10n_" will be resolved to a text in the current language by the localization system. |
GuiElement#textConsole | string [optional] Initial text value override for console version. "$l10n_" prefix works here, as well. |
GuiElement#onTextChanged | callback [optional] onTextChangedCallback(self, text) Called when text is changed by setText(). Receives this element and the new text. |
267 | function TextElement:copyAttributes(src) |
268 | TextElement:superClass().copyAttributes(self, src) |
269 | self.text = src.text |
270 | |
271 | self.textColor = ListUtil.copyTable(src.textColor) |
272 | self.textSelectedColor = ListUtil.copyTable(src.textSelectedColor) |
273 | self.textHighlightedColor = ListUtil.copyTable(src.textHighlightedColor) |
274 | self.textDisabledColor = ListUtil.copyTable(src.textDisabledColor) |
275 | self.text2Color = ListUtil.copyTable(src.text2Color) |
276 | self.text2SelectedColor = ListUtil.copyTable(src.text2SelectedColor) |
277 | self.text2HighlightedColor = ListUtil.copyTable(src.text2HighlightedColor) |
278 | self.text2DisabledColor = ListUtil.copyTable(src.text2DisabledColor) |
279 | self.textSize = src.textSize |
280 | self.textOffset = ListUtil.copyTable(src.textOffset) |
281 | self.textFocusedOffset = ListUtil.copyTable(src.textFocusedOffset) |
282 | self.text2Size = src.text2Size |
283 | self.text2Offset = ListUtil.copyTable(src.text2Offset) |
284 | self.text2FocusedOffset = ListUtil.copyTable(src.text2FocusedOffset) |
285 | self.textResizeWidth = src.textResizeWidth |
286 | self.textMaxWidth = src.textMaxWidth |
287 | self.textWrapWidth = src.textWrapWidth |
288 | self.ignoreDisabled = src.ignoreDisabled |
289 | self.textAutoSize = src.textAutoSize |
290 | |
291 | self.textResetSize = src.textResetSize |
292 | self.textBold = src.textBold |
293 | self.textSelectedBold = src.textSelectedBold |
294 | self.textHighlightedBold = src.textHighlightedBold |
295 | self.text2Bold = src.text2Bold |
296 | self.text2SelectedBold = src.text2SelectedBold |
297 | self.text2HighlightedBold = src.text2HighlightedBold |
298 | self.textUpperCase = src.textUpperCase |
299 | self.textLinesPerPage = src.textLinesPerPage |
300 | self.textMaxNumLines = src.textMaxNumLines |
301 | self.textAlignment = src.textAlignment |
302 | self.currentPage = src.currentPage |
303 | self.defaultTextSize = src.defaultTextSize |
304 | self.defaultText2Size = src.defaultText2Size |
305 | self.textLineHeightScale = src.textLineHeightScale |
306 | self.textVerticalAlignment = src.textVerticalAlignment |
307 | |
308 | self.onTextChangedCallback = src.onTextChangedCallback |
309 | end |
558 | function TextElement:draw() |
559 | if self:getDoRenderText() then |
560 | if self.text ~= nil and self.text ~= "" then |
561 | setTextAlignment(self.textAlignment) |
562 | setTextWrapWidth(self.textWrapWidth) |
563 | setTextLineBounds((self.currentPage - 1) * self.textLinesPerPage, self.textLinesPerPage) |
564 | setTextLineHeightScale(self.textLineHeightScale) |
565 | |
566 | local text = self.text |
567 | if self.textUpperCase then |
568 | text = utf8ToUpper(text) |
569 | end |
570 | |
571 | if self.textMaxWidth ~= nil then |
572 | text = Utils.limitTextToWidth(text, self.textSize, self.textMaxWidth, false, "...") |
573 | end |
574 | |
575 | local bold = self.textBold or (self.textSelectedBold and self:getIsSelected() or (self.textHighlightedBold and self:getIsHighlighted())) |
576 | setTextBold(bold) |
577 | |
578 | local xPos, yPos = self:getTextPosition(text) |
579 | |
580 | if self.text2Size > 0 then |
581 | local x2Offset, y2Offset = self:getText2Offset() |
582 | local bold = self.text2Bold or (self.text2SelectedBold and self:getIsSelected()) or (self.text2HighlightedBold and self:getIsHighlighted()) |
583 | setTextBold(bold) |
584 | local r,g,b,a = unpack(self:getText2Color()) |
585 | setTextColor(r,g,b,a*self.alpha) |
586 | renderText(xPos + x2Offset, yPos + y2Offset, self.text2Size, text) |
587 | end |
588 | |
589 | local r,g,b,a = unpack(self:getTextColor()) |
590 | setTextColor(r,g,b,a*self.alpha) |
591 | |
592 | local xOffset, yOffset = self:getTextOffset() |
593 | renderText(xPos + xOffset, yPos + yOffset, self.textSize, text) |
594 | |
595 | -- TODO: apply engine vertical text alignment as soon as it's exposed to script |
596 | setTextBold(false) |
597 | setTextAlignment(RenderText.ALIGN_LEFT) |
598 | setTextLineHeightScale(RenderText.DEFAULT_LINE_HEIGHT_SCALE) |
599 | setTextColor(1, 1, 1, 1) |
600 | setTextLineBounds(0, 0) |
601 | setTextWrapWidth(0) |
602 | |
603 | if self.debugEnabled or g_uiDebugEnabled then |
604 | if self.textMaxWidth ~= nil then |
605 | local yPixel = 1 / g_screenHeight |
606 | setOverlayColor(GuiElement.debugOverlay, 0, 1, 0, 1) |
607 | |
608 | local x = xPos + xOffset |
609 | if self.textAlignment == RenderText.ALIGN_RIGHT then |
610 | x = x - self.textMaxWidth |
611 | elseif self.textAlignment == RenderText.ALIGN_CENTER then |
612 | x = x - self.textMaxWidth / 2 |
613 | end |
614 | |
615 | renderOverlay(GuiElement.debugOverlay, x, yPos + yOffset, self.textMaxWidth, yPixel) |
616 | elseif self.textWrapWidth ~= 1 and self.textMaxNumLines ~= nil then |
617 | local yPixel = 1 / g_screenHeight |
618 | setOverlayColor(GuiElement.debugOverlay, 0, 1, 1, 1) |
619 | |
620 | local x = xPos + xOffset |
621 | if self.textAlignment == RenderText.ALIGN_RIGHT then |
622 | x = x - self.textWrapWidth |
623 | elseif self.textAlignment == RenderText.ALIGN_CENTER then |
624 | x = x - self.textWrapWidth / 2 |
625 | end |
626 | |
627 | renderOverlay(GuiElement.debugOverlay, x, yPos + yOffset, self.textWrapWidth, yPixel) |
628 | end |
629 | end |
630 | end |
631 | end |
632 | TextElement:superClass().draw(self) |
633 | end |
115 | function TextElement:loadFromXML(xmlFile, key) |
116 | TextElement:superClass().loadFromXML(self, xmlFile, key) |
117 | |
118 | self.textColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#textColor"), self.textColor) |
119 | self.textSelectedColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#textSelectedColor"), self.textSelectedColor) |
120 | self.text2SelectedColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#text2SelectedColor"), self.text2SelectedColor) |
121 | self.textHighlightedColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#textHighlightedColor"), self.textHighlightedColor) |
122 | self.text2HighlightedColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#text2HighlightedColor"), self.text2HighlightedColor) |
123 | self.textDisabledColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#textDisabledColor"), self.textDisabledColor) |
124 | self.text2DisabledColor = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#text2DisabledColor"), self.text2DisabledColor) |
125 | self.text2Color = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#text2Color"), self.text2Color) |
126 | |
127 | self.textOffset = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textOffset"), self.outputSize, self.textOffset) |
128 | self.textFocusedOffset = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textFocusedOffset"), self.outputSize, self.textFocusedOffset) |
129 | self.text2Offset = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#text2Offset"), self.outputSize, self.text2Offset) |
130 | self.text2FocusedOffset = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#text2FocusedOffset"), self.outputSize, self.text2FocusedOffset) |
131 | self.textSize = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textSize"), {self.outputSize[2]}, {self.textSize})) |
132 | self.text2Size = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#text2Size"), {self.outputSize[2]}, {self.text2Size})) |
133 | self.textResizeWidth = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textResizeWidth"), {self.outputSize[1]}, {self.textResizeWidth})) |
134 | self.textMaxWidth = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textMaxWidth"), {self.outputSize[1]}, {self.textMaxWidth})) |
135 | self.textWrapWidth = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#textWrapWidth"), {self.outputSize[1]}, {self.textWrapWidth})) |
136 | |
137 | self.textBold = Utils.getNoNil(getXMLBool(xmlFile, key.."#textBold"), self.textBold) |
138 | self.textSelectedBold = Utils.getNoNil(getXMLBool(xmlFile, key.."#textSelectedBold"), self.textSelectedBold) |
139 | self.textHighlightedBold = Utils.getNoNil(getXMLBool(xmlFile, key.."#textHighlightedBold"), self.textHighlightedBold) |
140 | self.textUpperCase = Utils.getNoNil(getXMLBool(xmlFile, key.."#textUpperCase"), self.textUpperCase) |
141 | self.text2Bold = Utils.getNoNil(getXMLBool(xmlFile, key.."#text2Bold"), self.text2Bold) |
142 | self.text2SelectedBold = Utils.getNoNil(getXMLBool(xmlFile, key.."#text2SelectedBold"), self.text2SelectedBold) |
143 | self.text2HighlightedBold = Utils.getNoNil(getXMLBool(xmlFile, key.."#text2HighlightedBold"), self.text2HighlightedBold) |
144 | self.textResetSize = Utils.getNoNil(getXMLBool(xmlFile, key.."#textResetSize"), self.textResetSize) |
145 | self.textLinesPerPage = Utils.getNoNil(getXMLInt(xmlFile, key.."#textLinesPerPage"), self.textLinesPerPage) |
146 | self.textMaxNumLines = Utils.getNoNil(getXMLInt(xmlFile, key.."#textMaxNumLines"), self.textMaxNumLines) |
147 | self.textLineHeightScale = Utils.getNoNil(getXMLFloat(xmlFile, key.."#textLineHeightScale"), self.textLineHeightScale) |
148 | self.textAutoSize = Utils.getNoNil(getXMLBool(xmlFile, key.."#textAutoSize"), self.textAutoSize) |
149 | |
150 | self.defaultTextSize = self.textSize |
151 | self.defaultText2Size = self.text2Size |
152 | |
153 | if self.textMaxNumLines ~= nil and self.textWrapWidth == nil then |
154 | print("Warning: textWrapWidth has to be set if textMaxNumLines is used.") |
155 | self.textMaxNumLines = nil |
156 | end |
157 | |
158 | local textAlignment = getXMLString(xmlFile, key.."#textAlignment") |
159 | if textAlignment ~= nil then |
160 | textAlignment = textAlignment:lower() |
161 | if textAlignment == "right" then |
162 | self.textAlignment = RenderText.ALIGN_RIGHT |
163 | elseif textAlignment == "center" then |
164 | self.textAlignment = RenderText.ALIGN_CENTER |
165 | else |
166 | self.textAlignment = RenderText.ALIGN_LEFT |
167 | end |
168 | end |
169 | |
170 | local textVerticalAlignment = getXMLString(xmlFile, key .. "#textVerticalAlignment") or "" |
171 | local verticalAlignKey = string.upper(textVerticalAlignment) |
172 | self.textVerticalAlignment = TextElement.VERTICAL_ALIGNMENT[verticalAlignKey] or self.textVerticalAlignment |
173 | |
174 | self.ignoreDisabled = Utils.getNoNil(getXMLBool(xmlFile, key.."#ignoreDisabled"), self.ignoreDisabled) |
175 | |
176 | local text = getXMLString(xmlFile, key.."#text") |
177 | if GS_IS_CONSOLE_VERSION then |
178 | local textConsole = getXMLString(xmlFile, key.."#textConsole") |
179 | if textConsole ~= nil then |
180 | text = textConsole |
181 | end |
182 | end |
183 | if text ~= nil then |
184 | local addColon = false |
185 | local length = text:len() |
186 | if text:sub(length, length + 1) == ":" then |
187 | text = text:sub(1, length - 1) |
188 | addColon = true |
189 | end |
190 | if text:sub(1,6) == "$l10n_" then |
191 | text = g_i18n:getText(text:sub(7)) |
192 | end |
193 | if addColon and text ~= "" then |
194 | text = text .. ":" |
195 | end |
196 | |
197 | self:setText(text, false, true) |
198 | end |
199 | |
200 | self:addCallback(xmlFile, key.."#onTextChanged", "onTextChangedCallback") |
201 | self:updateSize() |
202 | end |
206 | function TextElement:loadProfile(profile, applyProfile) |
207 | TextElement:superClass().loadProfile(self, profile, applyProfile) |
208 | |
209 | self.textColor = GuiUtils.getColorArray(profile:getValue("textColor"), self.textColor) |
210 | self.textSelectedColor = GuiUtils.getColorArray(profile:getValue("textSelectedColor"), self.textSelectedColor) |
211 | self.textHighlightedColor = GuiUtils.getColorArray(profile:getValue("textHighlightedColor"), self.textHighlightedColor) |
212 | self.textDisabledColor = GuiUtils.getColorArray(profile:getValue("textDisabledColor"), self.textDisabledColor) |
213 | self.text2Color = GuiUtils.getColorArray(profile:getValue("text2Color"), self.text2Color) |
214 | self.text2SelectedColor = GuiUtils.getColorArray(profile:getValue("text2SelectedColor"), self.text2SelectedColor) |
215 | self.text2HighlightedColor = GuiUtils.getColorArray(profile:getValue("text2HighlightedColor"), self.text2HighlightedColor) |
216 | self.text2DisabledColor = GuiUtils.getColorArray(profile:getValue("text2DisabledColor"), self.text2DisabledColor) |
217 | |
218 | self.textSize = unpack(GuiUtils.getNormalizedValues(profile:getValue("textSize"), {self.outputSize[2]}, {self.textSize})) |
219 | self.textOffset = GuiUtils.getNormalizedValues(profile:getValue("textOffset"), self.outputSize, self.textOffset) |
220 | self.textFocusedOffset = GuiUtils.getNormalizedValues(profile:getValue("textFocusedOffset"), self.outputSize, {self.textOffset[1], self.textOffset[2]}) |
221 | self.text2Size = unpack(GuiUtils.getNormalizedValues(profile:getValue("text2Size"), {self.outputSize[2]}, {self.text2Size})) |
222 | self.text2Offset = GuiUtils.getNormalizedValues(profile:getValue("text2Offset"), self.outputSize, self.text2Offset) |
223 | self.text2FocusedOffset = GuiUtils.getNormalizedValues(profile:getValue("text2FocusedOffset"), self.outputSize, {self.text2Offset[1], self.text2Offset[2]}) |
224 | self.textResizeWidth = unpack(GuiUtils.getNormalizedValues(profile:getValue("textResizeWidth"), {self.outputSize[1]}, {self.textResizeWidth})) |
225 | self.textMaxWidth = unpack(GuiUtils.getNormalizedValues(profile:getValue("textMaxWidth"), {self.outputSize[1]}, {nil})) |
226 | self.textWrapWidth = unpack(GuiUtils.getNormalizedValues(profile:getValue("textWrapWidth"), {self.outputSize[1]}, {1})) |
227 | |
228 | self.textResetSize = profile:getBool("textResetSize", self.textResetSize) |
229 | self.textBold = profile:getBool("textBold", self.textBold) |
230 | self.textSelectedBold = profile:getBool("textSelectedBold", self.textSelectedBold) |
231 | self.textHighlightedBold = profile:getBool("textHighlightedBold", self.textHighlightedBold) |
232 | self.text2Bold = profile:getBool("text2Bold", self.text2Bold) |
233 | self.text2SelectedBold = profile:getBool("text2SelectedBold", self.text2SelectedBold) |
234 | self.text2HighlightedBold = profile:getBool("text2HighlightedBold", self.text2HighlightedBold) |
235 | self.textUpperCase = profile:getBool("textUpperCase", self.textUpperCase) |
236 | self.textLinesPerPage = profile:getNumber("textLinesPerPage", self.textLinesPerPage) |
237 | self.textMaxNumLines = profile:getNumber("textMaxNumLines", self.textMaxNumLines) |
238 | self.textLineHeightScale = profile:getNumber("textLineHeightScale", self.textLineHeightScale) |
239 | self.textAutoSize = profile:getBool("textAutoSize", self.textAutoSize) |
240 | |
241 | self.ignoreDisabled = profile:getBool("ignoreDisabled", self.ignoreDisabled) |
242 | |
243 | local textAlignment = profile:getValue("textAlignment") |
244 | if textAlignment ~= nil then |
245 | textAlignment = textAlignment:lower() |
246 | if textAlignment == "right" then |
247 | self.textAlignment = RenderText.ALIGN_RIGHT |
248 | elseif textAlignment == "center" then |
249 | self.textAlignment = RenderText.ALIGN_CENTER |
250 | else |
251 | self.textAlignment = RenderText.ALIGN_LEFT |
252 | end |
253 | end |
254 | |
255 | local textVerticalAlignment = profile:getValue("textVerticalAlignment", "") |
256 | local verticalAlignKey = string.upper(textVerticalAlignment) |
257 | self.textVerticalAlignment = TextElement.VERTICAL_ALIGNMENT[verticalAlignKey] or self.textVerticalAlignment |
258 | |
259 | if applyProfile then |
260 | self:applyTextAspectScale() |
261 | self:updateSize() |
262 | end |
263 | end |
67 | function TextElement:new(target, custom_mt) |
68 | if custom_mt == nil then |
69 | custom_mt = TextElement_mt |
70 | end |
71 | local self = GuiElement:new(target, custom_mt) |
72 | |
73 | self.textColor = {1, 1, 1, 1} |
74 | self.textDisabledColor = {0.5, 0.5, 0.5, 1} |
75 | self.textSelectedColor = {1, 1, 1, 1} |
76 | self.textHighlightedColor = {1, 1, 1, 1} |
77 | self.textOffset = {0,0} |
78 | self.textFocusedOffset = {0,0} |
79 | self.textSize = 0.03 |
80 | self.textBold = false |
81 | self.textSelectedBold = false |
82 | self.textHighlightedBold = false |
83 | self.text2Color = {1, 1, 1, 1} |
84 | self.text2DisabledColor = {1, 1, 1, 0} |
85 | self.text2SelectedColor = {0, 0, 0, 0.5} |
86 | self.text2HighlightedColor = {0, 0, 0, 0.5} |
87 | self.text2Offset = {0,0} |
88 | self.text2FocusedOffset = {0,0} |
89 | self.text2Size = 0 |
90 | self.text2Bold = false |
91 | self.text2SelectedBold = false |
92 | self.text2HighlightedBold = false |
93 | self.textUpperCase = false |
94 | self.textLinesPerPage = 0 |
95 | self.currentPage = 1 |
96 | self.textResetSize = false |
97 | self.defaultTextSize = self.textSize |
98 | self.defaultText2Size = self.text2Size |
99 | self.textLineHeightScale = RenderText.DEFAULT_LINE_HEIGHT_SCALE |
100 | self.text = "" |
101 | self.textAlignment = RenderText.ALIGN_CENTER |
102 | self.textVerticalAlignment = TextElement.VERTICAL_ALIGNMENT.MIDDLE |
103 | self.ignoreDisabled = false |
104 | self.textAutoSize = false |
105 | |
106 | self.textMaxWidth = nil |
107 | self.textResizeWidth = nil |
108 | self.textWrapWidth = 1 |
109 | |
110 | return self |
111 | end |
356 | function TextElement:setText(text, forceTextSize, isInitializing) |
357 | text = tostring(text) |
358 | if self.textUpperCase then |
359 | text = utf8ToUpper(text) |
360 | end |
361 | |
362 | local leftover = nil |
363 | if self.textMaxNumLines ~= nil and self.textWrapWidth ~= nil then |
364 | setTextWrapWidth(self.textWrapWidth) |
365 | local l = getTextLength(self.textSize, text, self.textMaxNumLines) |
366 | setTextWrapWidth(0) |
367 | leftover = utf8Substr(text, l) |
368 | text = utf8Substr(text, 0, l) |
369 | end |
370 | |
371 | local textHasChanged = self.text ~= text |
372 | self.text = text |
373 | |
374 | if self.textResetSize then |
375 | self.textSize = self.defaultTextSize |
376 | self.text2Size = self.defaultText2Size |
377 | end |
378 | |
379 | if self.textResizeWidth ~= nil then |
380 | while self:getTextWidth() > self.textResizeWidth and self.textSize > self.defaultTextSize*0.1 do |
381 | self.textSize = self.textSize - self.defaultTextSize*0.05 |
382 | self.text2Size = self.text2Size - self.defaultText2Size*0.05 |
383 | end |
384 | end |
385 | |
386 | self:raiseCallback("onTextChangedCallback", self, self.text) |
387 | if textHasChanged and not isInitializing then |
388 | self:updateScaledWidth(1, 1) |
389 | end |
390 | |
391 | self:updateSize(forceTextSize) |
392 | |
393 | return leftover |
394 | end |