indent rosette.c
This commit is contained in:
parent
fea1b424ba
commit
ac74e0ed51
1 changed files with 123 additions and 113 deletions
|
|
@ -57,23 +57,18 @@ char * rosette_get_name(magic_api * api, int which);
|
|||
char *rosette_get_description(magic_api * api, int which, int mode);
|
||||
int rosette_requires_colors(magic_api * api, int which);
|
||||
void rosette_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 rosette_shutdown(magic_api * api);
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void rosette_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);
|
||||
|
||||
void rosette_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);
|
||||
void rosette_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rosette_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int rosette_modes(magic_api * api, int which);
|
||||
void rosette_circle(void * ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int x, int y);
|
||||
void rosette_circle(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
Uint32 rosette_api_version(void)
|
||||
{
|
||||
|
|
@ -108,12 +103,19 @@ SDL_Surface * rosette_get_icon(magic_api * api, int which)
|
|||
|
||||
if (!which)
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/rosette.png", api->data_directory);
|
||||
else snprintf(fname, sizeof(fname), "%s/images/magic/picasso.png", api->data_directory);
|
||||
else
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/picasso.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char * rosette_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) { if (!which) return strdup(gettext_noop("Rosette")); else return strdup(gettext_noop("Picasso"));}
|
||||
char *rosette_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
if (!which)
|
||||
return strdup(gettext_noop("Rosette"));
|
||||
else
|
||||
return strdup(gettext_noop("Picasso"));
|
||||
}
|
||||
|
||||
char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
|
@ -123,7 +125,10 @@ char * rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int
|
|||
return strdup(gettext_noop("You can draw just like Picasso!")); //what is this actually doing?
|
||||
}
|
||||
|
||||
int rosette_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; }
|
||||
int rosette_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void rosette_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
|
|
@ -131,13 +136,15 @@ void rosette_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
|
|||
{
|
||||
}
|
||||
|
||||
void rosette_shutdown(magic_api * api ATTRIBUTE_UNUSED) { Mix_FreeChunk(rosette_snd); }
|
||||
void rosette_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
||||
{
|
||||
Mix_FreeChunk(rosette_snd);
|
||||
}
|
||||
|
||||
// Interactivity functions
|
||||
|
||||
void rosette_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -175,13 +182,17 @@ void rosette_draw(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * sna
|
|||
{
|
||||
angle = atan(yy / xx);
|
||||
|
||||
if ((xx<0) && (yy>0)) angle+=M_PI;
|
||||
if ((xx < 0) && (yy > 0))
|
||||
angle += M_PI;
|
||||
|
||||
if ((xx<0) && (yy<0)) angle+=M_PI;
|
||||
if ((xx < 0) && (yy < 0))
|
||||
angle += M_PI;
|
||||
|
||||
if ((xx>0) && (yy<0)) angle+=2*M_PI;
|
||||
if ((xx > 0) && (yy < 0))
|
||||
angle += 2 * M_PI;
|
||||
|
||||
if ((y==ymid) && (xx<0)) angle=M_PI;
|
||||
if ((y == ymid) && (xx < 0))
|
||||
angle = M_PI;
|
||||
|
||||
x1 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y1 = (int)(xx * sin(2 * angle) - yy * cos(angle));
|
||||
|
|
@ -196,8 +207,7 @@ void rosette_draw(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * sna
|
|||
}
|
||||
|
||||
void rosette_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)
|
||||
{
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, rosette_draw);
|
||||
api->playsound(rosette_snd, (x * 255) / canvas->w, 255);
|
||||
|
|
@ -208,19 +218,20 @@ void rosette_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void rosette_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)
|
||||
{
|
||||
rosette_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
||||
void rosette_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
void rosette_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
xmid = canvas->w / 2;
|
||||
ymid = canvas->h / 2;
|
||||
}
|
||||
|
||||
void rosette_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
void rosette_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -229,4 +240,3 @@ int rosette_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue