#define INVENTORY_SIZE 12 #define MAX_OBJECTS_PER_SCENE (30+INVENTORY_SIZE) #define MAX_SCRIPTS_PER_SCENE 30 #define MAX_STACKED_SCENES 5 #include struct object { int id; // 0 if slot unused int x; int y; int width; int height; const char *pixels; const struct level_clickregion *clickregion; // if not null, overrides click bounds check }; typedef void (*script_wake_fn)(struct script *scr, int wakeupMode, int arg1, int arg2, int arg3, int arg4); #define SCRIPT_HEADER \ int id /* 0 if slot unused */; \ int wakeupMode; \ script_wake_fn wakeupFn; \ int wakeupArg1; /* for SCRIPT_WAKEUP_OTHER_SCRIPT */ struct script { SCRIPT_HEADER int vars[100]; }; typedef void (*scene_render_fn)(struct scene *s); typedef void (*scene_animtimer_fn)(struct scene *s); typedef void (*scene_handle_tap_fn)(struct scene *s, int x, int y); void standard_scene_render(struct scene *s); void standard_handle_tap(struct scene *s, int x, int y); extern struct scene { int id; struct object objects[MAX_OBJECTS_PER_SCENE]; struct script scripts[MAX_SCRIPTS_PER_SCENE]; scene_render_fn render_fn; // default standard_scene_render scene_animtimer_fn animtimer_fn; // default null scene_handle_tap_fn handle_tap_fn; // default standard_handle_tap struct navmesh *navmesh; // defaults to non-null pointer to empty navmesh bool use_standard_inventory; // defaults to true bool dim_background; // defaults to false, because most scenes overwrite the whole screen } scenes[MAX_STACKED_SCENES]; extern int scene_depth; // number of stacked scenes #define top_scene scenes[scene_depth-1] struct script_player_walk { SCRIPT_HEADER int targetX; int targetY; int targetNavmeshTri; int currentNavmeshTri; }; #define SCRIPT_WAKEUP_VIDEO_FRAME 1 #define SCRIPT_WAKEUP_OTHER_SCRIPT 2 #define SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED 3 // Delivered to script that registers for SCRIPT_WAKEUP_OTHER_SCRIPT if that script is interrupted instead of completing. typedef void (*scene_setup_fn)(scene *s, int scene, int fromscene); // engine // Scene changes - even push - may discard remaining events for the scene. void push_scene(int scene); void push_scene(int scene, scene_setup_fn setup_fn); void replace_scene(int scene); void pop_scene(); void scene_add_clickrect(int id, int x, int y, int width, int height); struct object *scene_add_object(scene *s, int id, int x, int y, int width, int height, const char *pixels); void scene_load_predef(struct scene *sc, const struct level_predef_data *predef); struct object *find_object_by_id(int id); struct script *scene_add_script(int id, bool interrupt_existing); struct script *scene_get_script(int id); bool deliver_script_wakeup(int wakeupMode, int wakeupArg1, int wakeupType, int arg1, int arg2, int arg3, int arg4); // deliver to scripts with given wakeupMode and wakeupArg1. Returns true if scene changed. void start_player_walk_to_point(int x, int y); // x and y are not corrected to lie within navmesh void push_scene_textbox(const char *text); // standard inventory void create_standard_inventory(scene *s); void standard_inventory_onclick(struct object *obj); struct sprite { int width, height; uint32_t *pixels; const unsigned char *original_data_source; }; struct sprite *get_decompressed_sprite(const unsigned char *spritedata); // used during rendering // pixel is 0xRRGGBB extern uint32_t *curfb; extern bool need_rerender; void fillrect(int x1, int y1, int width, int height, uint32_t pixel); void blit(int x, int y, int width, int height, uint32_t *pixels); // game-specific constants #define SCENE_LOBBY 1 #define SCENE_MANAGERS_OFFICE 2 #define SCENE_MANAGERS_OFFICE_SAFE 3 #define SCENE_BASEMENT 4 #define SCENE_TEXTBOX 5 // game.cpp void scene_setup(scene *s, int scene, int fromscene); void onclick(int curscene, struct object *obj); extern struct savefile { bool got_pager_from_basement; } savefile;