/*
 * Stonage: a puzzle game
 * Copyright (C) 2001 Luc Saillard <luc@saillard.org>
 *
 * Header file to manage square (properties, draw, ...)
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 */


#ifndef __SQUARE_H
#define __SQUARE_H


enum
{
  CAN_MOVE_TO_NORTH = (1<<0),
  CAN_MOVE_TO_SOUTH = (1<<1),
  CAN_MOVE_TO_EAST  = (1<<2),
  CAN_MOVE_TO_WEST  = (1<<3),
  AFTER_MOVE_CRASH  = (1<<4),
  START             = (1<<5),
  FINISH            = (1<<6),
  CAN_GO_ABOVE      = (1<<7),
  KEY_RED	    = (1<<8),
  KEY_BLUE	    = (1<<9),
  KEY_GREEN	    = (1<<10),
  NEED_KEY_RED      = (1<<11),
  NEED_KEY_BLUE     = (1<<12),
  NEED_KEY_GREEN    = (1<<13),
  HOURGLASS         = (1<<14),
  TELEPORT          = (1<<15),
};

#define CAN_MOVE_TO_MASK (CAN_MOVE_TO_NORTH|CAN_MOVE_TO_SOUTH|CAN_MOVE_TO_EAST|CAN_MOVE_TO_WEST)


struct square_desc
{
  unsigned char properties[4] __attribute__ ((packed)); /* properties of the square  (u32) */
  unsigned char nimages[2]    __attribute__ ((packed)); /* number of images for animation (u16) */
  unsigned char delay[2]      __attribute__ ((packed)); /* delay between 2 images in ms */
  unsigned char filenamesz[2] __attribute__ ((packed)); /* Size of the block of filename */
};

extern struct enum_list square_properties_text2enum[];

#ifndef _NO_GFX_

#include <SDL.h>

struct t_square
{
  unsigned int properties;
  int nimages;
  int delay;
  SDL_Surface **images;
};


SDL_Surface *Square_Load(const char *theme, const char *filename);
void Square_Free(struct t_square *s);
int Square_FindProperties(const struct t_square *s, int nsquares, uint32 properties);
#endif

#endif

