summaryrefslogtreecommitdiff
path: root/src/scenes
diff options
context:
space:
mode:
authorphysick <mynameisgennadiy@vk.com>2026-08-29 14:12:24 +0500
committerphysick <mynameisgennadiy@vk.com>2026-08-29 14:12:24 +0500
commitd51d95b66dee211ef654693fb23238d5a234f48c (patch)
treef225999b981091944a1e7442e22fb0a0af2f4003 /src/scenes
parent52ab86e5f55b189aea4198fe4d15a29c4d3c9d57 (diff)
merged branches
Diffstat (limited to 'src/scenes')
-rw-r--r--src/scenes/collectionScene.c74
-rw-r--r--src/scenes/distractionScene.c2
-rw-r--r--src/scenes/puzzleScene.c5
-rw-r--r--src/scenes/resultView.c1
-rw-r--r--src/scenes/scenes.h2
5 files changed, 76 insertions, 8 deletions
diff --git a/src/scenes/collectionScene.c b/src/scenes/collectionScene.c
new file mode 100644
index 0000000..2173619
--- /dev/null
+++ b/src/scenes/collectionScene.c
@@ -0,0 +1,74 @@
+#include "scenes.h"
+#include <raylib.h>
+#include <string.h>
+#include "../ui_elements/UI.h"
+#include "../resources/resources.h"
+
+typedef struct {
+ char *DirPath;
+ char *Name;
+} CollectionSceneData;
+
+CollectionSceneData *getData(void *self) {
+ return ((Scene *)self)->data;
+}
+
+void DrawCollectionName(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);
+}
+
+// Does not allocate the memory
+char *getCollectionName(char *path) {
+ char *outp = path;
+ size_t len = strlen(path);
+ for (size_t i = 0; i < len; ++i) {
+ if ((path[i] == '/' || path[i] == '\\') && path[i+1] != 0x0) {
+ outp = path + i + 1;
+ }
+ }
+ return outp;
+}
+
+bool updateCollectionScene(void *self) {
+ return true;
+}
+
+bool drawCollectionScene(void *self) {
+ CollectionSceneData *data = getData(self);
+ DrawBackground();
+ DrawCollectionName(data->Name);
+ DrawPageView(GetScreenHeight() - 60, 5, 2);
+ return true;
+}
+
+void deinitCollectionScene(void *self) {
+ TraceLog(LOG_INFO, "Deleting a collection scene");
+ CollectionSceneData *data = getData(self);
+ if (data != NULL) free(data);
+ free((Scene *)self);
+}
+
+Scene *CreatePuzzleCollectionScene(char *path) {
+ TraceLog(LOG_INFO, "Creating a collection scene");
+ Scene *outp = malloc(sizeof(Scene));
+ if (outp == NULL) return NULL;
+ outp->Update = updateCollectionScene;
+ outp->Draw = drawCollectionScene;
+ outp->Deint = deinitCollectionScene;
+ outp->IsTransparent = false;
+
+ CollectionSceneData *data = malloc(sizeof(CollectionSceneData));
+ if (data == NULL) {
+ free(outp);
+ return NULL;
+ }
+ data->DirPath = strdup(path);
+ data->Name = getCollectionName(path);
+
+ outp->data = data;
+
+ return outp;
+}
diff --git a/src/scenes/distractionScene.c b/src/scenes/distractionScene.c
index 1f12aae..f249b53 100644
--- a/src/scenes/distractionScene.c
+++ b/src/scenes/distractionScene.c
@@ -5,8 +5,6 @@
#include "../resources/resources.h"
static const float BODY_PADDING = 0.05f;
-static const int BORDER = 2;
-static const int EDITOR_PADDING = 3;
typedef struct {
DistractionPuzzle *puzzle;
diff --git a/src/scenes/puzzleScene.c b/src/scenes/puzzleScene.c
index c3e48c1..1671cf8 100644
--- a/src/scenes/puzzleScene.c
+++ b/src/scenes/puzzleScene.c
@@ -17,11 +17,6 @@ typedef struct {
float time_acc;
} puzzleSceneData;
-const int HEADER_FONT_SIZE = 50;
-const int EDITOR_PADDING = 3;
-const int BORDER = 2;
-const int FOOTER_HEIGHT = 30;
-
// Time in seconds
const size_t BASE_TIME_LEFT = 1; // 5 * 60;
diff --git a/src/scenes/resultView.c b/src/scenes/resultView.c
index 1cbc182..e51898e 100644
--- a/src/scenes/resultView.c
+++ b/src/scenes/resultView.c
@@ -7,7 +7,6 @@
#include "../ui_elements/UI.h"
#include "../resources/resources.h"
-static const int BORDER = 2;
static const int SCROLL_SPEED = 10;
static const uint8_t MAX_TINT = 96;
diff --git a/src/scenes/scenes.h b/src/scenes/scenes.h
index 335a139..828f2f3 100644
--- a/src/scenes/scenes.h
+++ b/src/scenes/scenes.h
@@ -33,4 +33,6 @@ Scene *CreatePuzzleScene(Puzzle *puzzle);
Scene *CreateDistractionScene(DistractionPuzzle *puzzle, void (*addTime)(Scene *, size_t));
Scene *CreateResultView(SubmitionResult *result);
+Scene *CreatePuzzleCollectionScene(char *path);
+
#endif // SCENES_H