summaryrefslogtreecommitdiff
path: root/src/scenes/puzzleScene.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scenes/puzzleScene.c')
-rw-r--r--src/scenes/puzzleScene.c66
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;
}