Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioDetailsPanelComponent.c
Go to the documentation of this file.
1 /*
2 Panel which shows state of a scenario.
3 It refreshes itself periodically.
4 */
5 
7 {
8  protected ref MissionWorkshopItem m_Scenario;
9  protected SCR_MissionHeader m_Header;
10 
11  protected SCR_ScenarioBackendImageComponent m_BackendImageComponent;
12 
13  //------------------------------------------------------------------------------------------------
14  override void HandlerAttached(Widget w)
15  {
16  super.HandlerAttached(w);
17 
18  m_BackendImageComponent = SCR_ScenarioBackendImageComponent.Cast(m_CommonWidgets.m_wBackendImage.FindHandler(SCR_ScenarioBackendImageComponent));
19 
20  UpdateAllWidgets();
21  }
22 
23  // -------- Public API -----------
24  //-----------------------------------------------------------------------------------
25  void SetScenario(MissionWorkshopItem scenario)
26  {
27  if (m_Scenario == scenario)
28  return;
29 
30  m_Scenario = scenario;
31  if (scenario)
32  {
33  SCR_MissionHeader header = SCR_MissionHeader.Cast(scenario.GetHeader());
34  m_Header = header;
35  }
36  else
37  m_Header = null;
38 
39  UpdateAllWidgets();
40  }
41 
42  // -------- Protected / Private -----------
43  //-----------------------------------------------------------------------------------
44  protected void UpdateAllWidgets()
45  {
46  if (!GetGame().InPlayMode())
47  return;
48 
49  if (!m_Scenario && !m_Header)
50  {
51  m_CommonWidgets.m_wNameText.SetText(string.Empty);
52  m_CommonWidgets.m_wAuthorNameText.SetText(string.Empty);
53  SetDescriptionText(string.Empty);
54 
55  if (m_BackendImageComponent)
56  m_BackendImageComponent.SetScenarioAndImage(null, null);
57 
58  return;
59  }
60 
61  // Name
62  string title;
63  if (m_Header)
64  title = m_Header.m_sName;
65  else if (m_Scenario)
66  title = m_Scenario.Name();
67 
68  m_CommonWidgets.m_wNameText.SetText(title);
69 
70  // Author name
71  // We don't have author name in scenario header now.
72  UpdateAuthorNameText();
73 
74  // Description
75  if (m_Header)
76  SetDescriptionText(m_Header.m_sDescription);
77  else if(m_Scenario)
78  SetDescriptionText(m_Scenario.Description());
79 
80  // Image
81  if (m_BackendImageComponent)
82  {
83  if (m_Scenario)
84  m_BackendImageComponent.SetScenarioAndImage(m_Scenario, m_Scenario.Thumbnail());
85  else
86  m_BackendImageComponent.SetScenarioAndImage(m_Scenario, null);
87  }
88 
89  // Error message
90  bool isInError = SCR_ScenarioEntryHelper.IsModInErrorState(m_Scenario);
91  float saturation = UIConstants.ENABLED_WIDGET_SATURATION;
92 
93  m_CommonWidgets.m_WarningOverlayComponent.SetWarningVisible(isInError, false);
94  m_CommonWidgets.m_WarningOverlayComponent.SetWarning(SCR_ScenarioEntryHelper.GetErrorMessageVerbose(m_Scenario), SCR_ScenarioEntryHelper.GetErrorTexture(m_Scenario));
95 
96  if (isInError)
97  saturation = UIConstants.DISABLED_WIDGET_SATURATION;
98 
99  if (m_BackendImageComponent)
100  m_BackendImageComponent.SetImageSaturation(saturation);
101  }
102 
103  //-----------------------------------------------------------------------------------
104  protected void UpdateAuthorNameText()
105  {
106  if (!m_Scenario)
107  return;
108 
109  if (m_Scenario.GetOwner() && m_Scenario.GetOwner().Author())
110  m_CommonWidgets.m_wAuthorNameText.SetText(m_Scenario.Author());
111  else
112  m_CommonWidgets.m_wAuthorNameText.SetText(UIConstants.BOHEMIA_INTERACTIVE);
113  }
114 }
SCR_ScenarioDetailsPanelComponent
Definition: SCR_ScenarioDetailsPanelComponent.c:6
SCR_ContentDetailsPanelBase
Definition: SCR_ContentDetailsPanelBase.c:1
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_CommonWidgets
protected ref SCR_ContentDetailsPanelBaseWidgets m_CommonWidgets
Definition: SCR_ContentDetailsPanelBase.c:2
SCR_MissionHeader
Definition: SCR_MissionHeader.c:1
m_Scenario
SCR_ExitGameWhileDownloadingDialog m_Scenario
SetDescriptionText
protected void SetDescriptionText(string text)
Set description text with enforced text lenght limit.
Definition: SCR_ContentDetailsPanelBase.c:72