#ifndef _HPP_KUNGFLOW_MAIN
#define _HPP_KUNGFLOW_MAIN

#include "gaia/gaia.hpp"
using namespace gaia;

#include "defines.hpp"

#include <fmod.h>

class PlayState;

bool _optimize();
bool _verbose();

enum e_FontIDs {
  e_FontID_Debug = 1
};

class KungFlowGame : public Game {

  public:

    KungFlowGame(int desiredGraphicsTimeStep_ms = 10, int desiredPhysicsTimeStep_ms = 10);
    virtual ~KungFlowGame();

    virtual void OnKeyDown(SDL_Keysym keysym) override;
    virtual void OnKeyUp(SDL_Keysym keysym) override;
    virtual void OnJoyControllerAxisEvent(int joyControllerID, SDL_GameControllerAxis axisID, float value) override;
    virtual void OnJoyControllerButtonEvent(int joyControllerID, int buttonID, bool pressedOrReleased) override;

    virtual void OnStepPhysicsTime() override {
      Game::OnStepPhysicsTime();
      FMOD_System_Update(GetAudioSystem());
    }

    const KeyInput &GetKeyInput() const { return keyInput; }
    const JoyInput &GetJoyInput() const { return joyInput; }

    FMOD_SYSTEM *GetAudioSystem() const { return audioSystem; }
    unsigned int GetAudioLatency_ms();
    FMOD_CHANNELGROUP *GetAudioMasterChannelGroup() const { return audioMasterChannelGroup; }
    FMOD_CHANNELGROUP *GetAudioSFXChannelGroup() const { return audioSFXChannelGroup; }
    FMOD_CHANNELGROUP *GetAudioMusicChannelGroup() const { return audioMusicChannelGroup; }

  private:

    PlayState *playState;

    KeyInput keyInput;
    JoyInput joyInput;

    FMOD_SYSTEM *audioSystem;
    FMOD_CHANNELGROUP *audioMasterChannelGroup; // not to be confused with FMOD's internal master group, because I think there's such a thing
    FMOD_CHANNELGROUP *audioSFXChannelGroup;
    FMOD_CHANNELGROUP *audioMusicChannelGroup;

};

namespace boost {
  void assertion_failed(char const * expr, char const * function, char const * file, long line);
}

#endif
