[Tux4kids-commits] r1403 - branches/commonification/tuxtype/trunk/src
Bolesław Kulbabiński
bolekk-guest at alioth.debian.org
Sun Aug 9 00:04:37 UTC 2009
Author: bolekk-guest
Date: 2009-08-09 00:04:36 +0000 (Sun, 09 Aug 2009)
New Revision: 1403
Modified:
branches/commonification/tuxtype/trunk/src/audio.c
branches/commonification/tuxtype/trunk/src/globals.h
branches/commonification/tuxtype/trunk/src/laser.c
branches/commonification/tuxtype/trunk/src/laser.h
branches/commonification/tuxtype/trunk/src/main.c
branches/commonification/tuxtype/trunk/src/pause.c
branches/commonification/tuxtype/trunk/src/playgame.c
branches/commonification/tuxtype/trunk/src/practice.c
branches/commonification/tuxtype/trunk/src/scripting.c
branches/commonification/tuxtype/trunk/src/titlescreen.c
Log:
tuxtype games make use of fileops_media's sounds
Modified: branches/commonification/tuxtype/trunk/src/audio.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/audio.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/audio.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -41,7 +41,7 @@
if (!settings.sys_sound) return;
if (!musicFilename) return;
- tmp_music = LoadMusicNoPrefix(musicFilename);
+ tmp_music = LoadMusic(musicFilename);
if (tmp_music)
{
Modified: branches/commonification/tuxtype/trunk/src/globals.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/globals.h 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/globals.h 2009-08-09 00:04:36 UTC (rev 1403)
@@ -236,20 +236,6 @@
extern SDL_Event event;
-
-enum
-{
- WIN_WAV,
- BITE_WAV,
- LOSE_WAV,
- RUN_WAV,
- SPLAT_WAV,
- WINFINAL_WAV,
- EXCUSEME_WAV,
- PAUSE_WAV,
- NUM_WAVES
-};
-
#define MUSIC_FADE_OUT_MS 80
#endif
Modified: branches/commonification/tuxtype/trunk/src/laser.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/laser.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/laser.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -21,6 +21,7 @@
#include "funcs.h"
#include "SDL_extras.h"
#include "laser.h"
+#include "fileops_media.h"
#define FPS (1000 / 15) /* 15 fps max */
@@ -36,8 +37,6 @@
/* Local (to laser.c) 'globals': */
static sprite* shield = NULL;
static SDL_Surface* images[NUM_IMAGES] = {NULL};
-static Mix_Chunk* sounds[NUM_SOUNDS] = {NULL};
-static Mix_Music* musics[NUM_MUSICS] = {NULL};
static int wave, speed, score, pre_wave_score, num_attackers, distanceMoved;
static wchar_t ans[NUM_ANS];
@@ -712,14 +711,6 @@
images[i] = LoadImageNoPrefix(image_filenames[i], IMG_ALPHA);
shield = LoadSpriteNoPrefix( "/images/cities/shield", IMG_ALPHA );
- if (settings.sys_sound) {
- for (i = 0; i < NUM_SOUNDS; i++)
- sounds[i] = LoadSoundNoPrefix(sound_filenames[i]);
-
- for (i = 0; i < NUM_MUSICS; i++)
- musics[i] = LoadMusicNoPrefix(music_filenames[i]);
- }
-
// PauseLoadMedia();
}
@@ -733,13 +724,6 @@
for (i = 0; i < NUM_IMAGES; i++)
SDL_FreeSurface(images[i]);
- if (settings.sys_sound) {
- for (i = 0; i < NUM_SOUNDS; i++)
- Mix_FreeChunk(sounds[i]);
- for (i = 0; i < NUM_MUSICS; i++)
- Mix_FreeMusic(musics[i]);
- }
-
FreeSprite(shield);
shield = NULL;
}
Modified: branches/commonification/tuxtype/trunk/src/laser.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/laser.h 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/laser.h 2009-08-09 00:04:36 UTC (rev 1403)
@@ -149,40 +149,4 @@
"/images/status/gameover.png"
};
-enum {
- SND_POP,
- SND_LASER,
- SND_BUZZ,
- SND_ALARM,
- SND_SHIELDSDOWN,
- SND_EXPLOSION,
- SND_CLICK,
- NUM_SOUNDS
-};
-
-
-static char* sound_filenames[NUM_SOUNDS] = {
- "/sounds/pop.wav",
- "/sounds/laser.wav",
- "/sounds/buzz.wav",
- "/sounds/alarm.wav",
- "/sounds/shieldsdown.wav",
- "/sounds/explosion.wav",
- "/sounds/click.wav"
-};
-
-
-enum {
- MUS_GAME,
- MUS_GAME2,
- MUS_GAME3,
- NUM_MUSICS
-};
-
-static char * music_filenames[NUM_MUSICS] = {
- "/sounds/game.mod",
- "/sounds/game2.mod",
- "/sounds/game3.mod"
-};
-
#endif
Modified: branches/commonification/tuxtype/trunk/src/main.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/main.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/main.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -208,16 +208,16 @@
srand(time(NULL));
Opts_Initialize(); // First, initialize settings with hard-coded defaults
+ // This sets settings.default_data_path to the default theme file path:
+ SetupPaths(NULL);
+ LoadSettings(); // Second, read saved any saved settings
+
handle_command_args(argc, argv);
#ifdef HAVE_LIBT4KCOMMON
InitT4KCommon(debug_status);
#endif
- // This sets settings.default_data_path to the default theme file path:
- SetupPaths(NULL);
- LoadSettings(); // Second, read saved any saved settings
-
DEBUGMSG(debug_setup, "\n%s, version %s BEGIN\n", PACKAGE, VERSION);
//Now initialize locale/gettext system.
Modified: branches/commonification/tuxtype/trunk/src/pause.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/pause.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/pause.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -19,8 +19,8 @@
#include "globals.h"
#include "funcs.h"
#include "SDL_extras.h"
+#include "fileops_media.h"
-static Mix_Chunk *pause_sfx = NULL;
static SDL_Surface *up = NULL, *down = NULL, *left = NULL, *right = NULL;
static SDL_Rect rectUp, rectDown, rectLeft, rectRight;
const int pause_font_size1 = 24;
@@ -57,7 +57,7 @@
if (settings.sys_sound) {
Mix_Pause(-1);
- Mix_PlayChannel(-1, pause_sfx, 0);
+ Mix_PlayChannel(-1, sounds[SND_TOCK], 0);
sfx_volume = Mix_Volume(-1, -1); // get sfx volume w/o changing it
mus_volume = Mix_VolumeMusic(-1); // get mus volume w/o changing it
}
@@ -173,7 +173,7 @@
if (sfx_volume != old_sfx_volume) {
Mix_Volume(-1,sfx_volume);
if (tocks%4==0)
- Mix_PlayChannel(-1, pause_sfx, 0);
+ Mix_PlayChannel(-1, sounds[SND_TOCK], 0);
tocks++;
}
@@ -194,7 +194,7 @@
SDL_ShowCursor(0);
if (settings.sys_sound) {
- Mix_PlayChannel(-1, pause_sfx, 0);
+ Mix_PlayChannel(-1, sounds[SND_TOCK], 0);
Mix_Resume(-1);
}
@@ -207,9 +207,6 @@
static void pause_load_media(void) {
- if (settings.sys_sound)
- pause_sfx = LoadSoundNoPrefix( "/sounds/tock.wav" );
-
up = LoadImageNoPrefix("/images/up.png", IMG_ALPHA);
rectUp.w = up->w; rectUp.h = up->h;
@@ -226,17 +223,12 @@
// f2 = LoadFont(settings.theme_font_name, 36);
}
-static void pause_unload_media(void) {
- if (settings.sys_sound)
- {
- Mix_FreeChunk(pause_sfx);
- pause_sfx = NULL;
- }
+static void pause_unload_media(void){
SDL_FreeSurface(up);
SDL_FreeSurface(down);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
- up = down = left = right = NULL;
+ up = down = left = right = NULL;
}
Modified: branches/commonification/tuxtype/trunk/src/playgame.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/playgame.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/playgame.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -22,6 +22,7 @@
#include "playgame.h"
#include "snow.h"
#include "SDL_extras.h"
+#include "fileops_media.h"
/* Should these be constants? */
@@ -37,7 +38,6 @@
static SDL_Surface* fish = NULL;
static SDL_Surface* congrats[CONGRATS_FRAMES] = {NULL};
static SDL_Surface* ohno[OH_NO_FRAMES] = {NULL};
-static Mix_Chunk* sound[NUM_WAVES];
static sprite* fish_sprite = NULL;
static sprite* splat_sprite = NULL;
@@ -211,10 +211,7 @@
ResetObjects();
if (settings.sys_sound)
- {
- sprintf(filename, "/sounds/kmus%i.wav", curlevel + 1);
- AudioMusicLoad( filename, -1 );
- }
+ MusicPlay(musics[MUS_KMUS1 + curlevel], -1);
setup_new_level = 0;
@@ -245,7 +242,7 @@
{
if (event.type == SDL_KEYDOWN)
{
- if (event.key.keysym.sym == SDLK_F11)
+ if (event.key.keysym.sym == SDLK_F11)
SDL_SaveBMP(screen, "screenshot.bmp");
if (event.key.keysym.sym == SDLK_F6)
@@ -429,12 +426,12 @@
xamp = WIN_GAME_XAMP;
yamp = WIN_GAME_YAMP;
- if (settings.sys_sound)
- Mix_PlayChannel(WINFINAL_WAV, sound[WINFINAL_WAV], 0);
+ if (settings.sys_sound)
+ PlaySound(sounds[SND_WINFINAL]);
}
- if (settings.sys_sound)
- Mix_PlayChannel(WIN_WAV, sound[WIN_WAV], 0);
+ if (settings.sys_sound)
+ PlaySound(sounds[SND_WIN]);
for (i = 0; i < CONGRATS_FRAMES; i++)
temp_text[i] = congrats[i];
@@ -451,7 +448,7 @@
yamp = 0;
if (settings.sys_sound)
- Mix_PlayChannel(LOSE_WAV, sound[LOSE_WAV], 0);
+ PlaySound(sounds[SND_LOSE]);
for (i = 0; i < OH_NO_FRAMES; i++)
temp_text[i] = ohno[i];
@@ -641,24 +638,7 @@
for (i = 0; i < OH_NO_FRAMES; i++) {
ohno[i] = BlackOutline(gettext("Oh No!"), LABEL_FONT_SIZE, &white);
}
-
- if (settings.sys_sound) {
- LOG( "=Loading Sound FX\n" );
- sound[WIN_WAV] = LoadSoundNoPrefix( "/sounds/win.wav" );
- sound[WINFINAL_WAV] = LoadSoundNoPrefix( "/sounds/winfinal.wav" );
- sound[BITE_WAV] = LoadSoundNoPrefix( "/sounds/bite.wav" );
- sound[LOSE_WAV] = LoadSoundNoPrefix( "/sounds/lose.wav" );
- sound[RUN_WAV] = LoadSoundNoPrefix( "/sounds/run.wav" );
- sound[SPLAT_WAV] = LoadSoundNoPrefix( "/sounds/splat.wav" );
- sound[EXCUSEME_WAV] = LoadSoundNoPrefix( "/sounds/excuseme.wav" );
-
- LOG( "=Done Loading Sound FX\n" );
- } else
- LOG( "=NO SOUND FX LOADED (not selected)\n" );
-
-// PauseLoadMedia();
-
LOG( "=Setting NULL fish & splat & word\n" );
null_fishy.alive = 0;
@@ -885,19 +865,7 @@
SDL_FreeSurface(ohno[i]);
ohno[i] = NULL;
}
- if (settings.sys_sound)
- {
- LOG( "-Freeing sound\n" );
- for (i = 0; i < NUM_WAVES; ++i)
- {
- if (sound[i])
- Mix_FreeChunk(sound[i]);
- sound[i] = NULL;
- }
- }
-// PauseUnloadMedia();
-
LOG( "FreeGame(): END\n" );
}
@@ -1154,8 +1122,8 @@
if (*curlives <= 0)
*curlives = 0;
- if (settings.sys_sound)
- Mix_PlayChannel(SPLAT_WAV, sound[SPLAT_WAV], 0);
+ if (settings.sys_sound)
+ PlaySound(sounds[SND_SPLAT]);
LOG("Enterint AddSplat()\n");
}
@@ -1349,7 +1317,7 @@
(fish_object[i].x + (fish_object[i].w+fish_sprite->frame[0]->w)/2 <= tux_object.x + tux_max_width)) {
if (fish_object[i].can_eat) {
- LOG( "**EATING A FISHY** - in CheckCollision()\n" );
+ LOG( "**EATING A FISHY** - in CheckCollision()\n" );
fish_object[i].alive = 0;
fish_object[i].can_eat = 0;
@@ -1364,13 +1332,13 @@
tux_object.dx = 0;
tux_object.endx = tux_object.x;
- if (settings.sys_sound) Mix_PlayChannel(BITE_WAV, sound[BITE_WAV], 0);
+ if (settings.sys_sound) PlaySound(sounds[SND_BITE]);
} else if (tux_object.state == TUX_STANDING) {
LOG( "***EXCUSE ME!** - in CheckCollision()\n" );
- if (settings.sys_sound && !Mix_Playing(EXCUSEME_WAV))
- Mix_PlayChannel(EXCUSEME_WAV, sound[EXCUSEME_WAV], 0);
+ if (settings.sys_sound) // FIXME: was: && !Mix_Playing(EXCUSEME_WAV))
+ PlaySound(sounds[SND_EXCUSEME]);
}
}
}
@@ -1425,17 +1393,17 @@
tux_object.dx = WALKING_SPEED;
tux_object.state = TUX_WALKING;
- //stop running sound (if playing)
- if (settings.sys_sound && Mix_Playing(RUN_WAV))
- Mix_HaltChannel(RUN_WAV);
+ //stop running sound (if playing)
+ //if (settings.sys_sound) // FIXME: was: && Mix_Playing(RUN_WAV))
+ //Mix_HaltChannel(RUN_WAV);
} else {
- if (time_to_splat > frame)
+ if (time_to_splat > frame)
tux_object.dx = float_restrict( MIN_RUNNING_SPEED, abs(tux_object.endx - tux_object.x) / (time_to_splat-frame), MAX_RUNNING_SPEED );
else {
tux_object.dx = MAX_RUNNING_SPEED;
- if (settings.sys_sound && !Mix_Playing(RUN_WAV))
+ if (settings.sys_sound) // FIXME: was: && !Mix_Playing(RUN_WAV))
if (abs(tux_object.endx - tux_object.x) > 50)
- Mix_PlayChannel(RUN_WAV, sound[RUN_WAV], 0);
+ PlaySound(sounds[SND_RUN]);
}
tux_object.state = TUX_RUNNING;
@@ -1445,7 +1413,6 @@
}
/* --- move tux (if moving) --- */
-
tux_object.x = float_restrict(0, tux_object.x + (tux_object.facing==RIGHT ? 1.0 : -1.0)*tux_object.dx, (screen->w - tux_max_width));
/* if done with certain frames, then reset to standing */
Modified: branches/commonification/tuxtype/trunk/src/practice.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/practice.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/practice.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -25,6 +25,7 @@
#include "funcs.h"
#include "SDL_extras.h"
#include "convert_utf.h"
+#include "fileops_media.h"
#define MAX_PHRASES 256
#define MAX_PHRASE_LENGTH 256
@@ -54,10 +55,7 @@
static wchar_t phrases[MAX_PHRASES][MAX_PHRASE_LENGTH];
-static Mix_Chunk* wrong = NULL;
-static Mix_Chunk* cheer = NULL;
-
static int phrase_draw_width = 0; /* How wide before text needs wrapping */
static int num_phrases = 0;
@@ -739,7 +737,7 @@
{
int done = 0;
- PlaySound(cheer);
+ PlaySound(sounds[SND_CHEER]);
while (!done)
{
@@ -797,7 +795,7 @@
||(event.key.keysym.sym != SDLK_SPACE))
{
wrong_chars++;
- PlaySound(wrong);
+ PlaySound(sounds[SND_BUZZ]);
}
}
}
@@ -876,9 +874,6 @@
/* load tux sprites: */
tux_win = LoadSpriteNoPrefix("/images/tux/win", IMG_COLORKEY);
tux_stand = LoadSpriteNoPrefix("/images/tux/stand", IMG_COLORKEY);
- /* load needed sounds: */
- wrong = LoadSoundNoPrefix("/sounds/buzz.wav");
- cheer = LoadSoundNoPrefix("/sounds/cheer.wav");
/* load needed fonts: */
calc_font_sizes();
@@ -1167,14 +1162,6 @@
FreeSprite(tux_win);
tux_win = NULL;
}
-
- if (cheer)
- Mix_FreeChunk(cheer);
- cheer = NULL;
-
- if (wrong)
- Mix_FreeChunk(wrong);
- wrong = NULL;
}
Modified: branches/commonification/tuxtype/trunk/src/scripting.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/scripting.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/scripting.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -930,7 +930,7 @@
static void run_script(void)
{
/* FIXME FNLEN doesn't make sense for size of these arrays */
- Mix_Chunk* sounds[FNLEN] = {NULL};
+ Mix_Chunk* snds[FNLEN] = {NULL};
/* --- for on mouse click on an image --- */
Mix_Chunk* clickWavs[FNLEN] = {NULL};
@@ -1141,8 +1141,8 @@
case itemWAV:
{
// HACK, we need to make sure no more than 8 sounds or so..
- sounds[numWavs] = LoadSoundNoPrefix( curItem->data );
- Mix_PlayChannel( numWavs, sounds[numWavs], -curItem->loop );
+ snds[numWavs] = LoadSoundNoPrefix( curItem->data );
+ Mix_PlayChannel( numWavs, snds[numWavs], -curItem->loop );
numWavs++;
break;
}
@@ -1309,7 +1309,7 @@
for (i=0; i<numWavs; i++)
{
Mix_HaltChannel(i);
- Mix_FreeChunk(sounds[i]);
+ Mix_FreeChunk(snds[i]);
}
for (i = 0; i < numClicks; i++)
Modified: branches/commonification/tuxtype/trunk/src/titlescreen.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/titlescreen.c 2009-08-08 22:30:05 UTC (rev 1402)
+++ branches/commonification/tuxtype/trunk/src/titlescreen.c 2009-08-09 00:04:36 UTC (rev 1403)
@@ -24,6 +24,7 @@
#include "titlescreen.h"
#include "SDL_extras.h"
#include "convert_utf.h"
+#include "fileops_media.h"
/* these are all menu choices that are available in tuxtype.
By using a define we can create both an enum and
@@ -64,6 +65,7 @@
const char* egg_path = "/images/title/egg.svg";
const char* tux_path = "/images/tux";
char* menu_music_path = "/sounds/tuxi.ogg";
+char* full_menu_music_path;
/* beak coordinates relative to tux rect */
const float beak_pos[4] = {0.36, 0.21, 0.27, 0.14};
@@ -140,11 +142,10 @@
* Display the Standby screen....
*/
show_logo();
- snd_welcome = LoadSoundNoPrefix("/sounds/harp.wav");
- if (snd_welcome && settings.menu_sound)
+ if (sounds[SND_HARP] && settings.menu_sound)
{
- PlaySound(snd_welcome);
+ PlaySound(sounds[SND_HARP]);
}
SDL_WM_GrabInput(SDL_GRAB_ON); // User input goes to TuxType, not window manager
@@ -161,7 +162,8 @@
/* load menus */
SetActivitiesList(N_OF_ACTIVITIES, activities);
SetImagePathPrefix(settings.default_data_path);
- //SetMenuSounds(menu_music_path, sounds[SND_POP], sounds[SND_TOCK]);
+ full_menu_music_path = GetFullPath(menu_music_path);
+ SetMenuSounds(full_menu_music_path, sounds[SND_POP], sounds[SND_TOCK]);
sprintf(fn, "%s%s", settings.default_data_path, "/menus/main_menu.xml");
LoadMenu(MENU_MAIN, fn);
PrerenderAll();
@@ -241,16 +243,15 @@
SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest);
*/
/* Start playing menu music if desired: */
- if (settings.menu_music)
- AudioMusicLoad( "/sounds/tuxi.ogg", -1 );
LOG( "Tux and Title are in place now\n" );
SDL_WM_GrabInput(SDL_GRAB_OFF);
-
+ AudioMusicLoad(full_menu_music_path, -1);
run_main_menu();
+ free(full_menu_music_path);
LOG( "->>Freeing title screen images\n" );
@@ -484,6 +485,7 @@
FreeBothBkgds();
LoadBothBkgds(bkg_path);
SDL_ShowCursor(1);
+ AudioMusicLoad(full_menu_music_path, -1);
return 0;
}
More information about the Tux4kids-commits
mailing list