Move away from browser as a main plataform
This commit is contained in:
+20
-1
@@ -347,7 +347,7 @@ export class EditBox {
|
||||
}
|
||||
}
|
||||
|
||||
const LIST_ROW_HEIGHT = 40;
|
||||
export const LIST_ROW_HEIGHT = 40;
|
||||
const CHECK_SIZE = 20;
|
||||
|
||||
// rows of text that scroll with the mouse wheel, like minecraft's selection lists. a row can have a box ticked or not
|
||||
@@ -421,3 +421,22 @@ export class ListBox {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// text split into lines no wider than width pixels at TEXT_SCALE, at spaces and at its own line breaks
|
||||
export function wrap_text(text: string, width: number): string[] {
|
||||
const lines: string[] = [];
|
||||
for (const line of text.split("\n")) {
|
||||
let current = "";
|
||||
for (const word of line.split(" ")) {
|
||||
const next = current ? `${current} ${word}` : word;
|
||||
if (current && measure_text(next, TEXT_SCALE) > width) {
|
||||
lines.push(current);
|
||||
current = word;
|
||||
} else {
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
lines.push(current);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user