home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / audio / random_sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-08-15  |  4.5 KB  |  147 lines

  1. /***************************************************************************
  2.  * random_sound.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_RANDOM_SOUND_H
  17. #define SMC_RANDOM_SOUND_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../objects/sprite.h"
  21.  
  22. /* *** *** *** *** *** cRandom_Sound *** *** *** *** *** *** *** *** *** *** *** */
  23. class cRandom_Sound : public cSprite
  24. {
  25. public:
  26.     // constructor
  27.     cRandom_Sound( void );
  28.     // create from stream
  29.     cRandom_Sound( CEGUI::XMLAttributes &attributes );
  30.     // destructor
  31.     virtual ~cRandom_Sound( void );
  32.  
  33.     // create from stream
  34.     virtual void Create_from_Stream( CEGUI::XMLAttributes &attributes );
  35.     // save to stream
  36.     virtual void Save_to_Stream( ofstream &ofile );
  37.     // initialize defaults
  38.     void Init( void );
  39.  
  40.     // copy
  41.     virtual cRandom_Sound *Copy( void );
  42.  
  43.     // Set filename
  44.     void Set_Filename( string str );
  45.     // Get filename
  46.     string Get_Filename( void ) const;
  47.  
  48.     // Set if it is played continuously
  49.     void Set_Continuous( bool continuous );
  50.     // Set minimal delay
  51.     void Set_Delay_Min( unsigned int delay );
  52.     // Get minimal delay
  53.     unsigned int Get_Delay_Min( void ) const;
  54.     // Set maximum delay
  55.     void Set_Delay_Max( unsigned int delay );
  56.     // Get maximum delay
  57.     unsigned int Get_Delay_Max( void ) const;
  58.  
  59.     // Set minimal volume
  60.     void Set_Volume_Min( float volume );
  61.     // Get minimal volume
  62.     float Get_Volume_Min( void ) const;
  63.     // Set maximum volume
  64.     void Set_Volume_Max( float volume );
  65.     // Get maximum volume
  66.     float Get_Volume_Max( void ) const;
  67.  
  68.     // Set start of gradual volume reduction
  69.     void Set_Volume_Reduction_Begin( float distance );
  70.     // Get start of gradual volume reduction
  71.     float Get_Volume_Reduction_Begin( void ) const;
  72.     // Set end of gradual volume reduction
  73.     void Set_Volume_Reduction_End( float distance );
  74.     // Get end of gradual volume reduction
  75.     float Get_Volume_Reduction_End( void ) const;
  76.  
  77.     // Returns the volume modifier (0.0 - 1.0) for the current distance
  78.     float Get_Distance_Volume_Mod( void );
  79.  
  80.     // update
  81.     virtual void Update( void );
  82.     // draw
  83.     virtual void Draw( cSurfaceRequest *request = NULL );
  84.  
  85.     // if update is valid for the current state
  86.     virtual bool Is_Update_Valid( void );
  87.     // if draw is valid for the current state and position
  88.     virtual bool Is_Draw_Valid( void );
  89.  
  90.     // if camera went out of range
  91.     void Event_Out_Of_Range( void );
  92.     // ignore onground check
  93.     virtual void Check_on_Ground( void ) {};
  94.  
  95.     // editor activation
  96.     virtual void Editor_Activate( void );
  97.     // editor filename key up event
  98.     bool Editor_Filename_Key( const CEGUI::EventArgs &event );
  99.     // editor continuous changed event
  100.     bool Editor_Continuous_Changed( const CEGUI::EventArgs &event );
  101.     // editor delay min key up event
  102.     bool Editor_Delay_Min_Key( const CEGUI::EventArgs &event );
  103.     // editor delay max key up event
  104.     bool Editor_Delay_Max_Key( const CEGUI::EventArgs &event );
  105.     // editor volume min key up event
  106.     bool Editor_Volume_Min_Key( const CEGUI::EventArgs &event );
  107.     // editor volume max key up event
  108.     bool Editor_Volume_Max_Key( const CEGUI::EventArgs &event );
  109.     // editor volume reduction begin key up event
  110.     bool Editor_Volume_Reduction_Begin_Key( const CEGUI::EventArgs &event );
  111.     // editor volume reduction end key up event
  112.     bool Editor_Volume_Reduction_End_Key( const CEGUI::EventArgs &event );
  113.  
  114. private:
  115.     // the audio filename to play
  116.     string m_filename;
  117.     // is it played continuous
  118.     bool m_continuous;
  119.     // delay in milliseconds
  120.     unsigned int m_delay_min;
  121.     unsigned int m_delay_max;
  122.     // volume in percent
  123.     float m_volume_min;
  124.     float m_volume_max;
  125.  
  126.     // volume reduction begin
  127.     float m_volume_reduction_begin;
  128.     // volume reduction end
  129.     float m_volume_reduction_end;
  130.  
  131.     // distance to camera
  132.     float m_distance_to_camera;
  133.  
  134.     // time until next play
  135.     float m_next_play_delay;
  136.     // time until next volume update
  137.     float m_volume_update_counter;
  138.  
  139.     // editor color volume reduction begin
  140.     Color m_editor_color_volume_reduction_begin;
  141.     // editor color volume reduction end
  142.     Color m_editor_color_volume_reduction_end;
  143. };
  144.  
  145. #endif
  146.  
  147.