Pixel-Composer/scripts/preview_overlay_scalar/preview_overlay_scalar.gml

43 lines
964 B
Text
Raw Normal View History

2023-04-05 20:13:27 +02:00
function preview_overlay_scalar(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _angle, _scale, _spr) {
2023-09-15 20:12:02 +02:00
var _val = getValue();
2023-01-17 08:11:55 +01:00
var hover = -1;
2023-05-03 21:42:17 +02:00
if(!is_real(_val)) return hover;
2023-01-17 08:11:55 +01:00
var index = 0;
var __ax = lengthdir_x(_val * _scale, _angle);
var __ay = lengthdir_y(_val * _scale, _angle);
var _ax = _x + __ax * _s;
var _ay = _y + __ay * _s;
if(drag_type) {
index = 1;
var dist = point_distance(_mx, _my, _x, _y) / _s / _scale;
if(key_mod_press(CTRL))
dist = round(dist);
if(setValue( dist ))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
2023-10-18 14:58:55 +02:00
if(interact && active && point_in_circle(_mx, _my, _ax, _ay, 8)) {
2023-01-17 08:11:55 +01:00
hover = 1;
index = 1;
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_mx = _mx;
drag_my = _my;
drag_sx = _ax;
drag_sy = _ay;
}
}
2023-04-08 20:06:27 +02:00
draw_sprite_colored(_spr, index, _ax, _ay);
2023-01-17 08:11:55 +01:00
return hover;
}