-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBusinessMonitor.pluto
494 lines (438 loc) · 11.9 KB
/
BusinessMonitor.pluto
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
--stupid autoupdater
if async_http.have_access() then
local SCRIPT_VERSION = '0.1.1'
local resp = false
async_http.init(
'raw.githubusercontent.com/stagnate6628/stand-businessmonitor/main/version',
nil,
function(body, headers, status_code)
if soup.version_compare(SCRIPT_VERSION, body) == -1 then
menu.my_root():action(
'Update Script',
{},
$"\"{body}\" is available, you are currently on \"{SCRIPT_VERSION}\".",
function()
async_http.init(
'raw.githubusercontent.com/stagnate6628/stand-businessmonitor/main/BusinessMonitor.pluto',
nil,
function(body_)
local f = assert(io.open($'{filesystem.scripts_dir()}{SCRIPT_RELPATH}', 'wb'))
assert(f:write(body_))
f:close()
util.restart_script()
end)
async_http.dispatch()
end
)
menu.my_root():divider('')
end
resp = true
end,
function()
resp = true
end
)
async_http.dispatch()
repeat
util.yield()
until resp
end
local char_slot = util.get_char_slot()
local og_util_stat_get_int64 = util.stat_get_int64
util.stat_get_int64 = function(stat)
return og_util_stat_get_int64($'mp{char_slot}_{stat}')
end
local x = 0
local y = 0
local width = 0.167
local height = 0.39
local gap_0 = 0.003
local align_0 = ALIGN_TOP_LEFT
local gap_1 = 0.11
local align_1 = ALIGN_TOP_RIGHT
local gap_2 = 0.16
local align_2 = ALIGN_TOP_RIGHT
local row_spacing = 0.0165
local text_size = 0.425
local show_max = true
local background_colour = { r = 0, g = 0, b = 0, a = 0.8 }
local text_colour = { r = 1, g = 1, b = 1, a = 1 }
local max_colour = { r = 0, g = 1, b = 0, a = 1 }
local safe<const> = {
{
label = 'Nightclub',
stat_1 = 'CLUB_POPULARITY',
stat_2 = 'CLUB_SAFE_CASH_VALUE',
max = 250_000
},
{
label = 'Arcade',
stat_2 = 'ARCADE_SAFE_CASH_VALUE',
max = 100_000
},
{
label = 'Agency',
stat_2 = 'FIXER_SAFE_CASH_VALUE',
max = 250_000
}
}
--[[
0: forgery
1: weed
2: cash
3: meth,
4: cocaine
]]
local mapping<const> = {
[1] = 3,
[2] = 1,
[3] = 4,
[4] = 2,
[5] = 0,
[6] = 3,
[7] = 1,
[8] = 4,
[9] = 2,
[10] = 0,
[11] = 3,
[12] = 1,
[13] = 4,
[14] = 2,
[15] = 0,
[16] = 3,
[17] = 1,
[18] = 4,
[19] = 2,
[20] = 0
}
local mc<const> = {
[0] = { label = 'Forgery', max = 60 },
[1] = { label = 'Weed', max = 80 },
[2] = { label = 'Cash', max = 40 },
[3] = { label = 'Meth', max = 20 },
[4] = { label = 'Cocaine', max = 10 },
[5] = { label = 'Bunker', max = 100 },
[6] = { label = 'Acid Lab', max = 160 }
}
local nc<const> = {
{ label = 'Hub Cargo', max = 50 },
{ label = 'Hub Weapons', max = 100 },
{ label = 'Hub Cocaine', max = 10 },
{ label = 'Hub Meth', max = 20 },
{ label = 'Hub Weed', max = 80 },
{ label = 'Hub Forgery', max = 60 },
{ label = 'Hub Cash', max = 40 }
}
local ceo<const> = {
{ label = 'Warehouse 1' },
{ label = 'Warehouse 2' },
{ label = 'Warehouse 3' },
{ label = 'Warehouse 4' },
{ label = 'Warehouse 5' }
}
local ceo_data<const> = {
{ label = 'Pacific Bait Storage', max = 16 },
{ label = 'White Widow Garage', max = 16 },
{ label = 'Celltowa Unit', max = 16 },
{ label = 'Convenience Store Lockup', max = 16 },
{ label = 'Foreclosed Garage', max = 16 },
{ label = 'Xero Gas Factory', max = 111 },
{ label = 'Derriere Lingerie Backlot', max = 42 },
{ label = 'Bilgeco Warehouse', max = 111 },
{ label = 'Pier 400 Utility Building', max = 16 },
{ label = 'GEE Warehouse', max = 42 },
{ label = 'LS Marine Building 3', max = 42 },
{ label = 'Railyard Warehouse', max = 42 },
{ label = 'Fridgit Annexe', max = 42 },
{ label = 'Disused Factory Outlet', max = 42 },
{ label = 'Discount Retail Unit', max = 42 },
{ label = 'Logistics Depot', max = 111 },
{ label = 'Darnell Bros Warehouse', max = 111 },
{ label = 'Wholesale Furniture', max = 111 },
{ label = 'Cypress Warehouses', max = 111 },
{ label = 'West Vinewood Backlot', max = 111 },
{ label = 'Old Power Station', max = 42 },
{ label = 'Walker & Sons Warehouse', max = 111 }
}
local r = menu.my_root()
local views = r:list('Views', {}, 'Configure what to monitor.')
local safe_list = views:list('Safes')
local safe_list_children
local mc_list = views:list('MC Business')
local mc_list_children
local nc_list = views:list('Nightclub')
local nc_list_children
local ceo_list = views:list('Special Cargo Warehouse')
local ceo_list_children
do
local function add_children_to_list(list, children)
for children as v do
list:toggle(v.label, {}, '', function(s)
v.value = s
end, true)
end
end
local function run_list(children, cb)
for children as v do
cb(v)
end
end
add_children_to_list(safe_list, safe)
safe_list_children = safe_list:getChildren()
add_children_to_list(mc_list, mc)
mc_list_children = mc_list:getChildren()
add_children_to_list(nc_list, nc)
nc_list_children = nc_list:getChildren()
add_children_to_list(ceo_list, ceo)
ceo_list_children = ceo_list:getChildren()
safe_list:attachBefore(
menu.shadow_root():list_select('State', {}, '', { 'Disable All', 'Enable All' }, 2, function(idx)
local state = idx == 2
run_list(safe_list_children, function(v)
v.value = state
end)
run_list(mc_list_children, function(v)
v.value = state
end)
run_list(nc_list_children, function(v)
v.value = state
end)
run_list(ceo_list_children, function(v)
v.value = state
end)
end)
):setTemporary()
r:divider('Configuration')
local window = r:list('Window')
window:slider_float('Width', {'bmwidth'}, '', 0, 10000, 167, 1, function(v)
width = v / 1000
end)
window:slider_float('Height', {'bmheight'}, '', 0, 10000, 39, 1, function(v)
height = v / 100
end)
local position = r:list('Position')
position:slider_float('X Position', {'bmxpos'}, '', 0, 83, 0, 1, function(v)
x = v / 100
end)
position:slider_float('Y Position', {'bmypos'}, '', 0, 71, 0, 1, function(v)
y = v / 100
end)
position:slider_float('Label', {'bmlblpos'}, 'Aka. the "Property".', -1000, 1000, 3, 1, function(v)
gap_0 = v / 1000
end).precision = 4
position:slider_float('Left Column', {'bmllblpos'}, 'Aka. "Supplies".', -66, 32, 11, 1, function(v)
gap_1 = v / 100
end).precision = 4
position:slider_float('Right Column', {'bmrlblpos'}, 'Aka. "Product".', -68, 32, 16, 1, function(v)
gap_2 = v / 100
end).precision = 4
local text = r:list('Text')
text:slider_float('Scale', {'bmtxtscale'}, '', 0, 1000, 425, 1, function(v)
text_size = v / 1000
end).precision = 4
text:slider_float('Row Spacing', {'bmrowspacing'}, '', 0, 1000, 165, 1, function(v)
row_spacing = v / 10000
end).precision = 4
text:divider('Alignments')
text:slider('Label', {}, 'The "Property" text alignment.', 0, 9, align_0, 1, function(idx)
align_0 = idx
end)
text:slider('Left Column', {}, 'The "Supplies" text alignment.', 0, 9, align_1, 1, function(idx)
align_1 = idx
end)
text:slider('Right Column', {}, 'The "Product" text alignment.', 0, 9, align_2, 1, function(idx)
align_2 = idx
end)
text:divider('Other')
text:toggle('Show Capacity Values', {}, 'Displays the default maximum capacity for specific businesses.', function(s)
show_max = s
end, true)
local colours = r:list('Colours')
local contrast_warnings = true
local function is_contrast_sufficient(color_a, color_b)
--prevent toasts when on stop
if not SCRIPT_CAN_CONTINUE then
return true
end
if not contrast_warnings then
return false
end
return util.is_contrast_sufficient(color_a.r, color_a.g, color_a.b, color_b.r, color_b.g, color_b.b)
end
colours:toggle('Show Contrast Warnings', {}, 'Raises warnings if colors are not contrast sufficient for each other.', function(s)
contrast_warnings = s
end, contrast_warnings)
colours:colour('Background Colour', {}, '', background_colour, true, function(c, click_type)
background_colour = c
if not is_contrast_sufficient(background_colour, text_colour) then
util.toast('Text colour might be difficult to read...')
end
if not is_contrast_sufficient(background_colour, max_colour) then
util.toast('Max colour might be difficult to read...')
end
end)
colours:colour('Text Colour', {}, '', text_colour, false, function(c)
text_colour = c
if not is_contrast_sufficient(text_colour, background_colour) then
util.toast('Text colour might be difficult to read...')
end
end)
colours:colour('Max Colour', {}, '', max_colour, false, function(c)
max_colour = c
if not is_contrast_sufficient(max_colour, background_colour) then
util.toast('Max colour might be difficult to read...')
end
end)
menu.apply_command_states()
end
local tmp
local to_draw = {}
util.on_transition_finished(function()
char_slot = util.get_char_slot()
end)
util.create_tick_handler(function()
if util.is_session_started() then
directx.draw_rect(x, y, width, height, background_colour)
tmp = y
to_draw = {}
for k, v in safe do
if not safe_list_children[k].value then
continue
end
tmp += row_spacing
table.insert(to_draw, {
x_pos = x + gap_0,
y_pos = tmp,
text = v.label,
align = align_0,
colour = text_colour
})
if v.stat_1 then
local out = util.stat_get_int64(v.stat_1)
out = math.floor(out / 10)
table.insert(to_draw, {
x_pos = x + gap_1,
y_pos = tmp,
text = $"{out}%",
align = align_1,
colour = text_colour
})
end
local out = util.stat_get_int64(v.stat_2)
table.insert(to_draw, {
x_pos = x + gap_2,
y_pos = tmp,
text = out,
align = align_2,
colour = out == v.max ? max_colour : text_colour
})
end
for k, v in mc do
local curr
local should_exit
if 0 <= k and k <= 4 then
local p = util.stat_get_int64($'factoryslot{k}')
local p_info = mapping[p]
curr = mc[p_info]
if not curr then
continue
end
--i hate this
for mc_list_children as v_ do
if curr.label == v_.menu_name and not v_.value then
should_exit = true
end
end
if should_exit then
continue
end
else
if not mc_list_children[k+1].value then
continue
end
curr = mc[k]
end
tmp += row_spacing
local s = util.stat_get_int64($'mattotalforfactory{k}')
local p = util.stat_get_int64($'prodtotalforfactory{k}')
table.insert(to_draw, {
x_pos = x + gap_0,
y_pos = tmp,
text = curr.label,
align = align_0,
colour = text_colour
})
table.insert(to_draw, {
x_pos = x + gap_1,
y_pos = tmp,
text = $'{s}%',
align = align_1,
colour = text_colour
})
table.insert(to_draw, {
x_pos = x + gap_2,
y_pos = tmp,
text = show_max ? $'{p}/{curr.max}' : p,
align = align_2,
colour = p == curr.max ? max_colour : text_colour
})
end
for k, v in nc do
if not nc_list_children[k].value then
continue
end
tmp += row_spacing
local out = util.stat_get_int64($'hub_prod_total_{k-1}')
table.insert(to_draw, {
x_pos = x + gap_0,
y_pos = tmp,
text = v.label,
align = align_0,
colour = text_colour
})
table.insert(to_draw, {
x_pos = x + gap_2,
y_pos = tmp,
text = show_max ? $'{out}/{v.max}' : out,
align = align_2,
colour = out == v.max ? max_colour : text_colour
})
end
for k, v in ceo do
if not ceo_list_children[k].value then
continue
end
local slot = util.stat_get_int64($'prop_whouse_slot{k-1}')
if slot != 0 then
tmp += row_spacing
table.insert(to_draw, {
x_pos = x + gap_0,
y_pos = tmp,
text = ceo_data[slot].label,
align = align_0,
colour = text_colour
})
local out = util.stat_get_int64($'contotalforwhouse{k-1}')
local max = ceo_data[slot].max
table.insert(to_draw, {
x_pos = x + gap_2,
y_pos = tmp,
text = show_max ? $'{out}/{max}' : out,
align = align_2,
colour = out > max ? max_colour : text_colour
})
end
end
for to_draw as v do
directx.draw_text(
v.x_pos,
v.y_pos,
v.text,
v.align,
text_size,
v.colour
)
end
end
return true
end)