diff options
| author | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-07-07 23:41:37 +0500 |
|---|---|---|
| committer | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-07-07 23:41:37 +0500 |
| commit | 73efefa4c6800b04aedad9f6d80722caa66864a0 (patch) | |
| tree | f1d5489d9c1660a4ae622bc3d4a31778369f9fc4 /src/scenes/puzzleScene.c | |
| parent | 1a095735b1d8e7ade61ac4f936032e0c9dcc044f (diff) | |
design 1
Diffstat (limited to 'src/scenes/puzzleScene.c')
| -rw-r--r-- | src/scenes/puzzleScene.c | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/src/scenes/puzzleScene.c b/src/scenes/puzzleScene.c index 10e3fc9..0377c03 100644 --- a/src/scenes/puzzleScene.c +++ b/src/scenes/puzzleScene.c @@ -2,6 +2,7 @@ #include <stdlib.h> #include "scenes.h" #include "../resources/resources.h" +#include "../ui_elements/UI.h" typedef struct { Puzzle *PuzzlePtr; @@ -12,16 +13,69 @@ bool updatePuzzleScene(void *self) { return true; } -Vector2 PuzzleNamePos = { .x = 0, .y = 0 }; +const int HEADER_FONT_SIZE = 50; +const int PADDING = 10; +const int BORDER = 2; +const int FOOTER_HEIGHT = 40; + +void DrawPuzzleName(char *name) { + Vector2 width = MeasureTextEx(*GetMainFont(), name, 50, 1); + int screen_width = GetScreenWidth(); + Vector2 pos = { .y = 20, .x = (screen_width - width.x) / 2, }; + DrawTextEx(*GetMainFont(), name, pos, HEADER_FONT_SIZE, 1, COLORSCHEME_BROWN); +} + +Rectangle GetBodyRect() { + int HeaderOffset = PADDING * 2 + HEADER_FONT_SIZE; + Rectangle outp = { + .x = PADDING, + .y = HeaderOffset, + .width = GetScreenWidth() - PADDING * 2, + .height = GetScreenHeight() - HeaderOffset - PADDING * 3 - FOOTER_HEIGHT, + }; + return outp; +} + +void GetPanesSplit(Rectangle *pane1, Rectangle *pane2, Rectangle body, float proportion_h, float proportion_v) { + if (body.height >= body.width) { + // vertical split + pane1->x = body.x; + pane1->y = body.y; + pane1->width = body.width; + pane1->height = (body.height - PADDING) * proportion_v; + + pane2->x = body.x; + pane2->y = body.y + pane1->height + PADDING; + pane2->width = body.width; + pane2->height = (body.height - PADDING) * (1 - proportion_v); + return; + } + + // horizontal split + pane1->x = body.x; + pane1->y = body.y; + pane1->height = body.height; + pane1->width = (body.width - PADDING) * proportion_h; + + pane2->y = body.y; + pane2->x = body.x + pane1->width + PADDING; + pane2->height = body.height; + pane2->width = (body.width - PADDING) * (1 - proportion_h); +} bool drawPuzzleScene(void *self) { puzzleSceneData *data = ((Scene *)self)->data; - ClearBackground(SKYBLUE); + ClearBackground(COLORSCHEME_WHITE); + DrawPuzzleName(data->PuzzlePtr->Name); + + Rectangle body = GetBodyRect(); + Rectangle pane1, pane2; + GetPanesSplit(&pane1, &pane2, body, 0.5, 0.4); + DrawRecBordered(pane1, WHITE, COLORSCHEME_ORANGE, BORDER); + DrawRecBordered(pane2, WHITE, COLORSCHEME_ORANGE, BORDER); + + // DrawRecBordered(body, COLORSCHEME_WHITE, COLORSCHEME_ORANGE, BORDER); - DrawTextEx(*GetMainFont(), - data->PuzzlePtr->Name, - PuzzleNamePos, - 100, 1, BLACK); return true; } |
