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_ButtonCloseEditorUIComponent.c
Go to the documentation of this file.
1
class
SCR_ButtonCloseEditorUIComponent
:
ScriptedWidgetComponent
2
{
3
[
Attribute
()]
4
protected
string
m_sButtonCloseName
;
5
6
[
Attribute
()]
7
protected
string
m_sButtonPlayerName
;
8
9
[
Attribute
()]
10
protected
string
m_sButtonRespawnMenuName
;
11
12
[
Attribute
()]
13
protected
string
m_sButtonRespawnMenuDisabledName
;
14
15
[
Attribute
(
"Toolbar_CaptureButton"
)]
16
protected
string
m_sButtonCapture
;
17
18
[
Attribute
(
"Text0"
)]
19
protected
string
m_sButtonPlayerTextName
;
20
21
[
Attribute
()]
22
protected
string
m_sButtonPlayerPlayCharacterText
;
23
24
[
Attribute
()]
25
protected
string
m_sButtonPlayerBackToMapText
;
26
27
protected
Widget
m_ButtonClose
;
28
protected
Widget
m_ButtonPlayer
;
29
protected
Widget
m_ButtonRespawnMenu
;
30
protected
Widget
m_ButtonRespawnMenuDisabled
;
31
protected
Widget
m_wButtonCapture
;
32
33
protected
TextWidget
m_wButtonPlayerText
;
34
35
//---- REFACTOR NOTE START: States could be enums
36
37
protected
const
int
BUTTON_CLOSE
= 0;
38
protected
const
int
BUTTON_PLAYER
= 1;
39
protected
const
int
BUTTON_RESPAWN_MENU
= 2;
40
protected
const
int
BUTTON_RESPAWN_MENU_DISABLED
= 3;
41
42
//------------------------------------------------------------------------------------------------
43
protected
int
GetButtonIndex
()
44
{
45
//--- Player avatar exists - 'Play' button
46
IEntity
localPlayer =
SCR_PlayerController
.
GetLocalMainEntity
();
47
if
(localPlayer && !localPlayer.
IsDeleted
())
48
{
49
DamageManagerComponent
damageManager =
DamageManagerComponent
.Cast(localPlayer.
FindComponent
(
DamageManagerComponent
));
50
if
(!damageManager)
51
return
BUTTON_PLAYER
;
52
53
if
(damageManager.GetState() !=
EDamageState
.DESTROYED)
54
return
BUTTON_PLAYER
;
55
}
56
57
//--- 'Return to respawn menu' button based on available spawn points
58
SCR_FactionManager
factionManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
59
if
(factionManager)
60
{
61
int
spawnPointCount;
62
Faction
playerFaction = factionManager.GetPlayerFaction(
SCR_PlayerController
.
GetLocalPlayerId
());
63
if
(playerFaction)
64
{
65
//--- Player has faction - return its spawn points
66
string
playerFactionKey;
67
playerFactionKey = playerFaction.GetFactionKey();
68
spawnPointCount =
SCR_SpawnPoint
.GetSpawnPointCountForFaction(playerFactionKey)
69
}
70
else
71
{
72
//--- Player has no faction - return all spawn points
73
spawnPointCount =
SCR_SpawnPoint
.
CountSpawnPoints
();
74
}
75
76
if
(spawnPointCount == 0)
77
return
BUTTON_RESPAWN_MENU_DISABLED
;
78
else
79
return
BUTTON_RESPAWN_MENU
;
80
}
81
82
//--- Default - plain 'Close' button
83
return
BUTTON_CLOSE
;
84
}
85
86
//------------------------------------------------------------------------------------------------
87
protected
void
SetPlayerButtonText
(
string
text)
88
{
89
if
(!
m_wButtonPlayerText
)
90
return
;
91
92
m_wButtonPlayerText
.SetText(text);
93
}
94
95
//------------------------------------------------------------------------------------------------
96
protected
void
Refresh
()
97
{
98
int
showButton =
GetButtonIndex
();
99
100
m_ButtonClose
.SetVisible(showButton ==
BUTTON_CLOSE
);
101
m_ButtonPlayer
.SetVisible(showButton ==
BUTTON_PLAYER
);
102
m_ButtonRespawnMenu
.SetVisible(showButton ==
BUTTON_RESPAWN_MENU
);
103
m_ButtonRespawnMenuDisabled
.SetVisible(showButton ==
BUTTON_RESPAWN_MENU_DISABLED
);
104
105
if
(
m_wButtonCapture
)
106
{
107
SCR_EditorManagerEntity
editorManager =
SCR_EditorManagerEntity
.GetInstance();
108
if
(!editorManager)
109
return
;
110
111
EEditorMode
mode = editorManager.GetCurrentMode();
112
m_wButtonCapture
.SetVisible(mode ==
EEditorMode
.PHOTO_SAVE);
113
}
114
}
115
116
//---- REFACTOR NOTE END ----
117
118
//------------------------------------------------------------------------------------------------
119
protected
void
OnPlayerKilled
(notnull
SCR_InstigatorContextData
instigatorContextData)
120
{
121
Refresh
();
122
}
123
124
//------------------------------------------------------------------------------------------------
125
protected
void
OnPlayerSpawnedOrDeleted
(
int
playerId,
IEntity
player)
126
{
127
Refresh
();
128
}
129
130
//------------------------------------------------------------------------------------------------
131
override
bool
OnClick
(
Widget
w,
int
x,
int
y,
int
button)
132
{
133
SCR_EditorManagerEntity
editorManager =
SCR_EditorManagerEntity
.GetInstance();
134
if
(editorManager)
135
GetGame
().GetCallqueue().CallLater(editorManager.Close, 1,
false
,
false
);
//--- Cannot trigger operation which closes UI from that UI's handler
136
137
return
false
;
138
}
139
140
//------------------------------------------------------------------------------------------------
141
override
void
HandlerAttached
(
Widget
w)
142
{
143
if
(
SCR_Global
.
IsEditMode
())
144
return
;
145
146
m_ButtonPlayer
= w.FindAnyWidget(
m_sButtonPlayerName
);
147
m_ButtonRespawnMenu
= w.FindAnyWidget(
m_sButtonRespawnMenuName
);
148
m_ButtonRespawnMenuDisabled
= w.FindAnyWidget(
m_sButtonRespawnMenuDisabledName
);
149
m_ButtonClose
= w.FindAnyWidget(
m_sButtonCloseName
);
150
m_wButtonCapture
= w.FindAnyWidget(
m_sButtonCapture
);
151
152
if
(
m_ButtonPlayer
)
153
m_wButtonPlayerText
=
TextWidget
.Cast(
m_ButtonPlayer
.FindAnyWidget(
m_sButtonPlayerTextName
));
154
155
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
156
if
(gameMode)
157
{
158
gameMode.
GetOnPlayerSpawned
().Insert(
OnPlayerSpawnedOrDeleted
);
159
gameMode.
GetOnPlayerKilled
().Insert(
OnPlayerKilled
);
160
gameMode.
GetOnPlayerDeleted
().Insert(
OnPlayerSpawnedOrDeleted
);
161
}
162
163
SCR_SpawnPoint
.Event_OnSpawnPointCountChanged.Insert(
Refresh
);
164
165
SCR_MapEntity
mapEntity =
SCR_MapEntity
.
GetMapInstance
();
166
if
(mapEntity && mapEntity.
IsOpen
())
167
SetPlayerButtonText
(
m_sButtonPlayerBackToMapText
);
168
else
169
SetPlayerButtonText
(
m_sButtonPlayerPlayCharacterText
);
170
171
Refresh
();
172
}
173
174
//------------------------------------------------------------------------------------------------
175
override
void
HandlerDeattached
(
Widget
w)
176
{
177
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
178
if
(gameMode)
179
{
180
gameMode.
GetOnPlayerSpawned
().Remove(
OnPlayerSpawnedOrDeleted
);
181
gameMode.
GetOnPlayerKilled
().Remove(
OnPlayerKilled
);
182
gameMode.
GetOnPlayerDeleted
().Remove(
OnPlayerSpawnedOrDeleted
);
183
}
184
185
SCR_SpawnPoint
.Event_OnSpawnPointCountChanged.Remove(
Refresh
);
186
}
187
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
SCR_EditorManagerEntity
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Definition
SCR_EditorManagerEntity.c:2211
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
DamageManagerComponent
Definition
DamageManagerComponent.c:13
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::IsDeleted
proto external bool IsDeleted()
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::GetOnPlayerSpawned
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerSpawned()
Definition
SCR_BaseGameMode.c:629
SCR_BaseGameMode::GetOnPlayerDeleted
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
Definition
SCR_BaseGameMode.c:637
SCR_BaseGameMode::GetOnPlayerKilled
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
Definition
SCR_BaseGameMode.c:633
SCR_ButtonCloseEditorUIComponent
Definition
SCR_ButtonCloseEditorUIComponent.c:2
SCR_ButtonCloseEditorUIComponent::BUTTON_CLOSE
const int BUTTON_CLOSE
Definition
SCR_ButtonCloseEditorUIComponent.c:37
SCR_ButtonCloseEditorUIComponent::BUTTON_RESPAWN_MENU
const int BUTTON_RESPAWN_MENU
Definition
SCR_ButtonCloseEditorUIComponent.c:39
SCR_ButtonCloseEditorUIComponent::m_sButtonPlayerPlayCharacterText
string m_sButtonPlayerPlayCharacterText
Definition
SCR_ButtonCloseEditorUIComponent.c:22
SCR_ButtonCloseEditorUIComponent::SetPlayerButtonText
void SetPlayerButtonText(string text)
Definition
SCR_ButtonCloseEditorUIComponent.c:87
SCR_ButtonCloseEditorUIComponent::m_sButtonCloseName
string m_sButtonCloseName
Definition
SCR_ButtonCloseEditorUIComponent.c:4
SCR_ButtonCloseEditorUIComponent::m_sButtonRespawnMenuDisabledName
string m_sButtonRespawnMenuDisabledName
Definition
SCR_ButtonCloseEditorUIComponent.c:13
SCR_ButtonCloseEditorUIComponent::BUTTON_RESPAWN_MENU_DISABLED
const int BUTTON_RESPAWN_MENU_DISABLED
Definition
SCR_ButtonCloseEditorUIComponent.c:40
SCR_ButtonCloseEditorUIComponent::m_sButtonRespawnMenuName
string m_sButtonRespawnMenuName
Definition
SCR_ButtonCloseEditorUIComponent.c:10
SCR_ButtonCloseEditorUIComponent::OnPlayerKilled
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
Definition
SCR_ButtonCloseEditorUIComponent.c:119
SCR_ButtonCloseEditorUIComponent::m_wButtonPlayerText
TextWidget m_wButtonPlayerText
Definition
SCR_ButtonCloseEditorUIComponent.c:33
SCR_ButtonCloseEditorUIComponent::OnPlayerSpawnedOrDeleted
void OnPlayerSpawnedOrDeleted(int playerId, IEntity player)
Definition
SCR_ButtonCloseEditorUIComponent.c:125
SCR_ButtonCloseEditorUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_ButtonCloseEditorUIComponent.c:141
SCR_ButtonCloseEditorUIComponent::m_ButtonRespawnMenuDisabled
Widget m_ButtonRespawnMenuDisabled
Definition
SCR_ButtonCloseEditorUIComponent.c:30
SCR_ButtonCloseEditorUIComponent::m_wButtonCapture
Widget m_wButtonCapture
Definition
SCR_ButtonCloseEditorUIComponent.c:31
SCR_ButtonCloseEditorUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_ButtonCloseEditorUIComponent.c:175
SCR_ButtonCloseEditorUIComponent::m_sButtonCapture
string m_sButtonCapture
Definition
SCR_ButtonCloseEditorUIComponent.c:16
SCR_ButtonCloseEditorUIComponent::BUTTON_PLAYER
const int BUTTON_PLAYER
Definition
SCR_ButtonCloseEditorUIComponent.c:38
SCR_ButtonCloseEditorUIComponent::m_ButtonPlayer
Widget m_ButtonPlayer
Definition
SCR_ButtonCloseEditorUIComponent.c:28
SCR_ButtonCloseEditorUIComponent::m_sButtonPlayerTextName
string m_sButtonPlayerTextName
Definition
SCR_ButtonCloseEditorUIComponent.c:19
SCR_ButtonCloseEditorUIComponent::m_sButtonPlayerName
string m_sButtonPlayerName
Definition
SCR_ButtonCloseEditorUIComponent.c:7
SCR_ButtonCloseEditorUIComponent::m_sButtonPlayerBackToMapText
string m_sButtonPlayerBackToMapText
Definition
SCR_ButtonCloseEditorUIComponent.c:25
SCR_ButtonCloseEditorUIComponent::m_ButtonClose
Widget m_ButtonClose
Definition
SCR_ButtonCloseEditorUIComponent.c:27
SCR_ButtonCloseEditorUIComponent::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
SCR_ButtonCloseEditorUIComponent.c:131
SCR_ButtonCloseEditorUIComponent::GetButtonIndex
int GetButtonIndex()
Definition
SCR_ButtonCloseEditorUIComponent.c:43
SCR_ButtonCloseEditorUIComponent::Refresh
void Refresh()
Definition
SCR_ButtonCloseEditorUIComponent.c:96
SCR_ButtonCloseEditorUIComponent::m_ButtonRespawnMenu
Widget m_ButtonRespawnMenu
Definition
SCR_ButtonCloseEditorUIComponent.c:29
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_InstigatorContextData
Definition
SCR_InstigatorContextData.c:2
SCR_MapEntity
Definition
SCR_MapEntity.c:18
SCR_MapEntity::IsOpen
bool IsOpen()
Check if the map is opened.
Definition
SCR_MapEntity.c:123
SCR_MapEntity::GetMapInstance
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Definition
SCR_MapEntity.c:112
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_PlayerController::GetLocalMainEntity
static IEntity GetLocalMainEntity()
Definition
SCR_PlayerController.c:511
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition
SCR_SpawnPoint.c:28
SCR_SpawnPoint::CountSpawnPoints
static int CountSpawnPoints()
Definition
SCR_SpawnPoint.c:436
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition
EEditorMode.c:6
EDamageState
EDamageState
Definition
EDamageState.c:13
scripts
Game
Editor
UI
Components
Common
SCR_ButtonCloseEditorUIComponent.c
Generated by
1.17.0