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
|
|
@ -36,7 +36,7 @@
|
|||
#include "SDL_mixer.h"
|
||||
#include <math.h> //for sin, cos, ...
|
||||
|
||||
static int ROSETTE_R = 8; //circle's diameter
|
||||
static int ROSETTE_R = 8; //circle's diameter
|
||||
|
||||
static int xmid, ymid;
|
||||
|
||||
|
|
@ -62,28 +62,22 @@ int rosette_get_group(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_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);
|
||||
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);
|
||||
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);
|
||||
Uint8 rosette_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rosette_default_size(magic_api * api, int which, int mode);
|
||||
void rosette_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void rosette_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 rosette_api_version(void)
|
||||
|
|
@ -91,8 +85,9 @@ Uint32 rosette_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void rosette_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 rosette_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
|
||||
rosette_colors.r = r;
|
||||
|
|
@ -104,8 +99,7 @@ int rosette_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/picasso.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/picasso.ogg", api->data_directory);
|
||||
rosette_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -121,11 +115,9 @@ SDL_Surface *rosette_get_icon(magic_api * api, int which)
|
|||
char fname[1024];
|
||||
|
||||
if (!which)
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rosette.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rosette.png", api->data_directory);
|
||||
else
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/picasso.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/picasso.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -138,14 +130,12 @@ char *rosette_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return strdup(gettext_noop("Picasso"));
|
||||
}
|
||||
|
||||
int rosette_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rosette_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PATTERN_PAINTING;
|
||||
}
|
||||
|
||||
char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (!which)
|
||||
return strdup(gettext_noop("Click and start drawing your rosette.")); //just k'scope with 3 bits?
|
||||
|
|
@ -153,8 +143,7 @@ char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
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)
|
||||
int rosette_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -163,8 +152,7 @@ void rosette_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +164,7 @@ void rosette_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
// 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;
|
||||
|
||||
|
|
@ -186,14 +173,11 @@ void rosette_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
for (yy = y - ROSETTE_R; yy < y + ROSETTE_R; yy++)
|
||||
for (xx = x - ROSETTE_R; xx < x + ROSETTE_R; xx++)
|
||||
if (api->in_circle(xx - x, yy - y, ROSETTE_R / 2))
|
||||
api->putpixel(canvas, xx, yy,
|
||||
SDL_MapRGB(canvas->format, rosette_colors.r,
|
||||
rosette_colors.g, rosette_colors.b));
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, rosette_colors.r, rosette_colors.g, rosette_colors.b));
|
||||
|
||||
}
|
||||
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -201,18 +185,18 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
double xx, yy; //distance to the center of the image
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
xx = (double) (xmid - x);
|
||||
yy = (double) (y - ymid);
|
||||
xx = (double)(xmid - x);
|
||||
yy = (double)(y - ymid);
|
||||
|
||||
if (which == 0)
|
||||
{
|
||||
angle = 2 * M_PI / 3; //an angle between brushes
|
||||
|
||||
x1 = (int) (xx * cos(angle) - yy * sin(angle));
|
||||
y1 = (int) (xx * sin(angle) + yy * cos(angle));
|
||||
x1 = (int)(xx * cos(angle) - yy * sin(angle));
|
||||
y1 = (int)(xx * sin(angle) + yy * cos(angle));
|
||||
|
||||
x2 = (int) (xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int) (xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
x2 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int)(xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -230,11 +214,11 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
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));
|
||||
x1 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y1 = (int)(xx * sin(2 * angle) - yy * cos(angle));
|
||||
|
||||
x2 = (int) (xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int) (xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
x2 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int)(xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
}
|
||||
|
||||
rosette_circle(api, which, canvas, snapshot, x, y);
|
||||
|
|
@ -243,11 +227,9 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
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->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, rosette_draw);
|
||||
api->playsound(rosette_snd, (x * 255) / canvas->w, 255);
|
||||
|
||||
update_rect->x = update_rect->y = 0;
|
||||
|
|
@ -256,29 +238,25 @@ 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)
|
||||
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)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int rosette_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rosette_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -294,7 +272,9 @@ Uint8 rosette_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 1;
|
||||
}
|
||||
|
||||
void rosette_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rosette_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
ROSETTE_R = (size + 2) * 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue