indent foam.c
This commit is contained in:
parent
8eff6a9930
commit
c855261af2
1 changed files with 220 additions and 215 deletions
|
|
@ -46,14 +46,11 @@ Uint32 foam_api_version(void);
|
|||
int foam_init(magic_api * api);
|
||||
char *foam_get_description(magic_api * api, int which, int mode);
|
||||
void foam_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void foam_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void foam_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface *foam_get_icon(magic_api * api, int which);
|
||||
char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED);
|
||||
void foam_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
|
@ -67,7 +64,10 @@ int foam_requires_colors(magic_api * api, int which);
|
|||
#define FOAM_PROP 8
|
||||
#define FOAM_RADIUS 3
|
||||
|
||||
Uint32 foam_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
||||
Uint32 foam_api_version(void)
|
||||
{
|
||||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
|
||||
// No setup required:
|
||||
|
|
@ -76,22 +76,16 @@ int foam_init(magic_api * api)
|
|||
char fname[1024];
|
||||
SDL_Surface *foam_data;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/foam.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/foam.ogg", api->data_directory);
|
||||
foam_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/foam_data.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/foam_data.png", api->data_directory);
|
||||
foam_data = IMG_Load(fname);
|
||||
|
||||
foam_7 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 4) / 4, 0);
|
||||
foam_5 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 3) / 4, 0);
|
||||
foam_3 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 2) / 4, 0);
|
||||
foam_1 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 1) / 4, 0);
|
||||
foam_7 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4, ((api->canvas_h / FOAM_PROP) * 4) / 4, 0);
|
||||
foam_5 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4, ((api->canvas_h / FOAM_PROP) * 3) / 4, 0);
|
||||
foam_3 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4, ((api->canvas_h / FOAM_PROP) * 2) / 4, 0);
|
||||
foam_1 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4, ((api->canvas_h / FOAM_PROP) * 1) / 4, 0);
|
||||
|
||||
SDL_FreeSurface(foam_data);
|
||||
|
||||
|
|
@ -109,8 +103,7 @@ SDL_Surface * foam_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/foam.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/foam.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -129,11 +122,12 @@ char * foam_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
|
||||
// Do the effect:
|
||||
|
||||
static void do_foam(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
static void do_foam(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy, nx, ny;
|
||||
|
||||
/* SDL_Rect dest; */
|
||||
|
||||
for (yy = -FOAM_RADIUS; yy < FOAM_RADIUS; yy++)
|
||||
|
|
@ -145,9 +139,7 @@ static void do_foam(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas
|
|||
nx = (x / FOAM_PROP) + xx;
|
||||
ny = (y / FOAM_PROP) + yy;
|
||||
|
||||
if (nx >= 0 && ny >= 0 &&
|
||||
nx < foam_mask_w &&
|
||||
ny < foam_mask_h)
|
||||
if (nx >= 0 && ny >= 0 && nx < foam_mask_w && ny < foam_mask_h)
|
||||
{
|
||||
foam_mask[ny * foam_mask_w + nx] = 1;
|
||||
}
|
||||
|
|
@ -158,16 +150,27 @@ static void do_foam(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void foam_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_foam);
|
||||
|
||||
foam_release(api, which, canvas, last, x, y, update_rect);
|
||||
|
||||
/* FIXME */
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
if (ox > x)
|
||||
{
|
||||
int tmp = ox;
|
||||
|
||||
ox = x;
|
||||
x = tmp;
|
||||
}
|
||||
if (oy > y)
|
||||
{
|
||||
int tmp = oy;
|
||||
|
||||
oy = y;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -434,11 +437,13 @@ int foam_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0; /* FIXME: Would be nice to tint the bubbles */
|
||||
}
|
||||
|
||||
void foam_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
void foam_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void foam_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
void foam_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue