mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
per character line break
This commit is contained in:
parent
d6a9980dba
commit
2c4ebb08e5
21 changed files with 155 additions and 35 deletions
|
@ -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",},
|
||||
|
|
Binary file not shown.
3
datafiles/data/locale/en/config.json
Normal file
3
datafiles/data/locale/en/config.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"per_character_line_break": false
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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 ],
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue