Finished Fade, Darken, Mirror, Flip and Negative Magic tools as plugins.
This commit is contained in:
parent
4aaec931be
commit
535220e921
3 changed files with 52 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include "tp_magic_api.h"
|
#include "tp_magic_api.h"
|
||||||
#include "SDL_image.h"
|
#include "SDL_image.h"
|
||||||
|
#include "SDL_mixer.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TOOL_FADE,
|
TOOL_FADE,
|
||||||
|
|
@ -10,12 +11,21 @@ enum {
|
||||||
NUM_TOOLS
|
NUM_TOOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
Mix_Chunk * snd_effects[NUM_TOOLS];
|
||||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
|
||||||
|
|
||||||
// No setup required:
|
|
||||||
int fade_darken_init(magic_api * api)
|
int fade_darken_init(magic_api * api)
|
||||||
{
|
{
|
||||||
|
char fname[1024];
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/fade.wav",
|
||||||
|
api->data_directory);
|
||||||
|
snd_effects[TOOL_FADE] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/darken.wav",
|
||||||
|
api->data_directory);
|
||||||
|
snd_effects[TOOL_DARKEN] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,6 +122,7 @@ void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_LockSurface(canvas);
|
SDL_LockSurface(canvas);
|
||||||
|
|
||||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_fade_darken);
|
api->line(which, canvas, last, ox, oy, x, y, 1, do_fade_darken);
|
||||||
|
api->playsound(snd_effects[which], (x * 255) / canvas->w, 255);
|
||||||
|
|
||||||
SDL_UnlockSurface(canvas);
|
SDL_UnlockSurface(canvas);
|
||||||
SDL_UnlockSurface(last);
|
SDL_UnlockSurface(last);
|
||||||
|
|
@ -129,6 +140,10 @@ void fade_darken_click(magic_api * api, int which,
|
||||||
// No setup happened:
|
// No setup happened:
|
||||||
void fade_darken_shutdown(magic_api * api)
|
void fade_darken_shutdown(magic_api * api)
|
||||||
{
|
{
|
||||||
|
if (snd_effects[0] != NULL)
|
||||||
|
Mix_FreeChunk(snd_effects[0]);
|
||||||
|
if (snd_effects[1] != NULL)
|
||||||
|
Mix_FreeChunk(snd_effects[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use colors
|
// We don't use colors
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include "tp_magic_api.h"
|
#include "tp_magic_api.h"
|
||||||
#include "SDL_image.h"
|
#include "SDL_image.h"
|
||||||
|
#include "SDL_mixer.h"
|
||||||
|
|
||||||
/* What tools we contain: */
|
/* What tools we contain: */
|
||||||
|
|
||||||
|
|
@ -12,9 +13,22 @@ enum {
|
||||||
NUM_TOOLS
|
NUM_TOOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Mix_Chunk * snd_effects[NUM_TOOLS];
|
||||||
|
|
||||||
|
|
||||||
// No setup required:
|
// No setup required:
|
||||||
int mirror_flip_init(magic_api * api)
|
int mirror_flip_init(magic_api * api)
|
||||||
{
|
{
|
||||||
|
char fname[1024];
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/mirror.wav",
|
||||||
|
api->data_directory);
|
||||||
|
snd_effects[TOOL_MIRROR] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/flip.wav",
|
||||||
|
api->data_directory);
|
||||||
|
snd_effects[TOOL_FLIP] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,11 +130,17 @@ void mirror_flip_click(magic_api * api, int which,
|
||||||
|
|
||||||
api->special_notify(SPECIAL_FLIP);
|
api->special_notify(SPECIAL_FLIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api->playsound(snd_effects[which], 128, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No setup happened:
|
// No setup happened:
|
||||||
void mirror_flip_shutdown(magic_api * api)
|
void mirror_flip_shutdown(magic_api * api)
|
||||||
{
|
{
|
||||||
|
if (snd_effects[0] != NULL)
|
||||||
|
Mix_FreeChunk(snd_effects[0]);
|
||||||
|
if (snd_effects[1] != NULL)
|
||||||
|
Mix_FreeChunk(snd_effects[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use colors:
|
// We don't use colors:
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,20 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include "tp_magic_api.h"
|
#include "tp_magic_api.h"
|
||||||
#include "SDL_image.h"
|
#include "SDL_image.h"
|
||||||
|
#include "SDL_mixer.h"
|
||||||
|
|
||||||
|
Mix_Chunk * negative_snd;
|
||||||
|
|
||||||
// No setup required:
|
// No setup required:
|
||||||
int negative_init(magic_api * api)
|
int negative_init(magic_api * api)
|
||||||
{
|
{
|
||||||
|
char fname[1024];
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/negative.wav",
|
||||||
|
api->data_directory);
|
||||||
|
|
||||||
|
negative_snd = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,6 +84,8 @@ void negative_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_LockSurface(canvas);
|
SDL_LockSurface(canvas);
|
||||||
|
|
||||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_negative);
|
api->line(which, canvas, last, ox, oy, x, y, 1, do_negative);
|
||||||
|
|
||||||
|
api->playsound(negative_snd, (x * 255) / canvas->w, 255);
|
||||||
|
|
||||||
SDL_UnlockSurface(canvas);
|
SDL_UnlockSurface(canvas);
|
||||||
SDL_UnlockSurface(last);
|
SDL_UnlockSurface(last);
|
||||||
|
|
@ -88,9 +100,10 @@ void negative_click(magic_api * api, int which,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// No setup happened:
|
|
||||||
void negative_shutdown(magic_api * api)
|
void negative_shutdown(magic_api * api)
|
||||||
{
|
{
|
||||||
|
if (negative_snd != NULL)
|
||||||
|
Mix_FreeChunk(negative_snd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use colors
|
// We don't use colors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue