Skip to content

Commit 661cd7b

Browse files
committed
fix: clamp dragbar progress to 1.0 to avoid drawing past bar length
1 parent 6f9a995 commit 661cd7b

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

scripts/draw_dragbar/draw_dragbar.gml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ function draw_dragbar(value, max, x, y, length, id, str, kstr, window){
88
if ((theme == 3 && fdark) || (isplayer && blackout)) draw_set_color(make_color_rgb(134, 134, 134))
99
draw_rectangle(x, y, x + length, y + 2 + (theme = 3), 0)
1010
draw_set_alpha(0.5 * dropalpha)
11+
var progress = min(value / max, 1.0)
1112
if (theme = 3) {
1213
draw_rectangle(x - 1, y + 1, x + length + 1, y + 2, 0)
1314
draw_set_alpha(1 * dropalpha)
1415
draw_set_color(accent[5])
15-
draw_rectangle(x, y, floor(x + (value / max) * length + 0.5), y + 2 + (theme = 3), 0)
16+
draw_rectangle(x, y, floor(x + progress * length + 0.5), y + 2 + (theme = 3), 0)
1617
draw_set_alpha(0.5 * dropalpha)
17-
draw_rectangle(x - 1, y + 1, floor(x + (value / max) * length + 0.5), y + 2, 0)
18+
draw_rectangle(x - 1, y + 1, floor(x + progress * length + 0.5), y + 2, 0)
1819
}
1920
draw_set_alpha(1 * dropalpha)
2021
a = ((mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) || mouse_rectangle(x - 3, y + 1 - 3, length + 6, 6 + (theme = 3))) && window = obj_controller.window)
@@ -24,14 +25,14 @@ function draw_dragbar(value, max, x, y, length, id, str, kstr, window){
2425
draw_set_color(c_white)
2526
if (fdark || (isplayer && blackout)) draw_set_color(make_color_rgb(69, 69, 69))
2627
draw_set_alpha(0.5 * dropalpha)
27-
draw_circle(floor(x + (value / max) * length + 0.5), y + 1, 11, 0)
28+
draw_circle(floor(x + progress * length + 0.5), y + 1, 11, 0)
2829
draw_set_alpha(1 * dropalpha)
29-
draw_circle(floor(x + (value / max) * length + 0.5), y + 1, 10, 0)
30-
draw_set_color(accent[5 + (mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window)])
30+
draw_circle(floor(x + progress * length + 0.5), y + 1, 10, 0)
31+
draw_set_color(accent[5 + (mouse_rectangle(x + progress * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window)])
3132
draw_set_alpha(0.5 * dropalpha)
32-
draw_circle(floor(x + (value / max) * length + 0.5), y + 1, 6 + (mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window), 0)
33+
draw_circle(floor(x + progress * length + 0.5), y + 1, 6 + (mouse_rectangle(x + progress * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + progress * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window), 0)
3334
draw_set_alpha(1 * dropalpha)
34-
draw_circle(floor(x + (value / max) * length + 0.5), y + 1, 5 + (mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + (value / max) * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window), 0)
35+
draw_circle(floor(x + progress * length + 0.5), y + 1, 5 + (mouse_rectangle(x + progress * length - 6, y + 1 - 6, 13, 13) * (!mouse_check_button(mb_left)) - ((mouse_rectangle(x + progress * length - 6, y + 1 - 6, 13, 13) || aa = id) && mouse_check_button(mb_left))) * (window = obj_controller.window), 0)
3536
}
3637
draw_theme_color()
3738
if (a || aa = id) {

0 commit comments

Comments
 (0)