/*
  Copyright (C) 2010-2011  Charles Pence <charles@charlespence.net>
  Copyright (C) 1996-1997  Id Software, Inc.

  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.

  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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SERVICE_SIGNALS_H_
#define SERVICE_SIGNALS_H_

#include "../sound/sample.h"
#include "../util/or_combiner.h"

namespace service
{

// ==========
// FRAME TICK SIGNALS
// ==========

// Pre-render frametick event, called just before rendering starts, with the
// current-frame rendering parameters
//
// Signature: void FramePreRender (const refdef_t &refdef);
// refdef: renderig parameters
extern boost::signals2::signal<void (const refdef_t &)> FramePreRender;

// Post-render frametick event, called as soon as rendering is complete,
// once per frame
extern boost::signals2::signal<void ()> FramePostRender;


// ==========
// UI COMMANDS
// ==========

// A new console command has been entered.
//
// Signature: bool Command(std::string cmd);
// cmd: the command typed
// return: true if the command is handled
extern boost::signals2::signal<bool (const std::string &), util::or_combiner<bool> > ConsoleCommand;


// ==========
// SOUND
// ==========

// Play a sound localized in the world
//
// Signature: void PlaySound(int entnum, int entchannel, unsigned soundindex, 
//    vec3_t origin, float fvol, float attenuation);
// entnum: number of entity this sound is attached to
// entchannel: entity channel
// soundindex: index of sound returned from Sample::Load
// origin: location of sound
// fvol: volume, 0.0-1.0
// attenuation: distance attenuation: 0 for full strength in the entire
//   level, 1 for standard attenuation, >1 for more localized
extern boost::signals2::signal<void (int, int, unsigned, vec3_t, float, float)> PlaySound;

// Play a non-localized sound
// This is a wrapper for PlaySound.
inline void LocalSound(const std::string &filename)
{ PlaySound(cl.viewentity, -1, sound::Sample::Load(filename), vec3_origin, 1, 1); }

// Stop a sound by entity number and channel
//
// Signature: void StopSound(int entnum, int entchannel);
// entnum: number of entity this sound is attached to
// entchannel: entity channel
extern boost::signals2::signal<void (int, int)> StopSound;

// Play a looping sound, localized in the world
//
// Signature: void PlayStaticSound(unsigned soundindex, vec3_t origin, 
//    float vol, float attenuation)
// soundindex: index of sound returned from Sample::Load
// origin: location of sound
// fvol: volume, 0.0-1.0
// attenuation: distance attenuation: 0 for full strength in the entire
//   level, 1 for standard attenuation, >1 for more localized
extern boost::signals2::signal<void (unsigned, vec3_t, float, float)> PlayStaticSound;

// Play music track X.  These are CD tracks, where track 1 is the data track
// and hence never used.  The original Quake soundtrack had 11 tracks.
//
// Signature: void PlayMusic(int track)
// track: track number, originally in [2, 11]
extern boost::signals2::signal<void (int)> PlayMusic;

// Pause or unpause music
//
// Signature: void PauseMusic(bool paused)
extern boost::signals2::signal<void (bool)> PauseMusic;

// Stop music
//
// Signature: void StopMusic(void)
extern boost::signals2::signal<void (void)> StopMusic;

}

#endif /* SERVICE_SIGNALS_H_ */
