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
|
|
@ -15,33 +15,35 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
COLORSEP_TOOL_3DGLASSES,
|
||||
COLORSEP_TOOL_COLORSEP,
|
||||
COLORSEP_TOOL_DOUBLEVISION,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
static char * colorsep_snd_filenames[NUM_TOOLS] = {
|
||||
static char *colorsep_snd_filenames[NUM_TOOLS] = {
|
||||
"3dglasses.ogg",
|
||||
"colorsep.ogg",
|
||||
"doublevision.ogg",
|
||||
};
|
||||
|
||||
static char * colorsep_icon_filenames[NUM_TOOLS] = {
|
||||
static char *colorsep_icon_filenames[NUM_TOOLS] = {
|
||||
"3dglasses.png",
|
||||
"colorsep.png",
|
||||
"doublevision.png"
|
||||
};
|
||||
|
||||
char * colorsep_names[NUM_TOOLS] = {
|
||||
char *colorsep_names[NUM_TOOLS] = {
|
||||
gettext_noop("3D Glasses"),
|
||||
gettext_noop("Color Sep."),
|
||||
gettext_noop("Double Vision"),
|
||||
};
|
||||
|
||||
char * colorsep_descrs[NUM_TOOLS] = {
|
||||
gettext_noop("Click and drag left and right to separate your picture's red and cyan, to make anaglyphs you can view with 3D glasses!"),
|
||||
char *colorsep_descrs[NUM_TOOLS] = {
|
||||
gettext_noop
|
||||
("Click and drag left and right to separate your picture's red and cyan, to make anaglyphs you can view with 3D glasses!"),
|
||||
gettext_noop("Click and drag to separate your picture's colors."),
|
||||
gettext_noop("Click and drag to simulate double vision."),
|
||||
};
|
||||
|
|
@ -61,25 +63,22 @@ int colorsep_requires_colors(magic_api * api, int which);
|
|||
int colorsep_modes(magic_api * api, int which);
|
||||
void colorsep_shutdown(magic_api * api);
|
||||
void colorsep_click(magic_api * api, int which, int mode,
|
||||
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 colorsep_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void colorsep_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 colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int offset_x, int offset_y, int preview);
|
||||
void colorsep_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void colorsep_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void colorsep_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void colorsep_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void colorsep_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
Uint8 colorsep_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 colorsep_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
void colorsep_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 colorsep_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);
|
||||
|
||||
|
||||
Uint32 colorsep_api_version(void)
|
||||
|
|
@ -92,9 +91,9 @@ int colorsep_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s",
|
||||
api->data_directory, colorsep_snd_filenames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, colorsep_snd_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -111,32 +110,27 @@ SDL_Surface *colorsep_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, colorsep_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, colorsep_icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *colorsep_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
char *colorsep_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return strdup(gettext(colorsep_names[which]));
|
||||
}
|
||||
|
||||
int colorsep_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
char *colorsep_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode ATTRIBUTE_UNUSED)
|
||||
char *colorsep_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext(colorsep_descrs[which]));
|
||||
}
|
||||
|
||||
int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == COLORSEP_TOOL_COLORSEP)
|
||||
return 1;
|
||||
|
|
@ -144,8 +138,7 @@ int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int colorsep_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
@ -154,7 +147,8 @@ void colorsep_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
if (snd_effects[i] != NULL)
|
||||
Mix_FreeChunk(snd_effects[i]);
|
||||
}
|
||||
|
|
@ -162,8 +156,7 @@ void colorsep_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
colorsep_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
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)
|
||||
{
|
||||
api->stopsound();
|
||||
|
||||
|
|
@ -183,9 +176,12 @@ colorsep_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
int offset_x, offset_y;
|
||||
|
||||
offset_x = colorsep_click_x - x;
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
offset_y = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
offset_y = colorsep_click_y - y;
|
||||
}
|
||||
|
||||
|
|
@ -206,41 +202,54 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
Uint8 r1, g1, b1, r2, g2, b2, r, g, b;
|
||||
SDL_Rect dest;
|
||||
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
step = 3;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
step = 1;
|
||||
}
|
||||
|
||||
for (yy = 0; yy < canvas->h; yy = yy + step) {
|
||||
for (xx = 0; xx < canvas->w; xx = xx + step) {
|
||||
for (yy = 0; yy < canvas->h; yy = yy + step)
|
||||
{
|
||||
for (xx = 0; xx < canvas->w; xx = xx + step)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(snapshot, xx + offset_x / 2, yy + offset_y / 2), snapshot->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(snapshot, xx - offset_x / 2, yy - offset_y / 2), snapshot->format, &r2, &g2, &b2);
|
||||
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
/* Split red aparet from green & blue (cyan) */
|
||||
r = r1;
|
||||
g = g2;
|
||||
b = b2;
|
||||
} else if (which == COLORSEP_TOOL_COLORSEP) {
|
||||
r = (Uint8) ((float) r1 * colorsep_r_pct) + ((float) r2 * (1.0 - colorsep_r_pct));
|
||||
g = (Uint8) ((float) g1 * colorsep_g_pct) + ((float) g2 * (1.0 - colorsep_g_pct));
|
||||
b = (Uint8) ((float) b1 * colorsep_b_pct) + ((float) b2 * (1.0 - colorsep_b_pct));
|
||||
} else { /* which == COLORSEP_TOOL_DOUBLEVISION */
|
||||
}
|
||||
else if (which == COLORSEP_TOOL_COLORSEP)
|
||||
{
|
||||
r = (Uint8) ((float)r1 * colorsep_r_pct) + ((float)r2 * (1.0 - colorsep_r_pct));
|
||||
g = (Uint8) ((float)g1 * colorsep_g_pct) + ((float)g2 * (1.0 - colorsep_g_pct));
|
||||
b = (Uint8) ((float)b1 * colorsep_b_pct) + ((float)b2 * (1.0 - colorsep_b_pct));
|
||||
}
|
||||
else
|
||||
{ /* which == COLORSEP_TOOL_DOUBLEVISION */
|
||||
/* 50/50 for all colors */
|
||||
r = (Uint8) ((float) r1 * 0.5) + ((float) r2 * 0.5);
|
||||
g = (Uint8) ((float) g1 * 0.5) + ((float) g2 * 0.5);
|
||||
b = (Uint8) ((float) b1 * 0.5) + ((float) b2 * 0.5);
|
||||
r = (Uint8) ((float)r1 * 0.5) + ((float)r2 * 0.5);
|
||||
g = (Uint8) ((float)g1 * 0.5) + ((float)g2 * 0.5);
|
||||
b = (Uint8) ((float)b1 * 0.5) + ((float)b2 * 0.5);
|
||||
}
|
||||
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
dest.x = xx;
|
||||
dest.y = yy;
|
||||
dest.w = step;
|
||||
dest.h = step;
|
||||
|
||||
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, r, g, b));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
|
|
@ -249,17 +258,17 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void colorsep_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)
|
||||
{
|
||||
int offset_x, offset_y;
|
||||
|
||||
offset_x = colorsep_click_x - x;
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
offset_y = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
offset_y = colorsep_click_y - y;
|
||||
}
|
||||
colorsep_apply(api, which, canvas, snapshot, offset_x, offset_y, 0);
|
||||
|
|
@ -272,16 +281,16 @@ void colorsep_release(magic_api * api, int which,
|
|||
|
||||
|
||||
void colorsep_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)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
colorsep_r_pct = (float) r / 255.0;
|
||||
colorsep_g_pct = (float) g / 255.0;
|
||||
colorsep_b_pct = (float) b / 255.0;
|
||||
colorsep_r_pct = (float)r / 255.0;
|
||||
colorsep_g_pct = (float)g / 255.0;
|
||||
colorsep_b_pct = (float)b / 255.0;
|
||||
|
||||
if (colorsep_r_pct == colorsep_g_pct && colorsep_r_pct == colorsep_b_pct) {
|
||||
if (colorsep_r_pct == colorsep_g_pct && colorsep_r_pct == colorsep_b_pct)
|
||||
{
|
||||
colorsep_r_pct = 1.0;
|
||||
colorsep_g_pct = 0.0;
|
||||
colorsep_b_pct = 0.0;
|
||||
|
|
@ -290,15 +299,12 @@ void colorsep_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
|
||||
|
||||
void colorsep_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 colorsep_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +319,8 @@ Uint8 colorsep_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
}
|
||||
|
||||
|
||||
void colorsep_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 colorsep_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue