/*-----------------------------------------------------------------------------
Copyright (c) 2009, Sonetto Project Developers
All rights reserved.

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

1.  Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
2.  Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
3.  Neither the name of the Sonetto Project nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SONETTO_DATABASE_H
#define SONETTO_DATABASE_H

#include <OgreSingleton.h>
#include "SonettoPrerequisites.h"
#include "SonettoSavemap.h"
#include "SonettoScriptDataHandler.h"
#include "SonettoMusic.h"
#include "SonettoSoundSource.h"
#include "SonettoSoundSet.h"

namespace Sonetto
{
    struct GameSystem
    {
        float textSize;
        float textAnimationSpeed;
        float textFadeInSpeed;
        float textFadeOutSpeed;
        float textHorizontalScale;
        float textVerticalSpacing;
        //Font * defaultFont;
        uint8 defaultColor;
    };

    struct GroundType
    {
        IDVector defaultFootsteps;
    };

    typedef std::vector<GroundType> GroundTypeVector;

    typedef std::map<uint32,IDVector> FootwearSounds;
    typedef std::vector<FootwearSounds> FootwearSoundsVector;

    class SONETTO_API Database : public Ogre::Singleton<Database>
    {
    public:
        Database() : mInitialized(false) {}
        ~Database();

        void initialize();

        /** Overrides standard Singleton retrieval

        @remarks
            Warning: These comments below were copied straight from Ogre3D code.
            Why do we do this? Well, it's because the Singleton
            implementation is in a .h file, which means it gets compiled
            into anybody who includes it. This is needed for the
            Singleton template to work, but we actually only want it
            compiled into the implementation of the class based on the
            Singleton, not all of them. If we don't change this, we get
            link errors when trying to use the Singleton-based class from
            an outside dll.
        @param
            This method just delegates to the template version anyway,
            but the implementation stays in this single compilation unit,
            preventing link errors.
        */
        static Database &getSingleton();

        /** Overrides standard Singleton retrieval

        @remarks
            Warning: These comments below were copied straight from Ogre3D code.
            Why do we do this? Well, it's because the Singleton
            implementation is in a .h file, which means it gets compiled
            into anybody who includes it. This is needed for the
            Singleton template to work, but we actually only want it
            compiled into the implementation of the class based on the
            Singleton, not all of them. If we don't change this, we get
            link errors when trying to use the Singleton-based class from
            an outside dll.
        @param
            This method just delegates to the template version anyway,
            but the implementation stays in this single compilation unit,
            preventing link errors.
        */
        static Database *getSingletonPtr();

        GameSystem system;

        Savemap savemap;

        MusicVector musics;
        SoundDefVector sounds;
        SoundSetVector soundSets;

        GroundTypeVector groundTypes;
        FootwearSoundsVector footwears;

    private:
        bool mInitialized;

        ScriptDataHandler mScriptDataHandler;
    };
} // namespace

#endif
