diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-22 01:17:44 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-22 01:17:44 +0000 |
| commit | 2254600c6dfb50333327ddb94457427596b51807 (patch) | |
| tree | c2a36d9c4433adbc5db763aa0e7d5863ce592740 | |
| parent | 260d51b8399935c067eb79720db63e08d1c3f1f2 (diff) | |
| download | FindThings-2254600c6dfb50333327ddb94457427596b51807.tar.gz FindThings-2254600c6dfb50333327ddb94457427596b51807.tar.bz2 FindThings-2254600c6dfb50333327ddb94457427596b51807.zip | |
Interaction menu stuff and fps adhd
| -rw-r--r-- | src/entities/samantha.c | 2 | ||||
| -rw-r--r-- | src/game.c | 26 | ||||
| -rw-r--r-- | src/game.h | 5 | ||||
| -rw-r--r-- | src/player.c | 2 | ||||
| -rw-r--r-- | src/settings.c | 2 | ||||
| -rw-r--r-- | src/settings.h | 2 | ||||
| -rw-r--r-- | src/ui.c | 26 |
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) @@ -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(); } @@ -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; @@ -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); } |
