phantasia

Phantasia - 2D SDL3 RPG prototype.
git clone git://git.beep.wimdupont.com/phantasia.git
Log | Files | Refs | README | LICENSE

presentation.h (2861B)


      1 #ifndef PH_GAME_PRESENTATION_H
      2 #define PH_GAME_PRESENTATION_H
      3 
      4 #include "engine/battle.h"
      5 #include "engine/render.h"
      6 #include "game/content.h"
      7 
      8 #if PH_USE_SDL
      9 #include <SDL3/SDL.h>
     10 
     11 typedef enum {
     12 	PH_MENU_NONE,
     13 	PH_MENU_CHARACTER,
     14 	PH_MENU_INVENTORY,
     15 	PH_MENU_SPELLBOOK,
     16 	PH_MENU_SHOP,
     17 	PH_MENU_MAIN,
     18 	PH_MENU_START,
     19 } PhMenu;
     20 
     21 typedef enum {
     22 	PH_START_STAY,
     23 	PH_START_CONTINUE,
     24 	PH_START_NEW,
     25 } PhStartAction;
     26 
     27 typedef struct {
     28 	int selected;
     29 	int can_continue;
     30 } PhStartUi;
     31 
     32 typedef enum {
     33 	PH_GAME_WORLD,
     34 	PH_GAME_TRANSITION,
     35 	PH_GAME_BATTLE,
     36 	PH_GAME_VICTORY,
     37 	PH_GAME_OVER,
     38 } PhGameMode;
     39 
     40 typedef enum {
     41 	PH_INVENTORY_BROWSE,
     42 	PH_INVENTORY_ACTIONS,
     43 	PH_INVENTORY_EXAMINE,
     44 } PhInventoryMode;
     45 
     46 typedef enum {
     47 	PH_INVENTORY_EQUIP,
     48 	PH_INVENTORY_USE,
     49 	PH_INVENTORY_DROP,
     50 	PH_INVENTORY_EXAMINE_ACTION,
     51 	PH_INVENTORY_ACTION_COUNT,
     52 } PhInventoryAction;
     53 
     54 typedef struct {
     55 	int selected;
     56 	int option;
     57 	PhInventoryMode mode;
     58 	char status[64];
     59 } PhInventoryUi;
     60 
     61 typedef enum {
     62 	PH_SPELLBOOK_BROWSE,
     63 	PH_SPELLBOOK_ACTIONS,
     64 	PH_SPELLBOOK_EXAMINE,
     65 } PhSpellbookMode;
     66 
     67 typedef enum {
     68 	PH_SPELLBOOK_USE,
     69 	PH_SPELLBOOK_EXAMINE_ACTION,
     70 	PH_SPELLBOOK_ACTION_COUNT,
     71 } PhSpellbookAction;
     72 
     73 typedef struct {
     74 	int selected;
     75 	int option;
     76 	PhSpellbookMode mode;
     77 	int spell_used;
     78 	char status[64];
     79 } PhSpellbookUi;
     80 
     81 typedef enum {
     82 	PH_SHOP_ROOT,
     83 	PH_SHOP_BUY,
     84 	PH_SHOP_SELL,
     85 	PH_SHOP_TALK,
     86 } PhShopMode;
     87 
     88 typedef struct {
     89 	int shop_id;
     90 	int selected;
     91 	PhShopMode mode;
     92 	char status[64];
     93 } PhShopUi;
     94 
     95 typedef enum {
     96 	PH_OPTIONS_ROOT,
     97 	PH_OPTIONS_SOUND,
     98 } PhOptionsMode;
     99 
    100 typedef enum {
    101 	PH_OPTIONS_STAY,
    102 	PH_OPTIONS_CLOSE,
    103 	PH_OPTIONS_EXIT,
    104 } PhOptionsAction;
    105 
    106 typedef struct {
    107 	int selected;
    108 	int music_enabled;
    109 	int effects_enabled;
    110 	PhOptionsMode mode;
    111 } PhOptionsUi;
    112 
    113 typedef struct {
    114 	PhWorld *world;
    115 	PhInventoryUi *inventory;
    116 	PhSpellbookUi *spellbook;
    117 	PhShopUi *shop;
    118 	PhOptionsUi *options;
    119 	PhStartUi *start;
    120 	PhGameMode *mode;
    121 	PhBattle *battle;
    122 	PhSpellBook *spells;
    123 	PhMenu menu;
    124 } PhGameContext;
    125 
    126 int ph_inventory_step(const PhWorld *world, int selected, int direction);
    127 void ph_inventory_open(PhInventoryUi *ui, const PhWorld *world);
    128 int ph_inventory_key(PhInventoryUi *ui, PhWorld *world, SDL_Scancode key);
    129 void ph_spellbook_open(PhSpellbookUi *ui, const PhSpellBook *spells);
    130 int ph_spellbook_key(PhSpellbookUi *ui, PhWorld *world, PhSpellBook *spells,
    131 	SDL_Scancode key);
    132 void ph_shop_open(PhShopUi *ui, int shop_id);
    133 PhMenu ph_interaction_open(PhShopUi *shop_ui, int interaction_id);
    134 void ph_options_open(PhOptionsUi *ui);
    135 PhOptionsAction ph_options_key(PhOptionsUi *ui, SDL_Scancode key);
    136 PhStartAction ph_start_key(PhStartUi *ui, SDL_Scancode key);
    137 int ph_shop_key(PhShopUi *ui, PhWorld *world, PhSpellBook *spells,
    138 	SDL_Scancode key);
    139 void ph_present_frame(SDL_Renderer *renderer, const PhRenderAssets *assets,
    140 	const PhGameContext *context);
    141 
    142 #endif
    143 
    144 #endif