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_MapCommandCursor.c
Go to the documentation of this file.
1
class
SCR_MapCommandCursor
2
{
3
protected
bool
m_bIsDestinationEnabled
;
4
protected
vector
m_vStartPosition
;
5
protected
SCR_MapCursorModule
m_MapCursorModule
;
6
7
protected
ref
ScriptInvokerVector
m_OnCommandExecuted
;
8
protected
ref
ScriptInvokerVector
m_OnCommandNotExecuted
;
9
10
//------------------------------------------------------------------------------------------------
12
ScriptInvokerVector
GetOnCommandExecuted
()
13
{
14
if
(!
m_OnCommandExecuted
)
15
m_OnCommandExecuted
=
new
ScriptInvokerVector
();
16
17
return
m_OnCommandExecuted
;
18
}
19
20
//------------------------------------------------------------------------------------------------
22
ScriptInvokerVector
GetOnCommandNotExecuted
()
23
{
24
if
(!
m_OnCommandNotExecuted
)
25
m_OnCommandNotExecuted
=
new
ScriptInvokerVector
();
26
27
return
m_OnCommandNotExecuted
;
28
}
29
30
//------------------------------------------------------------------------------------------------
31
void
ShowCursor
(
vector
startCursorPosition)
32
{
33
ToggleNegativeCursor
(
true
);
34
m_bIsDestinationEnabled
=
false
;
35
36
SCR_MapEntity
.
GetOnSelection
().Insert(
OnSelection
);
37
SCR_MapEntity
.
GetOnMapClose
().Insert(
OnMapClose
);
38
39
m_vStartPosition
= startCursorPosition;
40
41
GetGame
().GetCallqueue().CallLater(
UpdateCursor
, 100,
true
);
42
}
43
44
//------------------------------------------------------------------------------------------------
45
protected
bool
CanExecuteCommand
(
vector
position
)
46
{
47
return
true
;
48
}
49
50
//------------------------------------------------------------------------------------------------
51
protected
void
OnCommandExecuted
(
vector
position
)
52
{
53
if
(
m_OnCommandExecuted
)
54
m_OnCommandExecuted
.Invoke(
position
);
55
}
56
57
//------------------------------------------------------------------------------------------------
58
protected
void
OnCommandNotExecuted
(
vector
position
)
59
{
60
if
(
m_OnCommandNotExecuted
)
61
m_OnCommandNotExecuted
.Invoke(
position
);
62
}
63
64
//------------------------------------------------------------------------------------------------
65
protected
void
OnSelection
(
vector
coords
)
66
{
67
SCR_MapEntity
mapEntity =
SCR_MapEntity
.
GetMapInstance
();
68
if
(!mapEntity)
69
return
;
70
71
float
x, y;
72
mapEntity.
ScreenToWorld
(
coords
[0],
coords
[2], x, y);
73
coords
[0] = x;
74
coords
[2] = y;
75
76
if
(
CanExecuteCommand
(
coords
))
77
{
78
OnCommandExecuted
(
coords
);
79
DisableSelection
();
80
}
81
else
82
{
83
OnCommandNotExecuted
(
coords
);
84
}
85
86
SCR_UISoundEntity
.SoundEvent(
SCR_SoundEvent
.SOUND_MAP_CLICK_POINT_ON);
87
}
88
89
//------------------------------------------------------------------------------------------------
90
protected
void
UpdateCursor
()
91
{
92
SCR_MapEntity
mapEntity =
SCR_MapEntity
.
GetMapInstance
();
93
if
(!mapEntity)
94
return
;
95
96
float
cursorX =
GetGame
().GetWorkspace().DPIScale(
SCR_MapCursorInfo
.x);
97
float
cursorY =
GetGame
().GetWorkspace().DPIScale(
SCR_MapCursorInfo
.y);
98
99
float
x, y;
100
vector
worldPosition;
101
mapEntity.
ScreenToWorld
(cursorX, cursorY, x, y);
102
worldPosition[0] = x;
103
worldPosition[2] = y;
104
105
// set cursor type and color
106
if
(
CanExecuteCommand
(worldPosition))
107
{
108
if
(
m_bIsDestinationEnabled
)
109
return
;
110
111
TogglePositiveCursor
(
true
);
112
ToggleNegativeCursor
(
false
);
113
m_bIsDestinationEnabled
=
true
;
114
}
115
else
116
{
117
if
(!
m_bIsDestinationEnabled
)
118
return
;
119
120
TogglePositiveCursor
(
false
);
121
ToggleNegativeCursor
(
true
);
122
m_bIsDestinationEnabled
=
false
;
123
}
124
}
125
126
//------------------------------------------------------------------------------------------------
127
protected
void
OnMapClose
(
MapConfiguration
config)
128
{
129
DisableSelection
(
false
);
// toggleOffCursors param is disabled here, because cursors are reset in the SCR_MapCursorModule
130
}
131
132
//------------------------------------------------------------------------------------------------
133
void
DisableSelection
(
bool
toggleOffCursors =
true
)
134
{
135
SCR_MapEntity
.
GetOnSelection
().Remove(
OnSelection
);
136
SCR_MapEntity
.
GetOnMapClose
().Remove(
OnMapClose
);
137
138
if
(toggleOffCursors)
139
{
140
TogglePositiveCursor
(
false
);
141
ToggleNegativeCursor
(
false
);
142
}
143
144
GetGame
().GetCallqueue().Remove(
UpdateCursor
);
145
}
146
147
//------------------------------------------------------------------------------------------------
148
protected
void
TogglePositiveCursor
(
bool
enable)
149
{
150
if
(!
m_MapCursorModule
)
151
return
;
152
153
m_MapCursorModule
.ToggleMapCommandPositiveCursor(enable);
154
}
155
156
//------------------------------------------------------------------------------------------------
157
protected
void
ToggleNegativeCursor
(
bool
enable)
158
{
159
if
(!
m_MapCursorModule
)
160
return
;
161
162
m_MapCursorModule
.ToggleMapCommandNegativeCursor(enable);
163
}
164
165
//------------------------------------------------------------------------------------------------
166
void
SCR_MapCommandCursor
()
167
{
168
SCR_MapEntity
mapEntity =
SCR_MapEntity
.
GetMapInstance
();
169
if
(!mapEntity)
170
return
;
171
172
m_MapCursorModule
= SCR_MapCursorModule.Cast(mapEntity.
GetMapModule
(SCR_MapCursorModule));
173
}
174
175
//------------------------------------------------------------------------------------------------
176
void
~SCR_MapCommandCursor
()
177
{
178
DisableSelection
();
179
}
180
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
coords
ref array< string > coords
Definition
PrefabImporter.c:21
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
ScriptInvokerVector
ScriptInvokerBase< ScriptInvokerVectorMethod > ScriptInvokerVector
Definition
SCR_ScriptInvokerHelper.c:101
MapConfiguration
Definition
MapConfiguration.c:3
SCR_MapCommandCursor::m_OnCommandNotExecuted
ref ScriptInvokerVector m_OnCommandNotExecuted
Definition
SCR_MapCommandCursor.c:8
SCR_MapCommandCursor::m_MapCursorModule
SCR_MapCursorModule m_MapCursorModule
Definition
SCR_MapCommandCursor.c:5
SCR_MapCommandCursor::SCR_MapCommandCursor
void SCR_MapCommandCursor()
Definition
SCR_MapCommandCursor.c:166
SCR_MapCommandCursor::OnSelection
void OnSelection(vector coords)
Definition
SCR_MapCommandCursor.c:65
SCR_MapCommandCursor::CanExecuteCommand
bool CanExecuteCommand(vector position)
Definition
SCR_MapCommandCursor.c:45
SCR_MapCommandCursor::OnCommandExecuted
void OnCommandExecuted(vector position)
Definition
SCR_MapCommandCursor.c:51
SCR_MapCommandCursor::OnCommandNotExecuted
void OnCommandNotExecuted(vector position)
Definition
SCR_MapCommandCursor.c:58
SCR_MapCommandCursor::OnMapClose
void OnMapClose(MapConfiguration config)
Definition
SCR_MapCommandCursor.c:127
SCR_MapCommandCursor::GetOnCommandExecuted
ScriptInvokerVector GetOnCommandExecuted()
Definition
SCR_MapCommandCursor.c:12
SCR_MapCommandCursor::GetOnCommandNotExecuted
ScriptInvokerVector GetOnCommandNotExecuted()
Definition
SCR_MapCommandCursor.c:22
SCR_MapCommandCursor::TogglePositiveCursor
void TogglePositiveCursor(bool enable)
Definition
SCR_MapCommandCursor.c:148
SCR_MapCommandCursor::DisableSelection
void DisableSelection(bool toggleOffCursors=true)
Definition
SCR_MapCommandCursor.c:133
SCR_MapCommandCursor::m_vStartPosition
vector m_vStartPosition
Definition
SCR_MapCommandCursor.c:4
SCR_MapCommandCursor::m_bIsDestinationEnabled
bool m_bIsDestinationEnabled
Definition
SCR_MapCommandCursor.c:3
SCR_MapCommandCursor::m_OnCommandExecuted
ref ScriptInvokerVector m_OnCommandExecuted
Definition
SCR_MapCommandCursor.c:7
SCR_MapCommandCursor::UpdateCursor
void UpdateCursor()
Definition
SCR_MapCommandCursor.c:90
SCR_MapCommandCursor::~SCR_MapCommandCursor
void ~SCR_MapCommandCursor()
Definition
SCR_MapCommandCursor.c:176
SCR_MapCommandCursor::ShowCursor
void ShowCursor(vector startCursorPosition)
Definition
SCR_MapCommandCursor.c:31
SCR_MapCommandCursor::ToggleNegativeCursor
void ToggleNegativeCursor(bool enable)
Definition
SCR_MapCommandCursor.c:157
SCR_MapCursorInfo
Cursor data.
Definition
SCR_MapCursorModule.c:4
SCR_MapEntity
Definition
SCR_MapEntity.c:18
SCR_MapEntity::GetMapModule
SCR_MapModuleBase GetMapModule(typename moduleType)
Definition
SCR_MapEntity.c:246
SCR_MapEntity::GetOnMapClose
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
Definition
SCR_MapEntity.c:92
SCR_MapEntity::GetOnSelection
static ScriptInvokerVector GetOnSelection()
Get on selection invoker.
Definition
SCR_MapEntity.c:104
SCR_MapEntity::ScreenToWorld
void ScreenToWorld(int screenPosX, int screenPosY, out float worldX, out float worldY)
Use scaled screen coords to get canvas world coords, flips the y-axis.
Definition
SCR_MapEntity.c:945
SCR_MapEntity::GetMapInstance
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Definition
SCR_MapEntity.c:112
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SCR_UISoundEntity
Definition
SCR_UISoundEntity.c:8
vector
Definition
vector.c:13
scripts
Game
FactionCommander
MapCommandCursors
SCR_MapCommandCursor.c
Generated by
1.17.0