Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_DownloadManager_CircularIndicatorComponent.c
Go to the documentation of this file.
1
4
5
class
SCR_DownloadManager_CircularIndicatorComponent
:
SCR_ScriptedWidgetComponent
6
{
7
protected
const
float
FADE_OUT_WAIT_TIME
= 2.5;
8
9
protected
ref
SCR_DownloadManager_CircleProgressIndicatorWidgets
m_Widgets
=
new
SCR_DownloadManager_CircleProgressIndicatorWidgets
();
10
11
protected
ref
SCR_FadeInOutAnimator
m_Animator
;
12
13
protected
bool
m_bIsDownloading
;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
HandlerAttached
(
Widget
w)
17
{
18
super.HandlerAttached(w);
19
20
m_Widgets
.Init(w);
21
22
m_Animator
=
new
SCR_FadeInOutAnimator
(
m_Widgets
.m_DownloadButton,
UIConstants
.FADE_RATE_FAST,
UIConstants
.FADE_RATE_SLOW,
FADE_OUT_WAIT_TIME
, fadeOutSetVisibleFalse:
true
);
23
24
if
(!
SCR_Global
.
IsEditMode
())
25
{
26
UpdateAllWidgets
();
27
28
if
(!
m_bIsDownloading
)
29
m_Animator
.FadeOutInstantly();
30
}
31
32
m_Widgets
.m_DownloadButtonComponent.m_OnClicked.Insert(
OnButtonClick
);
33
34
// Owner menu events
35
SCR_MenuHelper
.
GetOnMenuFocusGained
().Insert(
OnMenuEnabled
);
36
SCR_MenuHelper
.
GetOnMenuOpen
().Insert(
OnMenuEnabled
);
37
SCR_MenuHelper
.
GetOnMenuFocusLost
().Insert(
OnMenuDisabled
);
38
SCR_MenuHelper
.
GetOnMenuClose
().Insert(
OnMenuDisabled
);
39
}
40
41
//------------------------------------------------------------------------------------------------
42
override
void
HandlerDeattached
(
Widget
w)
43
{
44
super.HandlerDeattached(w);
45
46
GetGame
().GetCallqueue().Remove(
OnFrame
);
47
48
// Owner menu events
49
SCR_MenuHelper
.
GetOnMenuFocusGained
().Remove(
OnMenuEnabled
);
50
SCR_MenuHelper
.
GetOnMenuOpen
().Remove(
OnMenuEnabled
);
51
SCR_MenuHelper
.
GetOnMenuFocusLost
().Remove(
OnMenuDisabled
);
52
SCR_MenuHelper
.
GetOnMenuClose
().Remove(
OnMenuDisabled
);
53
}
54
55
//------------------------------------------------------------------------------------------------
56
protected
void
OnFrame
(
float
tDelta)
57
{
58
if
(!
m_wRoot
)
59
return
;
60
61
//float tDelta = ftime / 1000.0; // delta time for callqueue
62
63
if
(!
SCR_Global
.
IsEditMode
())
64
UpdateAllWidgets
();
65
66
m_Animator
.Update(tDelta);
67
}
68
69
//------------------------------------------------------------------------------------------------
70
protected
void
UpdateAllWidgets
()
71
{
72
SCR_DownloadManager
mgr =
SCR_DownloadManager
.
GetInstance
();
73
if
(!mgr)
74
return
;
75
76
int
nCompleted, nTotal;
77
mgr.
GetDownloadQueueState
(nCompleted, nTotal);
78
79
m_bIsDownloading
= nTotal > 0;
80
81
// Progress bar, progress text
82
m_Widgets
.m_DownloadDoneImage.SetVisible(nTotal == 0);
83
m_Widgets
.m_QueueSizeText.SetVisible(
m_bIsDownloading
);
84
if
(
m_bIsDownloading
)
85
{
86
// Get total progress of all downloads
87
array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.
GetDownloadQueue
();
88
float
progress =
SCR_DownloadManager
.
GetDownloadActionsProgress
(downloadQueue);
89
90
// Progress bar
91
m_Widgets
.m_ProgressCircle.SetMaskProgress(progress);
92
93
// Queue size text
94
string
queueSizeText =
string
.Format(
"%1"
, nTotal - nCompleted);
95
m_Widgets
.m_QueueSizeText.SetText(queueSizeText);
96
}
97
else
98
{
99
m_Widgets
.m_QueueSizeText.SetText(
string
.Empty);
100
m_Widgets
.m_ProgressCircle.SetMaskProgress(1.0);
101
}
102
103
m_Animator
.ForceVisible(
m_bIsDownloading
);
104
105
// Disable button when invisible
106
m_Widgets
.m_DownloadButtonComponent.SetEnabled(
m_bIsDownloading
);
107
}
108
109
//------------------------------------------------------------------------------------------------
110
protected
void
OnButtonClick
()
111
{
112
SCR_DownloadManager_Dialog.Create();
113
}
114
115
//------------------------------------------------------------------------------------------------
116
protected
void
OnMenuEnabled
(
ChimeraMenuBase
menu)
117
{
118
if
(menu ==
ChimeraMenuBase
.
GetOwnerMenu
(
GetRootWidget
()))
119
{
120
UpdateAllWidgets
();
121
if
(!
m_bIsDownloading
)
122
m_Animator
.FadeOutInstantly();
123
124
menu.
m_OnUpdate
.Remove(
OnFrame
);
125
menu.
m_OnUpdate
.Insert(
OnFrame
);
126
}
127
}
128
129
//------------------------------------------------------------------------------------------------
130
protected
void
OnMenuDisabled
(
ChimeraMenuBase
menu)
131
{
132
if
(menu ==
ChimeraMenuBase
.
GetOwnerMenu
(
GetRootWidget
()))
133
{
134
menu.
m_OnUpdate
.Remove(
OnFrame
);
135
}
136
}
137
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ChimeraMenuBase
Constant variables used in various menus.
Definition
ChimeraMenuBase.c:72
ChimeraMenuBase::GetOwnerMenu
static ChimeraMenuBase GetOwnerMenu(Widget w)
Returns parent menu of a widget.
Definition
ChimeraMenuBase.c:179
ChimeraMenuBase::m_OnUpdate
ref ScriptInvoker m_OnUpdate
Definition
ChimeraMenuBase.c:87
SCR_DownloadManager_CircleProgressIndicatorWidgets
Definition
SCR_DownloadManager_CircleProgressIndicatorWidgets.c:2
SCR_DownloadManager_CircularIndicatorComponent
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:6
SCR_DownloadManager_CircularIndicatorComponent::OnFrame
void OnFrame(float tDelta)
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:56
SCR_DownloadManager_CircularIndicatorComponent::OnButtonClick
void OnButtonClick()
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:110
SCR_DownloadManager_CircularIndicatorComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:42
SCR_DownloadManager_CircularIndicatorComponent::m_Animator
ref SCR_FadeInOutAnimator m_Animator
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:11
SCR_DownloadManager_CircularIndicatorComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:16
SCR_DownloadManager_CircularIndicatorComponent::OnMenuEnabled
void OnMenuEnabled(ChimeraMenuBase menu)
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:116
SCR_DownloadManager_CircularIndicatorComponent::m_Widgets
ref SCR_DownloadManager_CircleProgressIndicatorWidgets m_Widgets
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:9
SCR_DownloadManager_CircularIndicatorComponent::FADE_OUT_WAIT_TIME
const float FADE_OUT_WAIT_TIME
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:7
SCR_DownloadManager_CircularIndicatorComponent::m_bIsDownloading
bool m_bIsDownloading
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:13
SCR_DownloadManager_CircularIndicatorComponent::UpdateAllWidgets
void UpdateAllWidgets()
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:70
SCR_DownloadManager_CircularIndicatorComponent::OnMenuDisabled
void OnMenuDisabled(ChimeraMenuBase menu)
Definition
SCR_DownloadManager_CircularIndicatorComponent.c:130
SCR_DownloadManager
Definition
SCR_DownloadManager.c:21
SCR_DownloadManager::GetDownloadQueueState
void GetDownloadQueueState(out int nCompleted, out int nTotal)
Might get delayed by a frame! Just use it for UI.
Definition
SCR_DownloadManager.c:109
SCR_DownloadManager::GetDownloadActionsProgress
static float GetDownloadActionsProgress(array< ref SCR_WorkshopItemActionDownload > actions)
Returns overall progress of all download actions, from 0 to 1.
Definition
SCR_DownloadManager.c:425
SCR_DownloadManager::GetInstance
static SCR_DownloadManager GetInstance()
Definition
SCR_DownloadManager.c:91
SCR_DownloadManager::GetDownloadQueue
array< ref SCR_WorkshopItemActionDownload > GetDownloadQueue()
Definition
SCR_DownloadManager.c:138
SCR_FadeInOutAnimator
Definition
SCR_FadeInOutAnimator.c:9
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_MenuHelper
Definition
SCR_MenuHelper.c:19
SCR_MenuHelper::GetOnMenuFocusLost
static ScriptInvokerMenu GetOnMenuFocusLost()
Definition
SCR_MenuHelper.c:97
SCR_MenuHelper::GetOnMenuClose
static ScriptInvokerMenu GetOnMenuClose()
Definition
SCR_MenuHelper.c:79
SCR_MenuHelper::GetOnMenuOpen
static ScriptInvokerMenu GetOnMenuOpen()
Definition
SCR_MenuHelper.c:61
SCR_MenuHelper::GetOnMenuFocusGained
static ScriptInvokerMenu GetOnMenuFocusGained()
Definition
SCR_MenuHelper.c:88
SCR_ScriptedWidgetComponent
Definition
SCR_ScriptedWidgetComponent.c:8
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_ScriptedWidgetComponent::GetRootWidget
Widget GetRootWidget()
Definition
SCR_ScriptedWidgetComponent.c:51
UIConstants
Definition
Constants.c:151
Widget
Definition
Widget.c:13
scripts
Game
UI
Menu
DownloadManager
SCR_DownloadManager_CircularIndicatorComponent.c
Generated by
1.17.0