/*
 * Level.h - level header file stuff
 * By: Odis
 */
#ifndef INC_LEVEL
#define INC_LEVEL

/*******************************/
/* structs, defines & typdefs */
/******************************/
typedef struct object_data OBJ;
typedef struct level_data  LEVEL;
typedef struct sprite_info SPRITE_INFO;

struct object_data
{
  OBJ    *next;
  OBJ    *prev;
  int     state;  /* see states */
  char *  name;
  RECT    bounds; /* this objects rectangle */
};

typedef enum
{
  SOLID, KILL, CLIMB, EXIT, CLICK, MOVE, LAUNCH, NONE
} object_states;

typedef enum
{
  PLAY, HELP, PASSWORD
} menu_choices;

struct level_data
{
  OBJ    *first_obj;
  OBJ    *last_obj;
  SPRITE *first_sprite;
  SPRITE *last_sprite;
  SPRITE *first_proto;
  SPRITE *last_proto;
  SPRITE_INFO *first_info;
  SPRITE_INFO *last_info;
  RECT bounds;  /* the level's full square */
  POINT pos;    /* screen position, for scrolling */
  BG *bg;       /* this levels background */
  int num;      /* this level's number */
  int num_sprites; /* number of sprites */
  int num_proto;   /* number of proto sprites */
  int song;        /* what song should we play? */
};

struct sprite_info
{
  SPRITE_INFO *   next;
  SPRITE_INFO *   prev;
  RECT            pos_rect;
  POINT           pos_pt;
  char           *name;
  int             sprites[3]; /* see sprite_info_sprites */
  int             action; /* action for adding */
};

typedef enum
{
  MIN, CURRENT, MAX
} sprite_info_sprites;

typedef enum
{
 POS_ONLY, RANDOM, aNONE
} sprite_info_actions;

/* global functions...err, all functions basically */
LEVEL *load_level( int level );
LEVEL *change_level( LEVEL *level, int num );
OBJ   *is_point_in_obj( int x, int y, LEVEL *level );
void   clean_level( LEVEL *level, bool bmp );
void   populate_level( LEVEL *level );
void   subtract_from_population( char *name, LEVEL *level );

/* level definitions */
#define LEVELS 1

#ifdef LOG
#define LEVEL_LOG
#endif

/* script error handling stuff */
#ifdef LEVEL_LOG
extern int script_last_error;

typedef enum
{
SCRIPT_NONE, BAD_WORD, MISSING_WORD, BAD_VALUE, SCRIPT_WARNING, PARSE_ERROR
} script_error_types;
#endif

#endif