forked from Balatro-Multiplayer/BalatroMultiplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy_location.lua
More file actions
285 lines (274 loc) · 6.63 KB
/
Copy pathenemy_location.lua
File metadata and controls
285 lines (274 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
function MP.UI.enemy_location_blind_render()
local blind_key, blind_object = MP.GAME.enemy.location_blind, nil
if blind_key then blind_object = G.P_BLINDS[blind_key] end
local blind_object_render
if blind_object then
blind_object_render = SMODS.create_sprite(
0,
0,
0.4,
0.4,
blind_object.atlas or "blind_chips",
blind_object.pos or G.P_BLINDS.bl_small.pos
)
blind_object_render:define_draw_steps({
{ shader = "dissolve", shadow_height = 0.05 * 0.4 * 0.75 },
{ shader = "dissolve" },
})
elseif blind_key and blind_key ~= "" then
blind_object_render = DynaText({
string = { blind_key or "Unknown" },
colours = { G.C.WHITE },
scale = 0.35,
shadow = true,
})
else
blind_object_render = Moveable()
end
return blind_object_render
end
function MP.UI.round_score_definition()
return {
n = G.UIT.C,
config = { align = "cm", padding = 0.1, func = "mp_setup_hover_enemy_location_display" },
nodes = {
{
n = G.UIT.C,
config = { align = "cm", minw = 1.3 },
nodes = {
{
n = G.UIT.R,
config = { align = "cm", padding = 0, maxw = 1.3 },
nodes = {
{
n = G.UIT.T,
config = {
text = G.SETTINGS.language == "vi" and localize("k_lower_score")
or localize("k_round"),
scale = 0.42,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
},
{
n = G.UIT.R,
config = { align = "cm", padding = 0, maxw = 1.3 },
nodes = {
{
n = G.UIT.T,
config = {
text = G.SETTINGS.language == "vi" and localize("k_round")
or localize("k_lower_score"),
scale = 0.42,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
},
},
},
{
n = G.UIT.C,
config = { align = "cm", minw = 3.3, minh = 0.7, r = 0.1, colour = G.C.DYN_UI.BOSS_DARK },
nodes = {
{
n = G.UIT.O,
config = {
w = 0.5,
h = 0.5,
object = get_stake_sprite(G.GAME.stake or 1, 0.5),
hover = true,
can_collide = false,
},
},
{ n = G.UIT.B, config = { w = 0.1, h = 0.1 } },
{
n = G.UIT.T,
config = {
ref_table = G.GAME,
ref_value = "chips_text",
lang = G.LANGUAGES["en-us"],
scale = 0.85,
colour = G.C.WHITE,
id = "chip_UI_count",
func = "chip_UI_set",
shadow = true,
},
},
},
},
},
}
end
function MP.UI.enemy_location_definition()
return {
n = G.UIT.C,
config = { align = "cm", padding = 0.1 },
nodes = {
{
n = G.UIT.O,
config = {
w = 0.5,
h = 0.5,
object = get_stake_sprite(G.GAME.stake or 1, 0.5),
hover = true,
can_collide = false,
},
},
{
n = G.UIT.C,
config = { align = "cm", minw = 1.2 },
nodes = {
{
n = G.UIT.R,
config = { align = "cm", padding = 0, maxw = 1.2 },
nodes = {
{
n = G.UIT.T,
config = {
text = localize("ml_enemy_loc")[1],
scale = 0.42,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
},
{
n = G.UIT.R,
config = { align = "cm", padding = 0, maxw = 1.2 },
nodes = {
{
n = G.UIT.T,
config = {
text = localize("ml_enemy_loc")[2],
scale = 0.42,
colour = G.C.UI.TEXT_LIGHT,
shadow = true,
},
},
},
},
},
},
{
n = G.UIT.C,
config = { align = "cm", minw = 2.8, minh = 0.7, r = 0.1, colour = G.C.DYN_UI.BOSS_DARK },
nodes = {
{
n = G.UIT.C,
config = {
maxw = 2.2,
align = "cm",
},
nodes = {
{
n = G.UIT.T,
config = {
ref_table = MP.GAME.enemy,
ref_value = "location",
scale = 0.35,
colour = G.C.WHITE,
id = "chip_UI_count",
shadow = true,
maxw = 2.5,
},
},
},
},
{ n = G.UIT.B, config = { w = 0.1, h = 0.1 } },
{
n = G.UIT.O,
config = {
object = MP.UI.enemy_location_blind_render(),
id = "mp_enemy_location_render",
},
},
},
},
},
}
end
function MP.UI.show_enemy_location()
if not G.HUD then return end
local row_dollars_chips = G.HUD:get_UIE_by_ID("row_dollars_chips")
if row_dollars_chips then
row_dollars_chips.children[1]:remove()
row_dollars_chips.children[1] = nil
G.HUD:add_child(MP.UI.enemy_location_definition(), row_dollars_chips)
end
end
function MP.UI.hide_enemy_location()
if not G.HUD then return end
local row_dollars_chips = G.HUD:get_UIE_by_ID("row_dollars_chips")
if row_dollars_chips then
row_dollars_chips.children[1]:remove()
row_dollars_chips.children[1] = nil
G.HUD:add_child(MP.UI.round_score_definition(), row_dollars_chips)
end
end
function MP.UI.update_enemy_location_render()
if not G.HUD then return end
local renderer = G.HUD:get_UIE_by_ID("mp_enemy_location_render")
if renderer then
local blind_object_render = MP.UI.enemy_location_blind_render()
renderer.config.object:remove()
renderer.config.object = blind_object_render
blind_object_render.parent = renderer
renderer.UIBox:recalculate()
end
local hover_renderer = G.mp_enemy_location_ui and G.mp_enemy_location_ui:get_UIE_by_ID("mp_enemy_location_render")
if hover_renderer then
local blind_object_render = MP.UI.enemy_location_blind_render()
hover_renderer.config.object:remove()
hover_renderer.config.object = blind_object_render
blind_object_render.parent = hover_renderer
hover_renderer.UIBox:recalculate()
end
end
G.FUNCS.mp_setup_hover_enemy_location_display = function(e)
e.config.func = nil
if MP.LOBBY.config.enemy_location_disabled then return end
e.states.collide.can = true
e.states.hover.can = true
local old_hover = e.hover
function e:hover(...)
old_hover(self, ...)
if not G.mp_enemy_location_ui then
G.mp_enemy_location_ui = UIBox({
definition = {
n = G.UIT.ROOT,
config = { colour = G.C.DYN_UI.BOSS_MAIN, emboss = 0.05, r = 0.25 },
nodes = {
MP.UI.enemy_location_definition(),
},
},
config = {
align = "tmi",
offset = { x = 0, y = self.T.h + 0.15 },
major = self,
instance_type = "CARD",
},
})
end
end
local old_stop_hover = e.stop_hover
function e:stop_hover(...)
old_stop_hover(self, ...)
if G.mp_enemy_location_ui then
G.mp_enemy_location_ui:remove()
G.mp_enemy_location_ui = nil
end
end
local old_remove = e.remove
function e:remove(...)
old_remove(self, ...)
if G.mp_enemy_location_ui then
G.mp_enemy_location_ui:remove()
G.mp_enemy_location_ui = nil
end
end
end