aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-22 03:02:10 +0000
committernathan <nathansmith@disroot.org>2025-12-22 03:02:10 +0000
commitdb04bfb989a5ebbd1f57e9983a2bb819c3ce4d67 (patch)
tree370c02d05800b9f856aa3a867da90e7ebd0f3a2b
parentdabcd8342e77d4bfac4f7bc5cee8643121d379f7 (diff)
downloadFindThings-db04bfb989a5ebbd1f57e9983a2bb819c3ce4d67.tar.gz
FindThings-db04bfb989a5ebbd1f57e9983a2bb819c3ce4d67.tar.bz2
FindThings-db04bfb989a5ebbd1f57e9983a2bb819c3ce4d67.zip
hehehehe over designed interaction menu
-rw-r--r--src/entities/ron.c4
-rw-r--r--src/entity.h2
-rw-r--r--src/player.c32
-rw-r--r--src/ui.c11
4 files changed, 36 insertions, 13 deletions
diff --git a/src/entities/ron.c b/src/entities/ron.c
index 834c119..5c60b9f 100644
--- a/src/entities/ron.c
+++ b/src/entities/ron.c
@@ -38,7 +38,9 @@ InteractionCommand interactWithRon(Entity* entity, Game* game,
case SELECTION_INTERACT:
setInteractionMenu(menu, items, 9);
return INTERACTION_SHOW_MENU;
- default:
+ case SELECTION_LEAVE:
return INTERACTION_END;
+ default:
+ return INTERACTION_DO_NOTHING;
}
}
diff --git a/src/entity.h b/src/entity.h
index db798b4..bdb0967 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -49,6 +49,8 @@ enum InteractionCommand {
INTERACTION_END,
INTERACTION_TALK,
INTERACTION_SHOW_MENU,
+ INTERACTION_TALK_AND_SHOW_MENU,
+ INTERACTION_DO_NOTHING
};
enum Selection {
diff --git a/src/player.c b/src/player.c
index 40c60c3..27a4780 100644
--- a/src/player.c
+++ b/src/player.c
@@ -102,10 +102,22 @@ bool playerCanEntityBeSelected(Player* player, Entity entity)
<= PLAYER_MAX_SELECT_DISTANCE;
}
+void playerEndInteraction(Player* player, Game* game)
+{
+ player->selectedEntity = ENTITY_NONE;
+ player->isInteracting = false;
+
+ hideInteractionChat(&game->interactionChat);
+ hideInteractionMenu(&game->interactionMenu);
+ game->interactionChat.entityId = ENTITY_NONE;
+ game->interactionMenu.entityId = ENTITY_NONE;
+}
+
void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
Selection selection)
{
InteractionChat* chat = &game->interactionChat;
+ InteractionMenu* menu = &game->interactionMenu;
Entity* entity = &game->world.entities[uid];
@@ -114,14 +126,14 @@ void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
{
case SELECTION_INTERACT:
clearInteractionChat(chat);
+ resetInteractionMenu(menu);
chat->entityId = entity->id;
+ menu->entityId = entity->id;
player->selectedEntity = uid;
player->isInteracting = true;
break;
case SELECTION_LEAVE:
- player->selectedEntity = ENTITY_NONE;
- player->isInteracting = false;
- chat->entityId = ENTITY_NONE;
+ playerEndInteraction(player, game);
break;
default:
break;
@@ -131,13 +143,19 @@ void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
switch (interactWithEntity(entity, game, selection))
{
case INTERACTION_TALK:
+ hideInteractionMenu(menu);
showInteractionChat(chat);
break;
- case INTERACTION_END:
+ case INTERACTION_SHOW_MENU:
hideInteractionChat(chat);
- player->selectedEntity = ENTITY_NONE;
- player->isInteracting = false;
- chat->entityId = ENTITY_NONE;
+ showInteractionMenu(menu);
+ break;
+ case INTERACTION_TALK_AND_SHOW_MENU:
+ showInteractionChat(chat);
+ showInteractionMenu(menu);
+ break;
+ case INTERACTION_END:
+ playerEndInteraction(player, game);
break;
default:
break;
diff --git a/src/ui.c b/src/ui.c
index 84a8f75..41f4591 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -158,10 +158,10 @@ void updateInteractionMenu(InteractionMenu* menu, Game* game)
resizeInteractionMenu(menu, &game->settings);
}
- /* if (!menu->visible) */
- /* { */
- /* return; */
- /* } */
+ if (!menu->visible)
+ {
+ return;
+ }
// Draw background.
Color background = DARKGRAY;
@@ -187,7 +187,8 @@ void updateInteractionMenu(InteractionMenu* menu, Game* game)
// Draw items.
for (int index = 0; index < menu->itemCount; ++index)
{
- DrawText(TextFormat("%d: ", index + 1), position.x, position.y, fontSize, WHITE);
+ DrawText(TextFormat("%d: ", index + 1), position.x, position.y, fontSize,
+ WHITE);
DrawText(TextFormat(" %s", menu->items[index]), position.x, position.y,
fontSize, GREEN);
position.y += fontSize;