Adding "indent.sh" to re-indent code; ran it!!!
This commit is contained in:
parent
16336cc854
commit
18f9cad6fe
98 changed files with 5798 additions and 9001 deletions
|
|
@ -8,7 +8,8 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle
|
||||
static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle
|
||||
|
||||
#define CONFETTI_QUANTITY 3 //how many circles will be created every click?
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
@ -36,37 +37,34 @@ int confetti_get_group(magic_api * api, int which);
|
|||
char *confetti_get_description(magic_api * api, int which, int mode);
|
||||
int confetti_requires_colors(magic_api * api, int which);
|
||||
void confetti_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void confetti_shutdown(magic_api * api);
|
||||
inline char confetti_get_greater(const char what1, const char what2);
|
||||
inline char confetti_get_lesser(const char what1, const char what2);
|
||||
Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas);
|
||||
void confetti_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void confetti_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void confetti_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void confetti_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void confetti_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int confetti_modes(magic_api * api, int which);
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
Uint8 confetti_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 confetti_default_size(magic_api * api, int which, int mode);
|
||||
void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 confetti_api_version(void)
|
||||
{
|
||||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void confetti_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void confetti_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g,
|
||||
Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
confetti_colors.r = r;
|
||||
|
|
@ -78,8 +76,7 @@ int confetti_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg", api->data_directory);
|
||||
confetti_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -94,33 +91,27 @@ SDL_Surface *confetti_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/confetti.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/confetti.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Confetti"));
|
||||
}
|
||||
|
||||
int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Click to throw confetti!"));
|
||||
}
|
||||
|
||||
int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -129,8 +120,7 @@ void confetti_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -183,27 +173,23 @@ Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas) //this function
|
|||
|
||||
|
||||
static void confetti_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
int xx, yy;
|
||||
Uint32 color = confetti_get_new_color(api, canvas);
|
||||
|
||||
for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2;
|
||||
yy++)
|
||||
for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2; yy++)
|
||||
|
||||
for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2;
|
||||
xx++)
|
||||
for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2; xx++)
|
||||
|
||||
if (api->in_circle(xx - x, yy - y, CONFETTI_BRUSH_SIZE / 2))
|
||||
api->putpixel(canvas, xx, yy, color);
|
||||
}
|
||||
|
||||
void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
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)
|
||||
{
|
||||
unsigned char i;
|
||||
char min_x = 0, max_x = 0, min_y = 0, max_y = 0;
|
||||
|
|
@ -212,8 +198,8 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
for (i = 0; i < CONFETTI_QUANTITY; i++)
|
||||
{
|
||||
srand((dx + dy) / 2 + time(0)); //to get a unique seed even if dx and dy aren't defined
|
||||
dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50>
|
||||
dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position
|
||||
dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50>
|
||||
dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position
|
||||
|
||||
if (!i)
|
||||
{
|
||||
|
|
@ -227,7 +213,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
min_y = confetti_get_lesser(min_y, dy);
|
||||
max_y = confetti_get_greater(max_y, dy);
|
||||
}
|
||||
confetti_circle((void *) api, which, canvas, last, x + dx, y + dy);
|
||||
confetti_circle((void *)api, which, canvas, last, x + dx, y + dy);
|
||||
}
|
||||
|
||||
update_rect->x = x + min_x - CONFETTI_BRUSH_SIZE / 2;
|
||||
|
|
@ -239,8 +225,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int temp;
|
||||
|
||||
|
|
@ -261,19 +246,16 @@ void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void confetti_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void confetti_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int confetti_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -289,7 +271,9 @@ Uint8 confetti_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 2;
|
||||
}
|
||||
|
||||
void confetti_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void confetti_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
CONFETTI_BRUSH_SIZE = size * 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue