/*
	Wheels Of Steel
	Copyright (c) 2006, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef MIPMAPMANAGER_H
#define MIPMAPMANAGER_H

//##############################################################################
// Forward declarations
//##############################################################################

class Mipmap;
class Window;
class TrackPopulator;

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   MipmapManager
// Purpose:      Loading, storing and releasing mipmap resources was getting too
//               large and unwieldly to stick in the game class anymore, hence
//               the creation of this class to handle the task. All resources
//               are private, accessable only by the track populator.
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class MipmapManager
{
 /*-----------------------------------------------------------------------------
 Public functions and data
 -----------------------------------------------------------------------------*/

 public:
        //----------------------------------------------------------------------
        // Functions
        //----------------------------------------------------------------------

        static void loadAllMipmaps(Window * window);    // does what it says on the tin. loads all the games mipmaps. needs a window.
        static void freeAllMipmaps();                   // does what it says on the tin. frees all the games mipmaps.

        // Accessors for the images. only allows read only access

        static inline Mipmap const * getMipTree1()      { return mipTree1;      }
        static inline Mipmap const * getMipTree2()      { return mipTree2;      }
        static inline Mipmap const * getMipTree3()      { return mipTree3;      }
        static inline Mipmap const * getMipRock1()      { return mipRock1;      }
        static inline Mipmap const * getMipOilSpill()   { return mipOilSpill;   }
        static inline Mipmap const * getMipFinishSign() { return mipFinishSign; }

        static inline Mipmap const ** getMipArrayCar1()     { return (Mipmap const ** ) mipArrayCar1;       }
        static inline Mipmap const ** getMipArrayCar2()     { return (Mipmap const ** ) mipArrayCar2;       }
        static inline Mipmap const ** getMipArrayCar3()     { return (Mipmap const ** ) mipArrayCar3;       }
        static inline Mipmap const ** getMipArrayCar4()     { return (Mipmap const ** ) mipArrayCar4;       }
        static inline Mipmap const ** getMipArraySnowPuff() { return (Mipmap const ** ) mipArraySnowPuff;   }

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 /*-----------------------------------------------------------------------------
 Private functions and data
 -----------------------------------------------------------------------------*/

 private:

        //----------------------------------------------------------------------
        // Variables
        //----------------------------------------------------------------------

        // Various obstacle images

        static Mipmap * mipTree1;
        static Mipmap * mipTree2;
        static Mipmap * mipTree3;
        static Mipmap * mipRock1;
        static Mipmap * mipOilSpill;
        static Mipmap * mipFinishSign;

        // Each of the snow puff animation frames and an array to hold them all..

        static Mipmap * mipSnowPuff1;
        static Mipmap * mipSnowPuff2;
        static Mipmap * mipSnowPuff3;
        static Mipmap * mipSnowPuff4;
        static Mipmap * mipSnowPuff5;
        static Mipmap * mipSnowPuff6;

        static Mipmap * mipArraySnowPuff[6];

        //
        // The various car images. Postfixes mean as follows:
        //
        // 1,2,3,4 etc.. the car color or base car type of image
        //
        // l   - image of car turning slightly left
        // ll  - image of car turning more left
        // lll - image of car turning even more left
        // r   - image of car turning slightly right
        // rr  - image of car turning more right
        // rrr - image of car turning even more right
        //

        static Mipmap * mipCar1;            // first car type
        static Mipmap * mipCar1_l;
        static Mipmap * mipCar1_ll;
        static Mipmap * mipCar1_lll;
        static Mipmap * mipCar1_r;
        static Mipmap * mipCar1_rr;
        static Mipmap * mipCar1_rrr;

        static Mipmap * mipCar2;            // second car type
        static Mipmap * mipCar2_l;
        static Mipmap * mipCar2_ll;
        static Mipmap * mipCar2_lll;
        static Mipmap * mipCar2_r;
        static Mipmap * mipCar2_rr;
        static Mipmap * mipCar2_rrr;

        static Mipmap * mipCar3;            // third car type
        static Mipmap * mipCar3_l;
        static Mipmap * mipCar3_ll;
        static Mipmap * mipCar3_lll;
        static Mipmap * mipCar3_r;
        static Mipmap * mipCar3_rr;
        static Mipmap * mipCar3_rrr;

        static Mipmap * mipCar4;            // fourth car type
        static Mipmap * mipCar4_l;
        static Mipmap * mipCar4_ll;
        static Mipmap * mipCar4_lll;
        static Mipmap * mipCar4_r;
        static Mipmap * mipCar4_rr;
        static Mipmap * mipCar4_rrr;

        //
        // An array of pointers to mipmaps for each car: used by car constructor.
        //
        // Elements are as follows where x is the car number (car images are in left to right order):
        //
        // mipCarx_lll, mipCarx_ll, mipCarx_l,
        // mipCarx,
        // mipCarx_r, mipCarx_rr, mipCarx_rrr,
        //

        static Mipmap * mipArrayCar1[7];
        static Mipmap * mipArrayCar2[7];
        static Mipmap * mipArrayCar3[7];
        static Mipmap * mipArrayCar4[7];


}; // end of: class MipmapManager{}

//##############################################################################
// C++ Includes
//##############################################################################

#include "Mipmap.h"
#include "Window.h"
#include "TrackPopulator.h"


#endif // end of: ifndef MIPMAPMANAGER_H
