2022-01-13 05:24:03 +01:00
|
|
|
function checkBox(_onClick) constructor {
|
|
|
|
active = false;
|
|
|
|
hover = false;
|
|
|
|
|
|
|
|
onClick = _onClick;
|
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
static draw = function(_x, _y, _value, _m, _s = 28) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var cx = _x;
|
|
|
|
var cy = _y;
|
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
draw_sprite_stretched(s_checkbox, _value * 2, cx, cy, _s, _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
if(hover && point_in_rectangle(_m[0], _m[1], cx, cy, cx + _s, cy + _s)) {
|
|
|
|
draw_sprite_stretched(s_checkbox, _value * 2 + 1, _x, _y, _s, _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(active && mouse_check_button_pressed(mb_left)) {
|
|
|
|
if(onClick) onClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hover = false;
|
|
|
|
active = false;
|
|
|
|
}
|
|
|
|
}
|