2024-07-02 12:18:32 +02:00
|
|
|
function preview_overlay_scalar(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _angle, _scale, _type = 0) {
|
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);
|
2024-03-28 08:33:28 +01:00
|
|
|
var _r = 10;
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
var _ax = _x + __ax * _s;
|
|
|
|
var _ay = _y + __ay * _s;
|
|
|
|
|
|
|
|
if(drag_type) {
|
|
|
|
index = 1;
|
2024-07-07 12:55:27 +02:00
|
|
|
var _dist = point_distance(_mx, _my, _x, _y) / (_s * _scale);
|
|
|
|
var _sign = abs(angle_difference(point_direction(_mx, _my, _x, _y), _angle)) > 90? 1 : -1;
|
2024-07-07 06:07:42 +02:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
if(key_mod_press(CTRL))
|
2024-07-07 12:55:27 +02:00
|
|
|
_dist = round(_dist);
|
|
|
|
_dist *= _sign;
|
|
|
|
|
|
|
|
if(setValueInspector( _dist ))
|
2023-01-17 08:11:55 +01:00
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
|
|
|
if(mouse_release(mb_left)) {
|
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
2024-07-07 12:55:27 +02:00
|
|
|
|
2024-03-28 08:33:28 +01:00
|
|
|
if(interact && point_in_circle(_mx, _my, _ax, _ay, _r)) {
|
2023-01-17 08:11:55 +01:00
|
|
|
hover = 1;
|
|
|
|
index = 1;
|
2024-03-28 08:33:28 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
|
|
|
drag_type = 1;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = _ax;
|
|
|
|
drag_sy = _ay;
|
|
|
|
}
|
|
|
|
}
|
2024-07-07 12:55:27 +02:00
|
|
|
|
2024-04-22 14:13:03 +02:00
|
|
|
__overlay_hover = array_verify(__overlay_hover, 1);
|
|
|
|
__overlay_hover[0] = lerp_float(__overlay_hover[0], index, 4);
|
2024-07-02 12:18:32 +02:00
|
|
|
draw_anchor(__overlay_hover[0], _ax, _ay, _r, _type);
|
2024-04-13 07:32:04 +02:00
|
|
|
|
2024-07-07 06:07:42 +02:00
|
|
|
if(overlay_draw_text) {
|
2024-10-02 10:26:08 +02:00
|
|
|
if(overlay_text_valign == fa_top) {
|
|
|
|
draw_set_text(_f_p2b, fa_center, fa_bottom, COLORS._main_accent);
|
|
|
|
draw_text_add(round(_ax), round(_ay - 4), name);
|
|
|
|
|
|
|
|
} else if(overlay_text_valign == fa_bottom) {
|
|
|
|
draw_set_text(_f_p2b, fa_center, fa_top, COLORS._main_accent);
|
|
|
|
draw_text_add(round(_ax), round(_ay + 4), name);
|
|
|
|
|
|
|
|
}
|
2024-07-07 06:07:42 +02:00
|
|
|
}
|
2024-01-23 07:51:28 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
return hover;
|
|
|
|
}
|