mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- Add preference settings to add more folders for fonts and assets.
This commit is contained in:
parent
e7881f1bad
commit
32a250fe62
18 changed files with 276 additions and 111 deletions
|
@ -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",},
|
||||
|
|
|
@ -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",},},
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
global.ASSET_CACHE = ds_map_create();
|
||||
|
||||
function __initAssets() {
|
||||
global.ASSETS = new DirectoryObject("Assets", "");
|
||||
ds_map_clear(global.ASSET_MAP);
|
||||
|
||||
var root = DIRECTORY + "Assets";
|
||||
|
@ -11,11 +12,21 @@
|
|||
if(check_version($"{root}/version"))
|
||||
zip_unzip("data/Assets.zip", root);
|
||||
|
||||
global.ASSETS = new DirectoryObject("Assets", root);
|
||||
global.ASSETS.scan([".png"]);
|
||||
__initAssetsFolder(root);
|
||||
for( var i = 0, n = array_length(PREFERENCES.path_assets); i < n; i++ )
|
||||
__initAssetsFolder(PREFERENCES.path_assets[i]);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -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
|
104
scripts/folderArrayBox/folderArrayBox.gml
Normal file
104
scripts/folderArrayBox/folderArrayBox.gml
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
13
scripts/folderArrayBox/folderArrayBox.yy
Normal file
13
scripts/folderArrayBox/folderArrayBox.yy
Normal file
|
@ -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",
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
globalvar FONT_INTERNAL, FONT_SPRITES;
|
||||
FONT_SPRITES = ds_map_create();
|
||||
|
||||
#region font refresh
|
||||
function loadFontSprite(path) {
|
||||
if(ds_map_exists(FONT_SPRITES, path)) return;
|
||||
|
||||
|
@ -28,20 +27,28 @@ FONT_SPRITES = ds_map_create();
|
|||
|
||||
function refreshFontFolder() {
|
||||
FONT_INTERNAL = [];
|
||||
var root = DIRECTORY + "Fonts/*";
|
||||
var f = file_find_first(root, -1);
|
||||
var filter = [ ".ttf", ".otf" ];
|
||||
readFontFolder(DIRECTORY + "Fonts/");
|
||||
|
||||
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);
|
||||
for (var i = 0, n = array_length(PREFERENCES.path_fonts); i < n; i++)
|
||||
readFontFolder(string_trim_end(PREFERENCES.path_fonts[i], ["/"]) + "/");
|
||||
}
|
||||
f = file_find_next();
|
||||
|
||||
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);
|
||||
|
||||
if(!array_exists(filter, string_lower(ext))) continue;
|
||||
|
||||
array_push(FONT_INTERNAL, ful);
|
||||
loadFontSprite(ful);
|
||||
}
|
||||
|
||||
file_find_close();
|
||||
}
|
||||
#endregion
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -160,6 +160,9 @@
|
|||
PREFERENCES.file_explorer = "";
|
||||
PREFERENCES.dialog_path = "";
|
||||
|
||||
PREFERENCES.path_assets = [];
|
||||
PREFERENCES.path_fonts = [];
|
||||
|
||||
PREFERENCES.versions = {};
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue