aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-22 01:17:44 +0000
committernathan <nathansmith@disroot.org>2025-12-22 01:17:44 +0000
commit2254600c6dfb50333327ddb94457427596b51807 (patch)
treec2a36d9c4433adbc5db763aa0e7d5863ce592740
parent260d51b8399935c067eb79720db63e08d1c3f1f2 (diff)
downloadFindThings-2254600c6dfb50333327ddb94457427596b51807.tar.gz
FindThings-2254600c6dfb50333327ddb94457427596b51807.tar.bz2
FindThings-2254600c6dfb50333327ddb94457427596b51807.zip
Interaction menu stuff and fps adhd
-rw-r--r--src/entities/samantha.c2
-rw-r--r--src/game.c26
-rw-r--r--src/game.h5
-rw-r--r--src/player.c2
-rw-r--r--src/settings.c2
-rw-r--r--src/settings.h2
-rw-r--r--src/ui.c26
7 files changed, 49 insertions, 16 deletions
diff --git a/src/entities/samantha.c b/src/entities/samantha.c
index fed2db0..66b8996 100644
--- a/src/entities/samantha.c
+++ b/src/entities/samantha.c
@@ -43,7 +43,7 @@ void closeSamantha(Entity* entity)
InteractionCommand interactWithSamantha(Entity* entity, Game* game,
Selection selection)
{
- InteractionChat* chat = &game->chat;
+ InteractionChat* chat = &game->interactionChat;
Samantha* samantha = (Samantha*)entity->data;
switch (selection)
diff --git a/src/game.c b/src/game.c
index b2f2d32..7dbe9e8 100644
--- a/src/game.c
+++ b/src/game.c
@@ -52,6 +52,7 @@ void initGame(Game* game)
// Settings.
game->settings = defaultSettings();
game->isCrossHairEnabled = game->settings.isCrossHairEnabledDefault;
+ game->showFPS = game->settings.showFPSDefault;
// Window.
InitWindow(game->settings.windowWidth, game->settings.windowHeight,
@@ -85,8 +86,9 @@ void initGame(Game* game)
// Map.
initMap(&game->map, &game->world, &game->settings);
- // Interaction chat.
- initInteractionChat(&game->chat, &game->settings);
+ // Interaction chat and menu.
+ initInteractionChat(&game->interactionChat, &game->settings);
+ initInteractionMenu(&game->interactionMenu, &game->settings);
disableGameCursor(game);
}
@@ -220,10 +222,6 @@ void updateGameScene(Game* game)
drawGameScreen(game);
- updateMap(&game->map, game);
- updateGameEntityInfo(game);
- updateInteractionChat(&game->chat, game);
-
// Cross hair.
if (IsKeyPressed(game->settings.toggleCrossHairKey))
{
@@ -236,6 +234,11 @@ void updateGameScene(Game* game)
game->settings.crossHairThickness,
game->settings.crossHairColor);
}
+
+ updateMap(&game->map, game);
+ updateGameEntityInfo(game);
+ updateInteractionChat(&game->interactionChat, game);
+ updateInteractionMenu(&game->interactionMenu, game);
}
void handleGameResize(Game* game)
@@ -264,7 +267,16 @@ void updateGame(Game* game)
break;
}
- DrawFPS(0, 0);
+ // FPS stuff.
+ if (IsKeyPressed(game->settings.toggleFPSKey))
+ {
+ game->showFPS = !game->showFPS;
+ }
+
+ if (game->showFPS)
+ {
+ DrawFPS(0, 0);
+ }
EndDrawing();
}
diff --git a/src/game.h b/src/game.h
index e7d761e..971dde3 100644
--- a/src/game.h
+++ b/src/game.h
@@ -25,11 +25,14 @@ struct Game {
World world;
Model skybox;
Map map;
- InteractionChat chat;
+
+ InteractionChat interactionChat;
+ InteractionMenu interactionMenu;
SceneId sceneId;
bool isCursorEnabled;
bool isCrossHairEnabled;
+ bool showFPS;
struct {
RenderTexture render;
diff --git a/src/player.c b/src/player.c
index 057eee7..40c60c3 100644
--- a/src/player.c
+++ b/src/player.c
@@ -105,7 +105,7 @@ bool playerCanEntityBeSelected(Player* player, Entity entity)
void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
Selection selection)
{
- InteractionChat* chat = &game->chat;
+ InteractionChat* chat = &game->interactionChat;
Entity* entity = &game->world.entities[uid];
diff --git a/src/settings.c b/src/settings.c
index 0ae1a75..81a5aba 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -8,6 +8,7 @@ Settings defaultSettings()
.screenWidth = 596,
.screenHeight = 447,
.fov = 90.0,
+ .showFPSDefault = true,
.edgeDetectionWidth = 80.0,
.edgeDetectionHeight = 60.0,
.edgeDetectionFactor = 0.11,
@@ -40,6 +41,7 @@ Settings defaultSettings()
.leftKey = KEY_A,
.toggleCursorKey = KEY_LEFT_ALT,
.toggleCrossHairKey = KEY_C,
+ .toggleFPSKey = KEY_F,
.toggleMapPreviewKey = KEY_P,
.defaultMapZoomKey = KEY_Z,
.interactKey = KEY_E,
diff --git a/src/settings.h b/src/settings.h
index b95c94e..53972d3 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -14,6 +14,7 @@ typedef struct {
// Render.
float fov;
+ bool showFPSDefault;
// Edge detection.
float edgeDetectionWidth;
@@ -62,6 +63,7 @@ typedef struct {
KeyboardKey leftKey;
KeyboardKey toggleCursorKey;
KeyboardKey toggleCrossHairKey;
+ KeyboardKey toggleFPSKey;
KeyboardKey toggleMapPreviewKey;
KeyboardKey defaultMapZoomKey;
KeyboardKey interactKey;
diff --git a/src/ui.c b/src/ui.c
index e985dad..707bb06 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -96,12 +96,18 @@ void updateInteractionChat(InteractionChat* chat, Game* game)
void resizeInteractionMenu(InteractionMenu* menu, const Settings* settings)
{
+ menu->rect = (Rectangle){
+ 0.0,
+ 0.0,
+ GetRenderWidth() - settings->mapPreviewWidth,
+ GetRenderHeight() - settings->interactionChatHeight
+ };
}
void initInteractionMenu(InteractionMenu* menu, const Settings* settings)
{
resetInteractionMenu(menu);
- menu->rect = (Rectangle){100.0, 100.0, 200.0, 200.0};
+ resizeInteractionMenu(menu, settings);
menu->visible = false;
menu->entityId = ENTITY_NONE;
}
@@ -131,10 +137,18 @@ void updateInteractionMenu(InteractionMenu* menu, Game* game)
resizeInteractionMenu(menu, &game->settings);
}
- if (!menu->visible)
- {
- return;
- }
+ /* if (!menu->visible) */
+ /* { */
+ /* return; */
+ /* } */
-
+ Color background = DARKGRAY;
+ background.a = game->settings.interactionAlpha;
+ DrawRectangleRec(menu->rect, background);
+
+ float lineThickness = game->settings.interactionOutlineSize;
+ float border = lineThickness + 1.0;
+ int fontSize = game->settings.interactionFontSize;
+
+ DrawRectangleLinesEx(menu->rect, lineThickness, BLACK);
}