2022-09-23 13:28:42 +02:00
|
|
|
enum PUPPET_CONTROL {
|
|
|
|
mode,
|
|
|
|
cx,
|
|
|
|
cy,
|
|
|
|
fx,
|
|
|
|
fy,
|
|
|
|
width,
|
|
|
|
height
|
|
|
|
}
|
|
|
|
|
|
|
|
enum PUPPET_FORCE_MODE {
|
|
|
|
move,
|
|
|
|
pinch,
|
|
|
|
inflate,
|
|
|
|
wind,
|
|
|
|
}
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
function controlPointBox(_onModify) : widget() constructor {
|
2022-09-23 13:28:42 +02:00
|
|
|
onModify = _onModify;
|
|
|
|
onSurfaceSize = -1;
|
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
tbCx = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.cx, toNumber(val)); });
|
|
|
|
tbCy = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.cy, toNumber(val)); });
|
|
|
|
tbFx = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.fx, toNumber(val)); });
|
|
|
|
tbFy = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.fy, toNumber(val)); });
|
|
|
|
tbW = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.width, max(0, toNumber(val))); });
|
|
|
|
tbH = new textBox(TEXTBOX_INPUT.float, function(val) { onModify(PUPPET_CONTROL.height, max(0, toNumber(val))); });
|
2022-09-23 13:28:42 +02:00
|
|
|
rot = new rotator(function(val) { onModify(PUPPET_CONTROL.fy, toNumber(val)); });
|
|
|
|
tbFx.slidable = true;
|
|
|
|
tbFy.slidable = true;
|
|
|
|
tbW.slidable = true;
|
|
|
|
tbH.slidable = true;
|
|
|
|
|
|
|
|
sW = new slider(0, 32, 0.1, function(val) { onModify(PUPPET_CONTROL.width, toNumber(val)); });
|
|
|
|
|
|
|
|
sMode = ["Move", "Pinch", "Inflate", "Wind"];
|
|
|
|
scMode = new scrollBox(
|
|
|
|
sMode,
|
|
|
|
function(val) { onModify(PUPPET_CONTROL.mode, toNumber(val)); }
|
|
|
|
);
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
static setInteract = function(interactable = noone) {
|
|
|
|
self.interactable = interactable;
|
|
|
|
scMode.interactable = interactable;
|
|
|
|
tbCx.interactable = interactable;
|
|
|
|
tbCy.interactable = interactable;
|
|
|
|
tbFx.interactable = interactable;
|
|
|
|
tbFy.interactable = interactable;
|
|
|
|
tbW.interactable = interactable;
|
|
|
|
tbH.interactable = interactable;
|
|
|
|
rot.interactable = interactable;
|
|
|
|
}
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
static register = function(parent = noone) {
|
2023-01-25 06:49:00 +01:00
|
|
|
scMode.register(parent);
|
2023-01-17 08:11:55 +01:00
|
|
|
tbCx.register(parent);
|
|
|
|
tbCy.register(parent);
|
|
|
|
tbFx.register(parent);
|
|
|
|
tbFy.register(parent);
|
|
|
|
tbW.register(parent);
|
|
|
|
tbH.register(parent);
|
|
|
|
rot.register(parent);
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static draw = function(_x, _y, _w, _data, _m, _rx, _ry) {
|
2023-01-17 08:11:55 +01:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
tbCx.hover = hover; tbCx.active = active;
|
|
|
|
tbCy.hover = hover; tbCy.active = active;
|
|
|
|
tbFx.hover = hover; tbFx.active = active;
|
|
|
|
tbFy.hover = hover; tbFy.active = active;
|
|
|
|
tbW.hover = hover; tbW.active = active;
|
|
|
|
sW.hover = hover; sW.active = active;
|
|
|
|
tbH.hover = hover; tbH.active = active;
|
|
|
|
scMode.hover = hover; scMode.active = active;
|
|
|
|
rot.hover = hover; rot.active = active;
|
|
|
|
|
|
|
|
var yy = _y;
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
scMode.draw(_x, yy, _w, TEXTBOX_HEIGHT, sMode[_data[PUPPET_CONTROL.mode]], _m, _rx, _ry);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var lw = ui(80);
|
2022-09-23 13:28:42 +02:00
|
|
|
var w = _w / 2 - lw;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "cx");
|
|
|
|
draw_text(_x + _w / 2 + ui(10), yy + ui(17), "cy");
|
|
|
|
tbCx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.cx], _m);
|
|
|
|
tbCy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.cy], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
|
|
|
switch(_data[PUPPET_CONTROL.mode]) {
|
|
|
|
case PUPPET_FORCE_MODE.move:
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "fx");
|
|
|
|
draw_text(_x + _w / 2 + ui(10), yy + ui(17), "fy");
|
|
|
|
tbFx.draw(_x + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fx], _m);
|
|
|
|
tbFy.draw(_x + _w / 2 + lw, yy, w, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fy], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "radius");
|
|
|
|
sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
break;
|
|
|
|
case PUPPET_FORCE_MODE.pinch:
|
|
|
|
case PUPPET_FORCE_MODE.inflate:
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "radius");
|
|
|
|
sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "strength");
|
|
|
|
tbH.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.height], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
break;
|
|
|
|
case PUPPET_FORCE_MODE.wind:
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "stength");
|
|
|
|
tbFx.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fx], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(_x, yy + ui(17), "width");
|
|
|
|
tbW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m);
|
|
|
|
yy += TEXTBOX_HEIGHT + ui(8);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
|
|
|
rot.draw(_x + _w / 2, yy, _data[PUPPET_CONTROL.fy], _m);
|
2022-11-03 11:44:49 +01:00
|
|
|
yy += ui(94 + 8);
|
2022-09-23 13:28:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
resetFocus();
|
2022-09-23 13:28:42 +02:00
|
|
|
|
|
|
|
return yy - _y;
|
|
|
|
}
|
|
|
|
}
|