libsupertux_la_SOURCES =app/globals.cpp \
app/setup.cpp \
audio/musicref.cpp \
- audio/sound.cpp \
audio/sound_manager.cpp \
gui/button.cpp \
gui/menu.cpp \
app/gettext.h \
app/globals.h
libsupertuxaudio_HEADERS =audio/musicref.h \
- audio/sound.h \
audio/sound_manager.h
libsupertuxgui_HEADERS =gui/button.h \
gui/menu.h \
video/surface.h
libsupertux_la_LDFLAGS = -module
+
void usage(char * prog, int ret);
/* Does the given file exist and is it accessible? */
-int SuperTux::faccessible(const char *filename)
+int FileSystem::faccessible(const char *filename)
{
struct stat filestat;
if (stat(filename, &filestat) == -1)
}
/* Can we write to this location? */
-int SuperTux::fwriteable(const char *filename)
+int FileSystem::fwriteable(const char *filename)
{
FILE* fi;
fi = fopen(filename, "wa");
}
/* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/
-int SuperTux::fcreatedir(const char* relative_dir)
+int FileSystem::fcreatedir(const char* relative_dir)
{
char path[1024];
snprintf(path, 1024, "%s/%s/", st_dir, relative_dir);
}
}
-FILE * SuperTux::opendata(const char * rel_filename, const char * mode)
-{
- char * filename = NULL;
- FILE * fi;
-
- filename = (char *) malloc(sizeof(char) * (strlen(st_dir) +
- strlen(rel_filename) + 1));
-
- strcpy(filename, st_dir);
- /* Open the high score file: */
-
- strcat(filename, rel_filename);
-
- /* Try opening the file: */
- fi = fopen(filename, mode);
-
- if (fi == NULL)
- {
- fprintf(stderr, "Warning: Unable to open the file \"%s\" ", filename);
-
- if (strcmp(mode, "r") == 0)
- fprintf(stderr, "for read!!!\n");
- else if (strcmp(mode, "w") == 0)
- fprintf(stderr, "for write!!!\n");
- }
- free( filename );
-
- return(fi);
-}
-
/* Get all names of sub-directories in a certain directory. */
/* Returns the number of sub-directories found. */
/* Note: The user has to free the allocated space. */
-string_list_type SuperTux::dsubdirs(const char *rel_path,const char* expected_file)
+string_list_type FileSystem::dsubdirs(const char *rel_path,const char* expected_file)
{
DIR *dirStructP;
struct dirent *direntp;
return sdirs;
}
-string_list_type SuperTux::dfiles(const char *rel_path, const char* glob, const char* exception_str)
+string_list_type FileSystem::dfiles(const char *rel_path, const char* glob, const char* exception_str)
{
DIR *dirStructP;
struct dirent *direntp;
return sdirs;
}
-void SuperTux::free_strings(char **strings, int num)
-{
- int i;
- for(i=0; i < num; ++i)
- free(strings[i]);
-}
-
-void SuperTux::st_info_setup(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version)
+void Setup::info(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version)
{
package_name = _package_name;
package_symbol_name = _package_symbol_name;
/* --- SETUP --- */
/* Set SuperTux configuration and save directories */
-void SuperTux::st_directory_setup(void)
+void Setup::directories(void)
{
char *home;
char str[1024];
strcat(st_dir,st_dir_tmp.c_str());
/* Remove .supertux config-file from old SuperTux versions */
- if(faccessible(st_dir))
+ if(FileSystem::faccessible(st_dir))
{
remove
(st_dir);
printf("Datadir: %s\n", datadir.c_str());
}
-void SuperTux::st_general_setup(void)
+void Setup::general(void)
{
/* Seed random number generator: */
}
-void SuperTux::st_general_free(void)
+void Setup::general_free(void)
{
/* Free global images: */
}
-void SuperTux::st_video_setup(unsigned int screen_w, unsigned int screen_h)
+void Setup::video(unsigned int screen_w, unsigned int screen_h)
{
/* Init SDL Video: */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
/* Open display: */
if(use_gl)
- st_video_setup_gl(screen_w, screen_h);
+ video_gl(screen_w, screen_h);
else
- st_video_setup_sdl(screen_w, screen_h);
+ video_sdl(screen_w, screen_h);
Surface::reload_all();
SDL_WM_SetCaption((package_name + " " + package_version).c_str(), package_name.c_str());
}
-void SuperTux::st_video_setup_sdl(unsigned int screen_w, unsigned int screen_h)
+void Setup::video_sdl(unsigned int screen_w, unsigned int screen_h)
{
if (use_fullscreen)
{
}
}
-void SuperTux::st_video_setup_gl(unsigned int screen_w, unsigned int screen_h)
+void Setup::video_gl(unsigned int screen_w, unsigned int screen_h)
{
#ifndef NOOPENGL
}
-void SuperTux::st_joystick_setup(void)
+void Setup::joystick(void)
{
/* Init Joystick: */
}
}
-void SuperTux::st_audio_setup(void)
+void Setup::audio(void)
{
/* Init SDL Audio silently even if --disable-sound : */
- if (audio_device)
+ if (SoundManager::get()->audio_device_available())
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if (use_sound || use_music)
+ if (SoundManager::get()->sound_enabled() || SoundManager::get()->music_enabled())
{
fprintf(stderr,
"\nWarning: I could not initialize audio!\n"
because in this case, use_sound & use_music' values are ignored
when there's no available audio device
*/
- use_sound = false;
- use_music = false;
- audio_device = false;
+ SoundManager::get()->enable_sound(false);
+ SoundManager::get()->enable_music(false);
+ SoundManager::get()->set_audio_device_available(false);
}
}
/* Open sound silently regarless the value of "use_sound": */
- if (audio_device)
+ if (SoundManager::get()->audio_device_available())
{
- if (open_audio(44100, AUDIO_S16, 2, 2048) < 0)
+ if (SoundManager::get()->open_audio(44100, AUDIO_S16, 2, 2048) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if (use_sound || use_music)
+ if (SoundManager::get()->sound_enabled() || SoundManager::get()->music_enabled())
{
fprintf(stderr,
"\nWarning: I could not set up audio for 44100 Hz "
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
}
- use_sound = false;
- use_music = false;
- audio_device = false;
+ SoundManager::get()->enable_sound(false);
+ SoundManager::get()->enable_music(false);
+ SoundManager::get()->set_audio_device_available(false);
}
}
/* --- SHUTDOWN --- */
-void SuperTux::st_shutdown(void)
+void Termination::shutdown(void)
{
- close_audio();
+ SoundManager::get()->close_audio();
SDL_Quit();
config->save();
}
/* --- ABORT! --- */
-void SuperTux::st_abort(const std::string& reason, const std::string& details)
+void Termination::abort(const std::string& reason, const std::string& details)
{
fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str());
- st_shutdown();
- abort();
+ shutdown();
+ ::abort();
}
/* Set Icon (private) */
/* Parse command-line arguments: */
-void SuperTux::parseargs(int argc, char * argv[])
+void Setup::parseargs(int argc, char * argv[])
{
int i;
{
/* Disable the compiled in sound feature */
printf("Sounds disabled \n");
- use_sound = false;
- audio_device = false;
+ SoundManager::get()->enable_sound(false);
}
else if (strcmp(argv[i], "--disable-music") == 0)
{
/* Disable the compiled in sound feature */
printf("Music disabled \n");
- use_music = false;
+ SoundManager::get()->enable_music(false);
}
else if (strcmp(argv[i], "--debug") == 0)
{
exit(ret);
}
-std::vector<std::string> SuperTux::read_directory(const std::string& pathname)
+std::vector<std::string> FileSystem::read_directory(const std::string& pathname)
{
std::vector<std::string> dirnames;
#include <vector>
#include <string>
#include "../gui/menu.h"
-#include "../audio/sound.h"
#include "../special/base.h"
namespace SuperTux {
-int faccessible(const char *filename);
-int fcreatedir(const char* relative_dir);
-int fwriteable(const char *filename);
-std::vector<std::string> read_directory(const std::string& pathname);
-
-FILE * opendata(const char * filename, const char * mode);
-string_list_type dsubdirs(const char *rel_path, const char* expected_file);
-string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str);
-void free_strings(char **strings, int num);
-void st_info_setup(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version);
-void st_directory_setup(void);
-void st_general_setup(void);
-void st_general_free();
-void st_video_setup_sdl(unsigned int screen_w, unsigned int screen_h);
-void st_video_setup_gl(unsigned int screen_w, unsigned int screen_h);
-void st_video_setup(unsigned int screen_w, unsigned int screen_h);
-void st_audio_setup(void);
-void st_joystick_setup(void);
-void st_shutdown(void);
-void st_abort(const std::string& reason, const std::string& details);
-
-void parseargs(int argc, char * argv[]);
-
-}
+/// File system utility functions
+struct FileSystem
+ {
+ static int faccessible(const char *filename);
+ static int fcreatedir(const char* relative_dir);
+ static int fwriteable(const char *filename);
+ static std::vector<std::string> read_directory(const std::string& pathname);
+ static string_list_type dsubdirs(const char *rel_path, const char* expected_file);
+ static string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str);
+ };
+
+/// All you need to get an application up and running
+struct Setup
+ {
+ static void info(const std::string& _package_name, const std::string& _package_symbol_name, const std::string& _package_version);
+ static void directories(void);
+ static void general(void);
+ static void general_free();
+ static void video_sdl(unsigned int screen_w, unsigned int screen_h);
+ static void video_gl(unsigned int screen_w, unsigned int screen_h);
+ static void video(unsigned int screen_w, unsigned int screen_h);
+ static void audio(void);
+ static void joystick(void);
+ static void parseargs(int argc, char * argv[]);
+ };
+
+/// Termination handling
+struct Termination
+ {
+ static void shutdown(void);
+ static void abort(const std::string& reason, const std::string& details);
+ };
+
+} //namespace SuperTux
#endif /*SUPERTUX_SETUP_H*/
+++ /dev/null
-// $Id$
-//
-// SuperTux - A Jump'n Run
-// Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
-// Copyright (C) 2004 Duong-Khang NGUYEN <neoneurone@users.sf.net>
-//
-// 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 2
-// 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, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <string>
-#include "../audio/sound.h"
-
-/*global variable*/
-bool use_sound = true; /* handle sound on/off menu and command-line option */
-bool use_music = true; /* handle music on/off menu and command-line option */
-bool audio_device = true; /* != 0: available and initialized */
-
-#include <SDL_mixer.h>
-
-std::vector<Mix_Chunk*> sounds;
-
-/* --- OPEN THE AUDIO DEVICE --- */
-
-int open_audio (int frequency, Uint16 format, int channels, int chunksize)
-{
- if (Mix_OpenAudio( frequency, format, channels, chunksize ) < 0)
- return -1;
-
- // allocate 16 channels for mixing
- if (Mix_AllocateChannels(8) != 8)
- return -2;
-
- return 0;
-}
-
-
-/* --- CLOSE THE AUDIO DEVICE --- */
-
-void close_audio( void )
-{
- if (audio_device) {
- Mix_CloseAudio();
- }
-}
-
-
-/* --- LOAD A SOUND --- */
-
-Mix_Chunk* load_sound(const std::string& file)
-{
- if(!audio_device)
- return 0;
-
- Mix_Chunk* snd = Mix_LoadWAV(file.c_str());
-
- /*if (snd == 0)
- st_abort("Can't load", file);*/
-
- return(snd);
-}
-
-void free_chunk(Mix_Chunk *chunk)
-{
- Mix_FreeChunk( chunk );
-}
-
+++ /dev/null
-// $Id$
-//
-// SuperTux - A Jump'n Run
-// Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
-// Copyright (C) 2004 Duong-Khang NGUYEN <neoneurone@users.sf.net>
-//
-// 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 2
-// 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, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef SUPERTUX_SOUND_H
-#define SUPERTUX_SOUND_H
-
-//#include "defines.h" /* get YES/NO defines */
-#include <vector>
-
-/*global variable*/
-extern bool use_sound; /* handle sound on/off menu and command-line option */
-extern bool use_music; /* handle music on/off menu and command-line */
-extern bool audio_device; /* != 0: available and initialized */
-
-/* enum of different internal music types */
-enum Music_Type {
- NO_MUSIC,
- LEVEL_MUSIC,
- HURRYUP_MUSIC,
- HERRING_MUSIC
-};
-
-#include <string>
-#include <SDL_mixer.h>
-
-/* variables for stocking the sound and music */
-extern std::vector<Mix_Chunk*> sounds;
-
-/* functions handling the sound and music */
-int open_audio(int frequency, Uint16 format, int channels, int chunksize);
-void close_audio( void );
-
-Mix_Chunk * load_sound(const std::string& file);
-void free_chunk(Mix_Chunk*chunk);
-
-#endif /*SUPERTUX_SOUND_H*/
#include "../audio/sound_manager.h"
#include "../audio/musicref.h"
-#include "../audio/sound.h"
#include "../app/globals.h"
#include "../app/setup.h"
#include "../special/moving_object.h"
using namespace SuperTux;
+SoundManager* SoundManager::instance_ = 0;
+
SoundManager::SoundManager()
- : current_music(0), music_enabled(true)
+ : current_music(0), m_music_enabled(true) , m_sound_enabled(true) , audio_device(true)
{
}
{
if(audio_device)
Mix_HaltMusic();
+
+sounds.clear();
+destroy_instance();
}
void
SoundManager::play_sound(Mix_Chunk* sound)
{
- if(!audio_device || !use_sound)
+ if(!audio_device || !m_sound_enabled)
return;
Mix_PlayChannel(-1, sound, 0);
void
SoundManager::play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2)
{
- if(!audio_device || !use_sound)
+ if(!audio_device || !m_sound_enabled)
return;
// TODO make sure this formula is good
return MusicRef(0);
if(!exists_music(file))
- st_abort("Couldn't load musicfile ", file.c_str());
+ Termination::abort("Couldn't load musicfile ", file.c_str());
std::map<std::string, MusicResource>::iterator i = musics.find(file);
assert(i != musics.end());
current_music = musicref.music;
current_music->refcount++;
- if(music_enabled)
+ if(m_music_enabled)
Mix_PlayMusic(current_music->music, loops);
}
if(!audio_device)
return;
- if(enable == music_enabled)
+ if(enable == m_music_enabled)
return;
- music_enabled = enable;
- if(music_enabled == false) {
+ m_music_enabled = enable;
+ if(m_music_enabled == false) {
Mix_HaltMusic();
} else {
Mix_PlayMusic(current_music->music, -1);
}
}
+void
+SoundManager::enable_sound(bool enable)
+{
+ if(!audio_device)
+ return;
+
+ m_sound_enabled = enable;
+}
+
SoundManager::MusicResource::~MusicResource()
{
// don't free music buggy SDL_Mixer crashs for some mod files
// Mix_FreeMusic(music);
}
+/* --- LOAD A SOUND --- */
+
+Mix_Chunk* SoundManager::load_sound(const std::string& file)
+{
+ if(!audio_device)
+ return 0;
+
+ Mix_Chunk* snd = Mix_LoadWAV(file.c_str());
+
+ /*if (snd == 0)
+ Termination::abort("Can't load", file);*/
+
+ return(snd);
+}
+
+void SoundManager::free_chunk(Mix_Chunk *chunk)
+{
+ Mix_FreeChunk( chunk );
+}
+
+
+/* --- OPEN THE AUDIO DEVICE --- */
+
+int SoundManager::open_audio (int frequency, Uint16 format, int channels, int chunksize)
+{
+ if (Mix_OpenAudio( frequency, format, channels, chunksize ) < 0)
+ return -1;
+
+ // allocate 16 channels for mixing
+ if (Mix_AllocateChannels(8) != 8)
+ return -2;
+
+ return 0;
+}
+
+
+/* --- CLOSE THE AUDIO DEVICE --- */
+
+void SoundManager::close_audio( void )
+{
+ if (audio_device) {
+ Mix_CloseAudio();
+ }
+}
+
+Mix_Chunk* SuperTux::IDToSound(int id)
+{
+ return SoundManager::get()->sounds[id];
+}
+
#define SUPERTUX_SOUND_MANAGER_H
#include <string>
+#include <vector>
#include <map>
#include "SDL_mixer.h"
class MusicRef;
class MovingObject;
+ /// enum of different internal music types
+ enum Music_Type {
+ NO_MUSIC,
+ LEVEL_MUSIC,
+ HURRYUP_MUSIC,
+ HERRING_MUSIC
+ };
+
/// Sound manager
/** This class handles all sounds that are played
*/
class SoundManager
{
public:
- SoundManager();
- ~SoundManager();
/// Play sound.
void play_sound(Mix_Chunk* sound);
void play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2);
/// Play sound relative to a MovingObject and a Vector.
void play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos);
-
+
/// Load music.
/** Is used to load the music for a MusicRef. */
MusicRef load_music(const std::string& file);
+
+ /// Load sound.
+ Mix_Chunk * load_sound(const std::string& file);
+
/// Test if a certain music file exists.
bool exists_music(const std::string& filename);
/// Enable/Disable music.
void enable_music(bool enable);
+ /// Is music enabled?
+ bool music_enabled()
+ {
+ return m_music_enabled;
+ }
+
+ /// Enable/Disable sound.
+ void enable_sound(bool enable);
+
+ /// Is sound enabled?
+ bool sound_enabled()
+ {
+ return m_sound_enabled;
+ }
+
+ /* functions handling the sound and music */
+ int open_audio(int frequency, Uint16 format, int channels, int chunksize);
+ void close_audio( void );
+
+ /// Is audio available?
+ bool audio_device_available()
+ {
+ return audio_device;
+ }
+
+ void set_audio_device_available(bool available)
+ {
+ audio_device = available;
+ }
+
+ static SoundManager* get()
+ {
+ return instance_ ? instance_ : instance_ = new SoundManager();
+ }
+ static void destroy_instance()
+ {
+ delete instance_;
+ instance_ = 0;
+ }
+
+ void add_sound(Mix_Chunk* sound, int id)
+ {
+ sounds[id] = sound;
+ }
+
+ Mix_Chunk* get_sound(int id)
+ {
+ return sounds[id];
+ }
+
private:
+ SoundManager();
+ ~SoundManager();
+
// music part
friend class MusicRef;
+ friend class Setup;
+ friend Mix_Chunk* IDToSound(int id);
+
+ static SoundManager* instance_ ;
+
+ void free_chunk(Mix_Chunk* chunk);
/// Resource for music.
/** Contains the raw music data and
void free_music(MusicResource* music);
+ /*variables for stocking the sound and music*/
+ std::map<int, Mix_Chunk*> sounds;
std::map<std::string, MusicResource> musics;
MusicResource* current_music;
- bool music_enabled;
+ bool m_music_enabled;
+ bool m_sound_enabled;
+ bool audio_device; /* != 0: available and initialized */
+
};
+ Mix_Chunk* IDToSound(int id);
+
} // namespace SuperTux
-
#endif /*SUPERTUX_SOUND_MANAGER_H*/
if(!icon_file.empty())
{
snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file.c_str());
- if(!faccessible(filename))
+ if(!FileSystem::faccessible(filename))
snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
}
else
#include "../video/screen.h"
#include "../video/drawing_context.h"
#include "../app/setup.h"
-#include "../audio/sound.h"
#include "../special/timer.h"
#include "../app/gettext.h"
#include "../math/vector.h"
LispReader reader(cur);
if(!reader.read_string("name", name))
- st_abort("Sprite wihtout name", "");
+ Termination::abort("Sprite wihtout name", "");
reader.read_int("x-hotspot", x_hotspot);
reader.read_int("y-hotspot", y_hotspot);
reader.read_float("fps", fps);
std::vector<std::string> images;
if(!reader.read_string_vector("images", images))
- st_abort("Sprite contains no images: ", name.c_str());
+ Termination::abort("Sprite contains no images: ", name.c_str());
for(std::vector<std::string>::size_type i = 0; i < images.size(); ++i)
{
class Sprite
{
- private:
- std::string name;
-
- int x_hotspot;
- int y_hotspot;
-
- /** Frames per second */
- float fps;
-
- /** Number of seconds that a frame is displayed until it is switched
- to the next frame */
- float frame_delay;
-
- float time;
-
- std::vector<Surface*> surfaces;
-
- void init_defaults();
public:
/** cur has to be a pointer to data in the form of ((x-hotspot 5)
(y-hotspot 10) ...) */
return surfaces[frame];
else
return surfaces[0];
- }
+ }
+ private:
+ std::string name;
+
+ int x_hotspot;
+ int y_hotspot;
+
+ /** Frames per second */
+ float fps;
+
+ /** Number of seconds that a frame is displayed until it is switched
+ to the next frame */
+ float frame_delay;
+
+ float time;
+
+ std::vector<Surface*> surfaces;
+
+ void init_defaults();
};
} //namespace SuperTux
#include "../utils/configfile.h"
#include "../app/setup.h"
#include "../app/globals.h"
+#include "../audio/sound_manager.h"
using namespace SuperTux;
{
/* Set defaults: */
debug_mode = false;
- audio_device = true;
+ SoundManager::get()->set_audio_device_available(true);
use_fullscreen = false;
show_fps = false;
use_gl = false;
- use_sound = true;
- use_music = true;
+ SoundManager::get()->enable_sound(true);
+ SoundManager::get()->enable_music(true);
+}
+
+FILE * SuperTux::opendata(const char * rel_filename, const char * mode)
+{
+ char * filename = NULL;
+ FILE * fi;
+
+ filename = (char *) malloc(sizeof(char) * (strlen(st_dir) +
+ strlen(rel_filename) + 1));
+
+ strcpy(filename, st_dir);
+ /* Open the high score file: */
+
+ strcat(filename, rel_filename);
+
+ /* Try opening the file: */
+ fi = fopen(filename, mode);
+
+ if (fi == NULL)
+ {
+ fprintf(stderr, "Warning: Unable to open the file \"%s\" ", filename);
+
+ if (strcmp(mode, "r") == 0)
+ fprintf(stderr, "for read!!!\n");
+ else if (strcmp(mode, "w") == 0)
+ fprintf(stderr, "for write!!!\n");
+ }
+ free( filename );
+
+ return(fi);
}
void Config::load()
LispReader reader(lisp_cdr(root_obj));
reader.read_bool("fullscreen", use_fullscreen);
- reader.read_bool("sound", use_sound);
- reader.read_bool("music", use_music);
+ bool temp;
+ reader.read_bool("sound", temp);
+ SoundManager::get()->enable_sound(temp);
+ reader.read_bool("music", temp);
+ SoundManager::get()->enable_music(temp);
reader.read_bool("show_fps", show_fps);
std::string video;
fprintf(config, "(supertux-config\n");
fprintf(config, "\t;; the following options can be set to #t or #f:\n");
fprintf(config, "\t(fullscreen %s)\n", use_fullscreen ? "#t" : "#f");
- fprintf(config, "\t(sound %s)\n", use_sound ? "#t" : "#f");
- fprintf(config, "\t(music %s)\n", use_music ? "#t" : "#f");
+ fprintf(config, "\t(sound %s)\n", SoundManager::get()->sound_enabled() ? "#t" : "#f");
+ fprintf(config, "\t(music %s)\n", SoundManager::get()->music_enabled() ? "#t" : "#f");
fprintf(config, "\t(show_fps %s)\n", show_fps ? "#t" : "#f");
fprintf(config, "\n\t;; either \"opengl\" or \"sdl\"\n");
namespace SuperTux {
+FILE * opendata(const char * filename, const char * mode);
+
class Config {
public:
void load ();
return false;
if (!lisp_real_p(lisp_car(obj)) && !lisp_integer_p(lisp_car(obj)))
- st_abort("LispReader expected type real at token: ", name);
+ Termination::abort("LispReader expected type real at token: ", name);
f = lisp_real(lisp_car(obj));
return true;
while(!lisp_nil_p(obj))
{
if (!lisp_string_p(lisp_car(obj)))
- st_abort("LispReader expected type string at token: ", name);
+ Termination::abort("LispReader expected type string at token: ", name);
vec.push_back(lisp_string(lisp_car(obj)));
obj = lisp_cdr(obj);
}
while(!lisp_nil_p(obj))
{
if (!lisp_integer_p(lisp_car(obj)))
- st_abort("LispReader expected type integer at token: ", name);
+ Termination::abort("LispReader expected type integer at token: ", name);
vec.push_back(lisp_integer(lisp_car(obj)));
obj = lisp_cdr(obj);
}
while(!lisp_nil_p(obj))
{
if (!lisp_integer_p(lisp_car(obj)))
- st_abort("LispReader expected type integer at token: ", name);
+ Termination::abort("LispReader expected type integer at token: ", name);
vec.push_back(lisp_integer(lisp_car(obj)));
obj = lisp_cdr(obj);
}
return false;
if (!lisp_string_p(lisp_car(obj)))
- st_abort("LispReader expected type string at token: ", name);
+ Termination::abort("LispReader expected type string at token: ", name);
str = lisp_string(lisp_car(obj));
return true;
}
return false;
if (!lisp_boolean_p(lisp_car(obj)))
- st_abort("LispReader expected type bool at token: ", name);
+ Termination::abort("LispReader expected type bool at token: ", name);
b = lisp_boolean(lisp_car(obj));
return true;
}
LAYER_GUI = 500
};
+ /// Handles drawing of things.
/**
* This class provides functions for drawing things on screen. It also
* maintains a stack of transforms that are applied to graphics.
DrawingContext();
~DrawingContext();
- /** Adds a drawing request for a surface into the request list */
+ /// Adds a drawing request for a surface into the request list.
void draw_surface(const Surface* surface, const Vector& position, int layer,
Uint32 drawing_effect = NONE_EFFECT);
- /** Adds a drawing request for part of a surface */
+ /// Adds a drawing request for part of a surface.
void draw_surface_part(const Surface* surface, const Vector& source,
const Vector& size, const Vector& dest, int layer,
Uint32 drawing_effect = NONE_EFFECT);
- /** draws a text */
+ /// Draws a text.
void draw_text(Font* font, const std::string& text, const Vector& position,
int layer, Uint32 drawing_effect = NONE_EFFECT);
- /** draws aligned text */
+ /// Draws aligned text.
void draw_text_center(Font* font, const std::string& text,
const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT);
- /** draws a color gradient onto the whole screen */
+ /// Draws a color gradient onto the whole screen */
void draw_gradient(Color from, Color to, int layer);
- /** fills a rectangle */
+ /// Fills a rectangle.
void draw_filled_rect(const Vector& topleft, const Vector& size,
Color color, int layer);
- /** Processes all pending drawing requests and flushes the list */
+ /// Processes all pending drawing requests and flushes the list.
void do_drawing();
const Vector& get_translation() const
void push_transform();
void pop_transform();
- /** apply that effect in the next draws (effects are listed on surface.h) */
+ /// Apply that effect in the next draws (effects are listed on surface.h).
void set_drawing_effect(int effect);
private:
and displays it in a StarTrek fashion */
void display_text_file(const std::string& file, float scroll_speed);
- /* Text type */
+ /// Font
class Font
{
public:
- /* Kinds of texts. */
+ /// Kinds of texts.
enum FontType {
TEXT, // images for all characters
NUM // only images for numbers
Font(const std::string& file, FontType type, int w, int h, int shadowsize=2);
~Font();
- /** returns the height of the font */
+ /// returns the height of the font.
float get_height() const;
/** returns the width of a given text. (Note that I won't add a normal
* get_width function here, as we might switch to variable width fonts in the
temp->format->Bmask,
temp->format->Amask);
if(!surface)
- st_abort("No memory left.", "");
+ Termination::abort("No memory left.", "");
SDL_SetAlpha(temp,0,0);
SDL_BlitSurface(temp, NULL, surface, NULL);
}
temp = IMG_Load(file.c_str());
if (temp == NULL)
- st_abort("Can't load", file);
+ Termination::abort("Can't load", file);
/* Set source rectangle for conv: */
sdl_surface = SDL_DisplayFormatAlpha(conv);
if (sdl_surface == NULL)
- st_abort("Can't covert to display format", file);
+ Termination::abort("Can't covert to display format", file);
if (use_alpha == false && !use_gl)
SDL_SetAlpha(sdl_surface, 0, 0);
temp = IMG_Load(file.c_str());
if (temp == NULL)
- st_abort("Can't load", file);
+ Termination::abort("Can't load", file);
if(use_alpha == false && !use_gl)
sdl_surface = SDL_DisplayFormat(temp);
sdl_surface = SDL_DisplayFormatAlpha(temp);
if (sdl_surface == NULL)
- st_abort("Can't covert to display format", file);
+ Termination::abort("Can't covert to display format", file);
if (use_alpha == false && !use_gl)
SDL_SetAlpha(sdl_surface, 0, 0);
}
if (sdl_surface == NULL)
- st_abort("Can't covert to display format", "SURFACE");
+ Termination::abort("Can't covert to display format", "SURFACE");
if (use_alpha == false && !use_gl)
SDL_SetAlpha(sdl_surface, 0, 0);
screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
if(sdl_surface == NULL)
- st_abort("Cannot create surface for the gradient", "SURFACE");
+ Termination::abort("Cannot create surface for the gradient", "SURFACE");
if(top == bottom)
{
tux.kick_timer.start(KICKING_TIME);
set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5);
- sound_manager->play_sound(sounds[SND_KICK], this, Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_KICK), this, Sector::current()->player->get_pos());
}
}
check_horizontal_bump();
if(mode == KICK && changed != dir)
{
- sound_manager->play_sound(sounds[SND_RICOCHET], get_pos(), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(), Sector::current()->player->get_pos());
}
}
dying = DYING_NOT; // now the bomb hurts
timer.start(EXPLODETIME);
- sound_manager->play_sound(sounds[SND_EXPLODE], this, Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_EXPLODE), this, Sector::current()->player->get_pos());
} else if(mode == BOMB_EXPLODE) {
remove_me();
return;
Sector::current()->add_score(Vector(base.x, base.y),
50 * player_status.score_multiplier);
- sound_manager->play_sound(sounds[SND_SQUISH], get_pos(), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
player_status.score_multiplier++;
dying = DYING_SQUISHED;
player->bounce(this);
Sector::current()->add_score(Vector(base.x, base.y),
50 * player_status.score_multiplier);
- sound_manager->play_sound(sounds[SND_SQUISH], get_pos(), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
player_status.score_multiplier++;
return;
if (mode == NORMAL || mode == KICK)
{
/* Flatten! */
- sound_manager->play_sound(sounds[SND_STOMP], get_pos(), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_STOMP), get_pos(), Sector::current()->player->get_pos());
mode = FLAT;
set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
physic.set_velocity_x(0);
timer.start(4000);
} else if (mode == FLAT) {
/* Kick! */
- sound_manager->play_sound(sounds[SND_KICK], this, Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_KICK), this, Sector::current()->player->get_pos());
if (player->base.x < base.x + (base.width/2)) {
physic.set_velocity_x(5);
score * player_status.score_multiplier);
/* Play death sound: */
- sound_manager->play_sound(sounds[SND_FALL], this, Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_FALL), this, Sector::current()->player->get_pos());
}
void
/* Get kicked if were flat */
if (mode == FLAT && !dying)
{
- sound_manager->play_sound(sounds[SND_KICK], this, Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_KICK), this, Sector::current()->player->get_pos());
// Hit from left side
if (player->base.x < base.x) {
level->do_vertical_flip();
currentsector = level->get_sector("main");
if(!currentsector)
- st_abort("Level has no main sector.", "");
+ Termination::abort("Level has no main sector.", "");
currentsector->activate("main");
#if 0 // TODO
void
GameSession::levelintro(void)
{
- sound_manager->halt_music();
+ SoundManager::get()->halt_music();
char str[60];
switch(event.type)
{
case SDL_QUIT: /* Quit event - quit: */
- st_abort("Received window close", "");
+ Termination::abort("Received window close", "");
break;
case SDL_KEYDOWN: /* A keypress! */
switch(event.type)
{
case SDL_QUIT: /* Quit event - quit: */
- st_abort("Received window close", "");
+ Termination::abort("Received window close", "");
break;
case SDL_KEYDOWN: /* A keypress! */
{
end_sequence = ENDSEQUENCE_RUNNING;
last_x_pos = -1;
- sound_manager->play_music(level_end_song, 0);
+ SoundManager::get()->play_music(level_end_song, 0);
endsequence_timer.start(7000); // 5 seconds until we finish the map
tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.)
}
Sector::current()->add_bouncy_brick(Vector(((int)(x + 1) / 32) * 32,
(int)(y / 32) * 32));
- sound_manager->play_sound(sounds[SND_BRICK], Vector(x, y), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_BRICK), Vector(x, y), Sector::current()->player->get_pos());
}
/* (Status): */
#define SUPERTUX_GAMELOOP_H
#include "special/timer.h"
-#include "audio/sound.h"
#include "special/base.h"
using namespace SuperTux;
/* Save data file: */
filename = highscore_filename;
- fcreatedir(filename.c_str());
- if(fwriteable(filename.c_str()))
+ FileSystem::fcreatedir(filename.c_str());
+ if(FileSystem::fwriteable(filename.c_str()))
{
fi = fopen(filename.c_str(), "w");
if (fi == NULL)
snprintf(filename, 1024, "%s/levels/%s/", st_dir, subset);
if(access(filename, R_OK) == 0)
{
- files = read_directory(filename);
+ files = FileSystem::read_directory(filename);
}
else
{
snprintf(filename, 1024, "%s/levels/%s/", datadir.c_str(), subset);
- files = read_directory(filename);
+ files = FileSystem::read_directory(filename);
}
for(std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i)
/* Save data file: */
filename = "/levels/" + name + "/";
- fcreatedir(filename.c_str());
+ FileSystem::fcreatedir(filename.c_str());
filename = std::string(st_dir) + "/levels/" + name + "/info";
- if(!fwriteable(filename.c_str()))
+ if(!FileSystem::fwriteable(filename.c_str()))
filename = datadir + "/levels/" + name + "/info";
- if(fwriteable(filename.c_str()))
+ if(FileSystem::fwriteable(filename.c_str()))
{
fi = fopen(filename.c_str(), "w");
if (fi == NULL)
LevelEditor::LevelEditor()
{
- level_subsets = dsubdirs("/levels", "level1.stl");
+ level_subsets = FileSystem::dsubdirs("/levels", "level1.stl");
le_level_subset = new LevelSubset;
le_level = NULL;
le_level = NULL;
le_levelnb = 1;
- sound_manager->halt_music();
+ SoundManager::get()->halt_music();
while (SDL_PollEvent(&event))
{}
level_settings_menu->get_item_by_id(MNID_NAME).change_input(le_level->name.c_str());
level_settings_menu->get_item_by_id(MNID_AUTHOR).change_input(le_level->author.c_str());
- string_list_copy(level_settings_menu->get_item_by_id(MNID_SONG).list, dfiles("music/",NULL, "-fast"));
- string_list_copy(level_settings_menu->get_item_by_id(MNID_BGIMG).list, dfiles("images/background",NULL, NULL));
+ string_list_copy(level_settings_menu->get_item_by_id(MNID_SONG).list, FileSystem::dfiles("music/",NULL, "-fast"));
+ string_list_copy(level_settings_menu->get_item_by_id(MNID_BGIMG).list, FileSystem::dfiles("images/background",NULL, NULL));
string_list_add_item(level_settings_menu->get_item_by_id(MNID_BGIMG).list,"");
string_list_add_item(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,"");
string_list_add_item(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,"snow");
session.run();
player_status.reset();
- sound_manager->halt_music();
+ SoundManager::get()->halt_music();
Menu::set_current(NULL);
}
if(use_gl != options_menu->isToggled(MNID_OPENGL))
{
use_gl = !use_gl;
- st_video_setup(screen->w,screen->h);
+ Setup::video(screen->w,screen->h);
}
#else
options_menu->get_item_by_id(MNID_OPENGL).toggled = false;
if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN))
{
use_fullscreen = !use_fullscreen;
- st_video_setup(screen->w,screen->h);
+ Setup::video(screen->w,screen->h);
}
break;
case MNID_SOUND:
- if(use_sound != options_menu->isToggled(MNID_SOUND))
- use_sound = !use_sound;
+ if(SoundManager::get()->sound_enabled() != options_menu->isToggled(MNID_SOUND))
+ SoundManager::get()->enable_sound(!SoundManager::get()->sound_enabled());
break;
case MNID_MUSIC:
- if(use_music != options_menu->isToggled(MNID_MUSIC))
+ if(SoundManager::get()->music_enabled() != options_menu->isToggled(MNID_MUSIC))
{
- use_music = !use_music;
- sound_manager->enable_music(use_music);
+ SoundManager::get()->enable_music(!SoundManager::get()->music_enabled());
}
break;
case MNID_SHOWFPS:
options_menu->additem(MN_DEACTIVE,_("OpenGL (not supported)"),use_gl, 0, MNID_OPENGL);
#endif
options_menu->additem(MN_TOGGLE,_("Fullscreen"),use_fullscreen,0, MNID_FULLSCREEN);
- if(audio_device)
+ if(SoundManager::get()->audio_device_available())
{
- options_menu->additem(MN_TOGGLE,_("Sound "), use_sound,0, MNID_SOUND);
- options_menu->additem(MN_TOGGLE,_("Music "), use_music,0, MNID_MUSIC);
+ options_menu->additem(MN_TOGGLE,_("Sound "), SoundManager::get()->sound_enabled(),0, MNID_SOUND);
+ options_menu->additem(MN_TOGGLE,_("Music "), SoundManager::get()->music_enabled(),0, MNID_MUSIC);
}
else
{
if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) {
if(fabs(vx)>SKID_XM && !skidding_timer.check()) {
skidding_timer.start(SKID_TIME);
- sound_manager->play_sound(sounds[SND_SKID]);
+ SoundManager::get()->play_sound(IDToSound(SND_SKID));
ax *= 2.5;
} else {
ax *= 2;
jumping = true;
can_jump = false;
if (size == SMALL)
- sound_manager->play_sound(sounds[SND_JUMP]);
+ SoundManager::get()->play_sound(IDToSound(SND_JUMP));
else
- sound_manager->play_sound(sounds[SND_BIGJUMP]);
+ SoundManager::get()->play_sound(IDToSound(SND_BIGJUMP));
}
// Let go of jump key
else if(input.up == UP && jumping && physic.get_velocity_y() > 0)
if(player_status.lives < MAX_LIVES)
++player_status.lives;
/*We want to hear the sound even, if MAX_LIVES is reached*/
- sound_manager->play_sound(sounds[SND_LIFEUP]);
+ SoundManager::get()->play_sound(IDToSound(SND_LIFEUP));
}
}
if(dying)
return;
- sound_manager->play_sound(sounds[SND_HURT]);
+ SoundManager::get()->play_sound(IDToSound(SND_HURT));
physic.set_velocity_x(0);
#include "special/base.h"
#include "video/surface.h"
#include "collision.h"
-#include "audio/sound.h"
#include "special/moving_object.h"
#include "math/physic.h"
#include "app/defines.h"
int i;
sprite_manager = new SpriteManager(datadir + "/supertux.strf");
- sound_manager = new SoundManager();
- sound_manager->enable_music(use_music);
/* Tuxes: */
smalltux_star = sprite_manager->load("smalltux-star");
Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :)
*/
for (i = 0; i < NUM_SOUNDS; i++)
- sounds.push_back(load_sound(datadir + soundfilenames[i]));
+ SoundManager::get()->add_sound(SoundManager::get()->load_sound(datadir + soundfilenames[i]),i);
/* Herring song */
- herring_song = sound_manager->load_music(datadir + "/music/SALCON.MOD");
- level_end_song = sound_manager->load_music(datadir + "/music/leveldone.mod");
+ herring_song = SoundManager::get()->load_music(datadir + "/music/SALCON.MOD");
+ level_end_song = SoundManager::get()->load_music(datadir + "/music/leveldone.mod");
}
for (int i = 0; i < DOOR_OPENING_FRAMES; i++)
delete door_opening[i];
- for (i = 0; i < NUM_SOUNDS; i++)
- free_chunk(sounds[i]);
-
delete sprite_manager;
sprite_manager = 0;
- delete sound_manager;
sound_manager = 0;
}
throw std::runtime_error("wrong bullet type.");
add_object(new_bullet);
- sound_manager->play_sound(sounds[SND_SHOOT]);
+ SoundManager::get()->play_sound(IDToSound(SND_SHOOT));
return true;
}
solids->change_at(pos, tile->next_tile);
}
- sound_manager->play_sound(sounds[SND_DISTRO]);
+ SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
player_status.score = player_status.score + SCORE_DISTRO;
player_status.distros++;
return true;
(int)(pos.y / 32) * 32), tile);
/* Get some score: */
- sound_manager->play_sound(sounds[SND_BRICK]);
+ SoundManager::get()->play_sound(IDToSound(SND_BRICK));
player_status.score = player_status.score + SCORE_BRICK;
return true;
{
case 1: // Box with a distro!
add_bouncy_distro(Vector(posx, posy));
- sound_manager->play_sound(sounds[SND_DISTRO]);
+ SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
player_status.score = player_status.score + SCORE_DISTRO;
player_status.distros++;
break;
add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
else /* Tux is big, add a fireflower: */
add_upgrade(Vector(posx, posy), col_side, UPGRADE_FIREFLOWER);
- sound_manager->play_sound(sounds[SND_UPGRADE]);
+ SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
break;
case 5: // Add an ice flower upgrade!
add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
else /* Tux is big, add an iceflower: */
add_upgrade(Vector(posx, posy), col_side, UPGRADE_ICEFLOWER);
- sound_manager->play_sound(sounds[SND_UPGRADE]);
+ SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
break;
case 3: // Add a golden herring
return;
solids->change_at(pos, tile->next_tile);
- sound_manager->play_sound(sounds[SND_DISTRO]);
+ SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
if (bounciness == BOUNCE)
{
char* song_path;
char* song_subtitle;
- level_song = sound_manager->load_music(datadir + "/music/" + song_title);
+ level_song = SoundManager::get()->load_music(datadir + "/music/" + song_title);
song_path = (char *) malloc(sizeof(char) * datadir.length() +
strlen(song_title.c_str()) + 8 + 5);
strcpy(strstr(song_subtitle, "."), "\0");
sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(),
song_subtitle, strstr(song_title.c_str(), "."));
- if(!sound_manager->exists_music(song_path)) {
+ if(!SoundManager::get()->exists_music(song_path)) {
level_song_fast = level_song;
} else {
- level_song_fast = sound_manager->load_music(song_path);
+ level_song_fast = SoundManager::get()->load_music(song_path);
}
free(song_subtitle);
free(song_path);
currentmusic = type;
switch(currentmusic) {
case HURRYUP_MUSIC:
- sound_manager->play_music(level_song_fast);
+ SoundManager::get()->play_music(level_song_fast);
break;
case LEVEL_MUSIC:
- sound_manager->play_music(level_song);
+ SoundManager::get()->play_music(level_song);
break;
case HERRING_MUSIC:
- sound_manager->play_music(herring_song);
+ SoundManager::get()->play_music(herring_song);
break;
default:
- sound_manager->halt_music();
+ SoundManager::get()->halt_music();
break;
}
}
#include "camera.h"
#include "gameloop.h"
#include "video/screen.h"
-#include "audio/sound.h"
#include "scene.h"
#include "app/globals.h"
#include "player.h"
if(kind != UPGRADE_GROWUP)
return;
- sound_manager->play_sound(sounds[SND_BUMP_UPGRADE], Vector(base.x, base.y), Sector::current()->player->get_pos());
+ SoundManager::get()->play_sound(IDToSound(SND_BUMP_UPGRADE), Vector(base.x, base.y), Sector::current()->player->get_pos());
// determine new direction
Direction old_dir = dir;
if (kind == UPGRADE_GROWUP)
{
- sound_manager->play_sound(sounds[SND_EXCELLENT]);
+ SoundManager::get()->play_sound(IDToSound(SND_EXCELLENT));
pplayer->grow(true);
}
else if (kind == UPGRADE_FIREFLOWER)
{
- sound_manager->play_sound(sounds[SND_COFFEE]);
+ SoundManager::get()->play_sound(IDToSound(SND_COFFEE));
pplayer->grow(true);
pplayer->got_power = pplayer->FIRE_POWER;
}
else if (kind == UPGRADE_ICEFLOWER)
{
- sound_manager->play_sound(sounds[SND_COFFEE]);
+ SoundManager::get()->play_sound(IDToSound(SND_COFFEE));
pplayer->grow(true);
pplayer->got_power = pplayer->ICE_POWER;
}
else if (kind == UPGRADE_FIREFLOWER)
{
- sound_manager->play_sound(sounds[SND_COFFEE]);
+ SoundManager::get()->play_sound(IDToSound(SND_COFFEE));
pplayer->grow(true);
pplayer->got_power = pplayer->FIRE_POWER;
}
else if (kind == UPGRADE_HERRING)
{
- sound_manager->play_sound(sounds[SND_HERRING]);
+ SoundManager::get()->play_sound(IDToSound(SND_HERRING));
pplayer->invincible_timer.start(TUX_INVINCIBLE_TIME);
Sector::current()->play_music(HERRING_MUSIC);
}
{
if(player_status.lives < MAX_LIVES) {
player_status.lives++;
- sound_manager->play_sound(sounds[SND_LIFEUP]);
+ SoundManager::get()->play_sound(IDToSound(SND_LIFEUP));
}
}
textdomain(PACKAGE);
bind_textdomain_codeset(PACKAGE, "ISO-8859-1");
- st_info_setup(PACKAGE_NAME,PACKAGE,PACKAGE_VERSION);
+ Setup::info(PACKAGE_NAME,PACKAGE,PACKAGE_VERSION);
- st_directory_setup();
- parseargs(argc, argv);
+ Setup::directories();
+ Setup::parseargs(argc, argv);
- st_audio_setup();
- st_video_setup(SCREEN_W,SCREEN_H);
- st_joystick_setup();
- st_general_setup();
+ Setup::audio();
+ Setup::video(SCREEN_W,SCREEN_H);
+ Setup::joystick();
+ Setup::general();
st_menu();
loadshared();
//SDL_Flip(screen);
unloadshared();
- st_general_free();
+ Setup::general_free();
st_menu_free();
TileManager::destroy_instance();
#ifdef DEBUG
Surface::debug_check();
#endif
- st_shutdown();
+ Termination::shutdown();
#ifndef DEBUG // we want to see the backtrace in gdb when in debug mode
}
catch (SuperTuxException &e)
lisp_object_t* root_obj = lisp_read_from_file(filename);
if (!root_obj)
- st_abort("Couldn't load file", filename);
+ Termination::abort("Couldn't load file", filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-tiles") == 0)
{
void generate_contrib_menu()
{
/** Generating contrib levels list by making use of Level Subset */
- string_list_type level_subsets = dsubdirs("/levels", "info");
+ string_list_type level_subsets = FileSystem::dsubdirs("/levels", "info");
free_contrib_menu();
img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", true);
/* Generating contrib maps by only using a string_list */
- worldmap_list = dfiles("levels/worldmap", NULL, "icyisland.stwm");
+ worldmap_list = FileSystem::dfiles("levels/worldmap", NULL, "icyisland.stwm");
titlesession->get_current_sector()->activate();
titlesession->set_current();
lisp_object_t* root_obj = lisp_read_from_file(stwt_filename);
if (!root_obj)
- st_abort("Couldn't load file", stwt_filename);
+ Termination::abort("Couldn't load file", stwt_filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap-tiles") == 0)
{
{
lisp_object_t* root_obj = lisp_read_from_file(datadir + "/levels/worldmap/" + map_filename);
if (!root_obj)
- st_abort("Couldn't load file", datadir + "/levels/worldmap/" + map_filename);
+ Termination::abort("Couldn't load file", datadir + "/levels/worldmap/" + map_filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap") == 0)
{
switch(event.type)
{
case SDL_QUIT:
- st_abort("Received window close", "");
+ Termination::abort("Received window close", "");
break;
case SDL_KEYDOWN:
break;
}
- sound_manager->play_music(song);
+ SoundManager::get()->play_music(song);
Menu::set_current(0);
if (!savegame_file.empty())
savegame(savegame_file);
quit = false;
- song = sound_manager->load_music(datadir + "/music/" + music);
- sound_manager->play_music(song);
+ song = SoundManager::get()->load_music(datadir + "/music/" + music);
+ SoundManager::get()->play_music(song);
unsigned int last_update_time;
unsigned int update_time;