Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ProgressDialog.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 class SCR_ProgressDialog : ScriptedWidgetComponent
3 {
4  // Widget Names
5  const string WIDGET_TEXT_PROGRESS = "TxtProgress";
6  const string WIDGET_PROGRESS_BAR = "ProgressDownload";
7 
8  // Widgets
9  protected TextWidget m_wTxtProgress;
10  protected SCR_WLibProgressBarComponent m_ProgressBar;
11 
12  //------------------------------------------------------------------------------------------------
13  // Dialog override functions
14  //------------------------------------------------------------------------------------------------
15 
16  //------------------------------------------------------------------------------------------------
17  override void HandlerAttached(Widget w)
18  {
19  super.HandlerAttached(w);
20 
21  // Get widgets
22  m_wTxtProgress = TextWidget.Cast(w.FindAnyWidget(WIDGET_TEXT_PROGRESS));
23 
24  Widget wProgressBar = w.FindAnyWidget(WIDGET_PROGRESS_BAR);
25  if (wProgressBar)
26  m_ProgressBar = SCR_WLibProgressBarComponent.Cast(wProgressBar.FindHandler(SCR_WLibProgressBarComponent));
27  }
28 
29  //------------------------------------------------------------------------------------------------
30  // Public API
31  //------------------------------------------------------------------------------------------------
32 
33  //------------------------------------------------------------------------------------------------
34  void SetProgress(float progress)
35  {
36  // Progress bar
37  if (m_ProgressBar)
38  {
39  m_ProgressBar.SetValue(progress);
40 
41  // Get proper value in percent
42  float progValue = m_ProgressBar.GetValue() - m_ProgressBar.GetMin();
43  progValue /= m_ProgressBar.GetMax() - m_ProgressBar.GetMin();
44  progValue *= 100;
45  progValue = Math.Floor(progValue);
46 
47  // Progress text
48  if (m_wTxtProgress)
49  m_wTxtProgress.SetText(progValue.ToString() + "%");
50  }
51  }
52 
53 };
54 
55 
56 
SCR_ProgressDialog
Definition: SCR_ProgressDialog.c:2
SCR_WLibProgressBarComponent
Minimalist progress bar.
Definition: SCR_WLibProgressBar.c:3