diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 3b7f511cd..2340d7368 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -207,6 +207,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Side menu.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Vertical.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"en.zip","CopyToMask":-1,"filePath":"datafiles/data/locale",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"config.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"nodes.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"UI.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"words.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",}, diff --git a/datafiles/data/locale/en.zip b/datafiles/data/locale/en.zip index 1ed2df796..662f45e23 100644 Binary files a/datafiles/data/locale/en.zip and b/datafiles/data/locale/en.zip differ diff --git a/datafiles/data/locale/en/config.json b/datafiles/data/locale/en/config.json new file mode 100644 index 000000000..06e4c9fa9 --- /dev/null +++ b/datafiles/data/locale/en/config.json @@ -0,0 +1,3 @@ +{ + "per_character_line_break": false +} \ No newline at end of file diff --git a/objects/o_dialog_about/Create_0.gml b/objects/o_dialog_about/Create_0.gml index 475b5fbf9..36d0b6884 100644 --- a/objects/o_dialog_about/Create_0.gml +++ b/objects/o_dialog_about/Create_0.gml @@ -53,7 +53,7 @@ event_inherited(); draw_set_font(f_p0); draw_set_color(COLORS._main_text_sub); yy += ui(40); - draw_text_ext(cx, yy, "Made with GameMaker Studio 2, Adobe Illustrator, Aseprite", -1, sc_thank.w - ui(16)); + draw_text_line(cx, yy, "Made with GameMaker Studio 2, Adobe Illustrator, Aseprite", -1, sc_thank.w - ui(16)); yy += ui(32); BLEND_NORMAL diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index d4928f48d..f07b2026d 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -604,7 +604,7 @@ event_inherited(); var eq = string_replace(search_string, "=", ""); draw_set_text(f_h5, fa_center, fa_bottom, COLORS._main_text_sub); - draw_text_ext(search_pane.w / 2, search_pane.h / 2 - ui(8), + draw_text_line(search_pane.w / 2, search_pane.h / 2 - ui(8), __txtx("add_node_create_equation", "Create equation") + ": " + eq, -1, search_pane.w - ui(32)); draw_set_text(f_p0, fa_center, fa_top, COLORS._main_text_sub); diff --git a/objects/o_dialog_add_node/Draw_64.gml b/objects/o_dialog_add_node/Draw_64.gml index 544e4ed0c..e298b73bd 100644 --- a/objects/o_dialog_add_node/Draw_64.gml +++ b/objects/o_dialog_add_node/Draw_64.gml @@ -87,7 +87,7 @@ if !ready exit; if(spr) draw_sprite(spr, 0, x0 + ui(4), y0 + ui(4)); draw_set_text(f_p1, fa_left, fa_bottom, COLORS._main_text) - draw_text_ext(x0 + ui(8), y1 - ui(8), txt, -1, ww - ui(16)); + draw_text_line(x0 + ui(8), y1 - ui(8), txt, -1, ww - ui(16)); } node_tooltip = noone; diff --git a/objects/o_dialog_image_array_edit/Create_0.gml b/objects/o_dialog_image_array_edit/Create_0.gml index 2d7a9efb8..7e68fb679 100644 --- a/objects/o_dialog_image_array_edit/Create_0.gml +++ b/objects/o_dialog_image_array_edit/Create_0.gml @@ -90,7 +90,7 @@ event_inherited(); var name = string_cut_line(string_replace(filename_name(path), filename_ext(path), ""), ww); var txt_h = string_height_ext(name, -1, ww); - draw_text_ext(xx + ww / 2, yy + hh + ui(16), name, -1, ww); + draw_text_line(xx + ww / 2, yy + hh + ui(16), name, -1, ww); ch = max(ch, hh + txt_h + ui(32)); } diff --git a/objects/o_dialog_l_system/Create_0.gml b/objects/o_dialog_l_system/Create_0.gml index e7388af59..db727a8f2 100644 --- a/objects/o_dialog_l_system/Create_0.gml +++ b/objects/o_dialog_l_system/Create_0.gml @@ -67,7 +67,7 @@ event_inherited(); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); var hh = string_height_ext(_f, -1, sp_note.surface_w - ui(8 + 8)); - draw_text_ext(ui(8), yy, _f, -1, sp_note.surface_w - ui(8 + 8)); + draw_text_line(ui(8), yy, _f, -1, sp_note.surface_w - ui(8 + 8)); ind = 0; yy += hh + pad * 2; diff --git a/objects/o_dialog_migration/Draw_64.gml b/objects/o_dialog_migration/Draw_64.gml index dc104a8d5..40c65c0f3 100644 --- a/objects/o_dialog_migration/Draw_64.gml +++ b/objects/o_dialog_migration/Draw_64.gml @@ -18,7 +18,7 @@ draw_set_alpha(1); py += line_get_height(, 4); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - draw_text_ext(dialog_x + ui(24), py, __txtx("dialog_migration_content", + draw_text_line(dialog_x + ui(24), py, __txtx("dialog_migration_content", "You can press migrate files or manually move all custom collections, assets, palettes, gradients, fonts and presets."), -1, dialog_w - ui(48)); var bw = ui(112), bh = TEXTBOX_HEIGHT; diff --git a/objects/o_dialog_notifications/Create_0.gml b/objects/o_dialog_notifications/Create_0.gml index bf0237da5..d3a5ddb7f 100644 --- a/objects/o_dialog_notifications/Create_0.gml +++ b/objects/o_dialog_notifications/Create_0.gml @@ -109,10 +109,10 @@ event_inherited(); var tx = ui(48) + timeW + ui(12); draw_set_text(f_p3, fa_right, fa_center, COLORS._main_text_sub); - draw_text_ext(tx - ui(4), yy + _h / 2, noti.time, -1, txw); + draw_text_line(tx - ui(4), yy + _h / 2, noti.time, -1, txw); draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text); - draw_text_ext(tx + ui(4), yy + _h / 2, noti.txt, -1, txw); + draw_text_line(tx + ui(4), yy + _h / 2, noti.txt, -1, txw); if(noti.amount > 1) { draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text); diff --git a/objects/o_dialog_release_note/Create_0.gml b/objects/o_dialog_release_note/Create_0.gml index 8152b6374..55772f49c 100644 --- a/objects/o_dialog_release_note/Create_0.gml +++ b/objects/o_dialog_release_note/Create_0.gml @@ -41,7 +41,7 @@ event_inherited(); draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_title); line = string_copy(line, sp + 1, string_length(line) - sp); yy += ui(16); - draw_text_ext(xx, _y + yy, line, -1, ww); + draw_text_line(xx, _y + yy, line, -1, ww); yy += ui(4); break; @@ -49,31 +49,31 @@ event_inherited(); draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_title); line = string_copy(line, sp + 1, string_length(line) - sp); yy += ui(8); - draw_text_ext(xx + ui(16), _y + yy, line, -1, ww); + draw_text_line(xx + ui(16), _y + yy, line, -1, ww); yy += ui(4); break; case "###" : draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent); line = string_copy(line, sp + 1, string_length(line) - sp); yy += ui(8); - draw_text_ext(xx + ui(16), _y + yy, line, -1, ww); + draw_text_line(xx + ui(16), _y + yy, line, -1, ww); yy += ui(4); break; case "-" : draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); line = string_copy(line, sp + 1, string_length(line) - sp); draw_sprite_ui_uniform(THEME.text_bullet, 0, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_icon); - draw_text_ext(xx + ui(28), _y + yy, line, -1, ww); + draw_text_line(xx + ui(28), _y + yy, line, -1, ww); break; case "+" : draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); line = string_copy(line, sp + 1, string_length(line) - sp); draw_sprite_ui_uniform(THEME.text_bullet, 1, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_value_positive); - draw_text_ext(xx + ui(28), _y + yy, line, -1, ww); + draw_text_line(xx + ui(28), _y + yy, line, -1, ww); break; default : draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - draw_text_ext(xx + 0, _y + yy, line, -1, ww); + draw_text_line(xx + 0, _y + yy, line, -1, ww); break; } diff --git a/objects/o_dialog_warning/Draw_64.gml b/objects/o_dialog_warning/Draw_64.gml index c3b59dd7f..a81b3471e 100644 --- a/objects/o_dialog_warning/Draw_64.gml +++ b/objects/o_dialog_warning/Draw_64.gml @@ -17,5 +17,5 @@ if !ready exit; draw_sprite_ui(THEME.noti_icon_warning, 1, dialog_x + ui(16), dialog_y + dialog_h / 2); draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text); - draw_text_ext(dialog_x + ui(32) + padding, dialog_y + padding, warning_text, -1, dialog_w - padding * 2 - ui(32)); + draw_text_line(dialog_x + ui(32) + padding, dialog_y + padding, warning_text, -1, dialog_w - padding * 2 - ui(32)); #endregion \ No newline at end of file diff --git a/scripts/addon_lua/addon_lua.gml b/scripts/addon_lua/addon_lua.gml index 33cc7c940..ee42e44aa 100644 --- a/scripts/addon_lua/addon_lua.gml +++ b/scripts/addon_lua/addon_lua.gml @@ -143,11 +143,11 @@ [ "draw_set_text", draw_set_text ], [ "draw_text", draw_text_add ], - [ "draw_text_ext", draw_text_ext_add ], + [ "draw_text_line", draw_text_ext_add ], [ "draw_text_colour", draw_text_colour ], [ "draw_text_transformed", draw_text_transformed ], [ "draw_text_ext_colour", draw_text_ext_colour ], - [ "draw_text_ext_transformed", draw_text_ext_transformed ], + [ "draw_text_ext_transformed", __draw_text_ext_transformed ], [ "draw_text_transformed_colour", draw_text_transformed_colour ], [ "draw_text_ext_transformed_colour", draw_text_ext_transformed_colour ], diff --git a/scripts/draw_text_function/draw_text_function.gml b/scripts/draw_text_function/draw_text_function.gml index 04ce7addb..c34299371 100644 --- a/scripts/draw_text_function/draw_text_function.gml +++ b/scripts/draw_text_function/draw_text_function.gml @@ -1,3 +1,7 @@ +function draw_text_line(_x, _y, _text, _sep, _w) { + __draw_text_ext_transformed(_x, _y, _text, _sep, _w, 1, 1, 0); +} + function draw_text_over(_x, _y, _text, scale = 1) { BLEND_ALPHA_MULP; draw_text_transformed(_x, _y, _text, scale, scale, 0); @@ -6,7 +10,7 @@ function draw_text_over(_x, _y, _text, scale = 1) { function draw_text_ext_over(_x, _y, _text, _sep, _w, scale = 1) { BLEND_ALPHA_MULP; - draw_text_ext_transformed(_x, _y, _text, _sep, _w, scale, scale, 0); + __draw_text_ext_transformed(_x, _y, _text, _sep, _w, scale, scale, 0); BLEND_NORMAL; } @@ -18,7 +22,7 @@ function draw_text_add(_x, _y, _text, scale = 1) { function draw_text_ext_add(_x, _y, _text, _sep, _w, scale = 1) { BLEND_ALPHA_MULP; - draw_text_ext_transformed(_x, _y, _text, _sep, _w, scale, scale, 0); + __draw_text_ext_transformed(_x, _y, _text, _sep, _w, scale, scale, 0); BLEND_NORMAL; } @@ -27,4 +31,119 @@ function draw_text_bbox(bbox, text) { ss = max(0.5, ss); draw_text_cut(bbox.xc, bbox.yc, text, bbox.w, ss); +} + +function draw_text_cut(x, y, str, w, scale = 1) { + draw_text_transformed(x, y, string_cut(str, w,, scale), scale, scale, 0); +} + +function __draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx, sy, rotation) { + if(!LOCALE.config.per_character_line_break) { + draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx, sy, rotation); + return; + } + + var lines = []; + var line = ""; + var line_w = 0; + var amo = string_length(_text); + + for( var i = 1; i <= amo; i++ ) { + var ch = string_char_at(_text, i); + var ww = string_width(ch) * sx; + + if(line_w + ww > _w) { + array_push(lines, line); + line = ch; + line_w = ww; + } else { + line += ch; + line_w += ww; + } + } + + if(line != "") array_push(lines, line); + + var ha = draw_get_halign(); + var va = draw_get_valign(); + var xx = _x, yy = _y; + var hh = string_height("M") * array_length(lines) * sy; + + draw_set_halign(fa_left); + draw_set_valign(fa_top); + + switch(va) { + case fa_top : yy = _y; break; + case fa_middle : yy = _y - hh / 2; break; + case fa_bottom : yy = _y - hh; break; + } + + for( var i = 0; i < array_length(lines); i++ ) { + var lw = string_width(lines[i]) * sx; + + switch(ha) { + case fa_left : xx = _x; break; + case fa_center : xx = _x - lw / 2; break; + case fa_right : xx = _x - lw; break; + } + + draw_text_transformed(xx, yy, lines[i], sx, sy, rotation); + yy += string_height("M") * sy; + } + + draw_set_halign(ha); + draw_set_valign(va); +} + +#macro _string_width_ext string_width_ext +#macro string_width_ext __string_width_ext + +function __string_width_ext(text, sep, w) { + if(!LOCALE.config.per_character_line_break) + return _string_width_ext(text, sep, w); + + var mxw = 0; + var lw = 0; + var amo = string_length(text); + + for( var i = 1; i <= amo; i++ ) { + var ch = string_char_at(text, i); + var ww = string_width(ch); + + if(lw + ww > w) { + mxw = max(mxw, lw); + lw = ww; + } else + lw += ww; + } + + mxw = max(mxw, lw); + return mxw; +} + +#macro _string_height_ext string_height_ext +#macro string_height_ext __string_height_ext + +function __string_height_ext(text, sep, w) { + if(!LOCALE.config.per_character_line_break) + return _string_height_ext(text, sep, w); + + var lw = 0; + var amo = string_length(text); + if(amo == 0) return 0; + + var hh = string_height("M"); + + for( var i = 1; i <= amo; i++ ) { + var ch = string_char_at(text, i); + var ww = string_width(ch); + + if(lw + ww > w) { + hh += string_height("M"); + lw = ww; + } else + lw += ww; + } + + return hh; } \ No newline at end of file diff --git a/scripts/draw_tooltip/draw_tooltip.gml b/scripts/draw_tooltip/draw_tooltip.gml index 884726c71..7d2edcdab 100644 --- a/scripts/draw_tooltip/draw_tooltip.gml +++ b/scripts/draw_tooltip/draw_tooltip.gml @@ -9,7 +9,7 @@ function draw_tooltip_text(txt) { draw_sprite_stretched(THEME.textbox, 3, mx, my, tw + ui(16), th + ui(16)); draw_sprite_stretched(THEME.textbox, 0, mx, my, tw + ui(16), th + ui(16)); - draw_text_ext(mx + ui(8), my + ui(8), txt, -1, tw); + draw_text_line(mx + ui(8), my + ui(8), txt, -1, tw); } function draw_tooltip_color(clr) { diff --git a/scripts/gameframe/gameframe.gml b/scripts/gameframe/gameframe.gml index ab522ed3d..962d536cd 100644 --- a/scripts/gameframe/gameframe.gml +++ b/scripts/gameframe/gameframe.gml @@ -839,7 +839,7 @@ function gameframe_caption_draw_caption_text_default(__x, __y, __width, __height var __alpha = draw_get_alpha(); var __textWidth = __right - __x; draw_set_alpha((gameframe_alpha * gameframe_caption_alpha)); - draw_text_ext_transformed((__x + ((gameframe_caption_text_align * __textWidth) div 2)), __y + ((__height - string_height_ext(_text, -1, __textWidth) * _dpiScale) div 2), _text, -1, __textWidth, _dpiScale, _dpiScale, 0); + __draw_text_ext_transformed((__x + ((gameframe_caption_text_align * __textWidth) div 2)), __y + ((__height - string_height_ext(_text, -1, __textWidth) * _dpiScale) div 2), _text, -1, __textWidth, _dpiScale, _dpiScale, 0); draw_set_alpha(__alpha); if (__newFont != -1) draw_set_font(__oldFont); draw_set_halign(__h); diff --git a/scripts/locale_data/locale_data.gml b/scripts/locale_data/locale_data.gml index f30e1848d..990b5cb74 100644 --- a/scripts/locale_data/locale_data.gml +++ b/scripts/locale_data/locale_data.gml @@ -24,6 +24,7 @@ LOCALE.word = json_load_struct(__locale_file("/words.json")); LOCALE.ui = json_load_struct(__locale_file("/UI.json")); LOCALE.node = json_load_struct(__locale_file("/nodes.json")); + LOCALE.config = json_load_struct(__locale_file("/config.json")); var fontDir = $"{DIRECTORY}Locale/{PREF_MAP[? "local"]}/fonts/"; LOCALE.fontDir = directory_exists(fontDir)? fontDir : noone; @@ -37,7 +38,7 @@ if(struct_has(LOCALE.ui, key)) return LOCALE.ui[$ key] - print($"LOCAL \"{key}\": \"{def}\","); + //print($"LOCAL \"{key}\": \"{def}\","); return def; } diff --git a/scripts/meta_data/meta_data.gml b/scripts/meta_data/meta_data.gml index 621e00caa..9c5c0029a 100644 --- a/scripts/meta_data/meta_data.gml +++ b/scripts/meta_data/meta_data.gml @@ -154,36 +154,36 @@ function MetaDataManager() constructor { var ty = my + ui(8); draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text); - draw_text_ext(mx + ui(8), ty, name, -1, _w); + draw_text_line(mx + ui(8), ty, name, -1, _w); ty += string_height_ext(name, -1, _w) - ui(4); draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub); - draw_text_ext(mx + ui(8), ty, _aut, -1, _w); + draw_text_line(mx + ui(8), ty, _aut, -1, _w); ty += string_height_ext(_aut, -1, _w); if(contact != "") { ty += ui(-4); draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub); - draw_text_ext(mx + ui(8), ty, contact, -1, _w); + draw_text_line(mx + ui(8), ty, contact, -1, _w); ty += string_height_ext(contact, -1, _w); } ty += ui(8); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - draw_text_ext(mx + ui(8), ty, description, -1, _w); + draw_text_line(mx + ui(8), ty, description, -1, _w); ty += string_height_ext(description, -1, _w); if(alias != "") { ty += ui(16); draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub); - draw_text_ext(mx + ui(8), ty, alias, -1, _w); + draw_text_line(mx + ui(8), ty, alias, -1, _w); ty += string_height_ext(alias, -1, _w); } if(version != SAVEFILE_VERSION) { ty += ui(8); draw_set_text(f_p2, fa_left, fa_top, COLORS._main_accent); - draw_text_ext(mx + ui(8), ty, _ver, -1, _w); + draw_text_line(mx + ui(8), ty, _ver, -1, _w); ty += string_height_ext(_ver, -1, _w); } diff --git a/scripts/panel_console/panel_console.gml b/scripts/panel_console/panel_console.gml index 4187bab7c..e81399e88 100644 --- a/scripts/panel_console/panel_console.gml +++ b/scripts/panel_console/panel_console.gml @@ -54,7 +54,7 @@ function Panel_Console() : PanelContent() constructor { var txt = his.txt; draw_set_color(his.color); - draw_text_ext(ui(8), hy, txt, -1, w - ui(16)); + draw_text_line(ui(8), hy, txt, -1, w - ui(16)); hy -= string_height_ext(txt, -1, w - ui(16)); if(hy <= 0) break; diff --git a/scripts/panel_notification/panel_notification.gml b/scripts/panel_notification/panel_notification.gml index 5dbd117c4..4e6e7e281 100644 --- a/scripts/panel_notification/panel_notification.gml +++ b/scripts/panel_notification/panel_notification.gml @@ -110,10 +110,10 @@ function Panel_Notification() : PanelContent() constructor { var tx = ui(48) + timeW + ui(12); draw_set_text(f_p3, fa_right, fa_center, COLORS._main_text_sub); - draw_text_ext(tx - ui(4), yy + _h / 2, noti.time, -1, txw); + draw_text_line(tx - ui(4), yy + _h / 2, noti.time, -1, txw); draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text); - draw_text_ext(tx + ui(4), yy + _h / 2, noti.txt, -1, txw); + draw_text_line(tx + ui(4), yy + _h / 2, noti.txt, -1, txw); if(noti.amount > 1) { draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text); diff --git a/scripts/string_cut/string_cut.gml b/scripts/string_cut/string_cut.gml index 96d2d1064..7c9cacbee 100644 --- a/scripts/string_cut/string_cut.gml +++ b/scripts/string_cut/string_cut.gml @@ -1,7 +1,3 @@ -function draw_text_cut(x, y, str, w, scale = 1) { - draw_text_transformed(x, y, string_cut(str, w,, scale), scale, scale, 0); -} - function string_cut(str, w, tail = "...", scale = 1) { var ww = 0; var ind = 1;