4 protected const int HINT_INDEX = -1;
5 protected const float SWITCH_TIME = 10;
7 protected int m_iHintCount;
8 protected int m_iHintIndex = -1;
9 protected float m_fTime;
10 protected TextWidget m_wText;
11 protected ResourceName m_Config =
"{CB10921F1096D4A0}Configs/UI/LoadingScreenHints.conf";
12 protected ref array<string> m_aAllHints;
13 protected ref array<string> m_aReadHints;
16 override void HandlerAttached(Widget w)
18 m_wText = TextWidget.Cast(w);
21 BaseContainer cont =
GetGame().GetGameUserSettings().GetModule(
"SCR_LoadingHints");
24 cont.Get(
"m_aReadHints", m_aReadHints);
26 m_iHintCount = m_aReadHints.Count();
29 Resource resource = BaseContainerTools.LoadContainer(m_Config);
34 BaseContainer entries = resource.GetResource().ToBaseContainer();
39 entries.Get(
"m_aHints", m_aAllHints);
46 void OnLoadingFinished()
49 UserSettings settings =
GetGame().GetGameUserSettings();
53 BaseContainer cont = settings.GetModule(
"SCR_LoadingHints");
54 if (!cont || !m_aReadHints || m_aReadHints.Count() == m_iHintCount)
57 cont.Set(
"m_aReadHints", m_aReadHints);
58 GetGame().UserSettingsChanged();
62 override void HandlerDeattached(Widget w)
70 void Update(
float timeSlice)
84 void ShowHint(
int entryIndex = -1)
86 if (!m_wText || !m_aAllHints)
95 array<string> unread = {};
96 int count = GetUnreadHints(unread);
100 int i = Math.RandomInt(0, count);
102 m_iHintIndex = m_aAllHints.Find(hint);
104 else if (entryIndex < m_aAllHints.Count())
106 hint = m_aAllHints[entryIndex];
109 m_wText.SetTextFormat(hint);
115 if (m_iHintIndex < 0 || m_iHintIndex >= m_aAllHints.Count())
118 m_aReadHints.Insert(m_aAllHints[m_iHintIndex]);
124 protected int GetUnreadHints(array<string> hints)
128 foreach (
string hint : m_aAllHints)
130 if (!m_aReadHints.Contains(hint))
135 if (hints.Count() == 0)
136 hints.InsertAll(m_aAllHints);
138 return hints.Count();