mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 12:34:06 +01:00
command palette
This commit is contained in:
parent
f4065ae249
commit
3293c09343
@ -269,9 +269,10 @@
|
||||
{"name":"o_dialog_assetbox","order":4,"path":"objects/o_dialog_assetbox/o_dialog_assetbox.yy",},
|
||||
{"name":"o_dialog_color_picker","order":6,"path":"objects/o_dialog_color_picker/o_dialog_color_picker.yy",},
|
||||
{"name":"o_dialog_color_quick_pick","order":5,"path":"objects/o_dialog_color_quick_pick/o_dialog_color_quick_pick.yy",},
|
||||
{"name":"o_dialog_command_palette","order":11,"path":"objects/o_dialog_command_palette/o_dialog_command_palette.yy",},
|
||||
{"name":"o_dialog_crashed","order":3,"path":"objects/o_dialog_crashed/o_dialog_crashed.yy",},
|
||||
{"name":"o_dialog_drag_folder","order":2,"path":"objects/o_dialog_drag_folder/o_dialog_drag_folder.yy",},
|
||||
{"name":"o_dialog_exit","order":2,"path":"objects/o_dialog_exit/o_dialog_exit.yy",},
|
||||
{"name":"o_dialog_exit","order":1,"path":"objects/o_dialog_exit/o_dialog_exit.yy",},
|
||||
{"name":"o_dialog_file_name_action","order":10,"path":"objects/o_dialog_file_name_action/o_dialog_file_name_action.yy",},
|
||||
{"name":"o_dialog_file_name_collection","order":6,"path":"objects/o_dialog_file_name_collection/o_dialog_file_name_collection.yy",},
|
||||
{"name":"o_dialog_file_name","order":1,"path":"objects/o_dialog_file_name/o_dialog_file_name.yy",},
|
||||
@ -279,26 +280,26 @@
|
||||
{"name":"o_dialog_gradient","order":1,"path":"objects/o_dialog_gradient/o_dialog_gradient.yy",},
|
||||
{"name":"o_dialog_group_input_order","order":3,"path":"objects/o_dialog_group_input_order/o_dialog_group_input_order.yy",},
|
||||
{"name":"o_dialog_group_output_order","order":4,"path":"objects/o_dialog_group_output_order/o_dialog_group_output_order.yy",},
|
||||
{"name":"o_dialog_image_array_edit","order":4,"path":"objects/o_dialog_image_array_edit/o_dialog_image_array_edit.yy",},
|
||||
{"name":"o_dialog_image_array_edit","order":2,"path":"objects/o_dialog_image_array_edit/o_dialog_image_array_edit.yy",},
|
||||
{"name":"o_dialog_l_system","order":1,"path":"objects/o_dialog_l_system/o_dialog_l_system.yy",},
|
||||
{"name":"o_dialog_lua_reference","order":5,"path":"objects/o_dialog_lua_reference/o_dialog_lua_reference.yy",},
|
||||
{"name":"o_dialog_menubox","order":2,"path":"objects/o_dialog_menubox/o_dialog_menubox.yy",},
|
||||
{"name":"o_dialog_migration","order":11,"path":"objects/o_dialog_migration/o_dialog_migration.yy",},
|
||||
{"name":"o_dialog_menubox","order":10,"path":"objects/o_dialog_menubox/o_dialog_menubox.yy",},
|
||||
{"name":"o_dialog_migration","order":7,"path":"objects/o_dialog_migration/o_dialog_migration.yy",},
|
||||
{"name":"o_dialog_output_visibility","order":2,"path":"objects/o_dialog_output_visibility/o_dialog_output_visibility.yy",},
|
||||
{"name":"o_dialog_palette","order":2,"path":"objects/o_dialog_palette/o_dialog_palette.yy",},
|
||||
{"name":"o_dialog_panel","order":13,"path":"objects/o_dialog_panel/o_dialog_panel.yy",},
|
||||
{"name":"o_dialog_preference","order":7,"path":"objects/o_dialog_preference/o_dialog_preference.yy",},
|
||||
{"name":"o_dialog_preference","order":3,"path":"objects/o_dialog_preference/o_dialog_preference.yy",},
|
||||
{"name":"o_dialog_preset","order":1,"path":"objects/o_dialog_preset/o_dialog_preset.yy",},
|
||||
{"name":"o_dialog_release_note","order":8,"path":"objects/o_dialog_release_note/o_dialog_release_note.yy",},
|
||||
{"name":"o_dialog_run_shell","order":13,"path":"objects/o_dialog_run_shell/o_dialog_run_shell.yy",},
|
||||
{"name":"o_dialog_save","order":12,"path":"objects/o_dialog_save/o_dialog_save.yy",},
|
||||
{"name":"o_dialog_release_note","order":4,"path":"objects/o_dialog_release_note/o_dialog_release_note.yy",},
|
||||
{"name":"o_dialog_run_shell","order":9,"path":"objects/o_dialog_run_shell/o_dialog_run_shell.yy",},
|
||||
{"name":"o_dialog_save","order":8,"path":"objects/o_dialog_save/o_dialog_save.yy",},
|
||||
{"name":"o_dialog_scrollbox_horizontal","order":11,"path":"objects/o_dialog_scrollbox_horizontal/o_dialog_scrollbox_horizontal.yy",},
|
||||
{"name":"o_dialog_scrollbox","order":3,"path":"objects/o_dialog_scrollbox/o_dialog_scrollbox.yy",},
|
||||
{"name":"o_dialog_splash","order":9,"path":"objects/o_dialog_splash/o_dialog_splash.yy",},
|
||||
{"name":"o_dialog_splash","order":5,"path":"objects/o_dialog_splash/o_dialog_splash.yy",},
|
||||
{"name":"o_dialog_textbox_autocomplete","order":7,"path":"objects/o_dialog_textbox_autocomplete/o_dialog_textbox_autocomplete.yy",},
|
||||
{"name":"o_dialog_textbox_function_guide","order":8,"path":"objects/o_dialog_textbox_function_guide/o_dialog_textbox_function_guide.yy",},
|
||||
{"name":"o_dialog_value_editor","order":9,"path":"objects/o_dialog_value_editor/o_dialog_value_editor.yy",},
|
||||
{"name":"o_dialog_warning","order":10,"path":"objects/o_dialog_warning/o_dialog_warning.yy",},
|
||||
{"name":"o_dialog_warning","order":6,"path":"objects/o_dialog_warning/o_dialog_warning.yy",},
|
||||
{"name":"o_main","order":1,"path":"objects/o_main/o_main.yy",},
|
||||
{"name":"o_pie_menu","order":14,"path":"objects/o_pie_menu/o_pie_menu.yy",},
|
||||
{"name":"Obj_Debug_FallText_Firestore","order":6,"path":"objects/Obj_Debug_FallText_Firestore/Obj_Debug_FallText_Firestore.yy",},
|
||||
|
@ -737,6 +737,7 @@
|
||||
{"id":{"name":"o_dialog_color_picker","path":"objects/o_dialog_color_picker/o_dialog_color_picker.yy",},},
|
||||
{"id":{"name":"o_dialog_color_quick_pick","path":"objects/o_dialog_color_quick_pick/o_dialog_color_quick_pick.yy",},},
|
||||
{"id":{"name":"o_dialog_color_selector","path":"objects/o_dialog_color_selector/o_dialog_color_selector.yy",},},
|
||||
{"id":{"name":"o_dialog_command_palette","path":"objects/o_dialog_command_palette/o_dialog_command_palette.yy",},},
|
||||
{"id":{"name":"o_dialog_crashed","path":"objects/o_dialog_crashed/o_dialog_crashed.yy",},},
|
||||
{"id":{"name":"o_dialog_drag_folder","path":"objects/o_dialog_drag_folder/o_dialog_drag_folder.yy",},},
|
||||
{"id":{"name":"o_dialog_exit","path":"objects/o_dialog_exit/o_dialog_exit.yy",},},
|
||||
|
166
objects/o_dialog_command_palette/Create_0.gml
Normal file
166
objects/o_dialog_command_palette/Create_0.gml
Normal file
@ -0,0 +1,166 @@
|
||||
/// @description init
|
||||
event_inherited();
|
||||
|
||||
#region data
|
||||
destroy_on_click_out = true;
|
||||
draggable = false;
|
||||
selecting = 0;
|
||||
|
||||
dialog_w = ui(480);
|
||||
dialog_h = ui(400);
|
||||
|
||||
setFocus(self.id);
|
||||
|
||||
data = [];
|
||||
keys = variable_struct_get_names(FUNCTIONS);
|
||||
|
||||
hk_editing = noone;
|
||||
|
||||
function searchMenu() {
|
||||
data = [];
|
||||
var pr_list = ds_priority_create();
|
||||
var search_lower = string_lower(search_string);
|
||||
|
||||
for (var i = 0, n = array_length(keys); i < n; i++) {
|
||||
var k = keys[i];
|
||||
var _menu = FUNCTIONS[$ k];
|
||||
|
||||
var _cnxt = _menu.context;
|
||||
var _name = _menu.name;
|
||||
var _fname = $"{string_lower(_cnxt)} {string_lower(_name)}"
|
||||
|
||||
var match = string_partial_match(_fname, search_lower);
|
||||
if(match == -9999) continue;
|
||||
|
||||
ds_priority_add(pr_list, _menu, match);
|
||||
}
|
||||
|
||||
repeat(ds_priority_size(pr_list))
|
||||
array_push(data, ds_priority_delete_max(pr_list));
|
||||
|
||||
ds_priority_destroy(pr_list);
|
||||
}
|
||||
|
||||
search_string = "";
|
||||
KEYBOARD_STRING = "";
|
||||
|
||||
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) {
|
||||
search_string = string(str);
|
||||
searchMenu();
|
||||
});
|
||||
|
||||
tb_search.hide = 2;
|
||||
tb_search.font = f_p2;
|
||||
tb_search.align = fa_left;
|
||||
tb_search.auto_update = true;
|
||||
|
||||
text_pad = ui(8);
|
||||
item_pad = ui(6);
|
||||
|
||||
_prex = mouse_mx;
|
||||
_prey = mouse_my;
|
||||
|
||||
sc_content = new scrollPane(dialog_w - ui(4), dialog_h - ui(32), function(_y, _m) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 1);
|
||||
var hght = line_get_height(f_p2, item_pad);
|
||||
var _dw = sc_content.surface_w;
|
||||
var _h = 0;
|
||||
var _ly = _y;
|
||||
|
||||
draw_set_color(CDEF.main_mdblack);
|
||||
draw_rectangle(0, 0, ui(32), dialog_h, false);
|
||||
|
||||
var mouse_move = _prex != mouse_mx || _prey != mouse_my;
|
||||
|
||||
for(var i = 0; i < array_length(data); i++) {
|
||||
var _menu = data[i];
|
||||
var _menuItem = _menu.menu;
|
||||
|
||||
if(selecting == i) {
|
||||
draw_sprite_stretched_ext(THEME.textbox, 3, 0, _ly, dialog_w, hght, COLORS.dialog_menubox_highlight, 1);
|
||||
|
||||
if(sc_content.active && (mouse_press(mb_left) || keyboard_check_pressed(vk_enter))) {
|
||||
_menu.action();
|
||||
instance_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
if(sc_content.hover && mouse_move && point_in_rectangle(_m[0], _m[1], 0, _ly, _dw, _ly + hght - 1)) {
|
||||
sc_content.hover_content = true;
|
||||
selecting = i;
|
||||
}
|
||||
|
||||
var _cnxt = _menu.context;
|
||||
var _name = _menu.name;
|
||||
var _tx = text_pad + ui(32);
|
||||
var _ty = _ly + hght / 2;
|
||||
|
||||
if(_cnxt != "") {
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
|
||||
draw_text_add(_tx, _ty, _cnxt);
|
||||
_tx += string_width(_cnxt);
|
||||
|
||||
draw_sprite_ext(THEME.arrow, 0, _tx + ui(10), _ty, 1, 1, 0, COLORS._main_text_sub);
|
||||
_tx += ui(20);
|
||||
}
|
||||
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_icon_light);
|
||||
draw_text_add(_tx, _ty, _name);
|
||||
|
||||
if(_menuItem != noone && _menuItem.spr != noone) {
|
||||
var spr = is_array(_menuItem.spr)? _menuItem.spr[0] : _menuItem.spr;
|
||||
var ind = is_array(_menuItem.spr)? _menuItem.spr[1] : 0;
|
||||
draw_sprite_ui(spr, ind, ui(16), _ty, .75, .75, 0, COLORS._main_icon, 0.75);
|
||||
}
|
||||
|
||||
if(_menu.hotkey != noone) {
|
||||
var _key = _menu.hotkey;
|
||||
var _hx = _dw - ui(6);
|
||||
var _hy = _ty + ui(1);
|
||||
|
||||
draw_set_font(f_p2);
|
||||
|
||||
var _ktxt = key_get_name(_key.key, _key.modi);
|
||||
var _tw = string_width(_ktxt);
|
||||
var _th = line_get_height();
|
||||
|
||||
var _bx = _hx - _tw - ui(4);
|
||||
var _by = _hy - _th / 2 - ui(2);
|
||||
var _bw = _tw + ui(8);
|
||||
var _bh = _th + ui(2);
|
||||
|
||||
if(hk_editing == _key) {
|
||||
draw_set_text(f_p2, fa_right, fa_center, COLORS._main_accent);
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 1, _bx, _by, _bw, _bh, COLORS._main_text_accent);
|
||||
|
||||
} else if(_ktxt != "") {
|
||||
draw_set_text(f_p2, fa_right, fa_center, COLORS._main_text_sub);
|
||||
draw_sprite_stretched_ext(THEME.ui_panel, 1, _bx, _by, _bw, _bh, CDEF.main_dkgrey);
|
||||
}
|
||||
|
||||
draw_text(_hx, _hy, _ktxt);
|
||||
}
|
||||
|
||||
_ly += hght;
|
||||
_h += hght;
|
||||
}
|
||||
|
||||
if(sc_content.active) {
|
||||
if(keyboard_check_pressed(vk_up)) {
|
||||
selecting--;
|
||||
if(selecting < 0) selecting = array_length(data) - 1;
|
||||
}
|
||||
|
||||
if(keyboard_check_pressed(vk_down))
|
||||
selecting = safe_mod(selecting + 1, array_length(data));
|
||||
|
||||
if(keyboard_check_pressed(vk_escape))
|
||||
instance_destroy();
|
||||
}
|
||||
|
||||
_prex = mouse_mx;
|
||||
_prey = mouse_my;
|
||||
|
||||
return _h;
|
||||
});
|
||||
#endregion
|
16
objects/o_dialog_command_palette/Draw_64.gml
Normal file
16
objects/o_dialog_command_palette/Draw_64.gml
Normal file
@ -0,0 +1,16 @@
|
||||
/// @description init
|
||||
|
||||
draw_sprite_stretched(THEME.textbox, 3, dialog_x, dialog_y, dialog_w, dialog_h);
|
||||
|
||||
WIDGET_CURRENT = tb_search;
|
||||
tb_search.setFocusHover(true, true);
|
||||
tb_search.draw(dialog_x, dialog_y, dialog_w, ui(32), search_string);
|
||||
tb_search.sprite_index = 0;
|
||||
|
||||
sc_content.setFocusHover(sFOCUS, sHOVER);
|
||||
sc_content.draw(dialog_x, dialog_y + ui(32));
|
||||
|
||||
draw_set_color(CDEF.main_dkgrey);
|
||||
draw_line(dialog_x, dialog_y + ui(32), dialog_x + dialog_w - 1, dialog_y + ui(32));
|
||||
|
||||
draw_sprite_stretched(THEME.textbox, 1, dialog_x, dialog_y, dialog_w, dialog_h);
|
39
objects/o_dialog_command_palette/o_dialog_command_palette.yy
Normal file
39
objects/o_dialog_command_palette/o_dialog_command_palette.yy
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"$GMObject":"",
|
||||
"%Name":"o_dialog_command_palette",
|
||||
"eventList":[
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
],
|
||||
"managed":true,
|
||||
"name":"o_dialog_command_palette",
|
||||
"overriddenProperties":[],
|
||||
"parent":{
|
||||
"name":"menu",
|
||||
"path":"folders/dialog/menu.yy",
|
||||
},
|
||||
"parentObjectId":{
|
||||
"name":"_p_dialog",
|
||||
"path":"objects/_p_dialog/_p_dialog.yy",
|
||||
},
|
||||
"persistent":false,
|
||||
"physicsAngularDamping":0.1,
|
||||
"physicsDensity":0.5,
|
||||
"physicsFriction":0.2,
|
||||
"physicsGroup":1,
|
||||
"physicsKinematic":false,
|
||||
"physicsLinearDamping":0.1,
|
||||
"physicsObject":false,
|
||||
"physicsRestitution":0.1,
|
||||
"physicsSensor":false,
|
||||
"physicsShape":1,
|
||||
"physicsShapePoints":[],
|
||||
"physicsStartAwake":true,
|
||||
"properties":[],
|
||||
"resourceType":"GMObject",
|
||||
"resourceVersion":"2.0",
|
||||
"solid":false,
|
||||
"spriteId":null,
|
||||
"spriteMaskId":null,
|
||||
"visible":true,
|
||||
}
|
@ -44,6 +44,7 @@ event_inherited();
|
||||
draw_set_text(font, fa_center, fa_center, COLORS._main_text);
|
||||
for(var i = 0; i < array_length(menu); i++) {
|
||||
var _menuItem = menu[i];
|
||||
|
||||
if(_menuItem == -1) {
|
||||
dialog_h += ui(8);
|
||||
continue;
|
||||
@ -75,10 +76,7 @@ event_inherited();
|
||||
}
|
||||
}
|
||||
|
||||
if(_menuItem.spr != noone)
|
||||
show_icon = true;
|
||||
if(_menuItem.toggle != noone)
|
||||
show_icon = true;
|
||||
if(_menuItem.spr != noone || _menuItem.toggle != noone) show_icon = true;
|
||||
}
|
||||
|
||||
dialog_w = max(dialog_w, ww);
|
||||
|
@ -32,11 +32,10 @@
|
||||
|
||||
#endregion
|
||||
|
||||
function registerFunction(_context, _name, _key, _mod, _action) { return new functionOnject(_context, _name, _key, _mod, _action); }
|
||||
function registerFunction(_context, _name, _key, _mod, _action) { return new functionObject(_context, _name, _key, _mod, _action); }
|
||||
|
||||
function functionOnject(_context, _name, _key, _mod, _action) constructor {
|
||||
addHotkey(_context, _name, _key, _mod, _action);
|
||||
|
||||
function functionObject(_context, _name, _key, _mod, _action) constructor {
|
||||
hotkey = addHotkey(_context, _name, _key, _mod, _action);
|
||||
context = _context;
|
||||
name = _name;
|
||||
dkey = _key;
|
||||
@ -46,6 +45,7 @@ function functionOnject(_context, _name, _key, _mod, _action) constructor {
|
||||
|
||||
fnName = _context == ""? _name : $"{_context} {_name}";
|
||||
fnName = string_to_var(fnName);
|
||||
menu = noone;
|
||||
|
||||
FUNCTIONS[$ fnName] = self;
|
||||
CMD_FUNCTIONS[$ fnName] = { action: _action, args: [] };
|
||||
@ -56,10 +56,10 @@ function functionOnject(_context, _name, _key, _mod, _action) constructor {
|
||||
return self;
|
||||
}
|
||||
|
||||
static setMenu = function(_id, _spr = noone, shelf = false) {
|
||||
var men = menuItemAction(__txt(name), action, _spr);
|
||||
if(shelf) men.setIsShelf();
|
||||
MENU_ITEMS[$ _id] = men;
|
||||
static setMenu = function(_id, _spr = noone, shelf = false) {
|
||||
menu = menuItemAction(__txt(name), action, _spr);
|
||||
if(shelf) menu.setIsShelf();
|
||||
MENU_ITEMS[$ _id] = menu;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -149,6 +149,8 @@ function addHotkey(_context, _name, _key, _mod, _action) {
|
||||
|
||||
if(_context == "") ds_list_insert(HOTKEYS[? _context], 0, key);
|
||||
else ds_list_add(HOTKEYS[? _context], key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
function find_hotkey(_context, _name) {
|
||||
|
@ -448,6 +448,7 @@
|
||||
function call_dialog_preference() { dialogCall(o_dialog_preference); }
|
||||
function call_dialog_splash() { dialogCall(o_dialog_splash); }
|
||||
function call_dialog_release_note() { dialogCall(o_dialog_release_note); }
|
||||
function call_dialog_command_palette() { dialogCall(o_dialog_command_palette); }
|
||||
function open_autosave_folder() { shellOpenExplorer(DIRECTORY + "autosave"); }
|
||||
|
||||
function call_panel_addon() { dialogPanelCall(new Panel_Addon()); }
|
||||
@ -477,9 +478,11 @@
|
||||
function call_panel_File_Explorer() { panelAdd("Panel_File_Explorer", true); }
|
||||
|
||||
function __fnInit_Panels() {
|
||||
|
||||
registerFunction("", "Preference", "", MOD_KEY.none, call_dialog_preference ).setMenu("preference", THEME.gear)
|
||||
registerFunction("", "Splash screen", "", MOD_KEY.none, call_dialog_splash ).setMenu("splash_screen")
|
||||
registerFunction("", "Release note", "", MOD_KEY.none, call_dialog_release_note ).setMenu("release_note")
|
||||
registerFunction("", "Command Palette", "T", MOD_KEY.ctrl | MOD_KEY.shift, call_dialog_command_palette ).setMenu("command_palette")
|
||||
registerFunction("", "Autosave folder", "", MOD_KEY.none, open_autosave_folder ).setMenu("autosave_folder", THEME.save_auto)
|
||||
|
||||
registerFunction("", "Addons", "", MOD_KEY.none, call_panel_addon ).setMenu("addons")
|
||||
@ -506,14 +509,5 @@
|
||||
registerFunction("", "Console Panel", "", MOD_KEY.none, call_panel_Console ).setMenu("console_panel")
|
||||
registerFunction("", "Globalvar Panel", "", MOD_KEY.none, call_panel_Globalvar ).setMenu("globalvar_panel")
|
||||
registerFunction("", "File Explorer Panel", "", MOD_KEY.none, call_panel_File_Explorer ).setMenu("file_explorer_panel")
|
||||
|
||||
|
||||
registerFunction("", "Recent files", "R", MOD_KEY.ctrl | MOD_KEY.shift, function() /*=>*/ {
|
||||
var arr = [];
|
||||
for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++)
|
||||
array_push(arr, menuItemAction(RECENT_FILES[| i], function(_dat) { LOAD_PATH(_dat.name); }));
|
||||
return menuCall("Recent files",,, arr);
|
||||
}).setMenu("recent_files");
|
||||
|
||||
}
|
||||
#endregion
|
@ -38,7 +38,7 @@
|
||||
registerFunction("", "Import .zip", "", MOD_KEY.none, __IMPORT_ZIP ).setMenu("import_zip", )
|
||||
registerFunction("", "Export .zip", "", MOD_KEY.none, __EXPORT_ZIP ).setMenu("export_zip", )
|
||||
|
||||
registerFunction("", "Recent Files", "", MOD_KEY.none,
|
||||
registerFunction("", "Recent Files", "R", MOD_KEY.ctrl | MOD_KEY.shift,
|
||||
function(_dat) {
|
||||
var arr = [];
|
||||
for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user