Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LimitTextLength.c
Go to the documentation of this file.
1 // Generic component that limits TextWidget or RichTextWidget content length
2 class SCR_LimitTextLength : ScriptedWidgetComponent
3 {
4  [Attribute("1000")]
5  protected int m_iMaxTextLenght;
6 
7  //------------------------------------------------------------------------------------------------
8  override void HandlerAttached(Widget w)
9  {
10  LimitText(w);
11  }
12 
13  //------------------------------------------------------------------------------------------------
14  override bool OnUpdate(Widget w)
15  {
16  GetGame().GetCallqueue().CallLater(LimitText, 0, false, w);
17 
18  return true;
19  }
20 
21  //-----------------------------------------------------------------------------------
22  protected void LimitText(Widget w)
23  {
24  TextWidget textWidget = TextWidget.Cast(w);
25 
26  if (!textWidget)
27  return;
28 
29  string text = textWidget.GetText();
30 
31  // Edit text if it's too long
32  if (text.Length() > m_iMaxTextLenght)
33  {
34  text = text.Substring(0, m_iMaxTextLenght);
35  text += "...";
36  }
37 
38  textWidget.SetText(text);
39  }
40 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_LimitTextLength
Definition: SCR_LimitTextLength.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.