indent confetti.c
This commit is contained in:
parent
44286395b3
commit
aac7e00ba2
1 changed files with 141 additions and 113 deletions
|
|
@ -26,15 +26,13 @@ char * confetti_get_name(magic_api * api, int which);
|
||||||
char *confetti_get_description(magic_api * api, int which, int mode);
|
char *confetti_get_description(magic_api * api, int which, int mode);
|
||||||
int confetti_requires_colors(magic_api * api, int which);
|
int confetti_requires_colors(magic_api * api, int which);
|
||||||
void confetti_release(magic_api * api, int which,
|
void confetti_release(magic_api * api, int which,
|
||||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||||
int x, int y, SDL_Rect * update_rect);
|
|
||||||
void confetti_shutdown(magic_api * api);
|
void confetti_shutdown(magic_api * api);
|
||||||
inline char confetti_get_greater(const char what1, const char what2);
|
inline char confetti_get_greater(const char what1, const char what2);
|
||||||
inline char confetti_get_lesser(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);
|
Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas);
|
||||||
void confetti_click(magic_api * api, int which, int mode,
|
void confetti_click(magic_api * api, int which, int mode,
|
||||||
SDL_Surface * canvas, SDL_Surface * last,
|
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||||
int x, int y, SDL_Rect * update_rect);
|
|
||||||
void confetti_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
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);
|
void confetti_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||||
int confetti_modes(magic_api * api, int which);
|
int confetti_modes(magic_api * api, int which);
|
||||||
|
|
@ -42,8 +40,7 @@ int confetti_modes(magic_api * api, int which);
|
||||||
// Housekeeping functions
|
// Housekeeping functions
|
||||||
|
|
||||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||||
SDL_Rect * update_rect);
|
|
||||||
|
|
||||||
Uint32 confetti_api_version(void)
|
Uint32 confetti_api_version(void)
|
||||||
{
|
{
|
||||||
|
|
@ -76,17 +73,25 @@ SDL_Surface * confetti_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%s/images/magic/confetti.png",
|
snprintf(fname, sizeof(fname), "%s/images/magic/confetti.png", api->data_directory);
|
||||||
api->data_directory);
|
|
||||||
|
|
||||||
return (IMG_Load(fname));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
char * confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Confetti")); }
|
char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
return strdup(gettext_noop("Confetti"));
|
||||||
|
}
|
||||||
|
|
||||||
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!")); }
|
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) { return 1; }
|
int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void confetti_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
void confetti_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||||
|
|
@ -96,14 +101,28 @@ void confetti_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
||||||
}
|
}
|
||||||
|
|
||||||
void confetti_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
void confetti_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
{ Mix_FreeChunk(confetti_snd); }
|
{
|
||||||
|
Mix_FreeChunk(confetti_snd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//private functions
|
//private functions
|
||||||
|
|
||||||
inline char confetti_get_greater(const char what1, const char what2) { if (what1>what2) return what1; else return what2; }
|
inline char confetti_get_greater(const char what1, const char what2)
|
||||||
|
{
|
||||||
|
if (what1 > what2)
|
||||||
|
return what1;
|
||||||
|
else
|
||||||
|
return what2;
|
||||||
|
}
|
||||||
|
|
||||||
inline char confetti_get_lesser(const char what1, const char what2) { if (what1<what2) return what1; else return what2; }
|
inline char confetti_get_lesser(const char what1, const char what2)
|
||||||
|
{
|
||||||
|
if (what1 < what2)
|
||||||
|
return what1;
|
||||||
|
else
|
||||||
|
return what2;
|
||||||
|
}
|
||||||
|
|
||||||
// Interactivity functions
|
// Interactivity functions
|
||||||
|
|
||||||
|
|
@ -129,8 +148,7 @@ Uint32 confetti_get_new_color(void * ptr, SDL_Surface * canvas) //this function
|
||||||
|
|
||||||
|
|
||||||
static void confetti_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
static void confetti_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED,
|
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||||
int x, int y)
|
|
||||||
{
|
{
|
||||||
magic_api *api = (magic_api *) ptr;
|
magic_api *api = (magic_api *) ptr;
|
||||||
|
|
||||||
|
|
@ -146,8 +164,7 @@ static void confetti_circle(void * ptr, int which ATTRIBUTE_UNUSED,
|
||||||
}
|
}
|
||||||
|
|
||||||
void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas, SDL_Surface * last,
|
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||||
int x, int y, SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
char min_x = 0, max_x = 0, min_y = 0, max_y = 0;
|
char min_x = 0, max_x = 0, min_y = 0, max_y = 0;
|
||||||
|
|
@ -183,22 +200,33 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
}
|
}
|
||||||
|
|
||||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||||
SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
if (ox>x) {temp=x; x=ox; ox=temp;}
|
if (ox > x)
|
||||||
if (oy>y) {temp=y; y=oy; oy=temp; }
|
{
|
||||||
|
temp = x;
|
||||||
|
x = ox;
|
||||||
|
ox = temp;
|
||||||
|
}
|
||||||
|
if (oy > y)
|
||||||
|
{
|
||||||
|
temp = y;
|
||||||
|
y = oy;
|
||||||
|
oy = temp;
|
||||||
|
}
|
||||||
|
|
||||||
confetti_click(api, which, MODE_PAINT, canvas, snapshot, x, y, update_rect);
|
confetti_click(api, which, MODE_PAINT, canvas, snapshot, x, y, update_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void confetti_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
void confetti_switchin(magic_api * api 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)
|
void confetti_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