diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index ab2cee15c..1f10cc778 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -631,6 +631,7 @@ {"name":"FirebaseREST_firestore_value","order":16,"path":"scripts/FirebaseREST_firestore_value/FirebaseREST_firestore_value.yy",}, {"name":"FirebaseREST_HTTP_Failed_Firestore","order":18,"path":"scripts/FirebaseREST_HTTP_Failed_Firestore/FirebaseREST_HTTP_Failed_Firestore.yy",}, {"name":"FirebaseREST_HTTP_Success_Firestore","order":19,"path":"scripts/FirebaseREST_HTTP_Success_Firestore/FirebaseREST_HTTP_Success_Firestore.yy",}, + {"name":"folderArrayBox","order":18,"path":"scripts/folderArrayBox/folderArrayBox.yy",}, {"name":"font_data","order":10,"path":"scripts/font_data/font_data.yy",}, {"name":"font_loader","order":8,"path":"scripts/font_loader/font_loader.yy",}, {"name":"font_sprite_loader","order":10,"path":"scripts/font_sprite_loader/font_sprite_loader.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index c8fbd5b98..7fea2725f 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -976,6 +976,7 @@ {"id":{"name":"FirebaseREST_firestore_value","path":"scripts/FirebaseREST_firestore_value/FirebaseREST_firestore_value.yy",},}, {"id":{"name":"FirebaseREST_HTTP_Failed_Firestore","path":"scripts/FirebaseREST_HTTP_Failed_Firestore/FirebaseREST_HTTP_Failed_Firestore.yy",},}, {"id":{"name":"FirebaseREST_HTTP_Success_Firestore","path":"scripts/FirebaseREST_HTTP_Success_Firestore/FirebaseREST_HTTP_Success_Firestore.yy",},}, + {"id":{"name":"folderArrayBox","path":"scripts/folderArrayBox/folderArrayBox.yy",},}, {"id":{"name":"font_data","path":"scripts/font_data/font_data.yy",},}, {"id":{"name":"font_loader","path":"scripts/font_loader/font_loader.yy",},}, {"id":{"name":"font_sprite_loader","path":"scripts/font_sprite_loader/font_sprite_loader.yy",},}, diff --git a/objects/o_dialog_fontscrollbox/Alarm_0.gml b/objects/o_dialog_fontscrollbox/Alarm_0.gml index 678bfe276..d599e17fc 100644 --- a/objects/o_dialog_fontscrollbox/Alarm_0.gml +++ b/objects/o_dialog_fontscrollbox/Alarm_0.gml @@ -1,7 +1,7 @@ /// @description init #region pos var hght = line_get_height(f_p0, 8); - var hh = array_length(FONT_INTERNAL) * hght; + var hh = array_length(FONT_INTERNAL) * hght; dialog_h = min(max_h, hh); sc_content.resize(dialog_w - ui(6), dialog_h); diff --git a/objects/o_dialog_fontscrollbox/Create_0.gml b/objects/o_dialog_fontscrollbox/Create_0.gml index 394b66aec..be86931df 100644 --- a/objects/o_dialog_fontscrollbox/Create_0.gml +++ b/objects/o_dialog_fontscrollbox/Create_0.gml @@ -14,6 +14,7 @@ event_inherited(); sc_content = new scrollPane(0, 0, function(_y, _m) { draw_clear_alpha(COLORS.panel_bg_clear, 0); + var hght = line_get_height(f_p0, 8); var data = FONT_INTERNAL; var _h = array_length(data) * hght; @@ -21,7 +22,7 @@ event_inherited(); for(var i = 0; i < array_length(data); i++) { var _ly = _y + i * hght; - var fullpath = DIRECTORY + "Fonts/" + data[i]; + var fullpath = data[i]; if(sHOVER && sc_content.hover && point_in_rectangle(_m[0], _m[1], 0, _ly + 1, _dw, _ly + hght - 1)) { selecting = i; @@ -37,7 +38,7 @@ event_inherited(); } draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); - draw_text_cut(ui(8), _ly + hght / 2, data[i], _dw); + draw_text_cut(ui(8), _ly + hght / 2, filename_name_only(data[i]), _dw); if(ds_map_exists(FONT_SPRITES, fullpath)) { var spr = FONT_SPRITES[? fullpath]; diff --git a/objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy b/objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy index b435ef786..5a34c8207 100644 --- a/objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy +++ b/objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy @@ -2,10 +2,10 @@ "$GMObject":"", "%Name":"o_dialog_fontscrollbox", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_dialog_fontscrollbox", diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index 22984ecfb..1a3a940fd 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -102,29 +102,6 @@ event_inherited(); #region general pref_global = ds_list_create(); - ds_list_add(pref_global, __txt("Paths")); - - ds_list_add(pref_global, new __Panel_Linear_Setting_Item( - __txtx("pref_directory", "Main directory path" + "*"), - new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { PRESIST_PREF.path = txt; json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); }) - .setSideButton(button(function() /*=>*/ { - PRESIST_PREF.path = get_directory(PRESIST_PREF.path); - json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); - }, THEME.button_path_icon)).setFont(f_p2).setEmpty(), - - function( ) /*=>*/ { return PRESIST_PREF.path; }, - function(val) /*=>*/ { PRESIST_PREF.path = val; json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); }, - APP_DIRECTORY, - )); - - ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( - __txtx("pref_directory_temp", "Temp directory path" + "*"), - "temp_path", - new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { PREFERENCES.temp_path = txt; PREF_SAVE(); }) - .setSideButton(button(function() /*=>*/ { PREFERENCES.temp_path = get_directory(PREFERENCES.temp_path); PREF_SAVE(); }, THEME.button_path_icon)) - .setFont(f_p2).setEmpty(), - )); - ds_list_add(pref_global, __txt("Inputs")); ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( @@ -217,6 +194,41 @@ event_inherited(); new checkBox(function() /*=>*/ { PREFERENCES.test_mode = !PREFERENCES.test_mode; should_restart = true; PREF_SAVE(); }) )); + ds_list_add(pref_global, __txt("Paths")); + + ds_list_add(pref_global, new __Panel_Linear_Setting_Item( + __txtx("pref_directory", "Main directory path" + "*"), + new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { PRESIST_PREF.path = txt; json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); }) + .setSideButton(button(function() /*=>*/ { + PRESIST_PREF.path = get_directory(PRESIST_PREF.path); + json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); + }, THEME.button_path_icon)).setFont(f_p2).setEmpty(), + + function( ) /*=>*/ { return PRESIST_PREF.path; }, + function(val) /*=>*/ { PRESIST_PREF.path = val; json_save_struct(APP_DIRECTORY + "persistPreference.json", PRESIST_PREF); }, + APP_DIRECTORY, + )); + + ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( + __txtx("pref_directory_temp", "Temp directory path" + "*"), + "temp_path", + new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { PREFERENCES.temp_path = txt; PREF_SAVE(); }) + .setSideButton(button(function() /*=>*/ { PREFERENCES.temp_path = get_directory(PREFERENCES.temp_path); PREF_SAVE(); }, THEME.button_path_icon)) + .setFont(f_p2).setEmpty(), + )); + + ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( + __txtx("pref_directory_assets", "Assets directory path" + "*"), + "path_assets", + new folderArrayBox(PREFERENCES.path_assets, function() /*=>*/ { PREF_SAVE(); }).setFont(f_p2), + )); + + ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( + __txtx("pref_directory_font", "Font directory path" + "*"), + "path_fonts", + new folderArrayBox(PREFERENCES.path_fonts, function() /*=>*/ { PREF_SAVE(); }).setFont(f_p2), + )); + ds_list_add(pref_global, __txt("Libraries")); ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( @@ -947,7 +959,7 @@ event_inherited(); if(search_text != "" && string_pos(string_lower(search_text), string_lower(name)) == 0) continue; - if(ind % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy - padd, sp_pref.surface_w, th + padd * 2, COLORS.dialog_preference_prop_bg, 1); + if(ind % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy - padd, sp_pref.surface_w, max(_pref.editWidget.h, th) + padd * 2, COLORS.dialog_preference_prop_bg, 1); draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); draw_text_add(ui(24), yy + th / 2, name); @@ -970,8 +982,8 @@ event_inherited(); var widget_w = ui(260); var widget_h = th; - if(is_instanceof(_pref.editWidget, textBox)) - widget_w = _pref.editWidget.input == TEXTBOX_INPUT.text? ui(400) : widget_w; + if(is_instanceof(_pref.editWidget, textBox)) widget_w = _pref.editWidget.input == TEXTBOX_INPUT.text? ui(400) : widget_w; + else if(is_instanceof(_pref.editWidget, folderArrayBox)) widget_w = ui(400); var widget_x = x1 - ui(4) - widget_w; var widget_y = yy; diff --git a/scripts/assets_data/assets_data.gml b/scripts/assets_data/assets_data.gml index 28cb008f8..464bb4e24 100644 --- a/scripts/assets_data/assets_data.gml +++ b/scripts/assets_data/assets_data.gml @@ -1,8 +1,9 @@ #region assets - global.ASSET_MAP = ds_map_create(); + global.ASSET_MAP = ds_map_create(); global.ASSET_CACHE = ds_map_create(); function __initAssets() { + global.ASSETS = new DirectoryObject("Assets", ""); ds_map_clear(global.ASSET_MAP); var root = DIRECTORY + "Assets"; @@ -10,12 +11,22 @@ if(check_version($"{root}/version")) zip_unzip("data/Assets.zip", root); + + __initAssetsFolder(root); + for( var i = 0, n = array_length(PREFERENCES.path_assets); i < n; i++ ) + __initAssetsFolder(PREFERENCES.path_assets[i]); + } - global.ASSETS = new DirectoryObject("Assets", root); - global.ASSETS.scan([".png"]); + function __initAssetsFolder(_dir) { + + var _folder = new DirectoryObject(filename_name_only(_dir), _dir); + _folder.scan([".png"]); + _folder.open = true; + + ds_list_add(global.ASSETS.subDir, _folder); var st = ds_stack_create(); - ds_stack_push(st, global.ASSETS); + ds_stack_push(st, _folder); while(!ds_stack_empty(st)) { var _st = ds_stack_pop(st); diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index 898500d80..076be3a10 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -15,7 +15,7 @@ function FileObject(_name, _path) constructor { #region meta = noone; type = FILE_TYPE.collection; - switch(filename_ext_raw(path)) { #region + switch(filename_ext_raw(path)) { case "png" : case "jpg" : case "gif" : @@ -26,7 +26,7 @@ function FileObject(_name, _path) constructor { #region case "cpxc" : type = FILE_TYPE.project; break; - } #endregion + } retrive_data = false; thumbnail_data = -1; @@ -35,7 +35,7 @@ function FileObject(_name, _path) constructor { #region static getName = function() { return name; } - static getThumbnail = function() { #region + static getThumbnail = function() { if(thumbnail != noone && is_surface(thumbnail)) return thumbnail; // Thumbnail loaded if(size > 100000) return noone; // File too large @@ -45,9 +45,9 @@ function FileObject(_name, _path) constructor { #region thumbnail = surface_decode(thumbnail_data); return thumbnail; - } #endregion + } - static getSpr = function() { #region + static getSpr = function() { if(spr != -1 && sprite_exists(spr)) return spr; @@ -87,9 +87,9 @@ function FileObject(_name, _path) constructor { #region } return spr; - } #endregion + } - static getMetadata = function(_createnew = false) { #region + static getMetadata = function(_createnew = false) { retrive_data = true; if(meta != noone) return meta; @@ -119,7 +119,7 @@ function FileObject(_name, _path) constructor { #region } return meta; - } #endregion + } } #endregion function DirectoryObject(name, path) constructor { #region @@ -135,7 +135,7 @@ function DirectoryObject(name, path) constructor { #region static destroy = function() { ds_list_destroy(subDir); } static getName = function() { return name; } - static scan = function(file_type) { #region + static scan = function(file_type) { scanned = true; var _temp_name = []; @@ -189,9 +189,9 @@ function DirectoryObject(name, path) constructor { #region } } } - } #endregion + } - static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _params = {}) { #region + static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _params = {}) { var hg = ui(28); var hh = 0; @@ -199,15 +199,20 @@ function DirectoryObject(name, path) constructor { #region if(!ds_list_empty(subDir) && _hover && point_in_rectangle(_m[0], _m[1], _x, _y, ui(32), _y + hg - 1)) { draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _x, _y, ui(32), hg, CDEF.main_white, 1); - if(mouse_press(mb_left, _focus)) + if(mouse_press(mb_left, _focus)) { open = !open; + MOUSE_BLOCK = true; + } } if(_hover && point_in_rectangle(_m[0], _m[1], _x + ui(32), _y, _w, _y + hg - 1)) { draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _x + ui(28), _y, _w - ui(36), hg, CDEF.main_white, 1); - if(!triggered && mouse_click(mb_left, _focus)) { - if(!ds_list_empty(subDir)) + if(!triggered && mouse_press(mb_left, _focus)) { + if(!ds_list_empty(subDir)) { open = !open; + MOUSE_BLOCK = true; + } + parent.setContext(parent.context == self? _homedir : self); triggered = true; } @@ -240,5 +245,5 @@ function DirectoryObject(name, path) constructor { #region } return hh; - } #endregion + } } #endregion \ No newline at end of file diff --git a/scripts/folderArrayBox/folderArrayBox.gml b/scripts/folderArrayBox/folderArrayBox.gml new file mode 100644 index 000000000..2f6697d58 --- /dev/null +++ b/scripts/folderArrayBox/folderArrayBox.gml @@ -0,0 +1,104 @@ +function folderArrayBox(_arr, _onApply) : widget() constructor { + + onApply = _onApply; + array = _arr; + editing = noone; + tb_edit = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ { + array[editing] = str; + + if(str == "") { + array_delete(array, editing, 1); + editing = noone; + } + + onApply(); + return true; + }); + tb_edit.setEmpty(); + tb_edit.onDeactivate = function() /*=>*/ { editing = noone; } + + _hovering = false; + + static setFont = function(font) { + self.font = font; + tb_edit.font = font; + return self; + } + + static drawParam = function(params) { + setParam(params); + tb_edit.setParam(params); + + return draw(params.x, params.y, params.w, params.h, params.data, params.m); + } + + static draw = function(_x, _y, _w, _h, _arr, _m) { + x = _x; + y = _y; + w = _w; + h = (_h + ui(4)) * (array_length(_arr) + 1) - ui(4); + + array = _arr; + hovering = false; + + var _tx = x; + var _ty = y; + + if(editing && !_hovering && mouse_press(mb_left)) { + tb_edit.deactivate(); + editing = noone; + } + + for( var i = 0, n = array_length(_arr); i <= n; i++ ) { + _ty = y + i * (_h + ui(4)); + draw_sprite_stretched_ext(THEME.textbox, 3, _tx, _ty, _w, _h, boxColor); + + if(hover && point_in_rectangle(_m[0], _m[1], _tx, _ty, _tx + _w, _ty + _h)) + hovering = true; + + if(editing == i) continue; + + if(hover && point_in_rectangle(_m[0], _m[1], _tx, _ty, _tx + _w, _ty + _h)) { + draw_sprite_stretched_ext(THEME.textbox, 1, _tx, _ty, _w, _h, boxColor); + + if(editing != i && mouse_press(mb_left, active)) { + editing = i; + if(i == n) array_push(array, ""); + + tb_edit._current_text = array[i]; + tb_edit.activate(); + } + + if(mouse_click(mb_left, active)) + draw_sprite_stretched(THEME.textbox, 2, _tx, _ty, _w, _h); + + } else + draw_sprite_stretched_ext(THEME.textbox, 0, _tx, _ty, _w, _h, boxColor); + + if(i < n) { + draw_set_text(font, fa_left, fa_center, COLORS._main_text); + draw_text_cut(_tx + ui(8), _ty + _h / 2, array[i], _w - ui(16)); + } + } + + if(editing != noone) { + _ty = y + editing * (_h + ui(4)); + tb_edit.setFocusHover(active, hover); + tb_edit.draw(_tx, _ty, _w, _h, array[editing], _m); + } + + hovering = _hovering; + + if(WIDGET_CURRENT == self) draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1); + + resetFocus(); + + return h; + } + + static clone = function() { + var cln = new pathArrayBox(target, data, onClick); + + return cln; + } +} \ No newline at end of file diff --git a/scripts/folderArrayBox/folderArrayBox.yy b/scripts/folderArrayBox/folderArrayBox.yy new file mode 100644 index 000000000..1a1c0b986 --- /dev/null +++ b/scripts/folderArrayBox/folderArrayBox.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"", + "%Name":"folderArrayBox", + "isCompatibility":false, + "isDnD":false, + "name":"folderArrayBox", + "parent":{ + "name":"text", + "path":"folders/widgets/text.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/fontScrollBox/fontScrollBox.gml b/scripts/fontScrollBox/fontScrollBox.gml index 97d9aef2d..cc5aafe3f 100644 --- a/scripts/fontScrollBox/fontScrollBox.gml +++ b/scripts/fontScrollBox/fontScrollBox.gml @@ -89,8 +89,8 @@ function fontScrollBox(_onModify) : widget() constructor { return h; } - static clone = function() { #region + static clone = function() { var cln = new fontScrollBox(onModify); return cln; - } #endregion + } } \ No newline at end of file diff --git a/scripts/font_loader/font_loader.gml b/scripts/font_loader/font_loader.gml index e1f30d601..8fdf458c5 100644 --- a/scripts/font_loader/font_loader.gml +++ b/scripts/font_loader/font_loader.gml @@ -28,14 +28,14 @@ global.LINE_HEIGHTS = {}; FONT_ISLOADED = false; #endregion -function __font_add_height(font) { #region +function __font_add_height(font) { INLINE draw_set_font(font); global.LINE_HEIGHTS[$ font] = string_height("l"); -} #endregion +} -function __font_refresh() { #region +function __font_refresh() { __font_add_height(f_h1); __font_add_height(f_h2); __font_add_height(f_h3); @@ -52,9 +52,9 @@ function __font_refresh() { #region __font_add_height(f_code); __font_add_height(f_sdf); __font_add_height(f_sdf_medium); -} #endregion +} -function _font_add(path, size, sdf = false, custom = false) { #region +function _font_add(path, size, sdf = false, custom = false) { var _cache = custom? FONT_CUST_CACHE : FONT_CACHE; var font_cache_dir = DIRECTORY + "font_cache"; directory_verify(font_cache_dir); @@ -71,9 +71,9 @@ function _font_add(path, size, sdf = false, custom = false) { #region _font_extend_locale(_f, _f); return _f; -} #endregion +} -function _font_extend_locale(baseFont, localFont, override = false) { #region +function _font_extend_locale(baseFont, localFont, override = false) { if(!struct_exists(GLYPH_MAP, baseFont)) GLYPH_MAP[$ baseFont] = {}; @@ -89,9 +89,9 @@ function _font_extend_locale(baseFont, localFont, override = false) { #region if(override || !struct_has(Gmap, _g)) Gmap[$ _g] = localFont; } -} #endregion +} -function _font_path(rel) { #region +function _font_path(rel) { rel = string_replace_all(rel, "./", ""); var defPath = $"{DIRECTORY}Themes/{PREFERENCES.theme}/fonts/{rel}"; @@ -103,9 +103,9 @@ function _font_path(rel) { #region return overridePath; return defPath; -} #endregion +} -function _font_load_from_struct(str, name, def, over = true) { #region +function _font_load_from_struct(str, name, def, over = true) { if(!struct_has(str, name)) return def; var font = str[$ name]; @@ -126,11 +126,11 @@ function _font_load_from_struct(str, name, def, over = true) { #region var _font = _font_add(path, round(font.size * UI_SCALE), _sdf); return _font; -} #endregion +} function font_clear(font) { if(font_exists(font)) font_delete(font); } -function loadFonts() { #region +function loadFonts() { if(FONT_ISLOADED) { font_clear(f_h1); font_clear(f_h2); @@ -196,7 +196,7 @@ function loadFonts() { #region FONT_ISLOADED = true; __font_refresh(); -} #endregion +} #region unused font cache //function __fontCache() { diff --git a/scripts/font_sprite_loader/font_sprite_loader.gml b/scripts/font_sprite_loader/font_sprite_loader.gml index 6a23d9d64..d21bdd09e 100644 --- a/scripts/font_sprite_loader/font_sprite_loader.gml +++ b/scripts/font_sprite_loader/font_sprite_loader.gml @@ -1,47 +1,54 @@ globalvar FONT_INTERNAL, FONT_SPRITES; FONT_SPRITES = ds_map_create(); -#region font refresh - function loadFontSprite(path) { - if(ds_map_exists(FONT_SPRITES, path)) return; +function loadFontSprite(path) { + if(ds_map_exists(FONT_SPRITES, path)) return; + + var f = _font_add(path, 32); + if(!font_exists(f)) return; + + draw_set_text(f, fa_left, fa_top, c_white); + var name = "ABCabc123"; + var ww = max(1, string_width(name)); + var hh = max(1, string_height(name)); + + var s = surface_create(ww, hh); + surface_set_target(s); + DRAW_CLEAR + draw_text(0, 0, name); + surface_reset_target(); + + var spr = sprite_create_from_surface(s, 0, 0, ww, hh, false, false, 0, 0); + surface_free(s); + font_delete(f); + + FONT_SPRITES[? path] = spr; +} + +function refreshFontFolder() { + FONT_INTERNAL = []; + readFontFolder(DIRECTORY + "Fonts/"); + + for (var i = 0, n = array_length(PREFERENCES.path_fonts); i < n; i++) + readFontFolder(string_trim_end(PREFERENCES.path_fonts[i], ["/"]) + "/"); +} + +function readFontFolder(dirPath) { + var root = dirPath + "*"; + var filter = [ ".ttf", ".otf" ]; + var fil = file_find_first(root, -1); + var ful, ext; + + while(fil != "") { + ful = dirPath + fil; + fil = file_find_next(); + ext = filename_ext(ful); - var f = _font_add(path, 32); - if(!font_exists(f)) return; + if(!array_exists(filter, string_lower(ext))) continue; - draw_set_text(f, fa_left, fa_top, c_white); - var name = "ABCabc123"; - var ww = max(1, string_width(name)); - var hh = max(1, string_height(name)); - - var s = surface_create(ww, hh); - surface_set_target(s); - DRAW_CLEAR - draw_text(0, 0, name); - surface_reset_target(); - - var spr = sprite_create_from_surface(s, 0, 0, ww, hh, false, false, 0, 0); - surface_free(s); - font_delete(f); - - FONT_SPRITES[? path] = spr; + array_push(FONT_INTERNAL, ful); + loadFontSprite(ful); } - function refreshFontFolder() { - FONT_INTERNAL = []; - var root = DIRECTORY + "Fonts/*"; - var f = file_find_first(root, -1); - var filter = [ ".ttf", ".otf" ]; - - while(f != "") { - var fullname = DIRECTORY + "Fonts/" + f; - var ext = filename_ext(fullname); - if(array_exists(filter, string_lower(ext))) { - array_push(FONT_INTERNAL, f); - loadFontSprite(fullname); - } - f = file_find_next(); - } - - file_find_close(); - } -#endregion \ No newline at end of file + file_find_close(); +} \ No newline at end of file diff --git a/scripts/node_grid/node_grid.gml b/scripts/node_grid/node_grid.gml index 7827a78e4..59b9655c0 100644 --- a/scripts/node_grid/node_grid.gml +++ b/scripts/node_grid/node_grid.gml @@ -76,9 +76,11 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons inputs[| 27] = nodeValue("Diagonal", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + inputs[| 28] = nodeValue("Uniform height", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); + input_display_list = [ ["Output", false], 0, - ["Pattern", false], 1, 4, 15, 2, 13, 3, 26, 27, 14, 9, 8, 16, + ["Pattern", false], 1, 4, 15, 2, 13, 28, 3, 26, 27, 14, 9, 8, 16, ["Render", false], 10, 11, 5, 20, 6, 7, 25, 12, 24, ["Truchet", true, 17], 18, 19, 22, 23, ]; @@ -155,6 +157,7 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons shader_set_2("level", _data[24]); shader_set_f("gapAcc", _data[26]); shader_set_i("diagonal", _data[27]); + shader_set_i("uniformSize", _data[28]); shader_set_color("gapCol", _col_gap); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 3baefc1e5..ce9e712ac 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -841,7 +841,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru break; case VALUE_DISPLAY.path_font : - editWidget = new fontScrollBox( function(val) { return setValueInspector(DIRECTORY + "Fonts/" + FONT_INTERNAL[val]); } ); + editWidget = new fontScrollBox( function(val) { return setValueInspector(FONT_INTERNAL[val]); } ); break; } break; #endregion diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 1a67c78d2..64f3a594e 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -160,6 +160,9 @@ PREFERENCES.file_explorer = ""; PREFERENCES.dialog_path = ""; + PREFERENCES.path_assets = []; + PREFERENCES.path_fonts = []; + PREFERENCES.versions = {}; #endregion diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index a5549659e..43ade8772 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -68,6 +68,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { text_surface = surface_create(1, 1); shake_amount = 0; + onDeactivate = -1; static setOnRelease = function(release) { onRelease = release; return self; } @@ -132,6 +133,8 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { UNDO_HOLDING = false; if(PEN_USE) keyboard_virtual_hide(); + + if(onDeactivate != -1) onDeactivate(); } static onKey = function(key) { diff --git a/shaders/sh_grid/sh_grid.fsh b/shaders/sh_grid/sh_grid.fsh index 75e9c8b80..70ec43f0c 100644 --- a/shaders/sh_grid/sh_grid.fsh +++ b/shaders/sh_grid/sh_grid.fsh @@ -30,6 +30,7 @@ uniform int gradient_use; uniform vec2 level; uniform int diagonal; +uniform int uniformSize; uniform int textureTruchet; uniform float truchetSeed; @@ -261,7 +262,7 @@ void main() { #region vec2 sqSt = floor(_pos * sca) / sca; vec2 _dist = _pos - sqSt; vec2 nPos = abs(_dist * sca - vec2(0.5)) * 2.; //distance in x, y axis - float rat = sca.y / sca.x; + float rat = uniformSize == 1? sca.y / sca.x : 1.; float dist = 1. - max((nPos.x - 1.) * rat + 1., nPos.y); vec4 colr;