2024-03-24 04:58:08 +01:00
|
|
|
function sliderRange(_step, _int, _range, _onModify) : widget() constructor {
|
|
|
|
slide_range = _range;
|
|
|
|
curr_range = [ _range[0], _range[1] ];
|
|
|
|
stepSize = _step;
|
|
|
|
isInt = _int;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
onModify = _onModify;
|
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
tb_value_min = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(0, clamp(val, curr_range[0], curr_range[1])); }).setSlidable(_step, _int, _range);
|
|
|
|
tb_value_max = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(1, clamp(val, curr_range[0], curr_range[1])); }).setSlidable(_step, _int, _range);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
tb_value_min.hide = true;
|
|
|
|
tb_value_max.hide = true;
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-12-05 09:51:24 +01:00
|
|
|
static setSlideSpeed = function(speed) { #region
|
2023-11-15 14:42:53 +01:00
|
|
|
tb_value_min.setSlidable(speed);
|
|
|
|
tb_value_max.setSlidable(speed);
|
2023-12-05 09:51:24 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-05 09:51:24 +01:00
|
|
|
static setInteract = function(interactable = noone) { #region
|
2023-01-25 06:49:00 +01:00
|
|
|
self.interactable = interactable;
|
|
|
|
tb_value_min.interactable = interactable;
|
|
|
|
tb_value_max.interactable = interactable;
|
2023-12-05 09:51:24 +01:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-12-05 09:51:24 +01:00
|
|
|
static register = function(parent = noone) { #region
|
2023-01-17 08:11:55 +01:00
|
|
|
tb_value_min.register(parent);
|
|
|
|
tb_value_max.register(parent);
|
2023-12-05 09:51:24 +01:00
|
|
|
} #endregion
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-12-05 09:51:24 +01:00
|
|
|
static drawParam = function(params) { #region
|
2024-03-27 11:51:14 +01:00
|
|
|
setParam(params);
|
|
|
|
tb_value_min.setParam(params);
|
|
|
|
tb_value_max.setParam(params);
|
2024-03-26 04:03:45 +01:00
|
|
|
|
2023-07-30 19:56:53 +02:00
|
|
|
return draw(params.x, params.y, params.w, params.h, params.data, params.m);
|
2023-12-05 09:51:24 +01:00
|
|
|
} #endregion
|
2023-07-30 19:56:53 +02:00
|
|
|
|
2023-12-05 09:51:24 +01:00
|
|
|
static draw = function(_x, _y, _w, _h, _data, _m) { #region
|
2023-01-17 08:11:55 +01:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
w = _w;
|
|
|
|
h = _h;
|
2023-12-05 09:51:24 +01:00
|
|
|
if(!is_real(_data[0])) return h;
|
|
|
|
if(!is_real(_data[1])) return h;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
var _minn = slide_range[0];
|
|
|
|
var _maxx = slide_range[1];
|
|
|
|
var _rang = abs(_maxx - _minn);
|
|
|
|
var _currMin = min(_data[0], _data[1]);
|
|
|
|
var _currMax = max(_data[0], _data[1]);
|
|
|
|
|
|
|
|
if(tb_value_min.sliding != 2 && tb_value_max.sliding != 2) {
|
|
|
|
curr_range[0] = (_currMin >= _minn)? _minn : _minn - ceil(abs(_currMin - _minn) / _rang) * _rang;
|
|
|
|
curr_range[1] = (_currMax <= _maxx)? _maxx : _maxx + ceil(abs(_currMax - _maxx) / _rang) * _rang;
|
2023-12-05 09:51:24 +01:00
|
|
|
}
|
2024-03-24 04:58:08 +01:00
|
|
|
|
|
|
|
var lx = _w * (_currMin - curr_range[0]) / (curr_range[1] - curr_range[0]);
|
|
|
|
var lw = _w * ((_currMax - _currMin) - curr_range[0]) / (curr_range[1] - curr_range[0]);
|
2023-12-05 09:51:24 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 4, _x + lx, _y, lw, _h, c_white, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
var tb_w = _w / 2;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
if(tb_value_min.selecting || tb_value_max.selecting) {
|
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 1, _x, _y, _w, _h, c_white, 1);
|
|
|
|
} else {
|
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 04:58:08 +01:00
|
|
|
tb_value_min.setFocusHover(active, hover);
|
|
|
|
tb_value_min.draw(_x, _y, tb_w, _h, _data[0], _m);
|
|
|
|
|
|
|
|
tb_value_max.setFocusHover(active, hover);
|
|
|
|
tb_value_max.draw(_x + tb_w, _y, tb_w, _h, _data[1], _m);
|
2023-07-30 19:56:53 +02:00
|
|
|
|
|
|
|
return h;
|
2023-12-05 09:51:24 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|