Elin Decompiled Documentation
EA 23.102 Nightly
Loading...
Searching...
No Matches
Hotbar.cs
Go to the documentation of this file.
1
using
System.Collections.Generic;
2
using
Newtonsoft.Json;
3
4
public
class
Hotbar
:
EClass
5
{
6
public
enum
Type
7
{
8
Default
,
9
Main
,
10
ZoomMenu
11
}
12
13
public
class
Page
:
EClass
14
{
15
[JsonProperty]
16
public
List<HotItem>
items
=
new
List<HotItem>();
17
18
[JsonProperty]
19
public
int
selected
= -1;
20
21
public
HotItem
SelectedItem
22
{
23
get
24
{
25
if
(
selected
!= -1)
26
{
27
return
items
[
selected
];
28
}
29
return
null
;
30
}
31
}
32
33
public
void
SetItem
(
Hotbar
h,
HotItem
item
,
int
index)
34
{
35
if
(index == -1)
36
{
37
for
(
int
i = 0; i <
items
.Count; i++)
38
{
39
if
(
items
[i] ==
null
)
40
{
41
index = i;
42
break
;
43
}
44
}
45
if
(index == -1)
46
{
47
return
;
48
}
49
}
50
if
(
items
[index] !=
null
)
51
{
52
items
[index].button =
null
;
53
}
54
items
[index] =
item
;
55
}
56
57
public
HotItem
GetItem
(
int
index)
58
{
59
if
(index >=
items
.Count)
60
{
61
return
null
;
62
}
63
return
items
[index];
64
}
65
}
66
67
public
const
int
IDMainMenu
= 2;
68
69
public
const
int
IDBuild
= 3;
70
71
public
const
int
IDUser2
= 5;
72
73
public
const
int
IDUser3
= 6;
74
75
public
const
int
IDSpeed
= 7;
76
77
[JsonProperty]
78
public
int
currentPage
;
79
80
[JsonProperty]
81
public
int
itemsPerPage
= 6;
82
83
[JsonProperty]
84
public
int
id
;
85
86
[JsonProperty]
87
public
List<Page>
pages
=
new
List<Page>();
88
89
public
bool
dirty
;
90
91
public
WidgetHotbar
actor
;
92
93
public
HotbarManager
manager
=>
EClass
.
player
.
hotbars
;
94
95
public
HotItem
SelectedItem
=>
pages
[
currentPage
].SelectedItem;
96
97
public
HotItem
DefaultItem
=>
null
;
98
99
public
bool
IsLocked
=>
id
== 3;
100
101
public
bool
IsUserHotbar
102
{
103
get
104
{
105
if
(
id
!= 5)
106
{
107
return
id
== 6;
108
}
109
return
true
;
110
}
111
}
112
113
public
bool
ShowFunctionKey
=>
id
== 5;
114
115
public
Page
CurrentPage
=>
pages
[(
currentPage
>= 0) ?
currentPage
: 0];
116
117
public
void
SetSlotNum
(
int
a)
118
{
119
itemsPerPage
= a;
120
foreach
(
Page
page
in
pages
)
121
{
122
ValidatePage
(page);
123
}
124
}
125
126
public
void
AddPage
()
127
{
128
Page
page =
new
Page
();
129
pages
.Add(page);
130
ValidatePage
(page);
131
}
132
133
public
void
ValidatePage
(
Page
page,
int
num = -1)
134
{
135
if
(num != -1 &&
itemsPerPage
< num)
136
{
137
itemsPerPage
= num;
138
}
139
if
(page.
items
.Count <
itemsPerPage
)
140
{
141
int
num2 =
itemsPerPage
- page.
items
.Count;
142
for
(
int
i = 0; i < num2; i++)
143
{
144
page.
items
.Add(
DefaultItem
);
145
}
146
}
147
}
148
149
public
void
SetPage
(
int
pageIndex)
150
{
151
currentPage
= pageIndex;
152
}
153
154
public
void
Remove
(
HotItem
item
)
155
{
156
for
(
int
i = 0; i <
pages
.Count; i++)
157
{
158
for
(
int
j = 0; j <
pages
[i].items.Count; j++)
159
{
160
if
(
pages
[i].items[j] ==
item
)
161
{
162
SetItem
(
null
, j, i, refreshActor:
true
);
163
}
164
}
165
}
166
}
167
168
public
HotItem
GetItem
(
int
index,
int
pageIndex = -1)
169
{
170
return
pages
[(pageIndex == -1) ?
currentPage
: pageIndex].
GetItem
(index);
171
}
172
173
public
HotItem
SetItem
(
HotItem
item
,
int
index = -1,
int
pageIndex = -1,
bool
refreshActor =
false
)
174
{
175
if
(
item
==
null
)
176
{
177
item
=
DefaultItem
;
178
}
179
if
(pageIndex == -1)
180
{
181
pageIndex =
currentPage
;
182
}
183
if
(pageIndex >=
pages
.Count)
184
{
185
AddPage
();
186
pageIndex = pages.Count - 1;
187
}
188
Page
page =
pages
[pageIndex];
189
ValidatePage
(page, index + 1);
190
page.
SetItem
(
this
,
item
, index);
191
item
?.OnAddedToBar();
192
if
(refreshActor && (
bool
)
actor
)
193
{
194
actor
.
RebuildPage
();
195
}
196
return
item
;
197
}
198
199
public
void
Select
(
HotItem
item
)
200
{
201
SE.SelectHotitem();
202
EClass
.
player
.
SetCurrentHotItem
(
item
);
203
}
204
205
public
void
ToggleDisable
(
HotItem
item
)
206
{
207
item.disabled = !
item
.disabled;
208
if
(
item
.disabled)
209
{
210
item
.OnUnselect();
211
}
212
SE.SelectHotitem();
213
EClass
.
player
.
SetCurrentHotItem
(
item
.disabled ?
null
:
item
);
214
}
215
216
public
void
Unselect
(
int
pageIndex = -1)
217
{
218
if
(pageIndex == -1)
219
{
220
pageIndex =
currentPage
;
221
}
222
HotItem
selectedItem =
pages
[pageIndex].SelectedItem;
223
pages
[pageIndex].selected = -1;
224
selectedItem?.
OnUnselect
();
225
EClass
.
player
.
SetCurrentHotItem
(
null
);
226
}
227
228
public
HotItem
GetSelectedItem
()
229
{
230
int
selected =
pages
[
currentPage
].selected;
231
if
(selected == -1)
232
{
233
return
null
;
234
}
235
return
pages
[
currentPage
].items[selected];
236
}
237
238
public
int
GetNextSelectableIndex
(
int
pageIndex = -1)
239
{
240
if
(pageIndex == -1)
241
{
242
pageIndex =
currentPage
;
243
}
244
Page
page =
pages
[pageIndex];
245
int
num = page.selected + 1;
246
if
(num >=
itemsPerPage
)
247
{
248
num = -1;
249
}
250
ValidatePage
(page);
251
return
num;
252
}
253
254
public
int
GetPrevSelectableIndex
(
int
pageIndex = -1)
255
{
256
if
(pageIndex == -1)
257
{
258
pageIndex =
currentPage
;
259
}
260
Page
page =
pages
[pageIndex];
261
int
num = page.selected - 1;
262
if
(num < -1)
263
{
264
num =
itemsPerPage
- 1;
265
}
266
ValidatePage
(page);
267
return
num;
268
}
269
}
ContainerFlag.item
@ item
EClass
Definition:
EClass.cs:5
EClass.player
static Player player
Definition:
EClass.cs:12
HotItem
Definition:
HotItem.cs:5
HotItem.OnUnselect
virtual void OnUnselect()
Definition:
HotItem.cs:87
HotbarManager
Definition:
HotbarManager.cs:4
Hotbar.Page
Definition:
Hotbar.cs:14
Hotbar.Page.selected
int selected
Definition:
Hotbar.cs:19
Hotbar.Page.items
List< HotItem > items
Definition:
Hotbar.cs:16
Hotbar.Page.GetItem
HotItem GetItem(int index)
Definition:
Hotbar.cs:57
Hotbar.Page.SetItem
void SetItem(Hotbar h, HotItem item, int index)
Definition:
Hotbar.cs:33
Hotbar.Page.SelectedItem
HotItem SelectedItem
Definition:
Hotbar.cs:22
Hotbar
Definition:
Hotbar.cs:5
Hotbar.IDSpeed
const int IDSpeed
Definition:
Hotbar.cs:75
Hotbar.GetPrevSelectableIndex
int GetPrevSelectableIndex(int pageIndex=-1)
Definition:
Hotbar.cs:254
Hotbar.GetItem
HotItem GetItem(int index, int pageIndex=-1)
Definition:
Hotbar.cs:168
Hotbar.Select
void Select(HotItem item)
Definition:
Hotbar.cs:199
Hotbar.DefaultItem
HotItem DefaultItem
Definition:
Hotbar.cs:97
Hotbar.ToggleDisable
void ToggleDisable(HotItem item)
Definition:
Hotbar.cs:205
Hotbar.GetSelectedItem
HotItem GetSelectedItem()
Definition:
Hotbar.cs:228
Hotbar.IDMainMenu
const int IDMainMenu
Definition:
Hotbar.cs:67
Hotbar.IDUser3
const int IDUser3
Definition:
Hotbar.cs:73
Hotbar.IsUserHotbar
bool IsUserHotbar
Definition:
Hotbar.cs:102
Hotbar.Type
Type
Definition:
Hotbar.cs:7
Hotbar.Type.ZoomMenu
@ ZoomMenu
Hotbar.Type.Default
@ Default
Hotbar.Type.Main
@ Main
Hotbar.ValidatePage
void ValidatePage(Page page, int num=-1)
Definition:
Hotbar.cs:133
Hotbar.IDUser2
const int IDUser2
Definition:
Hotbar.cs:71
Hotbar.itemsPerPage
int itemsPerPage
Definition:
Hotbar.cs:81
Hotbar.SetSlotNum
void SetSlotNum(int a)
Definition:
Hotbar.cs:117
Hotbar.GetNextSelectableIndex
int GetNextSelectableIndex(int pageIndex=-1)
Definition:
Hotbar.cs:238
Hotbar.Remove
void Remove(HotItem item)
Definition:
Hotbar.cs:154
Hotbar.pages
List< Page > pages
Definition:
Hotbar.cs:87
Hotbar.CurrentPage
Page CurrentPage
Definition:
Hotbar.cs:115
Hotbar.Unselect
void Unselect(int pageIndex=-1)
Definition:
Hotbar.cs:216
Hotbar.ShowFunctionKey
bool ShowFunctionKey
Definition:
Hotbar.cs:113
Hotbar.dirty
bool dirty
Definition:
Hotbar.cs:89
Hotbar.AddPage
void AddPage()
Definition:
Hotbar.cs:126
Hotbar.manager
HotbarManager manager
Definition:
Hotbar.cs:93
Hotbar.currentPage
int currentPage
Definition:
Hotbar.cs:78
Hotbar.IsLocked
bool IsLocked
Definition:
Hotbar.cs:99
Hotbar.SetItem
HotItem SetItem(HotItem item, int index=-1, int pageIndex=-1, bool refreshActor=false)
Definition:
Hotbar.cs:173
Hotbar.actor
WidgetHotbar actor
Definition:
Hotbar.cs:91
Hotbar.id
int id
Definition:
Hotbar.cs:84
Hotbar.SetPage
void SetPage(int pageIndex)
Definition:
Hotbar.cs:149
Hotbar.IDBuild
const int IDBuild
Definition:
Hotbar.cs:69
Hotbar.SelectedItem
HotItem SelectedItem
Definition:
Hotbar.cs:95
Player.hotbars
HotbarManager hotbars
Definition:
Player.cs:886
Player.SetCurrentHotItem
void SetCurrentHotItem(HotItem item)
Definition:
Player.cs:2046
WidgetHotbar
Definition:
WidgetHotbar.cs:8
WidgetHotbar.RebuildPage
void RebuildPage(int page=-1)
Definition:
WidgetHotbar.cs:175
Elin
Hotbar.cs
Generated by
1.9.6