aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-11-06 11:30:38 +0000
committernathan <nathansmith@disroot.org>2025-11-06 11:30:38 +0000
commit1fe9fa841c9f485b4404716cf4fb834f6a98fcc9 (patch)
tree1a505a7549af5e17c3b077b5a8bbe2e98fc33889
parent6fea2be59237f6d43c45dbda95f62346779b21e6 (diff)
downloadFindThings-1fe9fa841c9f485b4404716cf4fb834f6a98fcc9.tar.gz
FindThings-1fe9fa841c9f485b4404716cf4fb834f6a98fcc9.tar.bz2
FindThings-1fe9fa841c9f485b4404716cf4fb834f6a98fcc9.zip
Working on window manager
-rw-r--r--src/game.c4
-rw-r--r--src/game.h2
-rw-r--r--src/messageArea.c14
-rw-r--r--src/ui.c35
-rw-r--r--src/ui.h16
5 files changed, 40 insertions, 31 deletions
diff --git a/src/game.c b/src/game.c
index 878d45b..71583f9 100644
--- a/src/game.c
+++ b/src/game.c
@@ -82,9 +82,6 @@ void initGame(Game* game)
game->player.position = Vector3Scale(game->world.size, 0.5);
disableGameCursor(game);
-
- // Message area.
- initMessageArea(&game->messageArea);
}
void updateMainMenuScene(Game* game)
@@ -127,7 +124,6 @@ void drawGameScreen(Game* game)
void updateGameUI(Game* game)
{
- updateMessageArea(&game->messageArea, game);
}
void updateGameScene(Game* game)
diff --git a/src/game.h b/src/game.h
index 5a0f4e8..3edb37a 100644
--- a/src/game.h
+++ b/src/game.h
@@ -4,7 +4,6 @@
#include "player.h"
#include "world.h"
#include "entity.h"
-#include "messageArea.h"
#ifndef GAME_H
#define GAME_H
@@ -23,7 +22,6 @@ struct Game {
Player player;
World world;
Model skybox;
- MessageArea messageArea;
SceneId sceneId;
bool isCursorEnabled;
diff --git a/src/messageArea.c b/src/messageArea.c
deleted file mode 100644
index 21fea03..0000000
--- a/src/messageArea.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "messageArea.h"
-
-void initMessageArea(MessageArea* messageArea)
-{
- memset(messageArea->text, 0, sizeof(char) * MESSAGE_AREA_MAX);
- memcpy(messageArea->text, "meowmeowmeowmeowmeowmeowmeowmeowmweowiwiweioo", sizeof("meowmeowmeowmeowmeowmeowmeowmeowmweowiwiweioo"));
-
- messageArea->window = createFloatingWindow();
-}
-
-void updateMessageArea(MessageArea* messageArea, Game* game)
-{
- updateFloatingWindow(&messageArea->window, "meow");
-}
diff --git a/src/ui.c b/src/ui.c
index d83ec52..296f658 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1,8 +1,8 @@
#include "ui.h"
-FloatingWindow createFloatingWindow()
+FloatingWindow createFloatingWindow(const char* title)
{
- return (FloatingWindow){
+ FloatingWindow window = (FloatingWindow){
.rect = (Rectangle){0.0, 0.0, 100.0, 100.0},
.minimized = false,
.moving = false,
@@ -11,6 +11,10 @@ FloatingWindow createFloatingWindow()
.contentSize = Vector2Zero(),
.scroll = Vector2Zero()
};
+
+ memcpy(window.title, title, UI_WINDOW_TITLE_MAX * sizeof(char));
+
+ return window;
}
void floatingWindowTransformCollisionCheck(FloatingWindow* window)
@@ -115,7 +119,7 @@ void updateFloatingWindowResizing(FloatingWindow* window)
}
}
-void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
+void updateFloatingWindowMinimized(FloatingWindow* window)
{
int closeTitleSizeDeltaHalf = (RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT -
RAYGUI_WINDOW_CLOSEBUTTON_SIZE) / 2;
@@ -123,7 +127,7 @@ void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
GuiStatusBar(
(Rectangle){window->rect.x, window->rect.y,
window->rect.width, RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT},
- title);
+ window->title);
if (GuiButton(
(Rectangle){window->rect.x + window->rect.width
@@ -138,11 +142,11 @@ void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
}
}
-void updateFloatingWindowNotMinimized(FloatingWindow* window, const char* title)
+void updateFloatingWindowNotMinimized(FloatingWindow* window)
{
window->minimized = GuiWindowBox(
(Rectangle){window->rect.x, window->rect.y, window->rect.width,
- window->rect.height}, title);
+ window->rect.height}, window->title);
// Scissor and draw content within a scroll panel.
if (window->callback != NULL)
@@ -183,7 +187,7 @@ void updateFloatingWindowNotMinimized(FloatingWindow* window, const char* title)
window->rect.y + window->rect.height - 20, 1, GREEN);
}
-void updateFloatingWindow(FloatingWindow* window, const char* title)
+void updateFloatingWindow(FloatingWindow* window)
{
// Window movement and resize input and collision check.
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !window->moving
@@ -205,10 +209,23 @@ void updateFloatingWindow(FloatingWindow* window, const char* title)
// window and content drawing with scissor and scroll area
if(window->minimized)
{
- updateFloatingWindowMinimized(window, title);
+ updateFloatingWindowMinimized(window);
}
else
{
- updateFloatingWindowNotMinimized(window, title);
+ updateFloatingWindowNotMinimized(window);
+ }
+}
+
+void initWindowManager(WindowManager* windowManager)
+{
+ memset(windowManager, 0, sizeof(WindowManager));
+}
+
+void updateWindowManager(WindowManager* windowManager)
+{
+ for (int index = 0; index < windowManager->windowCount; ++index)
+ {
+ updateFloatingWindow(&windowManager->windows[index]);
}
}
diff --git a/src/ui.h b/src/ui.h
index 5868b50..fcf17a0 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -11,9 +11,13 @@
#define RAYGUI_WINDOW_CLOSEBUTTON_SIZE 18
#endif
+#define UI_WINDOW_TITLE_MAX 32
+#define UI_WINDOW_MAX 4
+
typedef void (*DrawWindowContentCallback)(Vector2 position, Vector2 scroll);
typedef struct {
+ char title[UI_WINDOW_TITLE_MAX];
Rectangle rect;
bool minimized;
bool moving;
@@ -23,7 +27,15 @@ typedef struct {
Vector2 scroll;
} FloatingWindow;
-FloatingWindow createFloatingWindow();
-void updateFloatingWindow(FloatingWindow* window, const char* title);
+typedef struct {
+ FloatingWindow windows[UI_WINDOW_MAX];
+ int windowCount;
+} WindowManager;
+
+FloatingWindow createFloatingWindow(const char* title);
+void updateFloatingWindow(FloatingWindow* window);
+
+void initWindowManager(WindowManager* windowManager);
+void updateWindowManager(WindowManager* windowManager);
#endif