Re-ran indent on all .c & .h source code files
Like so --
find . -name "*.c" -or -name "*.h" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \;
The `indent` invocation differs from the last one noted in
CHANGES.txt (from 2006!?), in that I've added "--no-tabs",
to ensure indents are all space-based.
This commit is contained in:
parent
09f332367f
commit
cc05925d9e
99 changed files with 31659 additions and 27102 deletions
219
magic/src/tint.c
219
magic/src/tint.c
|
|
@ -76,10 +76,13 @@ const char *tint_names[tint_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *tint_descs[tint_NUM_TOOLS][2] = {
|
||||
{gettext_noop("Click and drag the mouse around to change the color of parts of your picture."),
|
||||
{gettext_noop
|
||||
("Click and drag the mouse around to change the color of parts of your picture."),
|
||||
gettext_noop("Click to change the color of your entire picture."),},
|
||||
{gettext_noop("Click and drag the mouse around to turn parts of your picture into white and a color you choose."),
|
||||
gettext_noop("Click to turn your entire picture into white and a color you choose.")}
|
||||
{gettext_noop
|
||||
("Click and drag the mouse around to turn parts of your picture into white and a color you choose."),
|
||||
gettext_noop
|
||||
("Click to turn your entire picture into white and a color you choose.")}
|
||||
};
|
||||
|
||||
int tint_init(magic_api * api);
|
||||
|
|
@ -90,20 +93,26 @@ char *tint_get_name(magic_api * api, int which);
|
|||
int tint_get_group(magic_api * api, int which);
|
||||
char *tint_get_description(magic_api * api, int which, int mode);
|
||||
static int tint_grey(Uint8 r1, Uint8 g1, Uint8 b1);
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which);
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which);
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void tint_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tint_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void tint_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tint_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tint_shutdown(magic_api * api);
|
||||
void tint_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
|
||||
int tint_requires_colors(magic_api * api, int which);
|
||||
void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void tint_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void tint_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
int tint_modes(magic_api * api, int which);
|
||||
|
||||
Uint32 tint_api_version(void)
|
||||
|
|
@ -118,10 +127,11 @@ int tint_init(magic_api * api)
|
|||
char fname[1024];
|
||||
|
||||
for (i = 0; i < tint_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, tint_snd_filenames[i]);
|
||||
tint_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
tint_snd_filenames[i]);
|
||||
tint_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +145,8 @@ SDL_Surface *tint_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, tint_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
tint_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -146,13 +157,15 @@ char *tint_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int tint_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int tint_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *tint_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
char *tint_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(tint_descs[which][mode - 1])));
|
||||
}
|
||||
|
|
@ -163,7 +176,8 @@ static int tint_grey(Uint8 r1, Uint8 g1, Uint8 b1)
|
|||
return 0.3 * r1 + .59 * g1 + 0.11 * b1;
|
||||
}
|
||||
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
{
|
||||
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -176,81 +190,88 @@ static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surfac
|
|||
int greyValue = tint_grey(r, g, b);
|
||||
|
||||
if (which == TOOL_TINT)
|
||||
{
|
||||
api->rgbtohsv(tint_r, tint_g, tint_b, &h, &s, &v);
|
||||
api->hsvtorgb(h, s, greyValue / 255.0, &r, &g, &b);
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
{
|
||||
api->rgbtohsv(tint_r, tint_g, tint_b, &h, &s, &v);
|
||||
api->hsvtorgb(h, s, greyValue / 255.0, &r, &g, &b);
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
else if (which == TOOL_THRESHOLD)
|
||||
{
|
||||
int thresholdValue = (tint_max - tint_min) / 2;
|
||||
{
|
||||
int thresholdValue = (tint_max - tint_min) / 2;
|
||||
|
||||
if (greyValue < thresholdValue)
|
||||
{
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
}
|
||||
if (greyValue < thresholdValue)
|
||||
{
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < last->h; y++)
|
||||
{
|
||||
for (x = 0; x < last->w; x++)
|
||||
{
|
||||
for (x = 0; x < last->w; x++)
|
||||
{
|
||||
do_tint_pixel(ptr, which, canvas, last, x, y);
|
||||
}
|
||||
do_tint_pixel(ptr, which, canvas, last, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
for (yy = y - tint_RADIUS; yy < y + tint_RADIUS; yy++)
|
||||
{
|
||||
for (xx = x - tint_RADIUS; xx < x + tint_RADIUS; xx++)
|
||||
{
|
||||
for (xx = x - tint_RADIUS; xx < x + tint_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, tint_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_tint_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
}
|
||||
if (api->in_circle(xx - x, yy - y, tint_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
{
|
||||
do_tint_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void tint_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_tint_brush);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1,
|
||||
do_tint_brush);
|
||||
|
||||
api->playsound(tint_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
int tmp = ox;
|
||||
{
|
||||
int tmp = ox;
|
||||
|
||||
ox = x;
|
||||
x = tmp;
|
||||
}
|
||||
ox = x;
|
||||
x = tmp;
|
||||
}
|
||||
if (oy > y)
|
||||
{
|
||||
int tmp = oy;
|
||||
{
|
||||
int tmp = oy;
|
||||
|
||||
oy = y;
|
||||
y = tmp;
|
||||
}
|
||||
oy = y;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
update_rect->x = ox - tint_RADIUS;
|
||||
update_rect->y = oy - tint_RADIUS;
|
||||
|
|
@ -260,25 +281,29 @@ void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void tint_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)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
tint_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
else
|
||||
{
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
do_tint_full(api, canvas, last, which);
|
||||
api->playsound(tint_snd_effect[which], 128, 255);
|
||||
}
|
||||
{
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
do_tint_full(api, canvas, last, which);
|
||||
api->playsound(tint_snd_effect[which], 128, 255);
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
void tint_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void tint_release(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x ATTRIBUTE_UNUSED,
|
||||
int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -289,16 +314,17 @@ void tint_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < tint_NUM_TOOLS; i++)
|
||||
{
|
||||
if (tint_snd_effect[i] != NULL)
|
||||
{
|
||||
if (tint_snd_effect[i] != NULL)
|
||||
{
|
||||
Mix_FreeChunk(tint_snd_effect[i]);
|
||||
}
|
||||
Mix_FreeChunk(tint_snd_effect[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b)
|
||||
void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g,
|
||||
Uint8 b)
|
||||
{
|
||||
tint_r = r;
|
||||
tint_g = g;
|
||||
|
|
@ -306,39 +332,42 @@ void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b)
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int tint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int tint_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
|
||||
int x, y;
|
||||
Uint8 r1, g1, b1;
|
||||
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r1, &g1, &b1);
|
||||
{
|
||||
int greyValue = tint_grey(r1, g1, b1);
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r1, &g1, &b1);
|
||||
{
|
||||
int greyValue = tint_grey(r1, g1, b1);
|
||||
|
||||
if (greyValue < tint_min)
|
||||
{
|
||||
tint_min = greyValue;
|
||||
}
|
||||
if (greyValue > tint_max)
|
||||
{
|
||||
tint_max = greyValue;
|
||||
}
|
||||
}
|
||||
if (greyValue < tint_min)
|
||||
{
|
||||
tint_min = greyValue;
|
||||
}
|
||||
if (greyValue > tint_max)
|
||||
{
|
||||
tint_max = greyValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tint_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
void tint_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