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
|
|
@ -16,32 +16,33 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
KAL_LENS_4,
|
||||
KAL_LENS_6,
|
||||
KAL_LENS_8,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
static char * kaleidox_snd_fnames[NUM_TOOLS] = {
|
||||
static char *kaleidox_snd_fnames[NUM_TOOLS] = {
|
||||
"kaleido-4.ogg",
|
||||
"kaleido-6.ogg",
|
||||
"kaleido-8.ogg",
|
||||
};
|
||||
|
||||
static char * kaleidox_icon_fnames[NUM_TOOLS] = {
|
||||
static char *kaleidox_icon_fnames[NUM_TOOLS] = {
|
||||
"kaleido-4.png",
|
||||
"kaleido-6.png",
|
||||
"kaleido-8.png",
|
||||
};
|
||||
|
||||
char * kaleidox_names[NUM_TOOLS] = {
|
||||
char *kaleidox_names[NUM_TOOLS] = {
|
||||
gettext_noop("Kaleido-4"),
|
||||
gettext_noop("Kaleido-6"),
|
||||
gettext_noop("Kaleido-8"),
|
||||
};
|
||||
|
||||
char * kaleidox_descrs[NUM_TOOLS] = {
|
||||
char *kaleidox_descrs[NUM_TOOLS] = {
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
|
|
@ -60,26 +61,21 @@ int kaleidox_requires_colors(magic_api * api, int which);
|
|||
int kaleidox_modes(magic_api * api, int which);
|
||||
void kaleidox_shutdown(magic_api * api);
|
||||
void kaleidox_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 kaleidox_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 kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void kaleidox_render(magic_api *, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y, int preview);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void kaleidox_render(magic_api *, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, int preview);
|
||||
void kaleidox_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void kaleidox_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void kaleidox_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void kaleidox_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void kaleidox_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int mirror(int n, int max, int flip);
|
||||
Uint8 kaleidox_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 kaleidox_default_size(magic_api * api, int which, int mode);
|
||||
void kaleidox_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void kaleidox_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 kaleidox_api_version(void)
|
||||
|
|
@ -92,9 +88,9 @@ int kaleidox_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, kaleidox_snd_fnames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, kaleidox_snd_fnames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -111,38 +107,32 @@ SDL_Surface *kaleidox_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, kaleidox_icon_fnames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, kaleidox_icon_fnames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *kaleidox_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
char *kaleidox_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return strdup(gettext(kaleidox_names[which]));
|
||||
}
|
||||
|
||||
int kaleidox_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *kaleidox_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode ATTRIBUTE_UNUSED)
|
||||
char *kaleidox_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext(kaleidox_descrs[which]));
|
||||
}
|
||||
|
||||
int kaleidox_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kaleidox_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT_WITH_PREVIEW;
|
||||
}
|
||||
|
|
@ -151,7 +141,8 @@ void kaleidox_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]);
|
||||
}
|
||||
|
|
@ -159,8 +150,7 @@ void kaleidox_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
kaleidox_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();
|
||||
|
||||
|
|
@ -170,23 +160,28 @@ kaleidox_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
#define linear(start, end, dist, full) (start + (((end - start) * dist) / full))
|
||||
#define length(x1, y1, x2, y2) sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2))
|
||||
|
||||
int mirror(int n, int max, int flip) {
|
||||
int mirror(int n, int max, int flip)
|
||||
{
|
||||
int adjusted;
|
||||
|
||||
if (flip)
|
||||
n = max - n;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
adjusted = 0;
|
||||
if (n < 0) {
|
||||
if (n < 0)
|
||||
{
|
||||
n = -n;
|
||||
adjusted = 1;
|
||||
}
|
||||
if (n >= max) {
|
||||
if (n >= max)
|
||||
{
|
||||
n = (max - 1) - (n - max);
|
||||
adjusted = 1;
|
||||
}
|
||||
} while (adjusted);
|
||||
}
|
||||
while (adjusted);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
@ -196,7 +191,8 @@ kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (snd_effects[which] != NULL) {
|
||||
if (snd_effects[which] != NULL)
|
||||
{
|
||||
api->playsound(snd_effects[which], 128, 255);
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +205,7 @@ kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y, int preview)
|
||||
SDL_Surface * snapshot, int x, int y, int preview)
|
||||
{
|
||||
int off_x, off_y, sides, max_radius;
|
||||
float angle, angle_offset;
|
||||
|
|
@ -221,15 +217,22 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
off_x = (canvas->w / 2) - x * 2;
|
||||
off_y = (canvas->h / 2) - y * 2;
|
||||
max_radius = max(canvas->w, canvas->h); /* FIXME: Better calculation should be used! */
|
||||
max_radius = max(canvas->w, canvas->h); /* FIXME: Better calculation should be used! */
|
||||
|
||||
if (which == KAL_LENS_4) {
|
||||
if (which == KAL_LENS_4)
|
||||
{
|
||||
sides = 4;
|
||||
} else if (which == KAL_LENS_6) {
|
||||
}
|
||||
else if (which == KAL_LENS_6)
|
||||
{
|
||||
sides = 6;
|
||||
} else if (which == KAL_LENS_8) {
|
||||
}
|
||||
else if (which == KAL_LENS_8)
|
||||
{
|
||||
sides = 8;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -237,12 +240,14 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
angle_offset = angle / 2;
|
||||
|
||||
/* Go around each side */
|
||||
for (s = 0; s < sides; s++) {
|
||||
a1 = (angle * (float) s) + angle_offset;
|
||||
a2 = (angle * (float) (s + 1)) + angle_offset;
|
||||
for (s = 0; s < sides; s++)
|
||||
{
|
||||
a1 = (angle * (float)s) + angle_offset;
|
||||
a2 = (angle * (float)(s + 1)) + angle_offset;
|
||||
|
||||
/* From the center outward... */
|
||||
for (r = 0; r < max_radius; r = r + (preview ? 4 : 1)) {
|
||||
for (r = 0; r < max_radius; r = r + (preview ? 4 : 1))
|
||||
{
|
||||
dx = (canvas->w / 2) + cos(a1) * r;
|
||||
dy = (canvas->h / 2) - sin(a1) * r;
|
||||
|
||||
|
|
@ -252,13 +257,15 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
len = length(dx, dy, dx2, dy2);
|
||||
|
||||
/* Scan rows of the source, and draw along each triangle */
|
||||
if (len != 0) {
|
||||
xxm = ((len > 0 ? 1 : -1 ) * (preview ? 4 : 1));
|
||||
if (len != 0)
|
||||
{
|
||||
xxm = ((len > 0 ? 1 : -1) * (preview ? 4 : 1));
|
||||
|
||||
push = (canvas->w - abs(len)) / 2;
|
||||
xx = 0;
|
||||
done = 0;
|
||||
do {
|
||||
do
|
||||
{
|
||||
src_x = (canvas->w / 2) + off_x + xx + push;
|
||||
src_x = mirror(src_x, canvas->w, (s % 2));
|
||||
|
||||
|
|
@ -268,20 +275,25 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
colr = api->getpixel(snapshot, src_x, src_y);
|
||||
dest.x = linear(dx, dx2, xx, len);
|
||||
dest.y = linear(dy, dy2, xx, len);
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
dest.w = 6;
|
||||
dest.h = 6;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
dest.w = 2;
|
||||
dest.h = 2;
|
||||
}
|
||||
SDL_FillRect(canvas, &dest, colr);
|
||||
|
||||
xx = xx + xxm;
|
||||
if ((xxm > 0 && xx > len) || (xxm < 0 && xx < len)) {
|
||||
if ((xxm > 0 && xx > len) || (xxm < 0 && xx < len))
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
} while (!done);
|
||||
}
|
||||
while (!done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -289,10 +301,7 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void kaleidox_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)
|
||||
{
|
||||
kaleidox_render(api, which, canvas, snapshot, x, y, 0);
|
||||
|
||||
|
|
@ -306,24 +315,21 @@ void kaleidox_release(magic_api * api, int which,
|
|||
|
||||
|
||||
void kaleidox_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void kaleidox_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 kaleidox_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -340,6 +346,8 @@ Uint8 kaleidox_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 0;
|
||||
}
|
||||
|
||||
void kaleidox_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 kaleidox_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