aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.h
blob: 14845d43a6eee9008bc55662bd6c1d4732bdd176 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "utils.h"
#include "entity.h"
#include "assets.h"
#include "world.h"

#ifndef UI_H
#define UI_H

#define INTERACTION_COLUMN_MAX 80
#define INVENTORY_MAX 10
#define INVENTORY_SPRITE_SIZE 32
#define INVENTORY_ROWS 8
#define INVENTORY_COLUMNS 8
#define INVENTORY_SCALE 2.0

typedef char InteractionItems[INTERACTION_MENU_MAX][INTERACTION_LABEL_MAX];

typedef struct {
  char text[INTERACTION_CHAT_MAX];
  char displayedText[INTERACTION_CHAT_MAX];
  size_t textSize;
  int displayUpTo; // Used for cool animation.
  double lastCharacterUpdate;
  Rectangle rect;
  bool visible;
  EntityId entityId;
} InteractionChat;

typedef struct {
  InteractionItems items;
  int itemCount;
  Rectangle rect;
  bool visible;
  EntityId entityId;
} InteractionMenu;

typedef struct {
  EntityId id;
  AssetId textureId;
  int count;
} InventoryItem;

typedef struct {
  Rectangle rect;
  bool visable;
  InventoryItem items[INVENTORY_MAX];
  int itemCount;
} Inventory;

// Interaction chat procedures.
void initInteractionChat(InteractionChat* chat, const Settings* settings);
void showInteractionChat(InteractionChat* chat);
void hideInteractionChat(InteractionChat* chat);
void setInteractionChat(InteractionChat* chat, const char* text);
void writeToInteractionChat(InteractionChat* chat, const char* text);
void clearInteractionChat(InteractionChat* chat);
bool isInteractionChatAnimationDone(InteractionChat* chat);
void endInteractionChatAnimation(InteractionChat* chat);
void updateInteractionChat(InteractionChat* chat, Game* game);

// Interaction menu procedures.
void initInteractionMenu(InteractionMenu* menu, const Settings* settings);
void setInteractionMenu(InteractionMenu* menu,
                        const InteractionItems items,
                        int itemCount);
void resetInteractionMenu(InteractionMenu* menu);
void showInteractionMenu(InteractionMenu* menu);
void hideInteractionMenu(InteractionMenu* menu);
void updateInteractionMenu(InteractionMenu* menu, Game* game);

// Inventory
void initInventory(Inventory* inventory, const Settings* settings);
void showInventory(Inventory* inventory);
void hideInventory(Inventory* inventory);
void addItemToInventory(Inventory* inventory, InventoryItem item);
void updateInventory(Inventory* inventory, Game* game);

#endif