diff options
| -rw-r--r-- | puzzles/test.pz | bin | 123 -> 123 bytes | |||
| -rw-r--r-- | src/scenes/puzzleScene.c | 2 | ||||
| -rw-r--r-- | src/ui_elements/UI.c | 20 |
3 files changed, 16 insertions, 6 deletions
diff --git a/puzzles/test.pz b/puzzles/test.pz Binary files differindex 59b1153..247b002 100644 --- a/puzzles/test.pz +++ b/puzzles/test.pz diff --git a/src/scenes/puzzleScene.c b/src/scenes/puzzleScene.c index 7f06672..6c8f623 100644 --- a/src/scenes/puzzleScene.c +++ b/src/scenes/puzzleScene.c @@ -20,7 +20,7 @@ typedef struct { } puzzleSceneData; // Time in seconds -const size_t BASE_TIME_LEFT = 1; // 5 * 60; +const size_t BASE_TIME_LEFT = 5 * 60; void DrawPuzzleName(char *name) { Vector2 width = MeasureTextEx(*GetMainFont(), name, 50, 1); diff --git a/src/ui_elements/UI.c b/src/ui_elements/UI.c index 85c7a02..ea3463a 100644 --- a/src/ui_elements/UI.c +++ b/src/ui_elements/UI.c @@ -27,10 +27,19 @@ int CalculateSpans(Rectangle rec, char *text, Font *font, int height, int *spans float char_width = MeasureChar(font, height, symbol); acc += char_width + SPACING_H; - if (symbol == ' ' || symbol == '\n') { + if (symbol == '\n') { + spans[span_ptr] = ptr; + spans += 1; + ptr += 1; + acc = 0; + continue; + } + + if (symbol == ' ') { last_space_ptr = ptr; } - if (acc > rec.width || symbol == '\n') { + + if (acc > rec.width) { if (last_space_ptr < spans[span_ptr - 1] || symbol == '\n' && last_space_ptr == -1) { spans[span_ptr] = (ptr > spans[span_ptr - 1]) ? ptr : ptr + 1; last_space_ptr = spans[span_ptr]; @@ -77,7 +86,7 @@ void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color colo return; } - int vertical_acc = scroll == NULL? rec.y : rec.y - *scroll; + int vertical_acc = scroll == NULL ? rec.y : rec.y - *scroll; int text_height = lines * height; int max_scroll = text_height - rec.height; @@ -93,12 +102,13 @@ void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color colo Vector2 pos = { .x = rec.x, .y = vertical_acc }; char *line_start = text + spans[i-1]; int line_length = spans[i] - spans[i-1]; - // printf("Drawing text '%.*s' at %f;%f\n", line_length, line_start, pos.x, pos.y); + // printf("Drawing text '%.*s' at %f;%f\n", line_length - 1, line_start, pos.x, pos.y); DrawTextEx(*font, - TextFormat("%.*s", line_length, line_start), + TextFormat("%.*s", line_length - 1, line_start), pos, height, SPACING_H, color); vertical_acc += height; } + // TraceLog(LOG_FATAL, "done"); EndScissorMode(); } |
