/***************************************************************************
 * img_settings.h  -  header for the corresponding cpp file
 *
 * Copyright (C) 2005 - 2008 Florian Richter
 ***************************************************************************/
/*
   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 3 of the License, or
   (at your option) any later version.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SMC_IMG_SETTINGS_H
#define SMC_IMG_SETTINGS_H

#include "../core/globals.h"
#include "../core/file_parser.h"
#include "../video/gl_surface.h"
#include "../core/math/rect.h"

/* *** *** *** *** *** *** cImage_settings_data *** *** *** *** *** *** *** *** *** *** *** */

class cImage_settings_data
{
public:
	cImage_settings_data( void );
	~cImage_settings_data( void );

	// returns the best surface size for the current resolution
	cSize_Float Get_Surface_Size( SDL_Surface *sdl_surface );
	// Apply settings to an image
	void Apply( cGL_Surface *image );
	// Apply base settings
	void Apply_Base( cImage_settings_data *base_settings_data );

	// base image/settings path
	string m_base;
	// inherit base settings
	bool m_base_settings;

	// internal drawing offset
	int m_int_x, m_int_y;
	// collision rect
	GL_rect m_col_rect;
	// width
	int m_width;
	// height
	int m_height;
	// rotation
	int m_rotation_x, m_rotation_y, m_rotation_z;
	// texture mipmapping
	bool m_mipmap;

	// editor tags
	string m_editor_tags;
	// name
	string m_name;
	// sprite type
	int m_type;
	// ground type
	GroundType m_ground_type;
	// author
	string m_author;
	// obsolete
	bool m_obsolete;
};

/* *** *** *** *** *** *** cImage_settings *** *** *** *** *** *** *** *** *** *** *** */

// Image Settings Handler
// Inherits from cFile_parser
class cImage_settings : public cFile_parser
{
public:
	cImage_settings( void );
	virtual ~cImage_settings( void );

	/* Returns the settings from the given file
	 * load_base_settings : if set will overwrite settings with all base settings if available
	 * The returned settings data should be deleted if not used anymore
	*/
	cImage_settings_data *Get( string &filename, bool load_base_settings = 1 );

	// Handles the Image Settings Line
	virtual bool HandleMessage( string *parts, unsigned int count, unsigned int line );

	// the surface pointer used
	cImage_settings_data *settings;
	// load base settings
	bool load_base;
};

/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */

// Image Settings Handler class
extern cImage_settings *pSettingsParser;

/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */

#endif
