diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-21 23:22:13 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-21 23:22:13 +0000 |
| commit | 260d51b8399935c067eb79720db63e08d1c3f1f2 (patch) | |
| tree | f4f8f28a942f8b2d9e3d796c5d75786301219d0f | |
| parent | e4acecf8cebacbcbb6b7739aff7f34fd0147ed45 (diff) | |
| download | FindThings-260d51b8399935c067eb79720db63e08d1c3f1f2.tar.gz FindThings-260d51b8399935c067eb79720db63e08d1c3f1f2.tar.bz2 FindThings-260d51b8399935c067eb79720db63e08d1c3f1f2.zip | |
Working on interaction menu thingy
| -rw-r--r-- | src/entities/samantha.c | 2 | ||||
| -rw-r--r-- | src/entity.h | 4 | ||||
| -rw-r--r-- | src/settings.c | 5 | ||||
| -rw-r--r-- | src/settings.h | 7 | ||||
| -rw-r--r-- | src/ui.c | 53 | ||||
| -rw-r--r-- | src/ui.h | 15 |
6 files changed, 75 insertions, 11 deletions
diff --git a/src/entities/samantha.c b/src/entities/samantha.c index d3c345b..fed2db0 100644 --- a/src/entities/samantha.c +++ b/src/entities/samantha.c @@ -60,9 +60,11 @@ InteractionCommand interactWithSamantha(Entity* entity, Game* game, } else { + samantha->dialogCount = 0; return INTERACTION_END; } case SELECTION_LEAVE: + samantha->dialogCount = 0; return INTERACTION_END; default: return INTERACTION_END; diff --git a/src/entity.h b/src/entity.h index a71b5ff..db798b4 100644 --- a/src/entity.h +++ b/src/entity.h @@ -10,7 +10,7 @@ #define ENTITY_NAME_MAX 16 #define INTERACTION_MENU_MAX 9 -#define INTERACTION_LABEL_MAX 6 +#define INTERACTION_LABEL_MAX 32 #define INTERACTION_CHAT_MAX 256 #define ENTITY_DEFAULT_STATE -1 @@ -55,7 +55,7 @@ enum Selection { SELECTION_INTERACT, SELECTION_NEXT_MESSAGE, SELECTION_MENU_ITEM, // +x to select any given menu entry - SELECTION_LEAVE = SELECTION_MENU_ITEM + 16 + SELECTION_LEAVE = SELECTION_MENU_ITEM + INTERACTION_MENU_MAX }; struct Entity { diff --git a/src/settings.c b/src/settings.c index 600431b..0ae1a75 100644 --- a/src/settings.c +++ b/src/settings.c @@ -29,9 +29,10 @@ Settings defaultSettings() .mapZoomSpeed = 0.2, .entityInfoFontSize = 20, .entityInfoAlpha = (unsigned char)255.0 * 0.8, - .interactionChatFontSize = 20, + .interactionFontSize = 20, + .interactionAlpha = (unsigned char)255.0 * 0.9, + .interactionOutlineSize = 2.0, .interactionChatHeight = 300.0, - .interactionChatAlpha = (unsigned char)255.0 * 0.9, .mouseSpeed = 0.1, .forwardKey = KEY_W, .backwardKey = KEY_S, diff --git a/src/settings.h b/src/settings.h index dd079a7..b95c94e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -48,10 +48,11 @@ typedef struct { int entityInfoFontSize; unsigned char entityInfoAlpha; - // Interaction chat. - int interactionChatFontSize; + // Interaction chat and menu. + int interactionFontSize; + unsigned char interactionAlpha; + float interactionOutlineSize; float interactionChatHeight; - unsigned char interactionChatAlpha; // Controls. float mouseSpeed; @@ -63,12 +63,12 @@ void updateInteractionChat(InteractionChat* chat, Game* game) } Color background = DARKGRAY; - background.a = game->settings.interactionChatAlpha; + background.a = game->settings.interactionAlpha; DrawRectangleRec(chat->rect, background); - float lineThickness = 2.0; - float border = 3.0; - int fontSize = game->settings.interactionChatFontSize; + float lineThickness = game->settings.interactionOutlineSize; + float border = lineThickness + 1.0; + int fontSize = game->settings.interactionFontSize; DrawRectangleLinesEx(chat->rect, lineThickness, BLACK); @@ -93,3 +93,48 @@ void updateInteractionChat(InteractionChat* chat, Game* game) fontSize, WHITE); } + +void resizeInteractionMenu(InteractionMenu* menu, const Settings* settings) +{ +} + +void initInteractionMenu(InteractionMenu* menu, const Settings* settings) +{ + resetInteractionMenu(menu); + menu->rect = (Rectangle){100.0, 100.0, 200.0, 200.0}; + menu->visible = false; + menu->entityId = ENTITY_NONE; +} + +void resetInteractionMenu(InteractionMenu* menu) +{ + for (int index = 0; index < INTERACTION_MENU_MAX; ++index) + { + memset(menu->items[index], 0, INTERACTION_LABEL_MAX * sizeof(char)); + } +} + +void showInteractionMenu(InteractionMenu* menu) +{ + menu->visible = true; +} + +void hideInteractionMenu(InteractionMenu* menu) +{ + menu->visible = false; +} + +void updateInteractionMenu(InteractionMenu* menu, Game* game) +{ + if (IsWindowResized()) + { + resizeInteractionMenu(menu, &game->settings); + } + + if (!menu->visible) + { + return; + } + + +} @@ -14,6 +14,14 @@ typedef struct { EntityId entityId; } InteractionChat; +typedef struct { + char items[INTERACTION_MENU_MAX][INTERACTION_LABEL_MAX]; + Rectangle rect; + bool visible; + EntityId entityId; +} InteractionMenu; + +// Interaction chat procedures. void initInteractionChat(InteractionChat* chat, const Settings* settings); void showInteractionChat(InteractionChat* chat); void hideInteractionChat(InteractionChat* chat); @@ -22,4 +30,11 @@ void writeToInteractionChat(InteractionChat* chat, const char* text); void clearInteractionChat(InteractionChat* chat); void updateInteractionChat(InteractionChat* chat, Game* game); +// Interaction menu procedures. +void initInteractionMenu(InteractionMenu* menu, const Settings* settings); +void resetInteractionMenu(InteractionMenu* menu); +void showInteractionMenu(InteractionMenu* menu); +void hideInteractionMenu(InteractionMenu* menu); +void updateInteractionMenu(InteractionMenu* menu, Game* game); + #endif |
