8 protected ref array<ref SCR_HintConditionList> m_aConditionLists;
13 void InitConditionLists(IEntity owner)
24 void ExitConditionLists(IEntity owner)
36 protected float m_fDefaultDuration;
38 [
Attribute(
"1",
desc:
"Mark the hint as shown only if it was display for this duration (seconds).\nIf the hint duration is shorter, mark it as shown when it's hidden.")]
39 protected float m_fPersistentDelay;
41 [
Attribute(
"0",
desc:
"When enabled, hints will be shown in this scenario even when they're disabled in game settings.\nUseful for tutorial scenarios.")]
42 protected bool m_bIgnoreHintSettings;
44 protected bool m_bIsShown;
45 protected float m_fDurationOverride;
47 protected BaseContainer m_SettingsContainer;
50 protected ref set<EHint> m_aSessionShownHints =
new set<EHint>();
51 protected ref ScriptInvokerBase<SCR_HintManagerComponent_OnHint> m_OnHintShow =
new ScriptInvokerBase<SCR_HintManagerComponent_OnHint>();
52 protected ref ScriptInvokerBase<SCR_HintManagerComponent_OnHint> m_OnHintHide =
new ScriptInvokerBase<SCR_HintManagerComponent_OnHint>();
67 if ((!
CanShow() || (!ignoreShown &&
WasShown(info))) && !info.IsInSequence())
71 if (m_bIsShown && m_LatestHint)
73 if (info.GetPriority() < m_LatestHint.GetPriority())
79 if (info.IsTimerVisible())
85 isSilent |= m_bIsShown && info == m_LatestHint;
95 m_OnHintShow.Invoke(info, isSilent);
99 if (m_fDurationOverride != 0)
100 duration = m_fDurationOverride;
102 duration = info.GetDuration();
109 duration = m_fDefaultDuration;
111 GetGame().GetCallqueue().CallLater(
Hide, duration * 1000,
false, info);
116 int type = info.GetType();
120 float delay = m_fPersistentDelay;
122 delay = Math.Min(delay, duration);
124 GetGame().GetCallqueue().CallLater(
SetShown, delay * 1000,
false, info);
152 m_CustomHint =
SCR_HintUIInfo.CreateInfo(description, name, duration,
type, fieldManualEntry, isTimerVisible);
153 return Show(m_CustomHint, isSilent);
177 return Show(m_LatestHint, isSilent,
true);
188 return Show(m_LatestHint,
true,
true);
204 if (info && info != m_LatestHint)
210 m_OnHintHide.Invoke(m_LatestHint,
false);
228 if (!
IsShown() || !m_LatestHint)
268 return m_bIgnoreHintSettings || !m_Settings || m_Settings.AreHintsEnabled();
280 (m_Settings && m_Settings.GetCount(hint) >= limit
281 || m_aSessionShownHints.Contains(hint))
291 return info &&
WasShown(info.GetType(), info.GetShowLimit());
299 m_fDurationOverride = duration;
306 return m_fDurationOverride;
334 BaseGameMode gameMode =
GetGame().GetGameMode();
336 return SCR_HintManagerComponent.Cast(gameMode.FindComponent(SCR_HintManagerComponent));
349 SCR_HintManagerComponent hintManager =
GetInstance();
351 return hintManager.Show(info, isSilent, ignoreShown);
374 static bool ShowCustomHint(
string description,
string name =
string.Empty,
float duration = 0,
bool isSilent =
false,
EFieldManualEntryId fieldManualEntry =
EFieldManualEntryId.NONE,
bool isTimerVisible =
false)
376 SCR_HintManagerComponent hintManager =
GetInstance();
378 return hintManager.ShowCustom(description, name, duration, isSilent,
EHint.UNDEFINED, fieldManualEntry, isTimerVisible);
385 static bool ClearLatestHint()
387 SCR_HintManagerComponent hintManager =
GetInstance();
389 return hintManager.ClearHint();
398 static bool RepeatHint(
bool isSilent =
false)
400 SCR_HintManagerComponent hintManager =
GetInstance();
402 return hintManager.Repeat(isSilent);
413 SCR_HintManagerComponent hintManager =
GetInstance();
415 return hintManager.Hide(info);
423 static bool IsHintShown()
425 SCR_HintManagerComponent hintManager =
GetInstance();
427 return hintManager.IsShown();
435 static bool CanShowHints()
437 SCR_HintManagerComponent hintManager =
GetInstance();
439 return hintManager.CanShow();
452 m_SettingsContainer =
GetGame().GetGameUserSettings().GetModule(
"SCR_HintSettings");
454 m_Settings.LoadShownHints(m_SettingsContainer);
456 if (!m_Settings.AreHintsEnabled() && (m_bIsShown && !m_LatestHint.IsInSequence()))
467 m_aSessionShownHints.Insert(
type);
468 int count = m_Settings.AddCount(
type);
469 m_Settings.SaveShownHints(m_SettingsContainer);
471 Print(
string.Format(
"Hint %1 = %2 saved persistently, count = %3.",
typename.EnumToString(
EHint,
type),
type, count), LogLevel.VERBOSE);
481 if (System.IsConsoleApp())
484 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_HINT_IGNORE_SHOWN,
"",
"Ignore hint persistency",
"UI");
495 componentPrefab.InitConditionLists(owner);
500 GetGame().GetInputManager().AddActionListener(
"HintToggle", EActionTrigger.DOWN,
Toggle);
501 GetGame().GetInputManager().AddActionListener(
"HintContext", EActionTrigger.DOWN,
OpenContext);
507 if (System.IsConsoleApp())
513 componentPrefab.ExitConditionLists(owner);
517 GetGame().GetInputManager().RemoveActionListener(
"HintToggle", EActionTrigger.DOWN,
Toggle);
518 GetGame().GetInputManager().RemoveActionListener(
"HintContext", EActionTrigger.DOWN,
OpenContext);