Pixel-Composer/objects/o_dialog_fontscrollbox/Create_0.gml

74 lines
1.8 KiB
Text
Raw Normal View History

2023-01-17 08:11:55 +01:00
/// @description init
event_inherited();
#region
dialog_w = 560;
max_h = 640;
draggable = false;
destroy_on_click_out = true;
2023-01-25 06:49:00 +01:00
selecting = -1;
2023-01-17 08:11:55 +01:00
scrollbox = noone;
anchor = ANCHOR.top | ANCHOR.left;
sc_content = new scrollPane(0, 0, function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
2023-05-28 20:00:51 +02:00
var hght = line_get_height(f_p0, 8);
2023-01-17 08:11:55 +01:00
var data = FONT_INTERNAL;
var _h = array_length(data) * hght;
var _dw = sc_content.surface_w;
2024-07-28 13:55:57 +02:00
sc_content.hover_content = true;
2023-01-17 08:11:55 +01:00
for(var i = 0; i < array_length(data); i++) {
var _ly = _y + i * hght;
var fullpath = data[i];
2023-01-17 08:11:55 +01:00
if(sHOVER && sc_content.hover && point_in_rectangle(_m[0], _m[1], 0, _ly + 1, _dw, _ly + hght - 1)) {
2023-01-25 06:49:00 +01:00
selecting = i;
}
if(selecting == i) {
2023-01-17 08:11:55 +01:00
draw_sprite_stretched_ext(THEME.textbox, 3, 0, _ly, _dw, hght, COLORS.dialog_menubox_highlight, 1);
2023-01-25 06:49:00 +01:00
if(sFOCUS && (mouse_press(mb_left) || keyboard_check_pressed(vk_enter))) {
2023-01-17 08:11:55 +01:00
scrollbox.onModify(i);
instance_destroy();
}
}
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text_cut(ui(8), _ly + hght / 2, filename_name_only(data[i]), _dw);
2023-01-17 08:11:55 +01:00
if(ds_map_exists(FONT_SPRITES, fullpath)) {
var spr = FONT_SPRITES[? fullpath];
var sw = sprite_get_width(spr);
var sh = sprite_get_height(spr);
var ss = (hght - ui(8)) / sh;
sw *= ss;
sh *= ss;
draw_sprite_ext(spr, 0, _dw - ui(8) - sw, _ly + hght / 2 - sh / 2, ss, ss, 0, c_white, 1);
}
}
2023-01-25 06:49:00 +01:00
if(sFOCUS) {
if(keyboard_check_pressed(vk_up)) {
selecting--;
if(selecting < 0) selecting = array_length(data) - 1;
}
if(keyboard_check_pressed(vk_down))
2023-02-20 10:16:31 +01:00
selecting = safe_mod(selecting + 1, array_length(data));
2023-01-25 06:49:00 +01:00
if(keyboard_check_pressed(vk_escape))
instance_destroy();
}
2023-01-17 08:11:55 +01:00
return _h;
});
#endregion